Output a JSON schema from the .well-known metadata endpoint
Signed-off-by: Harry Hogg <hhogg@spotify.com>
This commit is contained in:
@@ -41,7 +41,8 @@
|
||||
"@types/express": "^4.17.6",
|
||||
"express": "^4.17.1",
|
||||
"express-promise-router": "^4.1.0",
|
||||
"zod": "^3.11.6"
|
||||
"zod": "^3.11.6",
|
||||
"zod-to-json-schema": "^3.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/backend-test-utils": "workspace:^",
|
||||
|
||||
@@ -530,12 +530,42 @@ describe('createPermissionIntegrationRouter', () => {
|
||||
name: testRule1.name,
|
||||
description: testRule1.description,
|
||||
resourceType: testRule1.resourceType,
|
||||
schema: {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
items: [
|
||||
{
|
||||
description: 'firstParam',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
description: 'secondParam',
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
maxItems: 2,
|
||||
minItems: 2,
|
||||
type: 'array',
|
||||
},
|
||||
parameters: { count: 2 },
|
||||
},
|
||||
{
|
||||
name: testRule2.name,
|
||||
description: testRule2.description,
|
||||
resourceType: testRule2.resourceType,
|
||||
schema: {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
items: [
|
||||
{
|
||||
additionalProperties: false,
|
||||
description: 'firstParam',
|
||||
properties: {},
|
||||
type: 'object',
|
||||
},
|
||||
],
|
||||
maxItems: 1,
|
||||
minItems: 1,
|
||||
type: 'array',
|
||||
},
|
||||
parameters: { count: 1 },
|
||||
},
|
||||
],
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import express, { Response } from 'express';
|
||||
import Router from 'express-promise-router';
|
||||
import { z } from 'zod';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
import { InputError } from '@backstage/errors';
|
||||
import { errorHandler } from '@backstage/backend-common';
|
||||
import {
|
||||
@@ -201,6 +202,7 @@ export const createPermissionIntegrationRouter = <
|
||||
name: rule.name,
|
||||
description: rule.description,
|
||||
resourceType: rule.resourceType,
|
||||
schema: zodToJsonSchema(rule.schema),
|
||||
parameters: {
|
||||
count: rule.toQuery.length,
|
||||
},
|
||||
|
||||
@@ -6359,6 +6359,7 @@ __metadata:
|
||||
msw: ^0.47.0
|
||||
supertest: ^6.1.3
|
||||
zod: ^3.11.6
|
||||
zod-to-json-schema: ^3.18.1
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -40077,6 +40078,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"zod-to-json-schema@npm:^3.18.1":
|
||||
version: 3.18.1
|
||||
resolution: "zod-to-json-schema@npm:3.18.1"
|
||||
peerDependencies:
|
||||
zod: ^3.18.0
|
||||
checksum: e55d0de83b50fbd1caa7541d037858815964477b52a9e6495496e447107386cf16e2c08b007fcfbffd7fbe069ca2c19018425a53eaee36aff5dda942d3db71f4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"zod@npm:^3.11.6, zod@npm:^3.9.5":
|
||||
version: 3.18.0
|
||||
resolution: "zod@npm:3.18.0"
|
||||
|
||||
Reference in New Issue
Block a user