Merge pull request #761 from Ronaldvdh-ISAAC/filter-undefined-headers

Filter undefined headers before creating the headers
This commit is contained in:
Ferdi Koomen 2021-09-27 18:41:52 +02:00 committed by GitHub
commit bbaf97020a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 12 deletions

View File

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

View File

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

View File

@ -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}`);

View File

@ -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}`);

View File

@ -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}`);

View File

@ -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}\`);