jsonschema

Regex describing a regex pattern? [closed]

梦想的初衷 提交于 2019-12-02 06:32:59
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I am surprised that an answer to this is not easily found. I am in the process of making a JSON schema. I have an object and one of it's properties is a string containing a regex pattern. This property must contain only regex. So, this question is realistically two questions in

Build xml based on xml schema in Node.js

扶醉桌前 提交于 2019-12-02 05:55:31
问题 Is there any easy way to create XML based on XML schema in Node.js? Currently I see modules like xmlbuilder that does help in creating XML from scratch ( does not follow schema). I want something high level, based on XML schema /XSD which will help in creating xml. Like POJOs are created based on XSD and now easy to populate POJOs and then create XML. Thanks for any hints... 回答1: I am the author of Jsonix which is a powerful schema-driven XML<->JS converter, working in Node.js as well as in

How to specify which oneOf item a JSON object should take?

此生再无相见时 提交于 2019-12-02 05:51:12
Using Python and jsonschema I am trying to validate the assignment of ObjA or ObjB etc. to beta ( test.json ) { "alpha": { "beta": "ObjA" } } In my schema ( testschema.json ) beta is oneOf a number of items and each item is defined as below (with differing values for a , b , and c ) "ObjA": { "type": "object", "properties": { "items": { "a": [90, 95], "b": [4, 8], "c": [0.2, 0.6] } }, "additionalProperties": false } That is to say, beta can take on oneOf values that are ObjA , ObjB , ObjC and ObjD . I am simply trying to specify which one it should use in test.json "alpha": { "type": "object",

Is there a way to use Swagger just for validation without using the whole framework?

两盒软妹~` 提交于 2019-12-02 05:47:27
Suppose I have an existing Java service implementing a JSON HTTP API, and I want to add a Swagger schema and automatically validate requests and responses against it without retooling the service to use the Swagger framework / code generation. Is there anything providing a Java API that I can tie into and pass info about the requests / responses to validate? (Just using a JSON schema validator would mean manually implementing a lot of the additional features in Swagger.) I don't think there's anything ready to do this alone, but you can easily do this by the following: Grab the SchemaValidator

Build xml based on xml schema in Node.js

倾然丶 夕夏残阳落幕 提交于 2019-12-01 22:52:49
Is there any easy way to create XML based on XML schema in Node.js? Currently I see modules like xmlbuilder that does help in creating XML from scratch ( does not follow schema). I want something high level, based on XML schema /XSD which will help in creating xml. Like POJOs are created based on XSD and now easy to populate POJOs and then create XML. Thanks for any hints... lexicore I am the author of Jsonix which is a powerful schema-driven XML<->JS converter, working in Node.js as well as in browsers. See this answer for a complete example: XML parser for JavaScript Schema-driven means that

Recursive JSON Schema

时光怂恿深爱的人放手 提交于 2019-12-01 21:29:03
I'm trying to create proper JSON Schema for menu with sub-menus. So I should define an array from item which should contain three items. 1 Display name, 2 URL and Children (which should be an array of object with the same structure) At this time I've got this: { "type": "array", "additionalProperties": false, // have no idea what is this for :) "items": { "type": "object", "additionalProperties": false, // have no idea what is this for :) "description": "MenuLink", "id": "menuLink", "properties": { "display_name": { "type": "string", "title": "Link display name", "minLength": 2 }, "url": {

JSON Schema: How to check that an array contains at least one object with a property with a given value?

左心房为你撑大大i 提交于 2019-12-01 21:08:33
How can I check in the following json that at least one element in the array names has a property nickName with the value Ginny ? { "names": [ { "firstName": "Hermione", "lastName": "Granger" }, { "firstName": "Harry", "lastName": "Potter" }, { "firstName": "Ron", "lastName": "Weasley" }, { "firstName": "Ginevra", "lastName": "Weasley", "nickName": "Ginny" } ] } Currently I'm using the draft-06 version (FAQ here ). This is my NOT WORKING schema: { "$schema": "http://json-schema.org/draft-06/schema#", "title": "Complex Array", "description": "Schema to validate the presence and value of an

Storing a JSON schema in mongodb with spring

我只是一个虾纸丫 提交于 2019-12-01 18:49:45
I am new to Spring data and mongodb. I have a JSON object which represents a JSON Schema and I need to store that in mongodb using spring data. But the issue with JSON schema is the structure of JSON Schema is dynamic; for example below are two valid JSON schema with completely different structure. { "type": "object", "properties": { "name": { "type": "string", "minLength": 10 }, "age": { "type": "integer" } }, "required": [ "name", "age" ] } { "type": "array", "items": { "type": "object", "properties": { "abc": { "type": "boolean" }, "xyz": { "$ref": "#/definitions/" }, "asd": { "type": "null

Jackson: generate schemas with references

空扰寡人 提交于 2019-12-01 17:27:00
When using Jackson's JSON schema module, instead of serializing the complete graph I'd like to stop whenever one of my model classes is encountered, and use the class name to insert a $ref for another schema. Can you guide me to the right place in the jackson-module-jsonSchema source to start tinkering? Here's some code to illustrate the issue: public static class Zoo { public String name; public List<Animal> animals; } public static class Animal { public String species; } public static void main(String[] args) throws Exception { SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();

How to define JSON Schema for Map<String, Integer>?

自闭症网瘾萝莉.ら 提交于 2019-12-01 15:41:24
I have a json : { "itemType": {"food":22,"electrical":2}, "itemCount":{"NA":211} } Here the itemType and itemCount will be common but not the values inside them (food, NA, electrical) which will be keep changing but the will be in the format : Map How do I define Json Schema for such generic structure ? I tried : "itemCount":{ "type": "object" "additionalProperties": {"string", "integer"} } You can: { "type": "object", "properties": { "itemType": {"$ref": "#/definitions/mapInt"}, "itemCount": {"$ref": "#/definitions/mapInt"} }, "definitions": { "mapInt": { "type": "object",