diff --git a/packages/core/src/routes/swagger/utils/parameters.ts b/packages/core/src/routes/swagger/utils/parameters.ts index a3bccbc509c..c7486c2ee82 100644 --- a/packages/core/src/routes/swagger/utils/parameters.ts +++ b/packages/core/src/routes/swagger/utils/parameters.ts @@ -256,15 +256,16 @@ export const buildPathIdParameters = ( * Build a parameter object with additional parameters that are not inferred from the path. */ export const customParameters = (): Record => { + 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({ - tenantId: { - name: 'tenantId', - in: 'path', - description: 'The unique identifier of the tenant.', - required: true, - schema: { - type: 'string', - }, - }, + [`${entityId}-root`]: { name: 'id', ...shared }, + [entityId]: { name: 'tenantId', ...shared }, }); }; diff --git a/packages/core/src/utils/zod.ts b/packages/core/src/utils/zod.ts index d8331a037ed..18cbc93dc56 100644 --- a/packages/core/src/utils/zod.ts +++ b/packages/core/src/utils/zod.ts @@ -207,9 +207,7 @@ export const zodTypeToSwagger = ( if (config instanceof ZodObject) { // Type from Zod is any // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - const entries = Object.entries(config.shape) - // `tenantId` is not editable for all routes - .filter(([key]) => key !== 'tenantId'); + const entries = Object.entries(config.shape); const required = entries .filter(([, value]) => !(value instanceof ZodOptional)) .map(([key]) => key);