1212import com .networknt .openapi .NormalisedPath ;
1313import com .networknt .openapi .OpenApiOperation ;
1414import com .networknt .openapi .ValidatorConfig ;
15+ import com .networknt .schema .PathType ;
1516import com .networknt .schema .SchemaValidatorsConfig ;
1617import com .networknt .status .Status ;
1718import com .networknt .utility .MapUtil ;
@@ -87,9 +88,11 @@ private Status validateRequestBody(String requestBody, final OpenApiOperation op
8788 }
8889 return null ;
8990 }
90- SchemaValidatorsConfig config = new SchemaValidatorsConfig ();
91- config .setTypeLoose (false );
92- config .setHandleNullableField (validatorConfig .isHandleNullableField ());
91+ SchemaValidatorsConfig config = SchemaValidatorsConfig .builder ()
92+ .typeLoose (false )
93+ .pathType (PathType .JSON_POINTER )
94+ .nullableKeywordEnabled (validatorConfig .isHandleNullableField ())
95+ .build ();
9396 // the body can be converted to JsonNode here. If not, an error is returned.
9497 JsonNode requestNode = null ;
9598 requestBody = requestBody .trim ();
@@ -146,7 +149,7 @@ private Status validatePathParameters(final APIGatewayProxyRequestEvent requestE
146149 LOG .info ("Path parameter cannot be decoded, it will be used directly" );
147150 }
148151
149- return schemaValidator .validate (new TextNode (paramValue ), Overlay .toJson ((SchemaImpl )(parameter .get ().getSchema ())));
152+ return schemaValidator .validate (new TextNode (paramValue ), Overlay .toJson ((SchemaImpl )(parameter .get ().getSchema ())), paramName );
150153 }
151154 }
152155 return status ;
@@ -181,7 +184,7 @@ private Status validateQueryParameter(final APIGatewayProxyRequestEvent requestE
181184 return new Status (VALIDATOR_REQUEST_PARAMETER_QUERY_MISSING , queryParameter .getName (), openApiOperation .getPathString ().original ());
182185 }
183186 } else {
184- return schemaValidator .validate (new TextNode (queryParameterValue ), Overlay .toJson ((SchemaImpl )queryParameter .getSchema ()));
187+ return schemaValidator .validate (new TextNode (queryParameterValue ), Overlay .toJson ((SchemaImpl )queryParameter .getSchema ()), queryParameter . getName () );
185188 }
186189 return null ;
187190 }
@@ -235,7 +238,7 @@ private Status validateHeader(final APIGatewayProxyRequestEvent requestEvent,
235238 return new Status (VALIDATOR_REQUEST_PARAMETER_HEADER_MISSING , headerParameter .getName (), openApiOperation .getPathString ().original ());
236239 }
237240 } else {
238- return headerParameter .getSchema () != null ? schemaValidator .validate (new TextNode (headerValue .get ()), Overlay .toJson ((SchemaImpl )headerParameter .getSchema ())) : null ;
241+ return headerParameter .getSchema () != null ? schemaValidator .validate (new TextNode (headerValue .get ()), Overlay .toJson ((SchemaImpl )headerParameter .getSchema ()), headerParameter . getName () ) : null ;
239242 }
240243 return null ;
241244 }
@@ -251,7 +254,7 @@ private ValidationResult validateDeserializedValues(final APIGatewayProxyRequest
251254 if (null ==deserializedValue ) {
252255 validationResult .addSkipped (p );
253256 }else {
254- Status s = schemaValidator .validate (new TextNode (deserializedValue ), Overlay .toJson ((SchemaImpl )(p .getSchema ())));
257+ Status s = schemaValidator .validate (new TextNode (deserializedValue ), Overlay .toJson ((SchemaImpl )(p .getSchema ())), p . getName () );
255258 validationResult .addStatus (s );
256259 }
257260 });
0 commit comments