From 6780888aeffe7bf911b78951211e5dfaa8bd23bf Mon Sep 17 00:00:00 2001 From: skgndi12 Date: Sun, 6 Aug 2023 16:36:25 +0900 Subject: [PATCH] fix: Separate the mediaType value from bodyParams --- packages/tspec/src/generator/openapiGenerator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tspec/src/generator/openapiGenerator.ts b/packages/tspec/src/generator/openapiGenerator.ts index 47a3cc4..a9679a5 100644 --- a/packages/tspec/src/generator/openapiGenerator.ts +++ b/packages/tspec/src/generator/openapiGenerator.ts @@ -109,7 +109,7 @@ export const getOpenapiPaths = ( const headerParams = getObjectPropertyByPath(spec, 'header', openapiSchemas) as any; const cookieParams = getObjectPropertyByPath(spec, 'cookie', openapiSchemas) as any; - const bodyParams = getObjectPropertyByPath(spec, 'body', openapiSchemas) as any; + const { mediaType = '', ...bodyParams } = getObjectPropertyByPath(spec, 'body', openapiSchemas) as any; const operation = { operationId: `${controllerName}_${method}_${path}`, @@ -127,7 +127,7 @@ export const getOpenapiPaths = ( description: bodyParams.description, required: true, content: { - [bodyParams.mediaType || 'application/json']: { + [mediaType || 'application/json']: { schema: bodyParams, }, },