jsonschema

Getting Exception java.lang.NoClassDefFoundError: com/github/fge/Frozen while validating json schema using json-schema-validator 2.1.8

折月煮酒 提交于 2020-01-05 04:17:18
问题 I am trying to validate json using json schema validator and am using the following versions of jars: json-schema-validator-2.1.8 json-schema-core-1.1.9 jackson coreutils 1.5 guava 16.0.1 jackson databind 2.2.3 jackson core 2.3.1 jackson anno 2.3.1 . final JsonNode fstabSchema=Utils.loadResource("Schemas/JsonSchema/"+serviceName+".json"); final JsonNode jsonResponse = Utils.loadResource("Response/Json/devices_search_2.json"); final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();

Make sure object field has value existing in another field in Json Schema

橙三吉。 提交于 2020-01-04 05:35:16
问题 I am trying to express objects and relationships between them. Every object has an ID and every relationship references 2 object ids. I'd like to make sure every relationship references existing object ids. Could you do this with Json Schema? { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "Objects": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" } } } }, "Relations": { "type": "array", "items": { "type":

JSON make case insensitive

假如想象 提交于 2020-01-04 05:25:14
问题 I'm trying to generate a schema from my C# models, and so far things are going well with the following: JSchemaGenerator generator = new JSchemaGenerator(); JSchema schema = generator.Generate(typeof(MyClass)); schemachema.AllowAdditionalProperties = false; schemachema.UniqueItems = false; JObject update = JObject.Parse(@"{MYJSON}"); IList<string> messages; bool IsValid = update.IsValid(clientSchema, out messages); The one thing I have not been able to figure out is how to make it case

How to use definitions from external files in JSON Schema?

徘徊边缘 提交于 2020-01-03 18:00:29
问题 I'm trying to import the definitions from another json schema using $ref but getting the following error: can't resolve reference ../base/definitions.schema.json#/definitions/datetime from id # { "$schema": "http://json-schema.org/draft-06/schema#", "definitions": { "datetime": { "type": "string" }, "name": { "type": "string" }, } } { "$schema": "http://json-schema.org/draft-06/schema#", "properties": { "active": {"type": "boolean"}, "created_at": { "$ref": "../base/definitions.schema.json#

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

JSON Schema conditional: require and not require

不羁的心 提交于 2020-01-01 11:00:09
问题 I'm trying to implement this condition: if a particular property exists, then another property is required; but if it does not exist, another one is not required. Also, in JSON schemas, can we use not in dependencies? Here is a sample schema var schema = { "properties": { "smaller": { "type": "number" }, "larger": { "type": "number" }, "medium":{'type':'string'}, "bulky":{'type':'string'} }, require:['smaller','larger'], additionalProperties:false }; If "medium" is present, then "bulky" is

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"

Freeform subobject in json-schema

泄露秘密 提交于 2019-12-29 10:05:23
问题 I am drafting an API documentation with swagger.io and is trying to make it fit to our use case. The system is going to receive and process data from all sources, and they would each have different sets of fields. While the product of the processing share the same schema, we want to include the input in the schema too for reference purpose. For instance, given { "foo": "bar" "bar": "baz" } The product of the processing is { "original": { "foo": "bar", "bar": "baz" } "processed": { "stdFieldA"

JSON Schema property dependent on value of previous property

江枫思渺然 提交于 2019-12-29 09:29:25
问题 I'd like to be able to write JSON schema code that allows one property's value to be dependent on the value of another property. More specifically, I have two questions A and B. Question B's answer can only be not null when question A has a specific answer. If question A does not have that answer, then the value to question B must be null. E.g. A: Do you like cars? Yes/No B: What is your favourite car? Question B can only be answered if the answer to question A is "Yes", otherwise it must be