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
8
votes
1 answer

Override inherited json schema

how can I override the validation rules which are defined in a json schema which is inherited by the "allOf" keyword? Example: { "$schema": "http://json-schema.org/draft-06/schema", "title": "My JSON Schema", "description": "", …
Andreas G.
  • 103
  • 1
  • 6
8
votes
3 answers

JsonSchema: Validate type based on value of another property

I am using the following schema to validate my json: { "$schema": "http://json-schema.org/schema#", "title": " Rules", "description": "Describes a set of rules", "type": "object", "properties": { "rules": { …
Joel Harris
  • 1,966
  • 3
  • 20
  • 32
8
votes
1 answer

Schema object without a type attribute in Swagger 2.0

Does a Schema object in Swagger/OpenAPI 2.0 have to have the type attribute or not? On the one hand, according to the JSON Schema Draft 4 spec, not specifying the type attribute is OK and means that the instance can be of any type (an object, an…
Marko Lukša
  • 93
  • 1
  • 4
8
votes
2 answers

In JsonSchema, the format value should be set as "full-date" or "date"?

You may use jsonSchemaLint for testing purposes. I have this JsonSchema, which sets format as "full-date". All Draft-6 validators (Json.Net) accepts the schema as valid. { "title": "MyTestSchema", "type": "object", "properties": { …
Pecheneg
  • 768
  • 3
  • 11
  • 27
8
votes
1 answer

Properties based on enum value in JSON Schema

I'm building a json schema definition which has a fixed set of controls that I've currently limited with an enum. However, not all properties are relevant for all controls. I only want to require an options property if the controlType =…
Dvirm
  • 83
  • 1
  • 1
  • 3
8
votes
1 answer

What is a json hyper schema?

I am a beginner here and I have questions regarding JSON Hyper-Schema. What is the purpose of links in Hyper-Schema and how do I validate them?
8
votes
2 answers

Using only JsonSchema with Mongoose possible?

I have an api using express, mongodb and I use AJV validation to validate the incoming requests. //JSONSchema var recordJsonSchema = { type: "object", properties: { name: { type: "string" }, idNumber: { type: "number"…
Proximo
  • 6,235
  • 11
  • 49
  • 67
8
votes
2 answers

Json Schema - How to make anyOf two or more properties required

I have this parent schema: { "definitions": { "parcel": { "type": "object", "properties": { "id": { "type": "string" }, "accountNumber": { …
Hussain ali
  • 491
  • 3
  • 7
  • 21
8
votes
1 answer

How to change all keys to lowercase when parsing JSON to a JToken

I have a string of JSON and the keys have uppercase and lowercase characters: {"employees":[ {"FIrstName":"John", "LASTname":"Doe"}, {"FIRSTNAME":"Anna", "LaSTNaME":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]} I want convert…
Rafi
  • 2,433
  • 1
  • 25
  • 33
8
votes
2 answers

Validate JSON Schema for list of known values

I have a special enum case in my code and need to validate against it: { "status": 10 } Let's use this imaginary list of valid values: var valid = [10, 20, 23, 27]; How can I alter my JSON Schema to validate one of these values? { type:…
jocull
  • 20,008
  • 22
  • 105
  • 149
8
votes
1 answer

Pojo to json schema v4 and vice versa via maven

I am trying to come up with a set of documents for one of our projects where there is a requirement to convert Java POJOs to JSON Schema 4 and sometimes JSON schema 4 back to POJOs. I couldn't find a maven plug-in that does both of it. I was able to…
g0c00l.g33k
  • 2,458
  • 2
  • 31
  • 41
8
votes
2 answers

How can I define the sequence of properties in JSON Schema?

I have following java Object: ProcessBean.java import java.util.List; import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName(value = "process") public class ProcessBean{ private Integer id; private String name; private…
Niharika G.
  • 333
  • 2
  • 3
  • 14
8
votes
4 answers

what is the difference between properties and patternProperties in json schema?

For the following json string : { "abc" : 123, "def" : 345 } The following schema considers it valid : { "$schema": "http://json-schema.org/draft-03/schema#", "title": "My Schema", "description": "Blah", "type": "object", …
8
votes
2 answers

JSON schema - how to use oneOf

The following is a valid JSON schema according to http://jsonlint.com/ and http://jsonschemalint.com/draft4/#. { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": ["results"], "additionalProperties":…
ksl
  • 4,519
  • 11
  • 65
  • 106
8
votes
1 answer

JsonSchemaGenerator Not Setting Fields to required = false

I'm using a JsonSchemaGenerator from JSON.NET against a series of models to output the respective JSON schemas into a dictionary like below. JsonSchemaGenerator generator = new JsonSchemaGenerator() { UndefinedSchemaIdHandling =…
atconway
  • 20,624
  • 30
  • 159
  • 229