Questions tagged [jsonschema]

A JSON Schema is a JSON document (an object) which defines constraints on what other JSON documents (the instances) should obey; it can also be used to interpret instances so as to provide links to external resources (hyper schema).

JSON (JavaScript Object Notation) Schema defines the media type application/schema+json, a JSON based format for defining the structure of JSON data.

JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

References:

For the latest Internet Draft documents, see the specification section of the website.

3348 questions
5
votes
1 answer

Does pymongo support json schema validation?

In MongoDB 3.6 one can specify a json schema to validate documents in a collection, but I haven't seen anything like that in pymongo.
Eduardo
  • 1,235
  • 16
  • 27
5
votes
1 answer

How to use an "any" type with JSON Schema?

I am looking at this: https://json-schema.org/understanding-json-schema/reference/type.html I have an object with a function property, but I don't want to set additionalProperties to true. So I want do something like: "properties": { …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
5
votes
2 answers

JSON schema validation for first array element

I am interested in validating some JSON logic to check for a certain value is in place for for the first element in an array. I would like to achieve this via JSON schema if possible. For Example, I would like to check to see if the first element is…
jbambrough
  • 597
  • 2
  • 7
  • 15
5
votes
1 answer

Check that two arrays in json have the same size

Can I somehow validate that two arrays in one json have the same size using json schema? May be there is some way to use variable for maxItems and minItems?
5
votes
0 answers

python - marshmallow build Schema from jsonschema

Source of truth is a jsonschema file/string which I wish to utilise to build objects as using validations etc. Does Marshmallow allow to define schema using a JsonSchema rather than manually place the fields? So presently what I do is, Take in…
Isaac Philip
  • 498
  • 1
  • 5
  • 14
5
votes
2 answers

Deriving the list of JSON Paths from a JSON Schema model

I am looking for a Javascript library to list the possible Json Paths based on a Json Schema. For a json schema like below, I want to list the possible json paths. { "$id": "https://example.com/person.schema.json", "$schema":…
Mani
  • 105
  • 1
  • 1
  • 8
5
votes
2 answers

python jsonschema validation fails when additionalProperties is set to false

I'm trying to define a schema inside a python script, to be used right away to validate some json data. the schema definition looks like this: response_schema = { "required": ["identifiers" ], "properties": { "identifiers": { …
5
votes
1 answer

JSON Schema reporting error only for first element of array

I have the below JSON document. [ { "name": "aaaa", "data": { "key": "id", "value": "aaaa" } }, { "name": "bbbb", "data": { "key": "id1", "value":…
Purus
  • 5,701
  • 9
  • 50
  • 89
5
votes
1 answer

jsonSchema attribute conditionally required depends on parent object

Per this question jsonschema attribute conditionally required, I can apply conditional required properties. However, it can only depend on the properties on the same level of object. In certain case, I want to one property required depend on its…
Ron
  • 6,037
  • 4
  • 33
  • 52
5
votes
2 answers

Unable to parse JSON Schema and resolve the reference

I am having one JSON Schema with ref. I am trying to resolve all the ref using JsonSchemaResolver. But, unfortunately , ref is not resolved and getting an error as below. I am trying to get the substituted JSON by resolving all the ref. Code: …
Subburaj
  • 2,294
  • 3
  • 20
  • 37
5
votes
1 answer

ngx-schema-form: Add custom validation messages (Angular 6)?

I am using NGX-Schema-Form https://github.com/makinacorpus/ngx-schema-form to render form fields based on a json object. My question is: How to add custom validation error messages to my schema and also how to display them properly on the ui…
5
votes
2 answers

JSON schema deeper object uniqueness

I'm trying to get into JSON schema definitions and wanted to find out, how to achieve a deeper object uniqueness in the schema definition. Please look at the following example definition, in this case a simple IO of a module. { "$schema":…
iLuvLogix
  • 5,920
  • 3
  • 26
  • 43
5
votes
2 answers

How to get a JSON.NET JSchema generator to render the additionalProperties attribute in a JSON schema

I am using JSON.NET JSchema Generator to create schemas based on classes decorated with Data Annotation Attributes. I'm using the generator like this: var generator = new JSchemaGenerator(); generator.ContractResolver = new…
Stewart
  • 153
  • 3
  • 12
5
votes
1 answer

writing more complex json schemas that have dependencies upon other keys

I've been writing simple JSON schemas but I ran into an API input call that is a bit more complex. I have one restful end route that can take 3 very different types of JSON: localhost/foo can take: { "type" : "ice_cream", "cone" : "waffle"…
V_H
  • 1,793
  • 3
  • 34
  • 59
5
votes
2 answers

Json schema validation error

Im getting a few errors in while validaing JSON. Im unable to understand the errors can anyone help and explain a bit. { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Modified JSON Schema draft v4 that includes the optional…
Sam
  • 497
  • 1
  • 10
  • 34