@VisibleForTesting FormatProcessor(final Dictionary<FormatAttribute> dict) { attributes = dict.entries(); bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class); }
ValidationConfigurationBuilder() { libraries = Maps.newHashMap(); JsonRef ref; Library library; for (final Map.Entry<SchemaVersion, Library> entry: DEFAULT_LIBRARIES.entrySet()) { ref = JsonRef.fromURI(entry.getKey().getLocation()); library = entry.getValue(); libraries.put(ref, library); } syntaxMessages = MessageBundles .getBundle(JsonSchemaSyntaxMessageBundle.class); validationMessages = MessageBundles .getBundle(JsonSchemaValidationBundle.class); }
@Test(timeOut = 1000) public void circularReferencingDuringValidationIsDetected() throws IOException, ProcessingException, JsonPointerException { final JsonNode schemaNode = JsonLoader.fromResource("/other/issue102.json"); final JsonSchemaFactory factory = JsonSchemaFactory.byDefault(); final JsonValidator validator = factory.getValidator(); final MessageBundle bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class); try { validator.validate(schemaNode, JacksonUtils.nodeFactory().nullNode()); fail("No exception thrown!"); } catch (ProcessingException e) { final URI uri = URI.create("#/oneOf/1"); final ProcessingMessage message = e.getProcessingMessage(); final String expectedMessage = bundle.printf("err.common.validationLoop", uri, ""); assertMessage(message) .hasMessage(expectedMessage) .hasField("alreadyVisited", uri) .hasField("instancePointer", JsonPointer.empty().toString()) .hasField("validationPath", Arrays.asList("#", "#/oneOf/1")); } assertTrue(true); }
.put(key, value).build(); final MessageBundle bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class) .thaw().appendSource(source).freeze();
.put(key, value).build(); final MessageBundle bundle = MessageBundles.getBundle(JsonSchemaValidationBundle.class) .thaw().appendSource(source).freeze();
@Override public MessageBundle getBundle() { return MessageBundles .getBundle(JsonSchemaSyntaxMessageBundle.class) .thaw() .appendBundle(PropertiesBundle.forPath(PATH)) .freeze(); } }
@Override public MessageBundle getBundle() { return MessageBundles .getBundle(JsonSchemaSyntaxMessageBundle.class) .thaw() .appendBundle(PropertiesBundle.forPath(PATH)) .freeze(); } }
@Override public MessageBundle getBundle() { return MessageBundles .getBundle(JsonSchemaValidationBundle.class) .thaw() .appendBundle(PropertiesBundle.forPath(PATH)) .freeze(); } }
@Override public MessageBundle getBundle() { return MessageBundles .getBundle(JsonSchemaValidationBundle.class) .thaw() .appendBundle(PropertiesBundle.forPath(PATH)) .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(); }
/** * @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(); }
= MessageBundles.getBundle(JsonSchemaCoreMessageBundle.class);
= MessageBundles.getBundle(JsonSchemaCoreMessageBundle.class);
= MessageBundles.getBundle(JsonSchemaCoreMessageBundle.class);