jsonschema

How to conditionally forbid properties based on presence of other properties in JSON Schema?

僤鯓⒐⒋嵵緔 提交于 2020-04-13 03:53:10
问题 In my schema I declared these properties: "index_name": { "type": "string", "examples": ["foo-wwen-live", "foo"] }, "locale": { "type": "string", "examples": ["wwen", "usen", "frfr"] }, "environment": { "type": "string", "default": "live", "examples": [ "staging", "edgengram", "test" ] } I want a JSON body validated against my schema to be valid only if : index_name is present, and both locale and environment are not present; locale and/or enviroment are present, and index_name is not present

best way to make conditional arrays in json schema with decent error messages

半腔热情 提交于 2020-03-25 19:07:31
问题 I would like to constrain a (tuple) array in JSON-schema, and get decent error messages but so far I was unsuccessful. The array consists of 2 items, the first is a string, and the second is an object. The properties that are allowed/required in the object depends on the string. 2 valid examples would be: { "color": [ "white", { "a white property": 42 }] } and { "color": [ "black", { "this is a black property": "tAttUQoLtUaE" }] } for reference, the type in typescript would be defined as:

JSON schema deeper object uniqueness

痴心易碎 提交于 2020-03-23 06:18:17
问题 I'm trying to get into JSON schema definitions and wanted to find out, how to achieve a deeper object uniqueness in the schema definition. Please look at the following example definition, in this case a simple IO of a module. { "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", "required": ["modulIOs"], "properties": { "modulIOs": { "type": "array", "uniqueItems": true, "items": { "allOf": [ { "type": "object", "required": ["ioPosition","ioType","ioFunction"],

JSON schema conditional check on certain object attribute within an array

允我心安 提交于 2020-03-03 10:54:05
问题 What I want to do either via AJV - JSON Schema validation or Custom Keywords (preferably I would go with this): The Array can have 1 or 2 JSON objects with type as 'admin' and 'guest'. The "type":"guest" object will always be there and "type":"admin" object is optional. Extra Notes: -The object itself may contain addition attributes and nested objects, in future -The other valid enums aresuperadmin, admin,user and guest -The type sequence in array is: superadmin, admin,user and guest. Is it

Erroneous successful validation by JSON-schema

ε祈祈猫儿з 提交于 2020-01-25 08:23:05
问题 The fields in nodes depend on the value of entity. That is, if entity = "pd", then nodes has some fields, while entity = " top " - nodes has completely different fields, despite the fact that they are strictly required. For some reason, the JSON string is accepted by the valid schema, even if there are no fields defined in nodes as required. I already entire head broke, where can be mistake in the most scheme? JSON-schema: { "definitions": {}, "$schema": "http://json-schema.org/draft-07

Metaschema specifying required attribute for all properties

僤鯓⒐⒋嵵緔 提交于 2020-01-24 13:59:05
问题 I want to customize a metaschema such that all properties are required to have an additional attribute, for example, how could I require that all properties specify a "type" ? Then this schema should fail: { "$schema": "http://json-schema.org/schema#", "title": "...", "description": "...", "type": "object", "properties": { "name": { "description": "..." } } } But this one should succeed: { "$schema": "http://json-schema.org/schema#", "title": "...", "description": "...", "type": "object",

Decimal precision in JSON Schema

痞子三分冷 提交于 2020-01-24 02:39:47
问题 I want to have my JSON Schema validate that no more than two decimal places are sent to my REST api. From what I can see in the latest JSON Schema RFC (v4) doesn't allow this. V1 had a maxDecimals validator. Does anyone know why that was taken out? I have a field that only holds two decimals when I store it in the database, and I do not just want to round down to two decimals. That would be changing the input quite dramatically for some users. So I want to reject any greater precision and

How do I validate a JSON Schema schema, in Python?

你。 提交于 2020-01-22 08:23:32
问题 I am programmatically generating a JSON-Schema schema. I wish to ensure that the schema is valid. Is there a schema I can validate my schema against? Please note my use of schema twice in that sentence and the title. I don't want to validate data against my schema, I want to validate my schema. 回答1: Using jsonschema, you can validate a schema against the meta-schema. The core meta-schema is here, but jsonschema bundles it so downloading it is unnecessary. from jsonschema import

How do I validate a JSON Schema schema, in Python?

ぐ巨炮叔叔 提交于 2020-01-22 08:23:31
问题 I am programmatically generating a JSON-Schema schema. I wish to ensure that the schema is valid. Is there a schema I can validate my schema against? Please note my use of schema twice in that sentence and the title. I don't want to validate data against my schema, I want to validate my schema. 回答1: Using jsonschema, you can validate a schema against the meta-schema. The core meta-schema is here, but jsonschema bundles it so downloading it is unnecessary. from jsonschema import

json schema for dynamic array

偶尔善良 提交于 2020-01-17 05:12:06
问题 I have the following json { "Dettype": "QTY", "Details": [ { "12568": { "Id": 12568, "qty":1, "Freq":"2", "Option": 0, "promote":"yes" }, "22456": { "Id": 22456, "qty":2, "Freq":"3", "Option": 1, "promote":"no" } } ] } For the above json i need to write a json schema file which will valdiates the request. but the problem is in array the key value for each item changes dynamically. If it is some constant value i can write but don't how to do the dynamic pattern JSON schema i got { "type":