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:
parent
dfa0135b6a
commit
d123d46ebc
2 changed files with 11 additions and 12 deletions
|
@ -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',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue