json-schema-validator

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 ?

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

json schema property description and “$ref” usage

做~自己de王妃 提交于 2019-12-08 16:21:05
问题 I am writting a json schema to validate my json outputs produced by an exe.The schema being little bit complexe, I have defined some "definitions" that are referenced in properties ("$ref": "#/definitions/...). And using definitions here is all the more important because I have a case where the definition is recursive. My schema now works well, it validates correctly my json outputs. Now, I am trying to document the schema correctly using "description" keyword for each property. To develop

JSON schema: referencing a local child schema

有些话、适合烂在心里 提交于 2019-12-08 08:17:39
问题 I want to reference a child schema in a parent json schema. Here is the child schema named child.json { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Child", "description": "Child schema", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }} and here is the parent schema named parent.json and all the two files are in the same folder. I want to refer to the child schema and i do like this: { "$schema": "http://json-schema.org/draft-04

java json schema validation relative path not working (URI not found)

强颜欢笑 提交于 2019-12-08 00:00:19
问题 I am looking at the 2.2.6 version of the validator code from github. I have not changed any code from the repo "https://github.com/fge/json-schema-validator.git" I am unable to get example 1 running when i test it against my json schema that references a second schema file (I can get it working when I resort to a hardcoded URI). I have simply repointed the "com.github.fge.jsonschema.examples.Example1.java" to use my teams json schema and json files. I have built the project and copied my json

Enforce object non emptyness using json schema

依然范特西╮ 提交于 2019-12-07 01:43:59
问题 We can enforce empty attribute of type object as follows: { "description": "voice mail record", "type": "object", "additionalProperties": false, "properties": {} } as explained here. Now I want to validate attribute which is of object type, dont have any predefined properties can have properties of type string or numeric should not be empty Enforcing non-emptyness (point 4) is what I am unable to guess. This is somewhat opposite of enforcing emptyness as in above example. My current json

java json schema validation relative path not working (URI not found)

青春壹個敷衍的年華 提交于 2019-12-06 08:51:42
I am looking at the 2.2.6 version of the validator code from github. I have not changed any code from the repo " https://github.com/fge/json-schema-validator.git " I am unable to get example 1 running when i test it against my json schema that references a second schema file (I can get it working when I resort to a hardcoded URI). I have simply repointed the "com.github.fge.jsonschema.examples.Example1.java" to use my teams json schema and json files. I have built the project and copied my json schema files into "json-schema-validator\bin\com\github\fge\jsonschema\examples" (All in the same

REST Assured with JSON schema validation not working

回眸只為那壹抹淺笑 提交于 2019-12-06 02:32:43
问题 I'm working with Spring Boot and REST Assured to test REST APIs. I was trying the example with JSON schema validation but it throws this error: java.lang.IllegalArgumentException: Schema to use cannot be null According to documentation, the schema should be located in the classpath. My example schema is located there. Here is my project structure and example schema location: Here is my code. Without schema validation it works fine. given(). contentType("application/json"). when(). get("http:/

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

烈酒焚心 提交于 2019-12-06 02:07:18
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.json").getFile()); String jsonSchema = new String(Files.readAllBytes(jsonSchemaFile.toPath())); final

Json schema validation in Spring REST APIs

时光毁灭记忆、已成空白 提交于 2019-12-05 17:49:14
问题 I’m building a REST API using Spring Boot and [jackson-module-jsonSchema] (https://github.com/FasterXML/jackson-module-jsonSchema) for JSON schema generation. I’m looking the best way to validate the request JSON payload arriving to my APIs endpoints (Spring controllers) against the defined JSON schema defined for the exposed resource, validation includes check required fields , format , min and max values, etc.. everything we can validate against the schema. Seems jackson json schema module