Skip to content

Commit e6e2649

Browse files
authored
Merge pull request #441 from JochenDiekenbrock/fix-content-type-with-charset
fix: handling for content-type application/json with a charset parameter
2 parents 3bb7441 + 4f7fc5d commit e6e2649

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/schema-parser/schema-routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class SchemaRoutes {
207207

208208
getContentKind = (contentTypes) => {
209209
if (
210-
_.includes(contentTypes, "application/json") ||
210+
_.some(contentTypes, (contentType) => _.startsWith(contentType, "application/json")) ||
211211
_.some(contentTypes, (contentType) => _.endsWith(contentType, "+json"))
212212
) {
213213
return CONTENT_KIND.JSON;

tests/generated/v2.0/api-with-examples.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,21 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
253253
...params,
254254
}),
255255
};
256+
withCharset = {
257+
/**
258+
* @description consumes contains charset
259+
*
260+
* @name WithCharset
261+
* @summary consumes contains charset
262+
* @request POST:/with-charset/
263+
*/
264+
withCharset: (someParm: string, params: RequestParams = {}) =>
265+
this.request<any, void>({
266+
path: `/with-charset/`,
267+
method: "POST",
268+
body: someParm,
269+
type: ContentType.Json,
270+
...params,
271+
}),
272+
};
256273
}

tests/schemas/v2.0/api-with-examples.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,18 @@ paths:
165165
]
166166
}
167167
}
168+
/with-charset/:
169+
post:
170+
operationId: with-charset
171+
summary: consumes contains charset
172+
description: consumes contains charset
173+
consumes:
174+
- application/json;charset=UTF-8
175+
produces:
176+
- application/json;charset=UTF-8
177+
parameters:
178+
- in: body
179+
name: someParm
180+
type: string
168181
consumes:
169182
- application/json

0 commit comments

Comments
 (0)