jsonschema

How can this be a JSON Schema

浪尽此生 提交于 2021-01-05 12:57:24
问题 I'm trying to validate that a JSON Schema is actually a JSON Schema, and not an instance, as I have read, resource for that is validate against meta-schema e.g: Core validation meta-schema (http://json-schema.org/draft/2019-09/schema) Older versions meta-schema (https://json-schema.org/draft-04/schema) I have tried with different validation libraries, json-schema-validator for Java, and jsonschema for Python to have more assurance, but I keep on obtaining the funny assertion that this is a

Exposing the JSON Schema for API endpoints?

杀马特。学长 韩版系。学妹 提交于 2020-12-29 07:24:25
问题 Is there a standard to where and how to expose the schema of API endpoints? For example, let's say the following API endpoints are available: api/companies/ api/companies/{id}/employees/ Where should the schema for the company and employee resources be exposed? api/company-schema.json and api/employee-schema.json ? api/schemas/company.json and api/schemas/employee.json ? 回答1: You can setup your schema endpoints any way you like, but you should use one of the recommended correlation methods.

How to validate a object based on the value of root object in json schema?

醉酒当歌 提交于 2020-12-15 06:42:17
问题 I want to validate sale date and customer availability based on the value of ordertype.(Note., They are not under same object).Is there any way to validate child values based on root value? { "type": "object", "properties": { "Order": { "type": "object", "properties": { "OrderDetails": { "type": "object", "properties": { "OrderType": { "type": "string", "enum": [ "Y", "N" ] } } } } }, "Sale": { "type": "object", "properties": { "Saledate": { "format": "date"/*should be present when OrderType

How to validate a object based on the value of root object in json schema?

微笑、不失礼 提交于 2020-12-15 06:42:16
问题 I want to validate sale date and customer availability based on the value of ordertype.(Note., They are not under same object).Is there any way to validate child values based on root value? { "type": "object", "properties": { "Order": { "type": "object", "properties": { "OrderDetails": { "type": "object", "properties": { "OrderType": { "type": "string", "enum": [ "Y", "N" ] } } } } }, "Sale": { "type": "object", "properties": { "Saledate": { "format": "date"/*should be present when OrderType

Everit schema builder includes unset properties as null

安稳与你 提交于 2020-12-15 05:42:57
问题 Trying to build and use the Schema object: Schema rootSchema = ObjectSchema.builder() .additionalProperties(true) .build(); It seems to work fine until I try to serialize it as a string and then to reload using the SchemaLoader: String json = objectMapper.writeValueAsString(rootSchema); JSONObject schemaObject = new JSONObject(json); Schema schema = SchemaLoader.load(schemaObject); The problem is that the unset keywords are serialized as null: { "title" : null, "description" : null, "id" :

JSON Schema Conditional Statements

寵の児 提交于 2020-12-07 16:32:45
问题 I am trying to validate what I thought was a simple JSON schema as a configuration file for my Python application, it's a list of header key/value pairs, the only complication is that if the 'Type' field is set to 'AnyValue' then the value key is not required. Here is the schema as it is: { "definitions": { 'KeyEntry': { "properties": { 'Type': {"type" : "string"}, 'Key': {"type": "string"} }, "required": ['Type', 'Key'], "anyOf": [ { "if": { "properties": {'Type': {"const": 'ExactValue'}} },

JSON Schema Conditional Statements

若如初见. 提交于 2020-12-07 16:31:55
问题 I am trying to validate what I thought was a simple JSON schema as a configuration file for my Python application, it's a list of header key/value pairs, the only complication is that if the 'Type' field is set to 'AnyValue' then the value key is not required. Here is the schema as it is: { "definitions": { 'KeyEntry': { "properties": { 'Type': {"type" : "string"}, 'Key': {"type": "string"} }, "required": ['Type', 'Key'], "anyOf": [ { "if": { "properties": {'Type': {"const": 'ExactValue'}} },

JSON Schema Conditional Statements

若如初见. 提交于 2020-12-07 16:30:20
问题 I am trying to validate what I thought was a simple JSON schema as a configuration file for my Python application, it's a list of header key/value pairs, the only complication is that if the 'Type' field is set to 'AnyValue' then the value key is not required. Here is the schema as it is: { "definitions": { 'KeyEntry': { "properties": { 'Type': {"type" : "string"}, 'Key': {"type": "string"} }, "required": ['Type', 'Key'], "anyOf": [ { "if": { "properties": {'Type': {"const": 'ExactValue'}} },

JSON Schema Conditional Statements

╄→гoц情女王★ 提交于 2020-12-07 16:29:17
问题 I am trying to validate what I thought was a simple JSON schema as a configuration file for my Python application, it's a list of header key/value pairs, the only complication is that if the 'Type' field is set to 'AnyValue' then the value key is not required. Here is the schema as it is: { "definitions": { 'KeyEntry': { "properties": { 'Type': {"type" : "string"}, 'Key': {"type": "string"} }, "required": ['Type', 'Key'], "anyOf": [ { "if": { "properties": {'Type': {"const": 'ExactValue'}} },

JSON Schema with unknown property names

ぃ、小莉子 提交于 2020-11-30 17:09:05
问题 I want to have a JSON Schema with unknown property names in an array of objects. A good example is the meta-data of a web page: "meta": { "type": "array", "items": { "type": "object", "properties": { "unknown-attribute-1": { "type": "string" }, "unknown-attribute-2": { "type": "string" }, ... } } } Any ideas please, or other way to reach the same? 回答1: Use patternProperties instead of properties . In the example below, the pattern match regex .* accepts any property name and I am allowing