Skip to content

Commit

Permalink
fix: Ignore charset parameter in media-types (#5022)
Browse files Browse the repository at this point in the history
* ignore charset

* Changes from lint:fix

* Update .changeset/plenty-vans-mix.md

---------

Co-authored-by: cloud-sdk-js <[email protected]>
Co-authored-by: Marika Marszalkowski <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent 1539eaf commit c4153b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-vans-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-cloud-sdk/openapi-generator': minor
---

[Fixed Issue] Ignore charset parameter in media types given in OpenAPI specification.
4 changes: 3 additions & 1 deletion packages/openapi-generator/src/parser/media-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-generator/src/parser/media-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c4153b9

Please sign in to comment.