Skip to content

Commit 6e0fe09

Browse files
authored
[typescript] replace headers with same case-insensitive key to match http spec (#22393)
* replace headers with same caseinsensitive key to match http spec * regenerate samples * regenerate samples * enable test for header case-insensitive replacement * reduce redundant test comments
1 parent 41024dc commit 6e0fe09

File tree

18 files changed

+144
-1
lines changed

18 files changed

+144
-1
lines changed

modules/openapi-generator/src/main/resources/typescript/http/http.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ export class RequestContext {
183183
}
184184

185185
public setHeaderParam(key: string, value: string): void {
186+
// Delete any existing headers with case-insensitive matching keys
187+
const lowerKey = key.toLowerCase();
188+
for (const existingKey in this.headers) {
189+
if (existingKey.toLowerCase() === lowerKey) {
190+
delete this.headers[existingKey];
191+
}
192+
}
186193
this.headers[key] = value;
187194
}
188195

samples/client/echo_api/typescript/build/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/array-of-lists/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/enum-single-value/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/null-types-simple/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/builds/with-unique-items/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/others/typescript/encode-decode/build/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/browser/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/composed-schemas/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/default/http/http.ts

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)