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
9
votes
2 answers

Validating json payload against swagger file - json-schema-validator

I am trying to validate a json payload against a swagger file that contains the service agreement. I am using the json-schema-validator(2.1.7) library to achieve this, but at the moment it's not validating against the specified patterns or min/max…
Hendrien
  • 325
  • 1
  • 10
  • 20
9
votes
4 answers

Is there such a thing as JSON schema for MongoDB query language itself?

MongoDB queries--at least in JavaScript--are structured as JSON, but it's very flexible so I am aware this wouldn't be a simple thing to do and in fact not even sure if this is possible, but was just wondering. Is there a JSON schema to detect if a…
Vlad
  • 8,038
  • 14
  • 60
  • 92
9
votes
2 answers

How do you reference other property values in JSON schema?

I have a JSON schema with 2 properties, minimumTolerance and maximumTolerance. I need to make sure that the value of maximumTolerance is not smaller than minimumTolerance & vice versa. Is this possible in JSON schema? Here is an example of what I'd…
Daniel Mason
  • 270
  • 1
  • 5
  • 16
9
votes
3 answers

JSON schema: Why does "constant" not validate the same way as a single-valued "enum"?

I have an object that provides a sort of audit log of versions of an asset. A couple of its properties (versionSource.metadata and versionSource.files) are objects that should validate against one of two schemas, depending on the value of one of…
Jeremy Thomerson
  • 722
  • 2
  • 8
  • 19
9
votes
0 answers

Converting from jsonschema to swagger 2.0

New to swagger and would like to know if there is a way to convert and existing jsonschema model to swagger specification.
user4387602
  • 103
  • 1
  • 1
  • 7
9
votes
2 answers

Reuse pattern in JSON schema

Is it possible to define a regex once and re-use it? I have a few pretty complex regexes which I would like to use as the pattern for the value of a large number of properties of various different object in my schema. Doing Copy paste of this looks…
smcp
  • 129
  • 2
  • 8
9
votes
5 answers

Storing a JSON schema in mongodb with spring

I am new to Spring data and mongodb. I have a JSON object which represents a JSON Schema and I need to store that in mongodb using spring data. But the issue with JSON schema is the structure of JSON Schema is dynamic; for example below are two…
BiJ
  • 1,639
  • 5
  • 24
  • 55
9
votes
1 answer

Enforce object non emptyness using json schema

We can enforce empty attribute of type object as follows: { "description": "voice mail record", "type": "object", "additionalProperties": false, "properties": {} } as explained here. Now I want to validate attribute which is of object…
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
9
votes
2 answers

creating mongoengine class dynamicly from json schema

i'm looking for a way to take my json schema and dynamically create a mongoengine class at runtime. for example: the mongoengine class written below class user(Document): _id = StringField(required=False) # mongodb id name =…
meir dahan
  • 103
  • 6
9
votes
1 answer

JSON Schema - multiple types

I have this schema. It checks comments, and works fine at the moment. var schema = { id: '', type: 'object', additionalProperties: false, properties: { text: { type: 'string', minLength: 1, required: true }, …
Baumannzone
  • 760
  • 2
  • 19
  • 38
9
votes
4 answers

Validate JSON against a schema in .NET

I know there is a proposed standard for JSON schema validation, is there an implementation in .NET?
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
9
votes
1 answer

Merge two Json Schemas

I am new to JSON and JSON schema validation. I have the following schema to validate a single employee object: { "$schema":"http://json-schema.org/draft-03/schema#", "title":"Employee Type Schema", "type":"object", "properties": …
user3015526
  • 91
  • 1
  • 1
  • 3
8
votes
1 answer

Does JSON Schema validation in common-js utils support references?

Does JSON Schema validation in common-js utils support references? I can not do this with https://github.com/kriszyp/commonjs-utils/blob/master/json-schema.js I tried following code: { "type" : "object", "required" : true, "properties" : { …
Lalith
  • 19,396
  • 17
  • 44
  • 54
8
votes
1 answer

Json schema django rest framework, describe json field as json and not as string

I have an Api in DRF, describes with swagger. In my serializer i have a field like that : settings = serializers.DictField(child=serializers.JSONField()) Is it possible that in the swagger.json the field was describe as 'Json' and not as…
8
votes
1 answer

Multiple If-Then-Else not validating for JSON Schema

I have a program that I have built that takes a JSON object and produces a JSON schema file based on the details of the input. When I use this program to generate a schema for a smaller JSON object, the schema works correctly and validates as…
Jake12342134
  • 1,539
  • 1
  • 18
  • 45