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

AWS API Gateway: Documentation Swagger export model type null ignored

I am having an issue while exporting AWS's API Gateway documentation to Swagger. I have a documentation part for a JSON Schema model with null types such as: { "title": "Incident", "type": "object", "required": [ "id" ], "properties":…
6
votes
4 answers

How to correctly validate array of objects using JustinRainbow/JsonSchema

I have code that correctly validates an article returned from an endpoint that returns single articles. I'm pretty sure it's working correctly as it gives a validation error when I deliberately don't include a required field in the article. I also…
Danack
  • 24,939
  • 16
  • 90
  • 122
6
votes
1 answer

How do I use JSONSchema to accept any object string value, regardless of its key?

I have a system that is receiving JSON messages which contain metadata from a static analysis of a file. The names of these fields are dynamically generated from the scan and can be any valid string, but the value is always a valid string. e.g. { …
wolfson109
  • 898
  • 6
  • 10
6
votes
1 answer

Using jsonschema to validate that a key has a unique value within an array of objects?

How do I validate JSON, with jsonschema, that within an array of objects, a specific key in each object must be unique? For example, validating the uniqueness of each Name k-v pair should fail: "test_array": [ { "Name": "name1", …
TakingItCasual
  • 771
  • 1
  • 7
  • 22
6
votes
1 answer

JSON Schema migration or cleanup

We have a situation with a large number of JSON objects which adhere to a JSON Schema. The issue we have is that the JSON Schema is under constant development so regular changes are made to the schema (adding/removing fields etc) thus invalidating…
Paul Odeon
  • 4,407
  • 1
  • 37
  • 37
6
votes
1 answer

How to dynamically load json schema to typescript with webpack

I have a json schema describing an object Person. I would like to be able to load that schema into a typescript file directly this way: import Person from './schema/person.schema.json'; For this, I created a loader which convert the json file to a…
Luke Skywalker
  • 1,464
  • 3
  • 17
  • 35
6
votes
3 answers

Disabling null type in Newtonsoft JSON.NET schema

I have an MVC application, that serializes my model into json schema (using Newtonsoft json.net schema). The problem is that items in my array have type ["string", "null"], but what I need is just "string". Here is code for my class: public class…
actorapz
  • 83
  • 4
6
votes
1 answer

JSONSchema how to define a schema for a dynamic object

I have a JSON response that I am trying to create a JSONSchema for { "gauges": { "foo": { "value": 1234 }, "bar": { "value": 12.44 } } } It is important to know that the objects in the…
baynezy
  • 6,493
  • 10
  • 48
  • 73
6
votes
2 answers

Multi-value enum in JSON schema?

I have an array that contains strings, such as: [ 'foo', 'bar' ] The possible values are limited. For example, valid values are foo, bar, and baz. Now the array shall be valid when it contains only values that are valid, no value more than once,…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
6
votes
3 answers

Trying to make JSON Schema validator in Python to set default values

I'm using a slightly modified version of the code from the JSON Schema FAQ to create a validator that sets default values: def extend_with_default(validator_class): validate_properties = validator_class.VALIDATORS["properties"] def…
shroud
  • 725
  • 8
  • 13
6
votes
6 answers

JSON Schema Builder Program

Is there an existing program that helps forming a JSON Schema?
the_drow
  • 18,571
  • 25
  • 126
  • 193
6
votes
1 answer

How to tell a JSON schema is compatible with another in Java?

For example, I have a JSON schema looks as following: { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "billing_address": { "$ref": "#/definitions/address" }, "shipping_address": { "$ref":…
Cong Wang
  • 769
  • 1
  • 9
  • 30
6
votes
1 answer

JSON Schema Compare two properties to be equal length array

I have two properties in a schema which are both arrays. I would like to compare that they're equal length. For example: schema.json { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "thing": { …
Ryan
  • 399
  • 2
  • 6
6
votes
2 answers

JSON schema for object with either A and B or C required properties

I have two possible JSON objects for one request: { "from": "string", "to": "string", "text": "string" } or { "number": "integer", "text": "string" } In both cases "text" property is optional. Other properties are required (either…
Alexander Zhak
  • 9,140
  • 4
  • 46
  • 72
6
votes
2 answers

JSON schema which allows either an object or an array of those objects

Say I have a JSON schema that allows for an object like so: ... "assetMetadata": { "type": "object", "additionalProperties": false, "properties": { ... } } ... So say I want to change this to allow either that same object OR an…
djsumdog
  • 2,560
  • 1
  • 29
  • 55