mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Updated code to work with media types like "application/json; type=collection" where type is the first part of the header
This commit is contained in:
parent
f083ffb79d
commit
bbaa039d62
@ -23,7 +23,10 @@ const BASIC_MEDIA_TYPES = [
|
||||
|
||||
export function getContent(openApi: OpenApi, content: Dictionary<OpenApiMediaType>): Content | null {
|
||||
const basicMediaTypeWithSchema = Object.keys(content)
|
||||
.filter(mediaType => BASIC_MEDIA_TYPES.includes(mediaType))
|
||||
.filter(mediaType => {
|
||||
const cleanMediaType = mediaType.split(';')[0].trim();
|
||||
return BASIC_MEDIA_TYPES.includes(cleanMediaType);
|
||||
})
|
||||
.find(mediaType => isDefined(content[mediaType]?.schema));
|
||||
if (basicMediaTypeWithSchema) {
|
||||
return {
|
||||
|
||||
@ -127,7 +127,6 @@
|
||||
"nullable": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
@ -239,7 +238,6 @@
|
||||
"nullable": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
@ -270,7 +268,6 @@
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
@ -299,7 +296,6 @@
|
||||
"required": false,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
@ -611,7 +607,6 @@
|
||||
"default": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
@ -1303,7 +1298,7 @@
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"application/json; type=collection": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user