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

How to create JSON Schema for Tree structure?

I have a tree structure and i would like to create a JSON schema. The class structure class Node { String id; List children = new ArrayList<>(); } The JSON Schema so far: { "name": "node", "type": "object", "properties": { …
7
votes
2 answers

json schema to validate array of objects with anyOf and oneOf requirements

I am trying to define a json schema to limit the properties of objects conatined in an array. What I have so far is: { "title":"myCollection", "properties":{ "things":{ "type":"array", "items":[{ …
Ian Wood
  • 6,515
  • 5
  • 34
  • 73
7
votes
1 answer

JSON Schema: required field

Im trying to use json-schema validation at some project, and want to ask about the "required" field. In current doc there is a specifiaction: The value of this keyword MUST be an array. This array MUST have at least one element. Elements of this…
Sergey Kamardin
  • 1,640
  • 1
  • 18
  • 22
7
votes
2 answers

How to default construct JavaScript object from JSON Schema?

I've started using Newtonsoft.Json.Schema.JsonSchemaGenerator along with various property attributes over in my C# code to help keep my client script DRY. What I'd like to do is create a default initialized object client-side based on the schema…
BrandonLWhite
  • 1,866
  • 1
  • 23
  • 26
6
votes
1 answer

How to declare nullable property in OpenAPI 3.0.x that's compatible with AWS API Gateway

We have been using OpenAPI 3.0.x specification, which adds feature for declaring nullable properties. When I import this OpenAPI into AWS API Gateway, corresponding model does not honor this nullable setting. Is there any way how to declare nullable…
Martin Macak
  • 3,507
  • 2
  • 30
  • 54
6
votes
1 answer

Is there support in JSON Schema for deep object validation?

I was looking around the docs and couldn't find any direct or indirect solution. Is there any way to get validation on JSON objects without knowing exactly where the specific object is located? For example, I want to validate the following…
6
votes
0 answers

In VSCode, settings.json, error: "Draft 2019-09 schemas are not yet fully supported. (768)"

My goal is to configure my PowerShell Terminal prompt per Hanselman's instructions here: https://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh It seems I was able to…
Smithright
  • 61
  • 3
6
votes
2 answers

In json schema, how to define an enum with description of each elements in the enum?

In json schema, I can simply define a code list using "enum" with a list of code that is available, for example: { "type": "object", "properties": { "group": { "type":"string", "$ref": "#/definitions/Group" } }, …
James Yan
  • 61
  • 1
  • 2
6
votes
1 answer

AVJ not validating enum types

Apologies if this has already been ask, but I wasn't able able to find an answer that works I am having trouble validating a JSON Schema using an enum type with AVJ I would expect the below code to return false, since the given value does not appear…
user1506269
6
votes
1 answer

How to represent union types in JSON schema validator?

I am new to JSON schema validation and I am building a custom schema for a configuration. The schema I am building is based on a Typescript type. I understand how I can validate simple datatypes like array, object, number, string etc. But is there a…
user11534547
6
votes
1 answer

jsonschema extending and no additional properties

I am using jsonschema for validating entrytypes that describe how entries (of given types) are displayed. these entries can have pages and are separated into aspects. Both pages and aspects can be conditioned and I want to reuse a basic schema, even…
ramin
  • 928
  • 8
  • 12
6
votes
2 answers

JSON Schema Validation Failing - Error is not of type 'object'

I am attempting to use the jsonschema and python_jsonschema_objects libraries to create a python object from a schema file, populate some data in that object, and then validate it against the original schema. Somehow I think i'm doing something…
Tim B
  • 215
  • 1
  • 2
  • 12
6
votes
1 answer

JSONSchema - Required property dependent on parent property

I would like to apply an additional "required" property in an array sub schema based on the presence of a property in the root schema. I have my schema set like this: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", …
Mike Miller
  • 3,071
  • 3
  • 25
  • 32
6
votes
2 answers

How can I fix "Can't resolve reference" error when referencing an $id in the same document?

I want to validate a JSON against a JSON schema with Ajv in JavaScript. I get the error: throw new it.MissingRefError(it.baseId, $schema, $message); ^ Error: can't resolve reference #/definitions/requestGraph from id requestGetGraphs When…
Skvupp
  • 155
  • 2
  • 3
  • 12
6
votes
1 answer

OpenAPI: how to validate examples?

RAML automatically validates included examples with the corresponding schema when you render the documentation. Is there a way to do the same with an OpenAPI 3 spec? codekie/swagger-examples-validator currently only supports OpenAPI 2. Anyone knows…
user1369786