jsonschema

How to manage multiple JSON schema files?

纵饮孤独 提交于 2019-11-28 04:40:48
I'm trying to validate my JSON API using node.js + json-schema.js from commonjs-utils. Just single validation was easy but could not find right way how to manage multiple schema files to enable referencing each other. Suppose that I got two Models & two APIs. // book { "type": "object", "properties": { "title": { "type": "string" }, "author": { "type": "string" } } } // author { "type": "object", "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" } } } // authors API { "type": "array", "items": { "$ref": "author" } } // books API: list of books written by same

How do I require one field or another or (one of two others) but not all of them?

不羁的心 提交于 2019-11-28 04:29:41
I am having trouble coming up with a JSON schema that will validate if the JSON contains either: one field only another field only (one of two other fields) only but not to match when multiples of those are present. In my case specifically, I want one of copyAll fileNames matchesFiles and/or doesntMatchFiles to validate but I don't want to accept when more than that is there. Here's what I've got so far: { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": [ "unrelatedA" ], "properties": { "unrelatedA": { "type": "string" }, "fileNames": { "type": "array" },

Using RegEx in JSON Schema

跟風遠走 提交于 2019-11-28 02:26:34
问题 Trying to write a JSON schema that uses RegEx to validate a value of an item. Have an item named progBinaryName whose value should adhrere to this RegEx string "^[A-Za-z0-9 -_]+_Prog\\.(exe|EXE)$" . Can not find any tutorials or examples that actually explain the use of RegEx in a JSON schema. Any help/info would be GREATLY appreciated! Thanks, D JSON SCHEMA { "name": "string", "properties": { "progName": { "type": "string", "description": "Program Name", "required": true }, "ID": { "type":

Schema object without a type attribute in Swagger 2.0

爱⌒轻易说出口 提交于 2019-11-28 02:14:59
Does a Schema object in Swagger/OpenAPI 2.0 have to have the type attribute or not? On the one hand, according to the JSON Schema Draft 4 spec, not specifying the type attribute is OK and means that the instance can be of any type (an object, an array or a primitive). On the other hand, I've seen a lot of Swagger schemas which contain Schema objects without the type attribute, but with the properties attribute, which makes it clear that the schema author wants the instance to be a proper object (and doesn't want to accept arrays or primitive as valid values). Are all those schemas incorrect?

JSON schema validation with PHP [closed]

旧巷老猫 提交于 2019-11-27 23:34:09
Is there any PHP library that validates a JSON object against a JSON Schema? About jsonschemaphpv, although it´s not very well maintained, we use it a lot and it works. It´s a port from the js validator. It has a full test suite that runs against the php and the http://code.google.com/p/jsonschema/ . And guess what... It passes on more tests than the js. At least at the last time I run the tests. The thing is that the project is not very well structured and looks ugly. But I ensure you it´s very stable. It also allows you to validate associative arrays as objects either. I´ve written the tests

JSON Schema - require all properties

大憨熊 提交于 2019-11-27 20:52:45
问题 The required field in JSON Schema JSON Schema features the properties , required and additionalProperties fields. For example, { "type": "object", "properties": { "elephant": {"type": "string"}, "giraffe": {"type": "string"}, "polarBear": {"type": "string"} }, "required": [ "elephant", "giraffe", "polarBear" ], "additionalProperties": false } Will validate JSON objects like: { "elephant": "Johnny", "giraffe": "Jimmy", "polarBear": "George" } But will fail if the list of properties is not

Java/Android - Validate String JSON against String schema

早过忘川 提交于 2019-11-27 10:52:38
问题 I am having trouble finding the most simple way to validate a JSON String against a given JSON-schema String (for reference, this is in Java, running in an Android app). Ideally, I'd like to just pass in a JSON String and a JSON-schema String, and it returns a boolean as to whether it passes the validation. Through searching, I have found the following 2 promising libraries for accomplishing this: http://jsontools.berlios.de/ https://github.com/fge/json-schema-validator However, the first one

Generate C# classes from JSON Schema [closed]

不打扰是莪最后的温柔 提交于 2019-11-27 07:02:44
I'm creating a C# WCF Web Service that return a lot of data in a JSON format. The client is an iPad application that is currently being developped by another team, So I'm working on specifications, without example data. Currently the JSON string is created by the .net framework, my Web Service is returning a C# object containing all the information that are then serialized by the framework using DataContracts. My problem is that the communication specifications only contain JSON Schema files (based on http://json-schema.org/ ). In order to facilitate the development I'd like to generate the

Git学习总结(二)---git和bitbucket统计操作

我的梦境 提交于 2019-11-27 06:56:08
一、使用Git命令进行提交后的统计说明: 转载几篇说明较好的文章: git log常用命令以及技巧 Git代码行统计命令集 1、git log 它会列出所有历史记录,最近的排在最上方,显示提交对象的哈希值,作者、提交日期、和提交说明。如果记录过多,则按Page Up、Page Down、↓、↑来控制显示; 2、git log -n (n表示想要显示几条提交记录) 如果不想向上面那样全部显示,可以选择显示前n条。 3、git log --stat 在列出的历史记录中显示每次更新的文件修改统计信息(会列出每个修改的文件,和每个文件修改了多少行,包括增加的减少的,同时,会列出该commit总共修改了多少个文件,增加了多少行,减少了多少行) 4、git log --stat -n 在3的基础上显示前n条数据信息 5、git log --shortstat 内容3的简略形式,去掉了具体修改了那些文件 6、git log --shortstat -n 7、git show 26a6e9b6abf1820 --stat 获取哈希值为26a6e9b6abf1820 的该次提交的内容信息(每个修改的文件,和每个文件修改了多少行,包括增加的减少的,同时,会列出该commit总共修改了多少个文件,增加了多少行,减少了多少行) 8、git show 26a6e9b6abf1820 --shortstat

Validate JSON against JSON Schema C#

北战南征 提交于 2019-11-27 04:25:35
Is there a way to validate a JSON structure against a JSON schema for that structure? I have looked and found JSON.Net validate but this does not do what I want. JSON.net does: JsonSchema schema = JsonSchema.Parse(@"{ 'type': 'object', 'properties': { 'name': {'type':'string'}, 'hobbies': {'type': 'array'} } }"); JObject person = JObject.Parse(@"{ 'name': 'James', 'hobbies': ['.NET', 'LOLCATS'] }"); bool valid = person.IsValid(schema); // true This validates to true. JsonSchema schema = JsonSchema.Parse(@"{ 'type': 'object', 'properties': { 'name': {'type':'string'}, 'hobbies': {'type': 'array