json-schema-validator

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 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

JSON formatting “$ref” error

陌路散爱 提交于 2020-01-17 05:59:38
问题 I am trying to find what is making the following JSON invalid. The strange thing is that it passes off as valid JSON in this website but is invalid in this one Here's the schema: http://pastebin.com/QPxEPjMT The error logged on the second schema validation website is as follows: Error when resolving schema reference '#/definitions/identifiable'. Path 'definitions.subscription.allOf[0]', line 19, position 17. Can someone clarify whether my schema is incorrect or this is about some ambiguous

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":

How to run json-schema-validator from the command line

徘徊边缘 提交于 2020-01-06 08:30:34
问题 Is it possible to run the json-schema-validator from the command line? Is there a jar file for json-schema-validator? I found a jar at: [http://mvnrepository.com/artifact/com.github.fge/json-schema-validator/2.1.8][1] but it appears to be corrupt/incomplete/something (I'm not a Java programmer). Applying java.exe to the jar file: java -jar json-schema-validator-2.1.8.jar results in this error message: "no main manifest attribute, in json-schema-validator-2.1.8.jar" What does that mean? Here

Validating json payload against swagger file - json-schema-validator

懵懂的女人 提交于 2020-01-02 08:54:07
问题 I am trying to validate a json payload against a swagger file that contains the service agreement. I am using the json-schema-validator(2.1.7) library to achieve this, but at the moment it's not validating against the specified patterns or min/max length. Java Code: public void validateJsonData(final String jsonData) throws IOException, ProcessingException { ClassLoader classLoader = getClass().getClassLoader(); File jsonSchemaFile = new File (classLoader.getResource("coachingStatusUpdate

Is it possible in json schema to define a constraint between two properties

送分小仙女□ 提交于 2020-01-01 12:15:23
问题 I have two fields in my schema - one is a required property called "name" and the other is optional (used to define a sorting property) called "nameSort" and I want to express If the "nameSort" field is defined, the "name" field should also be defined as the same value. Is it possible to express such an "inter-element" constraint with JSON schema? My cursory read of JSON Schema here http://json-schema.org/latest/json-schema-validation.html says no. 回答1: You can express one property must be

Use conditional statements on json schema based on another schema object

给你一囗甜甜゛ 提交于 2019-12-31 01:44:36
问题 I have a json object like: { "session": { "session_id": "A", "start_timestamp": 1535619633301 }, "sdk": { "name": "android", "version": "21" } } The sdk name can either be android or ios . And the session_id is based on name field in sdk json . I have written a json schema using conditional statement (Using draft 7) as follows: But it works in an unexpected manner: { "$schema": "http://json-schema.org/draft-07/schema#", "$ref": "#/definitions/Base", "definitions": { "Base": { "type": "object"

JSON Schema - conditional validation

倾然丶 夕夏残阳落幕 提交于 2019-12-24 10:51:21
问题 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": { "enum": [ "q-who-did-you-order-from", "q-did-they-accept-your-order", "q-how-much-was-the-bill", "q-why-didnt-they-accept" ] }, "properties": { "q-who-did-you-order-from": { "type": "string", "title": "Who have you ordered pizza from?", "maxLength": 50,