Skip to content

Commit c9e6756

Browse files
committed
Wiremock: Ignore casing when matching requests' Content-Type headers
1 parent ef50550 commit c9e6756

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

modules/openapi-generator/src/main/resources/java-wiremock/wiremock.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class {{classname}}MockServer {
2020
public static MappingBuilder stub{{#lambda.pascalcase}}{{operationId}}{{/lambda.pascalcase}}{{{code}}}({{#allParams}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable {{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull {{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{^isBodyParam}}String {{paramName}}{{/isBodyParam}}{{#isBodyParam}}String body{{/isBodyParam}}{{^-last}}, {{/-last}}{{#-last}}{{#headers.0}}, {{/headers.0}}{{^headers.0}}{{#returnType}}, {{/returnType}}{{/headers.0}}{{/-last}}{{/allParams}}{{#headers}}String response{{#lambda.pascalcase}}{{baseName}}{{/lambda.pascalcase}}{{^-last}}, {{/-last}}{{#-last}}{{#returnType}}, {{/returnType}}{{/-last}}{{/headers}}{{#returnType}}String response{{/returnType}}) {
2121
MappingBuilder stub = {{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}({{^pathParams.0}}urlPathEqualTo{{/pathParams.0}}{{#pathParams.0}}urlPathTemplate{{/pathParams.0}}("{{{path}}}")){{#hasProduces}}{{#produces}}
2222
.withHeader("Accept", containing("{{{mediaType}}}")){{/produces}}{{/hasProduces}}{{#hasAuthMethods}}{{#hasConsumes}}
23-
.withHeader("Content-Type", havingExactly("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}")){{/hasConsumes}}
23+
.withHeader("Content-Type", havingExactly(equalToIgnoreCase("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}"))){{/hasConsumes}}
2424
.withHeader("Authorization", matching(".*")){{/hasAuthMethods}}{{#cookieParams}}
2525
.withCookie("{{baseName}}", havingExactly({{paramName}})){{/cookieParams}}{{#hasBodyParam}}
2626
.withRequestBody(equalToJson(body)){{/hasBodyParam}}
@@ -107,7 +107,7 @@ public class {{classname}}MockServer {
107107
public static MappingBuilder stub{{#lambda.pascalcase}}{{operationId}}{{/lambda.pascalcase}}Fault({{#allParams}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable {{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull {{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{^isBodyParam}}String {{paramName}}{{/isBodyParam}}{{#isBodyParam}}String body{{/isBodyParam}}, {{/allParams}}Fault fault) {
108108
MappingBuilder stub = {{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}({{^pathParams.0}}urlPathEqualTo{{/pathParams.0}}{{#pathParams.0}}urlPathTemplate{{/pathParams.0}}("{{{path}}}")){{#hasProduces}}{{#produces}}
109109
.withHeader("Accept", containing("{{{mediaType}}}")){{/produces}}{{/hasProduces}}{{#hasAuthMethods}}{{#hasConsumes}}
110-
.withHeader("Content-Type", havingExactly("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}")){{/hasConsumes}}
110+
.withHeader("Content-Type", havingExactly(equalToIgnoreCase("{{#consumes.0}}{{{mediaType}}}{{/consumes.0}}"))){{/hasConsumes}}
111111
.withHeader("Authorization", matching(".*")){{/hasAuthMethods}}{{#cookieParams}}
112112
.withCookie("{{baseName}}", havingExactly({{paramName}})){{/cookieParams}}{{#bodyParam}}
113113
.withRequestBody(equalToJson(body)){{/bodyParam}}

0 commit comments

Comments
 (0)