Skip to content

Commit c64f0c1

Browse files
authored
Merge pull request #5 from YannRobert/extractValidateJsonNode
extract method validate(JsonNode, String)
2 parents c19a831 + 37f6d52 commit c64f0c1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/com/github/bjansen/ssv/SwaggerValidator.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,24 @@ public ProcessingReport validate(String jsonPayload, String definitionPointer) t
8686
*/
8787
public ProcessingReport validate(String jsonPayload, String definitionPointer, ObjectMapper jsonMapper) throws ProcessingException, IOException {
8888
JsonNode jsonNode = jsonMapper.readTree(jsonPayload);
89-
9089
if (jsonNode == null) {
9190
throw new IOException("The JSON payload could not be parsed correctly");
9291
}
9392

94-
return getSchema(definitionPointer).validate(jsonNode);
93+
return validate(jsonNode, definitionPointer);
94+
}
95+
96+
/**
97+
* Validates the given {@code jsonPayload} against the definition located at {@code definitionPointer}.
98+
*
99+
* @param jsonPayload the JSON payload (as a JsonNode) to validate
100+
* @param definitionPointer the path to the schema object the payload should be validated against,
101+
* for example {@code /definitions/User}
102+
* @return a validation report
103+
* @throws ProcessingException in case a processing error occurred during validation
104+
*/
105+
public ProcessingReport validate(JsonNode jsonPayload, String definitionPointer) throws ProcessingException {
106+
return getSchema(definitionPointer).validate(jsonPayload);
95107
}
96108

97109
/**

0 commit comments

Comments
 (0)