/** * A builder with the default configuration * * @see JsonSchemaFactory#newBuilder() */ JsonSchemaFactoryBuilder() { reportProvider = new ListReportProvider(LogLevel.INFO, LogLevel.FATAL); loadingCfg = LoadingConfiguration.byDefault(); validationCfg = ValidationConfiguration.byDefault(); }
@Autowired public ConnectJsonSchemaValidatorImpl(ApplicationProperties applicationProperties, SystemPropertyService systemPropertyService) { this.factory = JsonSchemaFactory.newBuilder() .setReportProvider(new ListReportProvider(LogLevel.ERROR, LogLevel.FATAL)) .freeze(); this.applicationProperties = applicationProperties; this.systemPropertyService = systemPropertyService; }
private JsonSchema loadSchema(URL schemaUrl) { String schema; try { schema = IOUtils.toString(schemaUrl); } catch (IOException e) { throw new IllegalStateException("Unable to read from schema URL", e); } try { JsonNode schemaNode = JsonLoader.fromString(schema); return JsonSchemaFactory.newBuilder() .setReportProvider(new ListReportProvider(LogLevel.ERROR, LogLevel.FATAL)) .freeze().getJsonSchema(schemaNode); } catch (IOException e) { throw new IllegalStateException("Unable to deserialize schema", e); } catch (ProcessingException e) { throw new IllegalStateException("Unable to build schema from JSON", e); } }
/** * @return A {@link JsonSchemaFactory} instance configured with the OpenAPI / Swagger V20 metaschema library suitable * for use in validating OpenAPI / Swagger documents */ public static JsonSchemaFactory schemaFactory() { return JsonSchemaFactory .newBuilder() .setValidationConfiguration( ValidationConfiguration.newBuilder() .setDefaultLibrary(OAI_V2_METASCHEMA_URI, SwaggerV20Library.get()) .setSyntaxMessages(getBundle(SwaggerV20Library.SyntaxBundle.class)) .setValidationMessages(getBundle(SwaggerV20Library.ValidationBundle.class)) .freeze()) .setReportProvider( // Only emit ERROR and above from the JSON schema validation new ListReportProvider(LogLevel.ERROR, LogLevel.FATAL)) .freeze(); }
/** * @param logLevel log level * @param exceptionThreshold exception threshold * @return A {@link JsonSchemaFactory} instance configured with the OpenAPI / Swagger V20 metaschema library suitable * for use in validating OpenAPI / Swagger documents */ public static JsonSchemaFactory schemaFactory(final LogLevel logLevel, final LogLevel exceptionThreshold) { return JsonSchemaFactory .newBuilder() .setValidationConfiguration( ValidationConfiguration.newBuilder() .setDefaultLibrary(OAI_V2_METASCHEMA_URI, SwaggerV20Library.get()) .setSyntaxMessages(getBundle(SwaggerV20Library.SyntaxBundle.class)) .setValidationMessages(getBundle(SwaggerV20Library.ValidationBundle.class)) .freeze()) .setReportProvider( // Only emit ERROR and above from the JSON schema validation new ListReportProvider(logLevel, exceptionThreshold)) .freeze(); }
/** * @param logLevel log level * @param exceptionThreshold exception threshold * @return A {@link JsonSchemaFactory} instance configured with the OpenAPI / Swagger V20 metaschema library suitable * for use in validating OpenAPI / Swagger documents */ static JsonSchemaFactory schemaFactory(final LogLevel logLevel, final LogLevel exceptionThreshold) { return JsonSchemaFactory .newBuilder() .setValidationConfiguration( ValidationConfiguration.newBuilder() .setDefaultLibrary(OAI_V2_METASCHEMA_URI, SwaggerV20Library.get()) .setSyntaxMessages(getBundle(SwaggerV20Library.SyntaxBundle.class)) .setValidationMessages(getBundle(SwaggerV20Library.ValidationBundle.class)) .freeze()) .setReportProvider( // Only emit ERROR and above from the JSON schema validation new ListReportProvider(logLevel, exceptionThreshold)) .freeze(); }