diff --git a/.changeset/plenty-vans-mix.md b/.changeset/plenty-vans-mix.md new file mode 100644 index 0000000000..da23b35207 --- /dev/null +++ b/.changeset/plenty-vans-mix.md @@ -0,0 +1,5 @@ +--- +'@sap-cloud-sdk/openapi-generator': minor +--- + +[Fixed Issue] Ignore charset parameter in media types given in OpenAPI specification. diff --git a/packages/openapi-generator/src/parser/media-type.spec.ts b/packages/openapi-generator/src/parser/media-type.spec.ts index 87fa005766..2f0a3f1308 100644 --- a/packages/openapi-generator/src/parser/media-type.spec.ts +++ b/packages/openapi-generator/src/parser/media-type.spec.ts @@ -19,7 +19,9 @@ describe('parseTopLevelMediaType', () => { expect( parseTopLevelMediaType( { - content: { 'application/json': { schema: { type: 'object' } } } + content: { + 'application/json;charset=utf-8': { schema: { type: 'object' } } + } }, await createTestRefs(), defaultOptions diff --git a/packages/openapi-generator/src/parser/media-type.ts b/packages/openapi-generator/src/parser/media-type.ts index 164a3665d4..37f9e4211f 100644 --- a/packages/openapi-generator/src/parser/media-type.ts +++ b/packages/openapi-generator/src/parser/media-type.ts @@ -104,7 +104,7 @@ function getMediaTypeObject( ): OpenAPIV3.MediaTypeObject | undefined { if (bodyOrResponseObject?.content) { return Object.entries(bodyOrResponseObject.content).find(([key]) => - contentType.includes(key) + contentType.includes(key.split(';')[0]) )?.[1]; } return undefined;