jsonschema

JSON Schema - array of different objects

蓝咒 提交于 2021-02-19 07:44:20
问题 I'd like to know how to specify a JSON schema for an array of different objects. This thread gives me half the answer, but fails when I have multiple instances of each type of object. Here's a sample XML, based on the example given here but with the " Product " object being repeated:- { "things": [ { "entityType" : "Product", "name" : "Pepsi Cola", "brand" : "pepsi" }, { "entityType" : "Product", "name" : "Coca Cola", "brand" : "coke" }, { "entityType" : "Brand", "name" : "Pepsi Cola" } ] }

Can a property of an allOf item contain a $ref to another allOf items definition?

[亡魂溺海] 提交于 2021-02-10 20:11:16
问题 Is "#/allOf/1/properties/body/properties/foo" a valid $ref? As stated in this article which explains $ref usage, it looks like it should be. However both AJV and https://www.jsonschemavalidator.net/ seem to disagree. Trying with a plain JSON Pointer it definitely seems to be possible: https://repl.it/repls/WretchedSpiritedMammoth This is the schema I'm testing with. { "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", "allOf": [ { "$schema": "http://json-schema.org/draft

Reference remote enum values from json-schema

时间秒杀一切 提交于 2021-02-10 12:54:06
问题 In my schema definitions, I have a type, with an integer property which should be any of a "fixed" set of numbers. The problem is that this "fixed set" may be changed often. "person": { "type": "object", "properties": { "aproperty": { "type": "integer", "enum": [1, 12, 30 ... , 1000] }, } }, Is there any way to reference this array from a remote service (which will have the most updated set)? "person": { "type": "object", "properties": { "aproperty": { "type": "integer", "$ref": "http:/

JSON data enum types

一笑奈何 提交于 2021-02-08 09:18:17
问题 I have a JSON object like this. var data={ "Company" : "XYZ", "company" : ['RX','TX'] } The above json data has 2 keys Company whose type is string and company whose type is enum but not array (I didnt know how to represent enum in json data),because of which json schema says its an array. I want it to be enum type. So how will I represent Enum type in JSON data? 回答1: JSON has no enum type. The two ways of modeling an enum would be: An array , as you have currently. The array values are the

make json schema pattern case insensitive

末鹿安然 提交于 2021-02-07 12:05:42
问题 in my json schema i made a definition for "colors" like this { "colors": { "type":"string", "pattern": "AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGray|DarkGrey|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkSlateGrey|DarkTurquoise

make json schema pattern case insensitive

眉间皱痕 提交于 2021-02-07 12:04:27
问题 in my json schema i made a definition for "colors" like this { "colors": { "type":"string", "pattern": "AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGray|DarkGrey|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkSlateGrey|DarkTurquoise

JSON schema for validating list with different possible field values

百般思念 提交于 2021-02-05 11:59:26
问题 Within a JSON structure (“event bundle”), I am collecting several lists of events. These are called event lists. Each event in that list has at least a type field, whose value is dependent on which list it is stored in. Consider the following valid example: { "event_bundle": { "alert_events": [ { "type": "fooAlert1", "value": "bar" }, { "type": "fooAlert2", "value": "bar" }, { "type": "fooAlert3", "value": "bar" } ], "user_events": [ { "type": "fooUser1", "value": "bar" }, { "type": "fooUser2

JSON schema for validating list with different possible field values

对着背影说爱祢 提交于 2021-02-05 11:59:22
问题 Within a JSON structure (“event bundle”), I am collecting several lists of events. These are called event lists. Each event in that list has at least a type field, whose value is dependent on which list it is stored in. Consider the following valid example: { "event_bundle": { "alert_events": [ { "type": "fooAlert1", "value": "bar" }, { "type": "fooAlert2", "value": "bar" }, { "type": "fooAlert3", "value": "bar" } ], "user_events": [ { "type": "fooUser1", "value": "bar" }, { "type": "fooUser2

handling infinity values in JSON

笑着哭i 提交于 2021-02-05 11:34:06
问题 I need at one place to have the support for infinity, -infinity and NaN values in my JSON. Now though JSON does have support for these values, but is there any support for specifying about them in the schema of the same JSON instance, I mean the RFC specification says that these values are not supported under "number" type. However, when I validated one such JSON instance having infinity value against a schema with the type "number", it produced no error! Can someone help me to figure out why

Is it possible to reference property name in enum from another AJV definitions?

家住魔仙堡 提交于 2021-02-05 07:47:26
问题 I'm looking if it's possible to reference property names as enum values in AJV definitions. Here is an example: { "$id": "modes.json", "description": "Example modes", "type": "object", "properties": { "MODE_WALK": { "$ref": "walk.json" }, "MODE_BICYCLE": { "$ref": "bicycle.json" }, } } Then I have another file with: { "$id": "another.json", "description": "Example object", "type": "object", "properties": { "text": { "type": "string", "maxLength": 128 }, "mode": { "description": "Allowed modes