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

JSON Schema - conditional validation

I have the following Schema. I've implemented it as best I can, but it's still not working quite as I want it to. { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "title": "Ordering pizza", "propertyNames":…
Barry Piccinni
  • 1,685
  • 12
  • 23
1
vote
0 answers

How to validate a complex schema using meta-schema?

I'm trying to validate some schemas that I already have against to a meta-schema using the Ajv lib. I'm getting the result that the schemas are valid even when if I change it to an invalid definition. This is one schema: { "id": "TEST_SCHEMA", …
1
vote
1 answer

How to validate an array that can contain items that are objects of different types

I have a schema where I have an array (inside the transmit object) which could possibly have one of two options (A or B). I have attached both the schema and sample data (that is actually getting validated, when it should have thrown an…
Bhakta Raghavan
  • 664
  • 6
  • 16
1
vote
1 answer

Is there a way to split a Swaggerfile / OpenAPI definition into multiple files?

Is there a way to split a swaggerfile / OpenAPI specs file, either JSON or YAML, encoding every $ref into a separate file? Because I found a lot of solutions to achieve the opposite (multiple files -> single file), but none for this. What I'd like…
1
vote
1 answer

Mongodb v4 Document Validation Failed

I'm relatively new to mongo and I'm encountering a validation issue in our production environment that doesn't appear to be happening in our dev environment. I think this is due to the validationLevel not being set to strict in dev. I've lost hours…
Tom Miller
  • 431
  • 1
  • 5
  • 16
1
vote
1 answer

enum list as object property in json schema

I'm looking to find a way to declare objects defined in an enum list. Here is what I want to check : { "object1": { "subobject1": { "value": 123 }, "subobject2": { "value": 456 } }, "object2": { "subobject3": { …
1
vote
1 answer

Multi-stage $ref doesn't work with jsonschema version 3.0.1

It seems that jsonschema version 3.0.1 does not accept multi-stage schema using $refs (while it works with jsonschema version 2.6.0). I have to make it work under several module versions simply because my code will be running on different computers…
1
vote
0 answers

RUBY: Date format YYYY-MM-DD from json-schema gem not working, why?

I'm using the ruby gem json-schema I have json schema code that uses format "date" which doesn't work, however, "format": "date-time" works. Any clue why it's not working? schema.json { "id": "url here", "$schema":…
abdi test
  • 11
  • 1
1
vote
1 answer

Validating that a property value exists withing the keys of an object

Wise crowd, I already have a working JSON Schema (v0.7) to validate my data. This is an example of valid JSON: { "people": [ { "id": 1, "name": "bob" }, ... ] } Now I need to a bunch of strings in it: { "people": [ { "id": 1,…
Manu
  • 13
  • 4
1
vote
0 answers

Given multiple JSON instance files, how to infer a single JSON schema?

I have several JSON files: a.json, b.json, c.json. Is there a tool that could generate one single JSON schema from these files? I am looking for a tool where I could use a command like tool --files a.json b.json c.json > merge.schema.json.
ooj-001
  • 180
  • 9
1
vote
1 answer

Why does my JSON Schema appear to not validate a child object correctly?

Given the JSON and Schema below, actor.mbox, actor.member[0].objectType and actor.member[0].mbox should all fail. They do not. There must be something wrong in my schema. I think I have narrowed it to something dealing with the IdGroup definition…
dmcquay
  • 167
  • 2
  • 11
1
vote
1 answer

Valid name for definitions item

Is it correct to make a definition (suppose with name "abc") and then refer to it from an attribute called "abc" whose type is "array"? Or it's incorrect and array and its items have to have different names? Thanks! { "$schema":…
Mary
  • 45
  • 8
1
vote
1 answer

Can a sub-schema defined inside the definitions object refer to another sub-schema?

It might be that the answer is so obvious, it's not even worth mentioning anywhere, but I couldn't find any explicit information about this. Can a definition of a schema (defined inside "definitions" in the JSON schema) refer to another…
Dorielle
  • 85
  • 5
1
vote
1 answer

Should I validate input in API or BL layer?

I have a node.js application with an API, BL and DAL layers and I want to validate user input. Currently I'm doing the validation at the beginning of BL functions so it doubles as a user input validator and an inner application validators (calls…
Or Betzalel
  • 2,427
  • 11
  • 47
  • 70
1
vote
1 answer

How to validate existence and values of some object properties based on the value of a Type object property?

I'm trying to validate JSON which is more complex than what's below, but hopefully this simpler example illustrates the issue cleanly. Within the more complex schema, I need to have an array of objects, where: All objects have a set of the same…
mjcconsulting
  • 75
  • 1
  • 8