networknt / json-schema-validator Goto Github PK
View Code? Open in Web Editor NEWA fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
License: Apache License 2.0
A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
License: Apache License 2.0
Hello. I just found your library and I can't make it work.
I'm trying to test based on your example: https://github.com/networknt/json-schema-validator/blob/master/src/test/java/com/networknt/schema/JsonSchemaTest.java
But I'm receiving this error:
The constructor JsonSchema(ObjectMapper, JsonNode) is not visible
Am I doing something wrong?
In my other projects, I am gradually moving away from Jackson to Jsoniter due to huge performance difference. As many people are using this library with Jackson, I am wondering if we should support both or just discard Jackson as Jsoniter is very small and not depending on anything else. What do you think? Thanks.
I am using a schema to define all the common fields of my objects.
But when I refer to them from some field, the validation does not work correctly, even if it puts erroneous data always comes out that is valid.
subschema with fields defenition
{
"$schema": "http://json-schema.org/draft-04/schema#",
"someSubschemaField": {
"type": "integer",
"minimum": 1,
"maximum": 99999
}
}
schema that uses subschema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://www.example.com/subschema.json",
"type": "object",
"properties": {
"someSchemaField": {
"$ref": "#/someSubschemaField"
}
}
using http://www.jsonschemavalidator.net/
validates the schema correctly
Doesn't work with Android Version 6.0.1.
I am using library version com.networknt:json-schema-validator:0.1.18
. Is there something that can be done ?
04-07 11:28:10.932 3799-3813/? I/TestRunner: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Optional;
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:241)
at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:24)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:116)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:56)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:49)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:44)
at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:144)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:165)
The escaping for whitespaces in the uri-pattern is wrong which leads to uris containing an "s" not verifying.
The following test failed as Java string length function returns 4 instead of 2 for those special characters. Similar test in MinLength failed too.
[
{
"description": "maxLength validation",
"schema": {"maxLength": 2},
"tests": [
{
"description": "two supplementary Unicode code points is long enough",
"data": "\uD83D\uDCA9\uD83D\uDCA9",
"valid": true
}
]
}
]
When referencing the same schema within the same parent JsonSchema, resources could be cached?
E.g.:
"$ref": "https://domain.com/schemas/data_type.json#sub_type1"
and
"$ref": "https://domain.com/schemas/data_type.json#sub_type2"
Thanks
Hi,
I'm trying to use your lib to validate some json using this schema: https://realtime-listings.webservices.zpg.co.uk/docs/latest/schemas/listing/update.json
But I always get this error when loading schema file:
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@2d7a42eb; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2689) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:878) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:772) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3834) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3783) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2321) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:63) [json-schema-validator-0.1.7.jar:na]
at com.networknt.schema.BaseJsonValidator.obainSubSchemaNode(BaseJsonValidator.java:72) [json-schema-validator-0.1.7.jar:na]
at com.networknt.schema.BaseJsonValidator.<init>(BaseJsonValidator.java:41) [json-schema-validator-0.1.7.jar:na]
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:49) [json-schema-validator-0.1.7.jar:na]
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:44) [json-schema-validator-0.1.7.jar:na]
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:44) [json-schema-validator-0.1.7.jar:na]
I even tried to sout the schema json content and looks ok.
I also tried to use https://json-schema-validator.herokuapp.com/index.jsp and the schema validates alright on Schema Syntax Validation but I get the same error if I try to use it on Instance Validation.
Any clues what's wrong with this schema file?
Thanks!
Hello,
I am currently working on improving our JSON validator using your library, but I had trouble with large files:
Currently, running on a JSON with a size of 86MB using the FGE library takes 43825ms, but with this library it took 242476ms.
When running on smaller files(1kb) this library had a huge advantage, especially on large quantities of small files(1952ms using this library vs 18228ms using FGE).
I was wondering whether there is any configuration or settings that could help me with dealing with larger files, or whether this is a known issue.
Thank you,
Inbar Weiss
How to add custom message for validators. below is my sample schema.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"properties": {
"active": {
"type": "boolean"
},
"name": {
"type": "string",
"requiredErrorCode": "name is required"
}
},
"required": ["name"]
}
I'm looking for a Quickstart, and noticed the information on the Github front page is out of date.
Could the Quickstart section be updated? One apparently must now used a Builder() to begin with.
Thanks..
Validator never comme back and give result.
I put schema and json file I used.
Regards
I need to extend the standard JSON Schema definition and add a new constraint. Would it be possible to extend the JsonSchema class to accept custom validators. This could be additional packages to search, a list of classes or of classnames?
Is there an elegant way to make the enum case-insensitive?
Currently, paths are built in a format like $.foo.bar[0]
. It's almost like jq
, but not quite.
What are your thoughts on using an RFC-6901 JSON Pointer instead? The format looks more like /foo/bar/0
. It's supported out-of-the-box by Jackson, and it resolves ambiguities with characters like [
and .
being in field names.
It's something I can open a PR for, but I wanted to ask your opinion before doing the work.
I am looking to use constant (json-schema-org/json-schema-spec#58) from draft v6 and there is a proposal to use Switch, so would there be any chance of supporting for draft v6 in future?
It looks like only full schemas and arrays of properties are supported. Single property dependencies don't validate correctly.
Doesn't work:
{
"dependencies": {
"a": "b",
}
}
Works:
{
"dependencies": {
"a": ["b"],
}
}
The following test case fails as Java regular express returns false. Need a workaround.
{
"description": "pattern is not anchored",
"schema": {"pattern": "a+"},
"tests": [
{
"description": "matches a substring",
"data": "xxaayy",
"valid": true
}
]
}
The following schema containing a self reference:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"tree": { "$ref": "#/definitions/tree" }
},
"definitions": {
"tree": {
"type": "object",
"properties": {
"value": { "type": "string" },
"branches": {
"type": "array",
"items": { "$ref": "#/definitions/tree" },
"minItems": 1
}
},
"required": ["value"]
}
}
}
makes a stack overflow from com.networknt.schema.JsonSchema.read().
Not clear to me whether nested elements are supported by the standard, but some validators such as http://jeremydorn.com/json-editor/ support it.
regards
LM
A RequiredValidator initialized with all property names is created for the root level described by a schema. JSON schema allows for optional properties also in the root level of a described model.
sample-schema.yaml
%YAML 1.2
---
$schema: http://json-schema.org/draft-04/schema#
additionalProperties: false
description: Example.
properties:
property1:
type: string
property2:
type: string
required:
- property1
...
sample.yaml
%YAML 1.2
---
property1: TEST
...
result
$.property2: is missing but it is required
build 0.1.17 on windows environment and got error:
Tests in error:
JsonSchemaTest.testLoadingWithId:111 » FileNotFound http://localhost:1234/self...
It looks like Undertow server wasn't started correctly to serve the schema.
The Undertow server should be up and running and listen to 1234.
We are using the library in a web service to validate incoming requests against a schema. The application is by nature multi-threaded so there may be multiple validations going at the same time.
Is the JsonSchema class and the validate() method thread safe? Can I create and cache/share one instance of the JsonSchema and have all requests use it, or should I instantiate a new JsonSchema for each request?
I am trying to use this library, and have run into the following design issues:
JsonSchemaFactory
is a non-final class, but its only constructor is private
JsonSchema
is a non-final class, but its useful constructors are all package private
JsonSchemaFactory.Builder
requires an instance of JsonSchemaFactory
to instantiate - it seems silly to need to create an instance of a factory to create the builder of a new factory just to throw away the first initial factory.In general, this library is great, but ultimately is unusable except for exactly how it was programmed. A little bit of extenisbility would go a long way.
Hello! I went back and read the regular expression section for the JSON schema standard. It turns out that a full ECMA 262 (aka Javascript) regular expression engine is not required. The specification says that implementations SHOULD follow ECMA 262 but not that it MUST use it. The specification also recommends that "schema authors SHOULD limit themselves to the following regular expression tokens..."
One possible feature to this library is to add validation to enforce that regular expressions are limited to the tokens that are recommended in the schema. This is one way to ensure compatibility between Java regular expressions and ECMA 262 regular expressions. The recommended tokens are:
It would be a little tricky to implement the logic that only accepted the above tokens. Is it a good idea? What if someone really wants to use Java specific regular expressions? Should the library stop them?
I think this was just an oversight, and I'm happy to open a PR for it, but before I open the PR, I figured I'd ask.
In ValidationMessage
, getArguments()
has default access, but setArguments()
has public access. Was this an intentional design choice, or were they just flipped by mistake?
Yes, JSON in Java is a mess that is not going to be fixed in Java 9. As such, projects are using different libraries.
A common pattern to workaround this is to use a JsonFactory object that exposes all the needed methods and delegate to the actual implementation (Jackson, org.json, ...). It does not add significant performance overhead while making the code portable across libraries.
An example is provided here: https://github.com/jayway/JsonPath/blob/master/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonProvider.java
It would be great to have this library follow this pattern. We are using our own JSON library, so our only choice is to fork the code and update it. Now, instead of doing that our own way, I'll be happy to implement the pattern above and contribute it back, if you wish to accept it.
Hi,
Great job. I was taking a look at the library but noticed the undertow dependency in the pom and didn't see anywhere in the code where it is being used. Also could there be some more documentations even if it is javadoc so one can tell easily and quickly what is going on where.
Thanks for this.
I did another performance test with json-schema-validator-perftest by upgrade to 0.1.15 from 0.1.9 and see performance dropped significantly in percentage. Our customers are using this library in production runtime to do schema validation and we have to find out why and get it fixed. I tried to bump version one by one from 0.1.9 and found the changes in between 0.1.11 and 0.1.12 introduced some overhead. I am wondering if someone can help to figure out where is the root cause and get it fixed. Thanks.
0.1.11
Iteration 0 (in 5 ms)
Iteration 20 (in 34 ms)
Iteration 40 (in 51 ms)
Iteration 60 (in 66 ms)
Iteration 80 (in 82 ms)
Iteration 100 (in 100 ms)
Iteration 120 (in 118 ms)
Iteration 140 (in 136 ms)
Iteration 160 (in 152 ms)
Iteration 180 (in 169 ms)
Iteration 200 (in 185 ms)
Iteration 220 (in 198 ms)
Iteration 240 (in 207 ms)
Iteration 260 (in 220 ms)
Iteration 280 (in 226 ms)
Iteration 300 (in 232 ms)
Iteration 320 (in 237 ms)
Iteration 340 (in 242 ms)
Iteration 360 (in 247 ms)
Iteration 380 (in 252 ms)
Iteration 400 (in 258 ms)
Iteration 420 (in 263 ms)
Iteration 440 (in 268 ms)
Iteration 460 (in 273 ms)
Iteration 480 (in 278 ms)
END -- time in ms: 283
0.1.12
Iteration 0 (in 7 ms)
Iteration 20 (in 40 ms)
Iteration 40 (in 60 ms)
Iteration 60 (in 80 ms)
Iteration 80 (in 99 ms)
Iteration 100 (in 120 ms)
Iteration 120 (in 141 ms)
Iteration 140 (in 165 ms)
Iteration 160 (in 183 ms)
Iteration 180 (in 195 ms)
Iteration 200 (in 207 ms)
Iteration 220 (in 219 ms)
Iteration 240 (in 230 ms)
Iteration 260 (in 250 ms)
Iteration 280 (in 259 ms)
Iteration 300 (in 267 ms)
Iteration 320 (in 275 ms)
Iteration 340 (in 283 ms)
Iteration 360 (in 291 ms)
Iteration 380 (in 299 ms)
Iteration 400 (in 307 ms)
Iteration 420 (in 315 ms)
Iteration 440 (in 323 ms)
Iteration 460 (in 331 ms)
Iteration 480 (in 338 ms)
END -- time in ms: 346
This might not be an issue with this validator; it might be an issue with another validator.
What's the correct behavior for this schema?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object", "null"],
"allOf": [{"required": ["b"]}]
}
Other validators accept both null
and { "b": 0}
, but I'm not sure if that's the correct behavior.
Lower version of Jackson has CVE-2017-17485 deserialization flaw that is found by one of our customers during security scanning.
Implementation of CustomErrorMessageType.of(String errorCode, MessageFormat messageFormat) does not pass second parameter to the class constructor
Steve,
I'm trying to validate the following JSON node:
{
"data": {"xxx": 5},
"tree": {"values: "zzz"}
}
against this schema:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"tree": { "$ref": "#/definitions/tree" }
},
"definitions": {
"tree": {
"type": "object",
"properties": {
"value": { "type": "string" },
"branches": {
"type": "array",
"items": { "$ref": "#/definitions/tree" },
"minItems": 1
}
},
"required": ["value"]
}
}
}
The node is not valid since $tree has no member named "value" (confirmed by http://www.jsonschemavalidator.net/)
My code is like this:
Set<ValidationMessage> errors = schema.validate(node);
for(ValidationMessage validationMessage : errors ) {
System.out.println("Message : " + validationMessage);
}
with both node and schema created by methods XXXFromClasspath of the class BaseJsonSchemaValidatorTest (I made those methods public for this purpose)
The output is
13:18:27.422 [main] DEBUG com.networknt.schema.TypeValidator - validate( {"data":{"xxx":5},"tree":{"values":"zzz"}}, {"data":{"xxx":5},"tree":{"values":"zzz"}}, $)
13:18:27.432 [main] DEBUG c.n.schema.PropertiesValidator - validate( {"data":{"xxx":5},"tree":{"values":"zzz"}}, {"data":{"xxx":5},"tree":{"values":"zzz"}}, $)
13:20:13.264 [main] DEBUG com.networknt.schema.RefValidator - validate( {"values":"zzz"}, {"data":{"xxx":5},"tree":{"values":"zzz"}}, $.tree)
13:20:43.758 [main] DEBUG com.networknt.schema.TypeValidator - validate( {"values":"zzz"}, {"data":{"xxx":5},"tree":{"values":"zzz"}}, $.tree)
13:20:45.852 [main] DEBUG c.n.schema.PropertiesValidator - validate( {"values":"zzz"}, {"data":{"xxx":5},"tree":{"values":"zzz"}}, $.tree)
No error is detected!!
Did I do something wrong?
I tried to follow with a debugger. My understanding is that the error is detected but at some point one of the stacked validate() invocations generate a null message (I'm not sure at all!).
We have a schema that refers to three other schemas using $ref. The others are at the same relative path (folder). Trying to resolve by URL. The first schema is:
https://scap.nist.gov/schema/nvd/feed/0.1/nvd_cve_feed_json_0.1_beta.schema
The others are
https://scap.nist.gov/schema/nvd/feed/0.1/cvss-v3.0.json
https://scap.nist.gov/schema/nvd/feed/0.1/cvss-v2.0.json
https://scap.nist.gov/schema/nvd/feed/0.1/CVE_JSON_4.0_min.schema
Getting warning in log:
16:27:08,402 WARN [com.networknt.schema.JsonMetaSchema] (quartzScheduler_Worker-1) Could not load validator $ref
Any tips for troubleshooting? Is $ref supported by json-schema-validator? Nice library BTW, it has saved us a lot of time.
With v0.1.13
I have a schema file with an recursive object, i.e. a parent object that can have a child object with the same schema.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"parent": {
"$ref": "#/definitions/objectDef"
}
}
},
"definitions": {
"objectDef": {
"type": "object",
"properties": {
"value1": {
"type": "string"
},
"value2": {
"type": "string"
},
"childObject": {
"$ref": "#/definitions/objectDef"
}
}
}
}
It seems to not like this, as when I attempt to call schemaFactory.getSchema(node)
, it errors out with a stack overflow
com.networknt.schema.JsonSchemaException: java.lang.StackOverflowError
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:247)
at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:24)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:116)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:56)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:49)
at com.networknt.schema.AnyOfValidator.<init>(AnyOfValidator.java:38)
at sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:102)
...
Cause: java.lang.StackOverflowError:
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
I updated to v0.1.13 today from v0.1.7, where it returned the JsonSchema
object for the above schema without issue.
I am using this library to validate a service's JSON outputs and one of the outputs are the JSON schema (against which everything is validated) themselves.
When validating the schema, I get this warning:
WARN - Unknown keyword exclusiveMinimum - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword [main] com.networknt.schema.JsonMetaSchema.newValidator()
The only place I see exclusiveMinimum is in the JSON Schema (Draft 4) itself. What is the best way to avoid this warning, since I am not using it anywhere in my own schemas?
This is a brand new test case added in the official test suites and it failed as I am not ignoring non-objects. If foo object is required and you just pass in a number, I just don't understand why this can be valid. Need sometime to investigate why this is true before implement it.
[
{
"description": "required validation",
"schema": {
"properties": {
"foo": {},
"bar": {}
},
"required": ["foo"]
},
"tests": [
{
"description": "ignores non-objects",
"data": 12,
"valid": true
}
]
}
]
When resolving relative $ref
erences, URLs are constructed using the reference value directly without using the base URL of the referencing schema.
For example, if you own the foo.bar
domain, and you had a schema for addresses, you may set its id as follows:
"id": "http://foo.bar/schemas/address.json"
This provides a unique identifier for the schema, as well as, in most cases, indicating where it may be downloaded. For example: { "$ref": "person.json" }
A JSON schema validation library would fetch person.json
from http://foo.bar/schemas/person.json
, even if address.json
was loaded from the local filesystem.
This test case failed, and I know other libraries handle this well. Need time to investigate but not my high priority as I don't write schema like this.
{
"description": "escaped pointer ref",
"schema": {
"tilda~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
"tilda": {"$ref": "#/tilda~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
},
"tests": [
{
"description": "slash invalid",
"data": {"slash": "aoeu"},
"valid": false
},
{
"description": "tilda invalid",
"data": {"tilda": "aoeu"},
"valid": false
},
{
"description": "percent invalid",
"data": {"percent": "aoeu"},
"valid": false
},
{
"description": "slash valid",
"data": {"slash": 123},
"valid": true
},
{
"description": "tilda valid",
"data": {"tilda": 123},
"valid": true
},
{
"description": "percent valid",
"data": {"percent": 123},
"valid": true
}
]
},
Does this library support multiple json files?
I'm having this schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"address": {
"type": "object",
"properties": {
"street_address": { "type": "string" },
"city": { "type": "string" },
"state": { "type": "string" }
},
"required": ["street_address", "city", "state"]
}
},
"type": "object",
"properties": {
"billing_address": { "$ref": "file2.json#/address" },
"shipping_address": { "$ref": "file2.json#/address" }
}
}
and file2.json
{
"address": {
"type": "object",
"properties": {
"street_address": { "type": "string" },
"city": { "type": "string" },
"state": { "type": "string" }
},
"required": ["street_address", "city", "state"]
}
}
and I'm getting this error:
Exception in thread "main" com.networknt.schema.JsonSchemaException: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: UNKNOWN; line: 1, column: 0]
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:57)
at com.networknt.schema.RefValidator.<init>(RefValidator.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:120)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:54)
at com.networknt.schema.PropertiesValidator.<init>(PropertiesValidator.java:36)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:120)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:54)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:44)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:64)
at json.JsonTest.main(JsonTest.java:19)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: UNKNOWN; line: 1, column: 0]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:261)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3829)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3774)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2312)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:53)
... 17 more
On single json file it works. Am I doing something wrong?
Validating property of type string with format uri only allows absolute uri. For example "#item" is not allowed.
If you look at rfc3986 this should also be allowed.
I want to get error when in json has data which doesn't have in schema for example I have schema like this:
{
"type": "object",
"id": "urn:jsonschema:com:xxx:xxx:Student",
"properties": {
"name": {
"type": "string"
}
}
}
and json:
{
"name": "Smith",
"lastName": "Smithyan"
}
When I give the json to validate I want to get error that the "lastName" isn't defined in json schema.
Hi,
I'm actually coding tools for OpenAPI 3 using your json schema validator. I know that it's a field out of JSON Schema Spec, but what do you think about implementing discriminator
field of OpenAPI 3 spec? For more info: https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.md#fixed-fields-20
Thank you
Schema mentioned: {"name" : ...}
Passing payload : {"Name": ...}
Error showing currently :
Kindly advise any option to ignore only case validation. I want to allow all case should accept(camel,mix,small) ,make in-case sensitive for JSON keys.
Hi @stevehu ,
I am interested by using your project.
Can you give me more information about the current status of this project ?
What is working, not working, known issues, missing features ...
Thanks,
Paul
“inputDate”: “2017-13-25",
error is
{ “error” : {“statusCode”:400,“code”:“ERR11004",“message”:“VALIDATOR_SCHEMA”,“description”:“Schema Validation Error -
so, months validation is correct
for days we have this
“inputDate”: “2017-12-35",
java.time.format.DateTimeParseException: Text ‘2017-12-35’ could not be parsed: Invalid value for DayOfMonth (valid values 1 - 28/31): 35
this is thrown in API code
so swagger allows invalid day
doesn’t allow invalid month
It should have similar validation error as incorrect month
It'd be great to build the JAR so its MANIFEST becomes OSGi-compatible.
In case of building with Maven it's done just by adding a build plugin:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
and by specifying the packaging:
<packaging>bundle</packaging>
Is there any way to ignore some validation rules from schema or add some exceptions/override rules.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.