mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix: change special character to fix root paramter naming issue
feat: add customParameters function for fixing tenantId error on `/api/.well-known/endpoints/{tenantId}`
This commit is contained in:
parent
6dd487269d
commit
0a194c6752
2 changed files with 26 additions and 3 deletions
|
@ -34,6 +34,7 @@ import {
|
|||
paginationParameters,
|
||||
buildPathIdParameters,
|
||||
mergeParameters,
|
||||
customParameters,
|
||||
} from './utils/parameters.js';
|
||||
|
||||
type RouteObject = {
|
||||
|
@ -232,7 +233,11 @@ export default function swaggerRoutes<T extends AnonymousRouter, R extends Route
|
|||
components: {
|
||||
schemas: translationSchemas,
|
||||
parameters: identifiableEntityNames.reduce(
|
||||
(previous, entityName) => ({ ...previous, ...buildPathIdParameters(entityName) }),
|
||||
(previous, entityName) => ({
|
||||
...previous,
|
||||
...buildPathIdParameters(entityName),
|
||||
...customParameters(),
|
||||
}),
|
||||
{}
|
||||
),
|
||||
},
|
||||
|
|
|
@ -91,7 +91,7 @@ export const buildParameters: BuildParameters = (
|
|||
if (key === 'id') {
|
||||
if (rootComponent) {
|
||||
return {
|
||||
$ref: `#/components/parameters/${pluralize(rootComponent, 1)}Id:root`,
|
||||
$ref: `#/components/parameters/${pluralize(rootComponent, 1)}Id-root`,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ export const buildPathIdParameters = (
|
|||
// Need to duplicate the object because OpenAPI does not support partial reference.
|
||||
// See https://github.com/OAI/OpenAPI-Specification/issues/2026
|
||||
return {
|
||||
[`${entityId}:root`]: {
|
||||
[`${entityId}-root`]: {
|
||||
...shared,
|
||||
name: 'id',
|
||||
},
|
||||
|
@ -251,3 +251,21 @@ export const buildPathIdParameters = (
|
|||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Build a parameter object for the `tenantId` parameter.
|
||||
* @returns The parameter object for the `tenantId` parameter.
|
||||
*/
|
||||
export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> => {
|
||||
return {
|
||||
tenantId: {
|
||||
name: 'tenantId',
|
||||
in: 'path',
|
||||
description: 'The unique identifier of the tenant.',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue