From 42ae4bbbf295536b66a05b221936acf0732001c2 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 20 Dec 2024 18:23:39 +0800 Subject: [PATCH] fix: swagger json schema --- packages/openapi/src/generate.schema.ts | 3 ++- packages/openapi/src/share/view-get.ts | 2 +- packages/openapi/src/share/view-link-records.ts | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/openapi/src/generate.schema.ts b/packages/openapi/src/generate.schema.ts index f72e9e1904..c61f3f2643 100644 --- a/packages/openapi/src/generate.schema.ts +++ b/packages/openapi/src/generate.schema.ts @@ -14,7 +14,8 @@ function registerAllRoute() { type: 'http', scheme: 'bearer', }); - registry.registerPath({ ...routeObj, security: [{ [bearerAuth.name]: [] }] }); + const path = routeObj.path.startsWith('/') ? routeObj.path : `/${routeObj.path}`; + registry.registerPath({ ...routeObj, path, security: [{ [bearerAuth.name]: [] }] }); } return registry; } diff --git a/packages/openapi/src/share/view-get.ts b/packages/openapi/src/share/view-get.ts index 8e9aa74040..24f014a98f 100644 --- a/packages/openapi/src/share/view-get.ts +++ b/packages/openapi/src/share/view-get.ts @@ -18,7 +18,7 @@ export const shareViewGetVoSchema = z.object({ shareMeta: shareViewMetaSchema.optional(), view: viewVoSchema.optional(), fields: fieldVoSchema.array(), - records: recordSchema.array().openapi('first 50 records'), + records: recordSchema.array().openapi({ description: 'first 50 records' }), extra: z .object({ groupPoints: groupPointsVoSchema.optional().openapi({ diff --git a/packages/openapi/src/share/view-link-records.ts b/packages/openapi/src/share/view-link-records.ts index 94d50cdb9b..5a66cec2f0 100644 --- a/packages/openapi/src/share/view-link-records.ts +++ b/packages/openapi/src/share/view-link-records.ts @@ -18,7 +18,10 @@ export const shareViewLinkRecordsRoSchema = getRecordsRoSchema .extend({ fieldId: z.string(), search: z.string().optional(), - type: z.nativeEnum(ShareViewLinkRecordsType).optional().openapi('Only used for plugin views'), + type: z + .nativeEnum(ShareViewLinkRecordsType) + .optional() + .openapi({ description: 'Only used for plugin views' }), }); export type IShareViewLinkRecordsRo = z.infer;