org.everit.json.schema.loader.SchemaClient Java Examples
The following examples show how to use
org.everit.json.schema.loader.SchemaClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Validator.java From aws-cloudformation-resource-schema with Apache License 2.0 | 5 votes |
private Validator(JSONObject jsonSchema, JSONObject definitionSchema, SchemaClient downloader) { this.jsonSchemaObject = jsonSchema; this.definitionSchemaJsonObject = definitionSchema; this.downloader = downloader; }
Example #2
Source File: MetadataBuilderTest.java From fabric-chaincode-java with Apache License 2.0 | 5 votes |
@Test public void defaultSchemasNotLoadedFromNetwork() { final ContractDefinition contractDefinition = new ContractDefinitionImpl(SampleContract.class); MetadataBuilder.addContract(contractDefinition); setMetadataBuilderField("schemaClient", new SchemaClient() { @Override public InputStream get(final String uri) { throw new RuntimeException("Refusing to load schema: " + uri); } }); MetadataBuilder.validate(); }
Example #3
Source File: JSONPointer.java From json-schema with Apache License 2.0 | 5 votes |
/** * Static factory method. * * @param schemaClient * the client implementation to be used for obtaining the remote raw JSON schema * @param url * a complete URL (including protocol definition like "http://"). It may also contain a * fragment * @return a JSONPointer instance with a document provider created for the URL and the optional * fragment specified by the {@code url} */ @Deprecated public static final JSONPointer forURL(final SchemaClient schemaClient, final String url) { int poundIdx = url.indexOf('#'); String fragment; String toBeQueried; if (poundIdx == -1) { toBeQueried = url; fragment = ""; } else { fragment = url.substring(poundIdx); toBeQueried = url.substring(0, poundIdx); } return new JSONPointer(() -> JSONPointer.executeWith(schemaClient, toBeQueried), fragment); }
Example #4
Source File: Validator.java From aws-cloudformation-resource-schema with Apache License 2.0 | 4 votes |
public Validator(SchemaClient downloader) { this(loadResourceAsJSON(JSON_SCHEMA_PATH), loadResourceAsJSON(RESOURCE_DEFINITION_SCHEMA_PATH), downloader); }
Example #5
Source File: IssueTest.java From json-schema with Apache License 2.0 | 4 votes |
private void consumeValidatorConfig() { Map<String, Consumer<Object>> configKeyHandlers = new HashMap<>(); configKeyHandlers.put("failEarly", value -> { if (Boolean.TRUE.equals(value)) { validatorBuilder.failEarly(); } }); configKeyHandlers.put("resolutionScope", value -> loaderBuilder.resolutionScope((String) value)); configKeyHandlers.put("regexpImplementation", value -> { if (Objects.equals("RE2J", value)) { loaderBuilder.regexpFactory(new RE2JRegexpFactory()); } }); configKeyHandlers.put("customFormats", value -> { JSONObject json = (JSONObject) value; toMap(json).entrySet() .forEach(entry -> loaderBuilder .addFormatValidator(entry.getKey(), this.createFormatValidator(entry))); }); configKeyHandlers.put("metaSchemaVersion", value -> { int versionNo = (Integer) value; if (!asList(4, 6, 7).contains(versionNo)) { throw new IllegalArgumentException( "invalid metaSchemaVersion in validator-config.json: should be one of 4, 6, or 7, found: " + versionNo); } if (versionNo == 6) { loaderBuilder.draftV6Support(); } else if (versionNo == 7) { loaderBuilder.draftV7Support(); } }); configKeyHandlers.put("schemaClient", value -> { if ("classPathAware".equals(value)) { loaderBuilder.schemaClient(SchemaClient.classPathAwareClient()); } }); configKeyHandlers.put("enableOverrideOfBuiltInFormatValidators", value -> { if ((Boolean) value) { loaderBuilder.enableOverrideOfBuiltInFormatValidators(); } }); fileByName("validator-config.json").map(file -> streamAsJson(file)).ifPresent(configJson -> { configKeyHandlers.entrySet() .stream() .filter(entry -> configJson.has(entry.getKey())) .forEach(entry -> entry.getValue().accept(configJson.get(entry.getKey()))); }); }