-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.4.0: Is there a way to perform local verification? #1015
Comments
Examples can be found at https://github.com/networknt/json-schema-validator/blob/master/doc/schema-retrieval.md. |
thank u for ur attention, But I couldn't solve it, it still verifies my $schema or $id. Will you consider using a simpler way to support this requirement? Because of performance issues, I still want to use this project |
You at least need to post what you have tried and what isn't working. |
The following is an example since you didn't post what are the contents of the schema or the meta-schema. Typically you will map the schema data from a classpath resource so that you don't have it all as an inline string. String metaSchemaData = "{}";
String schemaData = "{}";
Map<String, String> schemas = new HashMap<>();
schemas.put("https://schemas.amazon.com/selling-partners/definitions/product-types/meta-schema/v1", metaSchemaData);
schemas.put("https://schemas.amazon.com/selling-partners/definitions/product-types/schema/v1/HAIR_BRUSH", schemaData);
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V201909,
builder -> builder.schemaLoaders(schemaLoaders -> schemaLoaders.schemas(schemas)));
JsonSchema schema = factory.getSchema(SchemaLocation
.of("https://schemas.amazon.com/selling-partners/definitions/product-types/schema/v1/HAIR_BRUSH"));
String inputData = "{}";
System.out.println(schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL)); It looks like there is a custom meta-schema |
I seem to have found a solution, thank you for your answer |
I try to use this project to do some verification as shown in the picture. This schema is provided by Amazon, but its $id and $schema are not reachable URLs, but more like an identifier, nothing more. But when I try to build JsonSchema, it seems that I will actively go to this URL to get the corresponding structure.
This is not what I expected. I hope to get the Schema directly from the file or String instead of through the network protocol.
I tried looking for "examples" but couldn't find any. If there is a solution, please help me, thank you
The text was updated successfully, but these errors were encountered: