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
15
votes
3 answers

JSON Schema with dynamic key field in MongoDB

Want to have a i18n support for objects stored in mongodb collection currently our schema is like: { _id: "id" name: "name" localization: [{ lan: "en-US", name: "name_in_english" }, { lan: "zh-TW", name:…
fin
  • 1,299
  • 1
  • 10
  • 20
14
votes
3 answers

Defining recursive models in Pydantic?

How can I define a recursive Pydantic model? Here's an example of what I mean: from typing import List from pydantic import BaseModel class Task(BaseModel): name: str subtasks: List[Task] = [] but when I run that I get the following…
A Poor
  • 856
  • 10
  • 26
14
votes
3 answers

JSON schema conditional dependency on value

I know there is a similar question here, but it didn't really address my issue. In short, I want one my fields to be dependent on the other field's value. But for some values, I don't want any field to be required. Here is an example: Schema { …
wesleyy
  • 2,575
  • 9
  • 34
  • 54
14
votes
3 answers

JSON Schema Documentation Generators

I have looked all over google for hours trying to find a good JSON Schema documentation generator, but I can't seem to find any good ones. Every one listed on http://json-schema.org/implementations has some problem. For Matic, I don't like the look…
user6144948
14
votes
2 answers

json-schema additional metadata

It is possible to add additional or custom metadata (other than title and description) to a json schema property? Ideally I'd like to add some metadata like so: //... "properties": { "contactFullName": { "$ref": "#/definitions/fullName", …
kreek
  • 8,774
  • 8
  • 44
  • 69
14
votes
2 answers

Ensure one property is not empty in JSON schema

For the given schema below, is it possible to ensure that at least one property contains a value (ie, minLength is 1): { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "fundRaiseId": { …
Ric
  • 12,855
  • 3
  • 30
  • 36
14
votes
1 answer

Recursive Self Referencing JSON-Schema

Is it a valid json schema: object: $ref: '#/definitions/object' Would you recommend to use such format?
Rana
  • 5,912
  • 12
  • 58
  • 91
14
votes
4 answers

How to define choice element in json schema when elements are optional?

------------Josn schema----------- { "type": "object", "properties": { "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type":…
javadev
  • 221
  • 1
  • 2
  • 10
13
votes
2 answers

'$id' property usage in JSON Schema

I'm using JSON Schema for validating data. I think that I may have a mistake on my schema by using the reserved keywords $id. The intention of this field was to designate what the REMOTE ID of the property on another platform was. So it was the…
sevenwithawp
  • 131
  • 1
  • 1
  • 3
13
votes
1 answer

How do I break a json schema into separate files?

Working from this example I want to break the schema into smaller separate schema files. Is this possible and if so how do I reference a relative path to the schema files? The baseSchema looks like this { "id":…
erotavlas
  • 4,274
  • 4
  • 45
  • 104
13
votes
2 answers

Why JSON API Specification suggest use of hyphen/minus to separate words in member names?

According to recommendation on JSON API specification site, we should use all lower case member names in JSON separated by hyphens: The allowed and recommended characters for an URL safe naming of members are defined in the format spec. To also…
Sebastian K
  • 6,235
  • 1
  • 43
  • 67
13
votes
2 answers

How to create jsdoc types from json schemas

I have tons of json schema for node.js project. Can I use them in any way for: Accessing them as jsdoc types from ".js" code files to increase webstorm intellisense accuracy Or for creating jsdoc type definitions automatically ?
uzay95
  • 16,052
  • 31
  • 116
  • 182
13
votes
2 answers

How to define custom object type in json-schema

Suppose I have couple of objects like Vehicle and Computer. {"brand":"Ford", "dateOfManufacture":"23/082015"} {"brand":"Apple", "dateOfManufacture":"23/082015"} I know I can represent vehicle schema like below. However looking at schema doesn't…
Rishi Saraf
  • 1,644
  • 2
  • 14
  • 27
13
votes
2 answers

How to tell JSON schema validator to pick schema from property value?

For example a schema for a file system, directory contains a list of files. The schema consists of the specification of file, next a sub type "image" and another one "text". At the bottom there is the main directory schema. Directory has a…
redben
  • 5,578
  • 5
  • 47
  • 63
13
votes
2 answers

Simple python validation library which reports all validation errors instead of first failed?

I have tried voluptuous and schema, both of which are simple and great in validation, but they both do exception-based error reporting, i.e. they fail on first error. Is there a way I can get all validation errors of data in Voluptuous or Schema? I…
DhruvPathak
  • 42,059
  • 16
  • 116
  • 175