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

JSON-schema exclude properties (opposite to required properties)

in JSON-schema, one can require certain keys in an object, see this example, taken from the json schema docs: { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" }, "address": { "type":…
S.A.
  • 1,819
  • 1
  • 24
  • 39
5
votes
2 answers

Golang struct to Json schema

Hi I need to infer a json schema (github.com/go-openapi/spec.Schema) from a struct : type Testcase struct { Id string `json:"id,omitempty"` // id of this test case Name string `json:"name,omitempty"` …
Antonin
  • 879
  • 2
  • 10
  • 27
5
votes
1 answer

How to validate json schema against metaschema in linux cli

I'm trying to validate my complex json schema definition file to be sure that there is no typo in the schema. I use the jsonschema script provided by python jsonschema library. I use meta-schema files downloaded from json schema specification…
eNca
  • 1,043
  • 11
  • 21
5
votes
1 answer

A strict mode warning from ajv when using electron-store

I want to save a object[] using electron-store with JSON Schema, after reading the doc of JSON Schema i get the code can be exec successfully but with warning: strict mode: "items" is 1-tuple, but minItems or maxItems/additionalItems are not…
GuangWu
  • 378
  • 4
  • 14
5
votes
1 answer

How to generate a strict json schema with pydantic?

I recently started to use pydandic to generate JSON schemas for validating data but I found the by default the generated schema does not complain about unknown keys inside my BaseModel. Example: class Query(BaseModel): id: str name:…
sorin
  • 161,544
  • 178
  • 535
  • 806
5
votes
1 answer

How to customize error messages for JSONSchema?

Is there a way to provide a custom error message depending on the given condition? I'm using https://github.com/networknt/json-schema-validator, version 1.0.43 This is my JSON Schema: { "$id": "https://configurations/provider.json", "$schema":…
dextertron_
  • 921
  • 1
  • 10
  • 19
5
votes
1 answer

How do I define my own JSON Schema keyword and vocabulary?

I would like to define a JSON schema vocabulary to extend any regular JSON schema with storage related metadata. As an example I would like to define a pk keyword which marks an arbitrary JSON property as a primary key. My meta-schema looks like…
5
votes
2 answers

Json schema with anyOf fields to POJO

I wonder what's the recommended way to generate POJOs for Json schemas with "anyOf" fields? For example, given the following json schemas: hobby.json { "anyOf": [ { "type": {"$ref": "./exercise.json" } }, { "type": {"$ref":…
Liutong Chen
  • 2,915
  • 5
  • 22
  • 29
5
votes
1 answer

Arrays are not being generated List but List
I have a complex schema for which I am generating POJO's. However, I noticed that complex types are not being generated for items inside type array although they are marked type object. I did a quick test with very simple schema { "$schema":…
Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
5
votes
1 answer

validate array json contains several unordered objects using json schema

Problem I want to use json schema draft 7 to validate that an array contains several unordered objects. For example, the array should contains student A, B, regardless of their orders. [{"name": "A"}, {"name": "B"}] //valid [{"name": "B"}, {"name":…
5
votes
2 answers

Create JSON instance from JSON schema

Hi I'm trying to create JSON instance from a JSON schema. Typescript answer is appreciated, but appreciate any answers. Below the the sample-schema.json file. I want to create a function to convert a schema to a schema instance. Ex:…
Ambati Dilip
  • 51
  • 1
  • 5
5
votes
1 answer

How should you reference the JSON schema that a JSON object conforms to?

There was another question similar to the one I am asking here (Can you specify the schema URI on a JSON document that conforms to a JSON schema?) that was tagged as a duplicate of (How to reference schema of json which is top level array), but I…
Mark T
  • 59
  • 3
5
votes
1 answer

How to generate JSON schema of object type with dynamic key names?

Say I have following json: { "empName": "rameshp", "designation": "SE1", "skills": [ { "id": 2, "rating": 4, "skillName": "Node.js 7", "skillCategory": "Programming" } …
xploreraj
  • 3,792
  • 12
  • 33
  • 51
5
votes
1 answer

Json Schema - oneOf with ref to wildcard path?

I would like to organize the definitions section of my schema to group a number of similar definitions. In the example below, I have an "ipAddress" group that has "ipv4" and "ipv6" sub-definitions. (You could imagine adding even more…
user3337629
  • 181
  • 3
  • 9
5
votes
3 answers

Filter JSON data against JSON schema in Python

I am looking for Python module to filter JSON data against schema. For example, there is JSON data: { "system" : { "state" : "enabled", "id" : 5, "keys" : [ { "key_id": 12, "key": "filename.key" } ] …
Elephant
  • 675
  • 1
  • 8
  • 18