/** * Return a default, frozen configuration * * @return a new configuration */ public static ValidationConfiguration byDefault() { return newBuilder().freeze(); }
@Test public void defaultLibraryIsAccountedFor() { final String ref = "x://y.z/schema#"; final Library library = Library.newBuilder().freeze(); cfg.setDefaultLibrary(ref, library); assertSame(cfg.freeze().getDefaultLibrary(), library); } }
protected TestSuite(final SchemaVersion version, final String fileName) throws IOException { final ValidationConfiguration cfg = ValidationConfiguration.newBuilder() .setDefaultVersion(version).freeze(); validator = JsonSchemaFactory.newBuilder() .setValidationConfiguration(cfg).freeze().getValidator(); testSuite = JsonLoader.fromResource("/testsuite/" + fileName + ".json"); }
@BeforeMethod public void init() { final Keyword keyword = Keyword.newBuilder(K1) .withSyntaxChecker(mock(SyntaxChecker.class)) .withIdentityDigester(NodeType.ARRAY, NodeType.values()) .withValidatorClass(K1Validator.class) .freeze(); final Library library = DraftV4Library.get().thaw() .addKeyword(keyword).freeze(); final ValidationConfiguration cfg = ValidationConfiguration.newBuilder() .setDefaultLibrary("foo://bar#", library).freeze(); final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder() .setValidationConfiguration(cfg).freeze(); processor = factory.getProcessor(); COUNT.set(0); }
.setValidationMessages(bundle).freeze();
.setValidationMessages(bundle).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(); }
/** * @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(); }