Class SchemaResolver
java.lang.Object
com.bonitasoft.processbuilder.validation.SchemaResolver
Utility class responsible for loading, resolving, and validating JSON data against
OpenAPI (Swagger) schema definitions.
This class handles file parsing, recursive reference resolution, schema extraction, and detailed logging of validation reports. It is non-instantiable.
- Since:
- 1.0
- Author:
- Bonitasoft
-
Method Summary
Modifier and TypeMethodDescriptionstatic LoadedSchemagetValidatorSchema(String resourcePath, String targetSchemaName, String jsonInput) Loads the OpenAPI document from a resource, resolves dependencies, and prepares theJsonSchemavalidator for a specific target schema.static booleanisJsonValid(LoadedSchema loadedSchema) Performs JSON validation against the loaded schema, logging the outcome and detailed errors.static com.fasterxml.jackson.databind.JsonNodeParses a JSON string into a Jackson JsonNode.static voidprintRelevantValidationErrors(com.github.fge.jsonschema.core.report.ProcessingReport report, Map<String, String> componentTitles) Logs the relevant validation errors (ERROR/FATAL) by descending into the 'allOf' structure.
-
Method Details
-
getValidatorSchema
public static LoadedSchema getValidatorSchema(String resourcePath, String targetSchemaName, String jsonInput) Loads the OpenAPI document from a resource, resolves dependencies, and prepares theJsonSchemavalidator for a specific target schema.- Parameters:
resourcePath- The path to the OpenAPI resource (e.g., "schemas/openapi.yaml").targetSchemaName- The name of the schema to extract from the components section (e.g., "Category").jsonInput- The raw JSON input string (stored in LoadedSchema).- Returns:
- A
LoadedSchemarecord containing the validator, titles map, and input. - Throws:
RuntimeException- If reading, parsing, schema resolution, or serialization fails.
-
parseJson
Parses a JSON string into a Jackson JsonNode.- Parameters:
json- The JSON string to parse.- Returns:
- The resulting
JsonNode. - Throws:
RuntimeException- if the JSON string is malformed.
-
isJsonValid
Performs JSON validation against the loaded schema, logging the outcome and detailed errors.- Parameters:
loadedSchema- The record containing the validator, titles map, and input JSON.- Returns:
trueif validation is successful,falseotherwise.
-
printRelevantValidationErrors
public static void printRelevantValidationErrors(com.github.fge.jsonschema.core.report.ProcessingReport report, Map<String, String> componentTitles) Logs the relevant validation errors (ERROR/FATAL) by descending into the 'allOf' structure.- Parameters:
report- The processing report containing validation errors.componentTitles- Map of internal pointer names to user-friendly component names.
-