jsonschema

JSON Schema - how do I specify that a boolean value must be false?

一曲冷凌霜 提交于 2019-12-04 22:26:27
Let's say I have a type that will be boolean, but I don't just want to specify that it will be boolean, I want to specify that it will have the value false. To just specify that it will be boolean I do the following: { "properties": { "some_flag": { "type": "boolean" } } } I have tried substituting "boolean" above for "false" and false (without quotes), but neither works. Use the enum keyword: { "properties": { "some_flag": { "enum": [ false ] } } } This keyword is designed for such cases. The list of JSON values in an enum is the list of possible values for the currently validated value. Here

How do I configure VS Code to enable code completion on .json files (jsonschema support)?

↘锁芯ラ 提交于 2019-12-04 18:53:03
问题 In the Visual Stuido Code demo minute 28:57-29:20 and 30:20-31:10, some cool JSON code completion is shown. Where and how do I add a schema for my JSON files to a project? How does VS Code know which schema to use for a given .json file? 回答1: The association of JSON schemas to files is done in the settings (File, Preferences, User Settings or Workspace Settings), under the property 'json.schemas'. This is an example how the JSON schema for bower is associated to the bower schema. "json

Generate JSON Schema for ASP.Net Web API

不羁岁月 提交于 2019-12-04 18:32:07
问题 I'm looking to generate JSON Schema for a WebAPI, including documentation from the XML comments. Its primarily so that I can then import that into our API docs (using apiary.io) I've managed to get a workaround solution by adding swagger (and swashbuckle) and then using the raw link on each service - but ideally I'd like something a bit cleaner, that works across all apis (this has to be done per service / controller), and didnt have so many dependencies. Before I go and look at how swagger

How to represent sum/union types in in json schema

只谈情不闲聊 提交于 2019-12-04 16:46:51
问题 I am trying to document an existing use of JSON using json-schema. The system permits the following two possabilities for one of the object attributes. Either { "tracking_number" : 123 } Or { "tracking_number" : [ 123, 124, 125 ] } How can I express this using json schema? 回答1: Use anyOf to assert that the property must conform to one or another schema. { "type": "object", "properties": { "tracking_number": { "anyOf": [ { "$ref": "#/definitions/tracking_number" }, { "type": "array", "items":

Android, Gradle and duplicate files error during packaging

拜拜、爱过 提交于 2019-12-04 14:47:18
I want to use the json-schema-validator in my Android project like this: dependencies { compile 'com.github.fge:json-schema-validator:2.1.8' } Unfortunately Gradle stops packaging due to this file duplicate error: Path in archive: draftv3/schema Origin 1: /Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-validator/2.1.8/4c2a5be8ce86c2338561a651d7d22fb4c4a8763d/json-schema-validator-2.1.8.jar Origin 2: /Users/andrej/.gradle/caches/modules-2/files-2.1/com.github.fge/json-schema-core/1.1.9/4ead9ba3fb3bde69d93f738042d12a9e60e41645/json-schema-core-1.1.9.jar I know I can

How can I export a rails model to json schema?

六眼飞鱼酱① 提交于 2019-12-04 14:01:24
问题 I am looking to optimize how we build forms for some of our models and ideally I would like to build them from json-schema. Is there a gem or the like which would allow me to export a model definition to json-schema? Bonus: With validations. Bonus: While modelling association relationships. 回答1: Formtastic: http://github.com/justinfrench/formtastic has a mechanism for building forms from the models. Maybe you could base your code on theirs. Check in lib/formtastic.rb line 474 or so. Railscast

How to generate JSON schema from a JAXB annotated class?

白昼怎懂夜的黑 提交于 2019-12-04 13:09:13
I have a entity class looks like this. @XmlRootElement public class ImageSuffix { @XmlAttribute private boolean canRead; @XmlAttribute private boolean canWrite; @XmlValue; private String value; } And I'm using following dependency for JSON generation. <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.1.4</version> </dependency> When I tried with following code, (which referred from Generating JSON Schemas with Jackson ) @Path("/imageSuffix.jsd") public class ImageSuffixJsdResource { @GET @Produces({MediaType.APPLICATION

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

此生再无相见时 提交于 2019-12-04 11:35:39
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. You can express one property must be defined when another is present, e.g.: { "type": "object", "dependencies": { "nameSort": ["name"] } } However,

How do you reference other property values in JSON schema?

老子叫甜甜 提交于 2019-12-04 10:45:46
I have a JSON schema with 2 properties, minimumTolerance and maximumTolerance. I need to make sure that the value of maximumTolerance is not smaller than minimumTolerance & vice versa. Is this possible in JSON schema? Here is an example of what I'd like to be able to do: { "$schema": "http://json-schema.org/draft-06/schema#", "title": "MinMax", "description": "Minum & Maximum", "type": "object", "properties": { "minimumTolerance":{ "type": "number" "maximum":{ "$ref":"maximumTolerance" } } "maximumTolerance":{ "type": "number" "minumum": { "$ref":"minimumTolerance" } } } Relequestual As of

Generate JSON schema from java class

一个人想着一个人 提交于 2019-12-04 09:52:30
问题 I have a POJO class public class Stock{ int id; String name; Date date; } Are there any annotations or development framework/api that can convert POJO to JSON schema like below {"id": { "type" : "int" }, "name":{ "type" : "string" } "date":{ "type" : "Date" } } and also i can expand the schema to add information like "Required" : "Yes", description for each field, etc., by specifying some annotations or configurations on POJO and can generate JSON Schema like below. {"id": { "type" : "int",