0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

refactor: add changeset and improve code

This commit is contained in:
Gao Sun 2024-06-23 13:47:10 +08:00
parent e24ff76c1f
commit d51e839cdb
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
3 changed files with 12 additions and 6 deletions

View file

@ -0,0 +1,8 @@
---
"@logto/core": patch
---
fix OpenAPI schema returned by the `GET /api/swagger.json` endpoint
1. The `:` character is invalid in parameter names, such as `organizationId:root`. These characters have been replaced with `-`.
2. The `tenantId` parameter of the `/api/.well-known/endpoints/{tenantId}` route was missing from the generated OpenAPI spec document, resulting in validation errors. This has been fixed.

View file

@ -236,9 +236,8 @@ export default function swaggerRoutes<T extends AnonymousRouter, R extends Route
(previous, entityName) => ({ (previous, entityName) => ({
...previous, ...previous,
...buildPathIdParameters(entityName), ...buildPathIdParameters(entityName),
...customParameters(),
}), }),
{} customParameters()
), ),
}, },
tags: [...tags, ...additionalTags].map((tag) => ({ name: tag })), tags: [...tags, ...additionalTags].map((tag) => ({ name: tag })),

View file

@ -253,11 +253,10 @@ export const buildPathIdParameters = (
}; };
/** /**
* Build a parameter object for the `tenantId` parameter. * Build a parameter object with additional parameters that are not inferred from the path.
* @returns The parameter object for the `tenantId` parameter.
*/ */
export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> => { export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> => {
return { return Object.freeze({
tenantId: { tenantId: {
name: 'tenantId', name: 'tenantId',
in: 'path', in: 'path',
@ -267,5 +266,5 @@ export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> =>
type: 'string', type: 'string',
}, },
}, },
}; });
}; };