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, }, },