0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix: include tenantId and its root param in responses (#6092)

* fix: include tenantId and its root param in responses

* refactor: use shared object

---------

Co-authored-by: Gao Sun <gao@silverhand.io>
This commit is contained in:
Mostafa Moradian 2024-06-25 04:24:56 +02:00 committed by GitHub
parent dfa0135b6a
commit d123d46ebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 12 deletions

View file

@ -256,15 +256,16 @@ export const buildPathIdParameters = (
* Build a parameter object with additional parameters that are not inferred from the path. * Build a parameter object with additional parameters that are not inferred from the path.
*/ */
export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> => { export const customParameters = (): Record<string, OpenAPIV3.ParameterObject> => {
const entityId = 'tenantId';
const shared = Object.freeze({
in: 'path',
description: 'The unique identifier of the tenant.',
required: true,
schema: { type: 'string' },
} as const);
return Object.freeze({ return Object.freeze({
tenantId: { [`${entityId}-root`]: { name: 'id', ...shared },
name: 'tenantId', [entityId]: { name: 'tenantId', ...shared },
in: 'path',
description: 'The unique identifier of the tenant.',
required: true,
schema: {
type: 'string',
},
},
}); });
}; };

View file

@ -207,9 +207,7 @@ export const zodTypeToSwagger = (
if (config instanceof ZodObject) { if (config instanceof ZodObject) {
// Type from Zod is any // Type from Zod is any
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const entries = Object.entries(config.shape) const entries = Object.entries(config.shape);
// `tenantId` is not editable for all routes
.filter(([key]) => key !== 'tenantId');
const required = entries const required = entries
.filter(([, value]) => !(value instanceof ZodOptional)) .filter(([, value]) => !(value instanceof ZodOptional))
.map(([key]) => key); .map(([key]) => key);