Output a JSON schema from the .well-known metadata endpoint

Signed-off-by: Harry Hogg <hhogg@spotify.com>
This commit is contained in:
Harry Hogg
2022-09-29 09:27:53 +01:00
parent 9fe88c4fab
commit eec3f766f2
4 changed files with 44 additions and 1 deletions
@@ -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,
},