mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Merge pull request #761 from Ronaldvdh-ISAAC/filter-undefined-headers
Filter undefined headers before creating the headers
This commit is contained in:
commit
bbaf97020a
@ -1,6 +1,7 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
const reservedWords =
|
||||
/^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
const reservedWords =
|
||||
/^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
|
||||
@ -4,11 +4,20 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
const password = await resolve(options, OpenAPI.PASSWORD);
|
||||
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
|
||||
|
||||
const headers = new Headers({
|
||||
const filteredHeaders = Object.entries({
|
||||
Accept: 'application/json',
|
||||
...defaultHeaders,
|
||||
...options.headers,
|
||||
});
|
||||
}).reduce((acc, [headerKey, headerValue]) => {
|
||||
if (typeof headerValue !== 'undefined') {
|
||||
return {
|
||||
...acc,
|
||||
[headerKey]: headerValue,
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const headers = new Headers(filteredHeaders);
|
||||
|
||||
if (isStringWithValue(token)) {
|
||||
headers.append('Authorization', `Bearer ${token}`);
|
||||
|
||||
@ -4,11 +4,20 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
const password = await resolve(options, OpenAPI.PASSWORD);
|
||||
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
|
||||
|
||||
const headers = new Headers({
|
||||
const filteredHeaders = Object.entries({
|
||||
Accept: 'application/json',
|
||||
...defaultHeaders,
|
||||
...options.headers,
|
||||
});
|
||||
}).reduce((acc, [headerKey, headerValue]) => {
|
||||
if (typeof headerValue !== 'undefined') {
|
||||
return {
|
||||
...acc,
|
||||
[headerKey]: headerValue,
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const headers = new Headers(filteredHeaders);
|
||||
|
||||
if (isStringWithValue(token)) {
|
||||
headers.append('Authorization', `Bearer ${token}`);
|
||||
|
||||
@ -4,11 +4,20 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
const password = await resolve(options, OpenAPI.PASSWORD);
|
||||
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
|
||||
|
||||
const headers = new Headers({
|
||||
const filteredHeaders = Object.entries({
|
||||
Accept: 'application/json',
|
||||
...defaultHeaders,
|
||||
...options.headers,
|
||||
});
|
||||
}).reduce((acc, [headerKey, headerValue]) => {
|
||||
if (typeof headerValue !== 'undefined') {
|
||||
return {
|
||||
...acc,
|
||||
[headerKey]: headerValue,
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const headers = new Headers(filteredHeaders);
|
||||
|
||||
if (isStringWithValue(token)) {
|
||||
headers.append('Authorization', `Bearer ${token}`);
|
||||
|
||||
@ -165,11 +165,20 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
const password = await resolve(options, OpenAPI.PASSWORD);
|
||||
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
|
||||
|
||||
const headers = new Headers({
|
||||
const filteredHeaders = Object.entries({
|
||||
Accept: 'application/json',
|
||||
...defaultHeaders,
|
||||
...options.headers,
|
||||
});
|
||||
}).reduce((acc, [headerKey, headerValue]) => {
|
||||
if (typeof headerValue !== 'undefined') {
|
||||
return {
|
||||
...acc,
|
||||
[headerKey]: headerValue,
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const headers = new Headers(filteredHeaders);
|
||||
|
||||
if (isStringWithValue(token)) {
|
||||
headers.append('Authorization', \`Bearer \${token}\`);
|
||||
@ -2520,11 +2529,20 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
const password = await resolve(options, OpenAPI.PASSWORD);
|
||||
const defaultHeaders = await resolve(options, OpenAPI.HEADERS);
|
||||
|
||||
const headers = new Headers({
|
||||
const filteredHeaders = Object.entries({
|
||||
Accept: 'application/json',
|
||||
...defaultHeaders,
|
||||
...options.headers,
|
||||
});
|
||||
}).reduce((acc, [headerKey, headerValue]) => {
|
||||
if (typeof headerValue !== 'undefined') {
|
||||
return {
|
||||
...acc,
|
||||
[headerKey]: headerValue,
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const headers = new Headers(filteredHeaders);
|
||||
|
||||
if (isStringWithValue(token)) {
|
||||
headers.append('Authorization', \`Bearer \${token}\`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user