mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Fixed parse of header for contentType
This commit is contained in:
parent
6c35b190e5
commit
45d4c2e9fc
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.5.2",
|
||||
"version": "0.5.3",
|
||||
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
|
||||
@ -2,12 +2,11 @@ async function getResponseBody(response: Response): Promise<any> {
|
||||
try {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
return await response.json();
|
||||
default:
|
||||
return await response.text();
|
||||
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
||||
if (isJSON) {
|
||||
return await response.json();
|
||||
} else {
|
||||
return await response.text();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -2,13 +2,11 @@ async function getResponseBody(response: Response): Promise<any> {
|
||||
try {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
return await response.json();
|
||||
|
||||
default:
|
||||
return await response.text();
|
||||
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
||||
if (isJSON) {
|
||||
return await response.json();
|
||||
} else {
|
||||
return await response.text();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -2,13 +2,11 @@ function getResponseBody(xhr: XMLHttpRequest): any {
|
||||
try {
|
||||
const contentType = xhr.getResponseHeader('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
return JSON.parse(xhr.responseText);
|
||||
|
||||
default:
|
||||
return xhr.responseText;
|
||||
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
||||
if (isJSON) {
|
||||
return JSON.parse(xhr.responseText);
|
||||
} else {
|
||||
return xhr.responseText;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -201,12 +201,11 @@ async function getResponseBody(response: Response): Promise<any> {
|
||||
try {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
return await response.json();
|
||||
default:
|
||||
return await response.text();
|
||||
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
||||
if (isJSON) {
|
||||
return await response.json();
|
||||
} else {
|
||||
return await response.text();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@ -2300,12 +2299,11 @@ async function getResponseBody(response: Response): Promise<any> {
|
||||
try {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
return await response.json();
|
||||
default:
|
||||
return await response.text();
|
||||
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
||||
if (isJSON) {
|
||||
return await response.json();
|
||||
} else {
|
||||
return await response.text();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user