Questions tagged [json-schema-validator]

A JSON Schema validation implementation in pure Java, which aims for correctness and performance

Description

A JSON Schema validation implementation in pure Java, which aims for JSON correctness and performance, in that order json-schema-validator

The implementation has complete validation support for draft v4.

Link

GitHub - json-schema-validator

736 questions
202
votes
28 answers

Read file from resources folder in Spring Boot

I'm using Spring Boot and json-schema-validator. I'm trying to read a file called jsonschema.json from the resources folder. I've tried a few different ways but I can't get it to work. This is my code. ClassLoader classLoader =…
g3blv
  • 3,877
  • 7
  • 38
  • 51
69
votes
1 answer

JSON Schema definition for array of objects

I've seen this other question but it's not quite the same, and I feel like my issue is simpler, but just isn't working. My data would look like this: [ { "loc": "a value 1", "toll" : null, "message" : "message is sometimes null"}, { "loc":…
Kyle Falconer
  • 8,302
  • 6
  • 48
  • 68
37
votes
1 answer

How to use JSON Schema to require one of two fields

I want to validate JSON to make one of two fields manadatory. Let's assume we have two fields (Email Address and Phone Number). I want to make sure that one of the two fields is required for the record to be valid. { "$schema":…
Jolly
  • 371
  • 1
  • 3
  • 3
25
votes
4 answers

How to define JSON Schema for Map?

I have a json : { "itemTypes": {"food":22,"electrical":2}, "itemCounts":{"NA":211} } Here the itemTypes and itemCounts will be common but not the values inside them (food, NA, electrical) which will be keep changing but the will be in the format :…
Newbie
  • 691
  • 4
  • 16
  • 28
23
votes
1 answer

Custom Properties in JSON Schema

Is it valid to extend a JSON schema with custom properties? The reason I am asking is, because I am using a schema to also render a form for the JSON the schema describes (each property described in the schema is used as a form element with label…
bbop99
  • 1,625
  • 1
  • 11
  • 25
23
votes
2 answers

JSON schema $ref does not work for relative path

I have 3 schemas: child schema: { "title": "child_schema", "type": "object", "properties": { "wyx":{ "type": "number" } }, "additionalProperties": false, "required": ["wyx"] } parent schema: { …
ahri
  • 387
  • 1
  • 5
  • 11
18
votes
2 answers

What is the difference between "anyof" and "oneof" in z schema?

Its looking like both works fine with my input validation code. Then what is the exact difference? Schema with oneof [{ "id": "MyAction", "oneOf": [{ "$ref": "A1" }, { "$ref": "A2" }] }, { "id": "A1", "properties": { …
Somnath
  • 3,247
  • 4
  • 28
  • 42
18
votes
2 answers

json schema property description and "$ref" usage

I am writting a json schema to validate my json outputs produced by an exe.The schema being little bit complexe, I have defined some "definitions" that are referenced in properties ("$ref": "#/definitions/...). And using definitions here is all the…
Azias
  • 547
  • 1
  • 4
  • 12
17
votes
1 answer

Python - Cerberus, jsonschema, voluptous - Which one will be appropriate?

I am developing a small RESTful web application in python and using JSON as interface. The application accepts JSON data and needs to validate them against a schema. The schema may be very strict or flexible depending on the request. Also, the…
17
votes
3 answers

Referencing a local relative file in a JSON Schema?

I am building a JSON for a REST web service. The schema however has grown to over 1300 lines and I want to split it up across multiple files. I am unit testing my schema against a folder of JSON sample responses using json-schema-validator version…
Sled
  • 18,541
  • 27
  • 119
  • 168
16
votes
4 answers

Jackson: How can I generate json schema which rejects all additional content

I want to generate JSON schema where "additionalProperties" : false will be applied for all classes which I have. Suppose I have following classes: class A{ private String s; private B b; public String getS() { return s; } …
Beno
  • 945
  • 11
  • 22
16
votes
2 answers

How do I mark a property in JSON schema as deprecated?

I have a JSON schema that defines JSON documents. There's an use case where we want to deprecate a particular attribute in favour of a new attribute being introduced and want to mark the old attribute as deprecated. Does JSON schema support that?
Abhay Dubey
  • 549
  • 2
  • 7
  • 18
15
votes
1 answer

json-schema-validator custom message

I am using json-schema-validator2.2.6 library to validate my json against json schema. The problem is that it gives generic error messages that are not relevant to me. I want to send custom message or code to user. Do we have any option like this…
New Bee
  • 1,007
  • 4
  • 18
  • 34
15
votes
3 answers

Json schema validation in Spring REST APIs

I’m building a REST API using Spring Boot and [jackson-module-jsonSchema] (https://github.com/FasterXML/jackson-module-jsonSchema) for JSON schema generation. I’m looking the best way to validate the request JSON payload arriving to my APIs…
Alec
  • 217
  • 1
  • 3
  • 8
15
votes
2 answers

Json schema dynamic key validation

Facing an issue with schema validation. schema : { "type": "object", "$schema": "http://json-schema.org/draft-03/schema", "id": "#", "required": true, "patternProperties": { "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$": { …
suri babu
  • 223
  • 1
  • 2
  • 8
1
2 3
49 50