jsonschema

JSON schema - how to use oneOf

此生再无相见时 提交于 2019-12-11 02:49:12
问题 The following is a valid JSON schema according to http://jsonlint.com/ and http://jsonschemalint.com/draft4/#. { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": ["results"], "additionalProperties": false, "properties": { "results": { "type": "string", "oneOf": [ { "result": "1" }, { "result": "2" }, { "result": "3" }, { "result": "4" } ] } } } The following JSON reports an error ( results is the wrong type ) when validated against the above schema: {

Json.NET validate JSON array against Schema

拥有回忆 提交于 2019-12-11 00:14:19
问题 I want to validate a schema which has an array, all in one call to the validate method. I did it in javascript but I am sturggling to do it in C# with Json.NET. With Json.NET I am calling the validation method for each object in the array like so: JSchema schema = JSchema.Parse(@"{ 'title': 'HouseCollection', 'description': '', '$schema': 'http://json-schema.org/draft-04/schema#', 'definitions': { 'Categories': { 'title': 'Categories', 'description': '', '$schema': 'http://json-schema.org

nested “oneOf” issue in json schema draft 4 using tv4.js

青春壹個敷衍的年華 提交于 2019-12-10 22:48:13
问题 I'm using tv4.js to validate some json against a schema (which has nested oneOf properties) but it returns errors when I am using valid data. Here is the result object I get back from the tv4.js validateMultiple method: {"valid":false,"errors":[{"code":11,"message":"Data does not match any schemas from \"oneOf\"","schemaKey":null,"dataPath":"/shape","subErrors":[{"code":302,"message":"Missing required property: boxname","schemaKey":null,"dataPath":"/shape","subErrors":null},{"code":1,"message

How do I do a nested list (array) of schema references in json schema

只愿长相守 提交于 2019-12-10 22:18:05
问题 I am trying to build a schema which has a list of items that I want to have an enforced schema. Basically here is the data I want to validate against the schema: data = { "VIN" : "123", "timestamp" : "xxxx", "model" : "jeep", "inspections": [ { "door_badge" : { "expected": "yes", "image": "/image/path/here", "state": 1 }, }, { "rear_badge" : { "expected" : "yes", "image" : "/image/path/here", "state": 1 } } ], } And my schema mapping as is such but seem to be getting errors when trying to

How can I define the sequence of properties in JSON Schema?

我的未来我决定 提交于 2019-12-10 19:12:01
问题 I have following java Object: ProcessBean.java import java.util.List; import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName(value = "process") public class ProcessBean{ private Integer id; private String name; private String description; private String user; private String executePermissions; private String createdDtm; private String updatedDtm; private Process tpProcess; private List<ProcessParamBean> processParameters; /* --------Getters and Setters ----------*/ } I need to

Is XML Schema xs:alternative equivalent available in JSON Schema?

十年热恋 提交于 2019-12-10 16:15:19
问题 Is it possible to use alternatives in JSON Schema? In XSD this is doable using xs:alternative element. For example see: How to use alternatives in XML Schema 1.1 UPDATE 1: This is a sample JSON I would like to describe using JSON schema: { "actions": [ { "type": "basic", "param1": "value" }, { "type": "extended", "param1": "value", "param2": "blah" } ] } Requirements: actions may have any number of items basic actions must contain param1 property extended actions must contain param1 and

How do I do a nested list (array) of schema references in json schema that isn't a dictionary

别等时光非礼了梦想. 提交于 2019-12-10 15:06:51
问题 So I have a similiar question (see: How do I do a nested list (array) of schema references in json schema), but now my structure is changed a little and can't seem to get it to validate. data = { 'VIN': '1234567', 'Vehicle color': blue, 'inspections': [ {'expected': 'MVA', 'found': 0.0, 'inspection': 'Fascia', 'location': 'rear_left', 'state': None}, {'expected': 'MVA', 'found': 0.0, 'inspection': 'Fascia', 'location': 'rear_right', 'state': None}, {'expected': 'UNKNOWN', 'found': 'CPW7',

JSON schema: date greater than an other

天涯浪子 提交于 2019-12-10 14:47:31
问题 I've a json schema like this: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Operation", "description": "The schema of an operation", "type": "object", "properties": { "id":{ "description": "Unique identifier of the service", "type": "string" }, "description":{ "type": "string" }, "dateDebut":{ "type": "string", "format": "date-time" }, "dateFin":{ "type": "string", "format": "date-time" } } } How can I say in my schema that the dateFin must be greater than the dateDebut ?

json-schema: how to transform from one json-schema to another

可紊 提交于 2019-12-10 09:35:35
问题 I have the two different json-schemas: schemaA -> A calendar as defined at http://json-schema.org/calendar { "$schema": "http://json-schema.org/draft-04/schema#", "description": "A representation of an event", "type": "object", "required": [ "dtstart", "summary" ], "properties": { "dtstart": { "format": "date-time", "type": "string", "description": "Event starting time" }, "dtend": { "format": "date-time", "type": "string", "description": "Event ending time" }, "summary": { "type": "string" }

What is the difference between “anyof” and “oneof” in z schema?

徘徊边缘 提交于 2019-12-10 05:15:50
问题 Its looking like both works fine with my input validation code. Then what is the exact difference? Schema with oneof [{ "id": "MyAction", "oneOf": [{ "$ref": "A1" }, { "$ref": "A2" }] }, { "id": "A1", "properties": { "class1": { "type": "string"}, "class2": { "type": "string"} } }, { "id": "A2", "properties": { "class2": { "type": "string"}, "class3": { "type": "string"} } } ] Schema with anyof [{ "id": "MyAction", "anyOf": [{ "$ref": "A1" }, { "$ref": "A2" }] }, { "id": "A1", "properties": {