jsonschema

Is it possible to create a JSON Schema with allOf (multiple if and then) and $ref?

荒凉一梦 提交于 2020-05-29 10:15:50
问题 I am trying to create a complex schema that will check for the value of a property and then validate according to the value of that same property. I am wondering if it's possible to use $ref and allOf in the same schema and if so, how? I am having some trouble getting this to work. It may be important to note that I am using AJV. Please see my code below { "$ref": "#/definitions/Welcome", "definitions": { "Welcome": { "properties": { "auth": { "type": "string", "enum": ["oauth1","oauth2"] },

What is the Correct way to define key-value pairs in json schema

天涯浪子 提交于 2020-05-29 03:21:32
问题 How do i define key value pairs object in json schema (the "correct" way) ? i want to define this: "id" : 99, _info : { "name" : "somename", "href" : "someUrl" } Are any of the following two accurate?: 1) { "type": "object", "name": "MyObj", "properties": { "id": { "type": "integer" }, "_info": { "type": "array", "items": { "type": "object" "properties": { "key": { "type": "string", "description": "key" }, "value": { "type": "string", "description": "the value" } } } } } } 2) { "type":

Why Spark outputs nullable = true, when schema inference left to Spark, in case of JSON?

不羁岁月 提交于 2020-05-16 06:33:33
问题 Why does Spark show nullable = true , when schema is not specified and its inference is left to Spark ? // shows nullable = true for fields which are present in all JSON records. spark.read.json("s3://s3path").printSchema() Going through the class JsonInferSchema, can see that for StructType, explicitly nullable is set to true . But am unable to understand the reason behind it. PS: My aim is to infer schema for a large JSON data set (< 100GB), and wanted to see if Spark provides the ability

Why Spark outputs nullable = true, when schema inference left to Spark, in case of JSON?

北战南征 提交于 2020-05-16 06:33:31
问题 Why does Spark show nullable = true , when schema is not specified and its inference is left to Spark ? // shows nullable = true for fields which are present in all JSON records. spark.read.json("s3://s3path").printSchema() Going through the class JsonInferSchema, can see that for StructType, explicitly nullable is set to true . But am unable to understand the reason behind it. PS: My aim is to infer schema for a large JSON data set (< 100GB), and wanted to see if Spark provides the ability

Is there a way to raise an error for any additional key present in JSON if I am using the if-else condition of JSON Schema?

烂漫一生 提交于 2020-05-15 07:59:05
问题 I have a use case where I want to check the keys present in JSON, depending on the value of a different key. Example JSON-1: { "key_name" : "value1", "foo" : "random_value1" } Example JSON-2: { "key_name" : "value2", "bar" : "random_value2" } As per these examples, Rule 1. If the value of "key_name" is "value1" then only "foo" key should be present in JSON. Rule 2. If the value of "key_name" is "value2", then only "bar" key should be present in JSON. I have written the following JSON Schema

Schema update validation fails Azure logic apps

故事扮演 提交于 2020-04-30 06:38:07
问题 In my Logic app I am using HTTP trigger which fires every 3 hours and using a get request on it. After the API responds, the parse JSON call does schema validation. So far with HTTP trigger and Parse JSON, I don't know a way to disable validation of JSON. I know 'when HTTP request is received' as disable validation option but in my case I don't need 'When http request is recieved', I need HTTP trigger on recurrence basis. Here are my two questions 1) Is there a way to disable schema

How to exclude Primitive types from required list of Json Schema (version4)

ε祈祈猫儿з 提交于 2020-04-18 03:54:08
问题 I have following classes as mentioned below: public class Test1 { private String name; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age= age; } } JsonSchema generating the following schema: { "$schema" : "http://json-schema.org/draft-04/schema#", "title" : "Test 1", "type" : "object", "additionalProperties" : false, "properties" : { "name" : { "type" :

How to enforce only one property value to true in an array (JSON Schema)

放肆的年华 提交于 2020-04-14 07:36:53
问题 I am trying to have JSON validation based on the following input: { "elements":[ { "..." "isSelected": true }, { "..." "isSelected": false }, { "..." "isSelected": false } ] } The input is going to be valid if and only if we have "isSelected" set to "true" (and all the rest set to "false"). Can't have "isSelected: true" more than once (and all the rest need to be "false"). Tried with the following: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "definitions": {

How to enforce only one property value to true in an array (JSON Schema)

Deadly 提交于 2020-04-14 07:36:30
问题 I am trying to have JSON validation based on the following input: { "elements":[ { "..." "isSelected": true }, { "..." "isSelected": false }, { "..." "isSelected": false } ] } The input is going to be valid if and only if we have "isSelected" set to "true" (and all the rest set to "false"). Can't have "isSelected: true" more than once (and all the rest need to be "false"). Tried with the following: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "definitions": {

How to enforce only one property value to true in an array (JSON Schema)

与世无争的帅哥 提交于 2020-04-14 07:36:10
问题 I am trying to have JSON validation based on the following input: { "elements":[ { "..." "isSelected": true }, { "..." "isSelected": false }, { "..." "isSelected": false } ] } The input is going to be valid if and only if we have "isSelected" set to "true" (and all the rest set to "false"). Can't have "isSelected: true" more than once (and all the rest need to be "false"). Tried with the following: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "definitions": {