- 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:
Ferdi Koomen 2021-11-11 15:33:06 +01:00
parent f083ffb79d
commit bbaa039d62
2 changed files with 5 additions and 7 deletions

View File

@ -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 {

View File

@ -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"
}