Package com.networknt.schema
Class SpecVersionDetector
java.lang.Object
com.networknt.schema.SpecVersionDetector
This class is used to detect schema version
- Since:
- 25/06/20
- Author:
- Subhajitdas298
-
Method Summary
Modifier and TypeMethodDescriptionstatic SpecVersion.VersionFlag
detect
(com.fasterxml.jackson.databind.JsonNode jsonNode) Detects schema version based on the schema tag: if the schema tag is not present, throwsJsonSchemaException
with the corresponding message, otherwise - returns the detected spec version.static Optional
<SpecVersion.VersionFlag> detectOptionalVersion
(com.fasterxml.jackson.databind.JsonNode jsonNode, boolean throwIfUnsupported) static Optional
<SpecVersion.VersionFlag> detectOptionalVersion
(String schemaUri) static SpecVersion.VersionFlag
detectVersion
(com.fasterxml.jackson.databind.JsonNode jsonNode, Path specification, SpecVersion.VersionFlag defaultVersion, boolean throwIfUnsupported) static Optional
<SpecVersion.VersionFlag> detectVersionFromPath
(Path path)
-
Method Details
-
detect
Detects schema version based on the schema tag: if the schema tag is not present, throwsJsonSchemaException
with the corresponding message, otherwise - returns the detected spec version.- Parameters:
jsonNode
- JSON Node to read from- Returns:
- Spec version if present, otherwise throws an exception
-
detectOptionalVersion
public static Optional<SpecVersion.VersionFlag> detectOptionalVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, boolean throwIfUnsupported) Detects schema version based on the schema tag: if the schema tag is not present, returns an emptyOptional
value, otherwise - returns the detected spec version wrapped intoOptional
.- Parameters:
jsonNode
- JSON Node to read fromthrowIfUnsupported
- whether to throw an exception if the version is not supported- Returns:
- Spec version if present, otherwise empty
-
detectVersion
public static SpecVersion.VersionFlag detectVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, Path specification, SpecVersion.VersionFlag defaultVersion, boolean throwIfUnsupported) -
detectVersionFromPath
-
detectOptionalVersion
-