@@ -54,7 +54,7 @@ public class OpenApiValidator {
54
54
final String VALIDATOR_REQUEST_PARAMETER_QUERY_MISSING = "ERR11000" ;
55
55
56
56
final String VALIDATOR_RESPONSE_CONTENT_UNEXPECTED = "ERR11018" ;
57
- final String REQUIRED_RESPONSE_HEADER_MISSING = "ERR11019 " ;
57
+ final String VALIDATOR_RESPONSE_HEADER_MISSING = "ERR11020 " ;
58
58
59
59
final String DEFAULT_STATUS_CODE = "default" ;
60
60
@@ -139,7 +139,7 @@ public Status validateRequestPath (String requestURI , String httpMethod, Reques
139
139
}
140
140
} catch (NullPointerException e ) {
141
141
// This exception is thrown from within the OpenApiOperation constructor on operation == null.
142
- return new Status (STATUS_METHOD_NOT_ALLOWED , requestURI );
142
+ return new Status (STATUS_METHOD_NOT_ALLOWED , httpMethod , requestURI );
143
143
}
144
144
145
145
if (requestEntity !=null ) {
@@ -446,7 +446,7 @@ public Status validateResponsePath(String requestURI, String httpMethod, String
446
446
}
447
447
} catch (NullPointerException e ) {
448
448
// This exception is thrown from within the OpenApiOperation constructor on operation == null.
449
- return new Status (STATUS_METHOD_NOT_ALLOWED , requestURI );
449
+ return new Status (STATUS_METHOD_NOT_ALLOWED , httpMethod , requestURI );
450
450
}
451
451
Status status = validateHeaders (responseEntity .getHeaders (), openApiOperation , statusCode );
452
452
if (status != null ) return status ;
@@ -462,7 +462,7 @@ private Status validateHeaders(Map<String, ?> headers, OpenApiOperation operatio
462
462
//based on OpenAPI specification, ignore "Content-Type" header
463
463
//If a response header is defined with the name "Content-Type", it SHALL be ignored. - https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responseObject
464
464
.filter (entry -> !"Content-Type" .equalsIgnoreCase (entry .getKey ()))
465
- .map (p -> validateHeader (headers , p .getKey (), p .getValue ()))
465
+ .map (p -> validateHeader (headers , p .getKey (), p .getValue (), operation ))
466
466
.filter (s -> s != null )
467
467
.findFirst ();
468
468
if (optional .isPresent ()) {
@@ -472,7 +472,7 @@ private Status validateHeaders(Map<String, ?> headers, OpenApiOperation operatio
472
472
return null ;
473
473
}
474
474
475
- private Status validateHeader (Map <String , ?> headers , String headerName , Header operationHeader ) {
475
+ private Status validateHeader (Map <String , ?> headers , String headerName , Header operationHeader , OpenApiOperation openApiOperation ) {
476
476
// According to RFC7230, header field names are case-insensitive.
477
477
Optional <Object > headerValue = Optional .ofNullable (headers ).flatMap (opt -> opt .entrySet ()
478
478
.stream ()
@@ -482,7 +482,7 @@ private Status validateHeader(Map<String, ?> headers, String headerName, Header
482
482
);
483
483
if (headerValue .isEmpty ()) {
484
484
if (Boolean .TRUE .equals (operationHeader .getRequired ())) {
485
- return new Status (REQUIRED_RESPONSE_HEADER_MISSING , headerName );
485
+ return new Status (VALIDATOR_RESPONSE_HEADER_MISSING , headerName , openApiOperation . getPathString (). original () );
486
486
}
487
487
} else {
488
488
SchemaValidatorsConfig config = new SchemaValidatorsConfig ();
0 commit comments