respect 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +289 -0
- data/RELATED_WORK.md +40 -0
- data/RELEASE_NOTES.md +23 -0
- data/Rakefile +31 -0
- data/STATUS_MATRIX.html +137 -0
- data/lib/respect.rb +231 -0
- data/lib/respect/any_schema.rb +22 -0
- data/lib/respect/array_def.rb +28 -0
- data/lib/respect/array_schema.rb +203 -0
- data/lib/respect/boolean_schema.rb +32 -0
- data/lib/respect/composite_schema.rb +86 -0
- data/lib/respect/core_statements.rb +206 -0
- data/lib/respect/datetime_schema.rb +27 -0
- data/lib/respect/def_without_name.rb +6 -0
- data/lib/respect/divisible_by_validator.rb +20 -0
- data/lib/respect/doc_helper.rb +24 -0
- data/lib/respect/doc_parser.rb +37 -0
- data/lib/respect/dsl_dumper.rb +181 -0
- data/lib/respect/equal_to_validator.rb +20 -0
- data/lib/respect/fake_name_proxy.rb +116 -0
- data/lib/respect/float_schema.rb +27 -0
- data/lib/respect/format_validator.rb +136 -0
- data/lib/respect/global_def.rb +79 -0
- data/lib/respect/greater_than_or_equal_to_validator.rb +19 -0
- data/lib/respect/greater_than_validator.rb +19 -0
- data/lib/respect/has_constraints.rb +34 -0
- data/lib/respect/hash_def.rb +40 -0
- data/lib/respect/hash_schema.rb +218 -0
- data/lib/respect/in_validator.rb +19 -0
- data/lib/respect/integer_schema.rb +27 -0
- data/lib/respect/ip_addr_schema.rb +23 -0
- data/lib/respect/ipv4_addr_schema.rb +27 -0
- data/lib/respect/ipv6_addr_schema.rb +27 -0
- data/lib/respect/items_def.rb +21 -0
- data/lib/respect/json_schema_html_formatter.rb +143 -0
- data/lib/respect/less_than_or_equal_to_validator.rb +19 -0
- data/lib/respect/less_than_validator.rb +19 -0
- data/lib/respect/match_validator.rb +19 -0
- data/lib/respect/max_length_validator.rb +20 -0
- data/lib/respect/min_length_validator.rb +20 -0
- data/lib/respect/multiple_of_validator.rb +10 -0
- data/lib/respect/null_schema.rb +26 -0
- data/lib/respect/numeric_schema.rb +33 -0
- data/lib/respect/org3_dumper.rb +213 -0
- data/lib/respect/regexp_schema.rb +19 -0
- data/lib/respect/schema.rb +285 -0
- data/lib/respect/schema_def.rb +16 -0
- data/lib/respect/string_schema.rb +21 -0
- data/lib/respect/unit_test_helper.rb +37 -0
- data/lib/respect/uri_schema.rb +23 -0
- data/lib/respect/utc_time_schema.rb +17 -0
- data/lib/respect/validator.rb +51 -0
- data/lib/respect/version.rb +3 -0
- data/test/any_schema_test.rb +79 -0
- data/test/array_def_test.rb +113 -0
- data/test/array_schema_test.rb +487 -0
- data/test/boolean_schema_test.rb +89 -0
- data/test/composite_schema_test.rb +30 -0
- data/test/datetime_schema_test.rb +83 -0
- data/test/doc_helper_test.rb +34 -0
- data/test/doc_parser_test.rb +109 -0
- data/test/dsl_dumper_test.rb +395 -0
- data/test/fake_name_proxy_test.rb +138 -0
- data/test/float_schema_test.rb +146 -0
- data/test/format_validator_test.rb +224 -0
- data/test/hash_def_test.rb +126 -0
- data/test/hash_schema_test.rb +613 -0
- data/test/integer_schema_test.rb +142 -0
- data/test/ip_addr_schema_test.rb +78 -0
- data/test/ipv4_addr_schema_test.rb +71 -0
- data/test/ipv6_addr_schema_test.rb +71 -0
- data/test/json_schema_html_formatter_test.rb +214 -0
- data/test/null_schema_test.rb +46 -0
- data/test/numeric_schema_test.rb +294 -0
- data/test/org3_dumper_test.rb +784 -0
- data/test/regexp_schema_test.rb +54 -0
- data/test/respect_test.rb +108 -0
- data/test/schema_def_test.rb +405 -0
- data/test/schema_test.rb +290 -0
- data/test/string_schema_test.rb +209 -0
- data/test/support/circle.rb +11 -0
- data/test/support/color.rb +24 -0
- data/test/support/point.rb +11 -0
- data/test/support/respect/circle_schema.rb +16 -0
- data/test/support/respect/color_def.rb +19 -0
- data/test/support/respect/color_schema.rb +33 -0
- data/test/support/respect/point_schema.rb +19 -0
- data/test/support/respect/rgba_schema.rb +20 -0
- data/test/support/respect/universal_validator.rb +25 -0
- data/test/support/respect/user_macros.rb +12 -0
- data/test/support/rgba.rb +11 -0
- data/test/test_helper.rb +90 -0
- data/test/uri_schema_test.rb +54 -0
- data/test/utc_time_schema_test.rb +63 -0
- data/test/validator_test.rb +22 -0
- metadata +288 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Nicolas Despres
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
# Welcome to Respect
|
2
|
+
|
3
|
+
_Respect_ is a DSL to concisely describe the structure of common data such as Hash and Array using
|
4
|
+
Ruby code. It comes with a validator, a sanitizer and dumpers to generate valid
|
5
|
+
[json-schema.org](http://json-schema.org/) compliant specifications. Although it was designed to
|
6
|
+
specify JSON schema, it can be used for any data represented as Hash and Array. It does not require
|
7
|
+
any JSON parser since it works only on data.
|
8
|
+
|
9
|
+
Respect is named after the contraction of _REST_ and _SPEC_. Indeed, it was first intended to be
|
10
|
+
used to specify REST API in the context of a Web application.
|
11
|
+
|
12
|
+
There is a plugin called [Respect for Rails](https://github.com/nicolasdespres/respect-rails) which
|
13
|
+
integrate this gem in Rails.
|
14
|
+
|
15
|
+
# Features
|
16
|
+
|
17
|
+
Already available:
|
18
|
+
|
19
|
+
* Compact Ruby DSL to specify your schema.
|
20
|
+
* Standard [json-schema.org](http://json-schema.org/) specification generator.
|
21
|
+
* Validator for JSON document or the like.
|
22
|
+
* Contextual validation error.
|
23
|
+
* Object sanitizer: turn plain string and integer values into real objects.
|
24
|
+
* Extensible API to add your custom validator and sanitizer.
|
25
|
+
* Extensible macro definition system to factor you schema definition code.
|
26
|
+
|
27
|
+
See the RELEASE_NOTES file for detailed feature listing.
|
28
|
+
|
29
|
+
# Take a Tour
|
30
|
+
|
31
|
+
_Respect_ comes with a compact Ruby DSL to specify the structure of a hash and/or an array.
|
32
|
+
Thus, it is ideal to specify JSON schema. I find it a way more concise than
|
33
|
+
[json-schema.org](http://json-schema.org/). And it is plain Ruby so you can rely on all great Ruby features
|
34
|
+
to factor your specification code.
|
35
|
+
|
36
|
+
For instance, this ruby code specify how one could structure a very simple user profile:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
schema = Respect::HashSchema.define do |s|
|
40
|
+
s.string "name"
|
41
|
+
s.integer "age", greater_than: 18
|
42
|
+
s.string "homepage", format: :email
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
But you can still convert this specification to
|
47
|
+
[JSON Schema specification draft v3](http://tools.ietf.org/id/draft-zyp-json-schema-03.html)
|
48
|
+
easily so that all your customers can read and understand it:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'json'
|
52
|
+
puts JSON.pretty_generate(schema.to_h)
|
53
|
+
```
|
54
|
+
|
55
|
+
prints
|
56
|
+
|
57
|
+
```json
|
58
|
+
{
|
59
|
+
"type": "object",
|
60
|
+
"properties": {
|
61
|
+
"name": {
|
62
|
+
"type": "string",
|
63
|
+
"required": true
|
64
|
+
},
|
65
|
+
"age": {
|
66
|
+
"type": "integer",
|
67
|
+
"required": true,
|
68
|
+
"minimum": 18,
|
69
|
+
"exclusiveMinimum": true
|
70
|
+
},
|
71
|
+
"email": {
|
72
|
+
"type": "string",
|
73
|
+
"required": true,
|
74
|
+
"format": "email"
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
As you can see the Ruby specification is 4 times shorter than the JSON Schema specification...
|
81
|
+
|
82
|
+
You can also use this specification to validate JSON documents:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
schema.validate?({ "name" => "My name", "age" => 20, "email" => "me@example.com" }) #=> true
|
86
|
+
schema.validate?({ "name" => "My name", "age" => 15, "email" => "me@example.com" }) #=> false
|
87
|
+
```
|
88
|
+
|
89
|
+
When it fails to validate a document, you get descriptive error messages with contextual information:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
schema.last_error #=> "15 is not greater than 18"
|
93
|
+
schema.last_error.message #=> "15 is not greater than 18"
|
94
|
+
schema.last_error.context[0] #=> "15 is not greater than 18"
|
95
|
+
schema.last_error.context[1] #=> "in hash property `age'"
|
96
|
+
```
|
97
|
+
|
98
|
+
_Respect_ does not parse JSON document by default but it is easy to do so using one of the JSON parser available in Ruby:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
schema.validate?(JSON.parse('{ "name": "My name", "age": 20, "email": "me@example.com" }')) #=> true
|
102
|
+
```
|
103
|
+
|
104
|
+
Once a JSON document has been validated, we often want to turn its basic strings and integers into real object like `URI`.
|
105
|
+
_Respect_ does that automatically for you for standard objects:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
schema = Respect::HashSchema.define do |s|
|
109
|
+
s.uri "homepage"
|
110
|
+
end
|
111
|
+
object = { "homepage" => "http://example.com" }
|
112
|
+
schema.validate!(object) #=> true
|
113
|
+
object["homepage"].class #=> URI::HTTP
|
114
|
+
```
|
115
|
+
|
116
|
+
You can easily extend the sanitizer with your own object type. Let's assume you have an object type define like this:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
class Place
|
120
|
+
def initialize(latitude, longitude)
|
121
|
+
@latitude, @longitude = latitude, longitude
|
122
|
+
end
|
123
|
+
|
124
|
+
attr_reader :latitude, :longitude
|
125
|
+
|
126
|
+
def ==(other)
|
127
|
+
@latitude == other.latitude && @longitude == other.longitude
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
Then you must extend the Schema hierarchy with the new schema for your custom type.
|
133
|
+
The `CompositeSchema` class assists you in this task so you just have to overwrite
|
134
|
+
two methods.
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
module Respect
|
138
|
+
class PlaceSchema < CompositeSchema
|
139
|
+
# This method returns the schema specification for your custom type.
|
140
|
+
def schema_definition
|
141
|
+
Respect::HashSchema.define do |s|
|
142
|
+
s.float "latitude"
|
143
|
+
s.float "longitude"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# The 'sanitize' method is called with the JSON document if the validation succeed.
|
148
|
+
# The returned value will be inserted into the JSON document.
|
149
|
+
def sanitize(object)
|
150
|
+
Place.new(object[:latitude], object[:longitude])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
Finally, you define the structure of your JSON document as usual. Note that you have
|
157
|
+
access to your custom schema via the `place` method.
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
schema = Respect::HashSchema.define do |s|
|
161
|
+
s.place "home"
|
162
|
+
end
|
163
|
+
|
164
|
+
object = {
|
165
|
+
"home" => {
|
166
|
+
"latitude" => "48.846559",
|
167
|
+
"longitude" => "2.344519",
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
schema.validate!(object) #=> true
|
172
|
+
object["home"].class #=> Place
|
173
|
+
```
|
174
|
+
|
175
|
+
Sometimes you just want to extend the DSL with a new statement providing higher level feature than
|
176
|
+
the primitive `integer`, `string` or `float`, etc... For instance if you specify identifier
|
177
|
+
in your schema like this:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
Respect::HashSchema.define do |s|
|
181
|
+
s.integer "article_id", greater_than: 0
|
182
|
+
s.string "title"
|
183
|
+
s.hash "author" do |s|
|
184
|
+
s.integer "author_id", greater_than: 0
|
185
|
+
s.string "name"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
In such case, you don't need a custom sanitizer. You just want to factor the definition of
|
191
|
+
identifier property. You can easily to it like this:
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
module MyMacros
|
195
|
+
def id(name, options = {})
|
196
|
+
unless name.nil? || name =~ /_id$/
|
197
|
+
name += "_id"
|
198
|
+
end
|
199
|
+
integer(name, { greater_than: 0 }.merge(options))
|
200
|
+
end
|
201
|
+
end
|
202
|
+
Respect.extend_dsl_with(MyMacros)
|
203
|
+
```
|
204
|
+
|
205
|
+
Now you can rewrite the original schema this way:
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
Respect::HashSchema.define do |s|
|
209
|
+
s.id "article"
|
210
|
+
s.string "title"
|
211
|
+
s.hash "author" do |s|
|
212
|
+
s.id "author"
|
213
|
+
s.string "name"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
```
|
217
|
+
|
218
|
+
# Getting started
|
219
|
+
|
220
|
+
The easiest way to install _Respect_ is to add it to your `Gemfile`:
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
gem "respect"
|
224
|
+
```
|
225
|
+
|
226
|
+
Then, after running the `bundle install` command, you can start to validate JSON document in your program like this:
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
require 'respect'
|
230
|
+
|
231
|
+
schema = Respect::HashSchema.define do |s|
|
232
|
+
s.string "name"
|
233
|
+
s.integer "age", greater_than: 18
|
234
|
+
end
|
235
|
+
|
236
|
+
schema.validate?({ "name" => "John", "age" => 30 })
|
237
|
+
```
|
238
|
+
|
239
|
+
# JSON Schema implementation status
|
240
|
+
|
241
|
+
_Respect_ currently implements most of the features included in the
|
242
|
+
[JSON Schema specification draft v3](http://tools.ietf.org/id/draft-zyp-json-schema-03.html).
|
243
|
+
|
244
|
+
See the `STATUS_MATRIX` file included in this package for detailed information.
|
245
|
+
|
246
|
+
Although, the semantics of the schema definition DSL available in this library may change slightly from the
|
247
|
+
_JSON schema standard_, we have tried to keep it as close as possible. For instance the `strict` option of
|
248
|
+
hash schema is not presented in the standard. However, when a schema is dumped to its _JSON Schema_ version
|
249
|
+
the syntax and semantic have been followed. You should note that there is no "loader" available yet in this
|
250
|
+
library. In other word, you cannot instantiate a Schema class from a _JSON Schema_ string representation.
|
251
|
+
|
252
|
+
# Getting help
|
253
|
+
|
254
|
+
The easiest way to get help about how to use this library is to post your question on the
|
255
|
+
[Respect discussion group](https://groups.google.com/forum/#!forum/ruby-respect-gem-talk).
|
256
|
+
I will be glade to answer. I may have already answered the
|
257
|
+
same question so before you post your question take a bit of time to search the group.
|
258
|
+
|
259
|
+
You can also read these documents for further documentation:
|
260
|
+
|
261
|
+
* [Repect API reference documentation](http://nicolasdespres.github.io/respect/)
|
262
|
+
|
263
|
+
# Compatibility
|
264
|
+
|
265
|
+
_Respect_ has been tested with:
|
266
|
+
|
267
|
+
* Ruby 1.9.3-p392 (should be compatible with all 1.9.x family)
|
268
|
+
* ActiveSupport 3.2.13
|
269
|
+
|
270
|
+
Note that **it does not depend on any JSON parsing library**. It works only on primitive Ruby data type. So,
|
271
|
+
any JSON parser returning normal basic types like `Hash`, `Array`, `String`, `Numeric`, `TrueClass`,
|
272
|
+
`FalseClass`, `NilClass`, should work.
|
273
|
+
|
274
|
+
# Feedback
|
275
|
+
|
276
|
+
I would love to hear what you think about this library. Feel free to post any comments/remarks on the
|
277
|
+
[Respect discussion group](https://groups.google.com/forum/#!forum/ruby-respect-gem-talk).
|
278
|
+
|
279
|
+
# Contributing patches
|
280
|
+
|
281
|
+
I spent quite a lot of time writing this gem but there is still a lot of work to do. Whether it
|
282
|
+
is a bug-fix, a new feature, some code re-factoring, or documentation clarification, I will be
|
283
|
+
glade to merge your pull request on GitHub. You just have to create a branch from `master` and
|
284
|
+
send me a pull request.
|
285
|
+
|
286
|
+
# License
|
287
|
+
|
288
|
+
_Respect_ is released under the term of the [MIT License](http://opensource.org/licenses/MIT).
|
289
|
+
Copyright (c) 2013 Nicolas Despres.
|
data/RELATED_WORK.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Related works
|
2
|
+
|
3
|
+
This section describes some projects sharing more or less the same purpose as _Respect_.
|
4
|
+
The goal is to have an overview of the eco-system around this topic to borrow ideas and
|
5
|
+
to drive implementation.
|
6
|
+
|
7
|
+
This section is not meant to be accurate even if we try to stay objective here.
|
8
|
+
|
9
|
+
## [json-schema](https://github.com/hoxworth/json-schema)
|
10
|
+
|
11
|
+
* No DSL
|
12
|
+
* No doc generation
|
13
|
+
* No sanitizer.
|
14
|
+
|
15
|
+
## [ruby-jsonschema](https://github.com/Constellation/ruby-jsonchema)
|
16
|
+
|
17
|
+
* No DSL
|
18
|
+
* No doc generation
|
19
|
+
* No sanitizer.
|
20
|
+
|
21
|
+
## [google/autoparse](https://github.com/google/autoparse)
|
22
|
+
|
23
|
+
* No DSL
|
24
|
+
* Seems no longer maintained.
|
25
|
+
* No doc generation.
|
26
|
+
* No sanitizer.
|
27
|
+
|
28
|
+
## [json expression](https://github.com/chancancode/json_expressions)
|
29
|
+
|
30
|
+
* Provide an easy way to test your JSON responses.
|
31
|
+
* No documentation generator.
|
32
|
+
* No DSL.
|
33
|
+
* No sanitizer.
|
34
|
+
|
35
|
+
## [Net HTTP API Spec](https://github.com/franckcuny/net-http-api-spec)
|
36
|
+
|
37
|
+
* Seems not used (i.e. no fork and almost no star)
|
38
|
+
* Seems no longer maintained.
|
39
|
+
* Not compliant with json-schema.org spec.
|
40
|
+
* No sanitizer.
|
data/RELEASE_NOTES.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Release notes
|
2
|
+
|
3
|
+
This document is a list of user visible feature changes made between
|
4
|
+
releases except for bug fixes.
|
5
|
+
|
6
|
+
Note that each entry is kept so brief that no reason behind or
|
7
|
+
reference information is supplied with. For a full list of changes
|
8
|
+
with all sufficient information, see the git(1) log.
|
9
|
+
|
10
|
+
A lot more is coming soon check out the issue tagged as `feature`
|
11
|
+
in the tracker.
|
12
|
+
|
13
|
+
## Part of the first release
|
14
|
+
|
15
|
+
Feature: DSL to describe schema of Hash, Array, String, Numeric, Integer, Float, Boolean, etc...
|
16
|
+
Feature: Dumper to pretty-print a schema using the same DSL syntax.
|
17
|
+
Feature: Dumper to generate [JSON schema draft v3 standard](http://tools.ietf.org/id/draft-zyp-json-schema-03.html) representation of a schema.
|
18
|
+
Feature: Validation system to check objects follow a schema.
|
19
|
+
Feature: Sanitizer to promote validated value to a more specific type.
|
20
|
+
Feature: CompositeSchema class to easily create your own schema.
|
21
|
+
Feature: Facilities to extends the DSL with user-defined module.
|
22
|
+
Feature: Contextual validation error.
|
23
|
+
Feature: A JSON schema HTML formatter.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'yard'
|
9
|
+
YARD::Rake::YardocTask.new do |t|
|
10
|
+
t.files = [
|
11
|
+
'lib/**/*.rb',
|
12
|
+
'-',
|
13
|
+
'README.md',
|
14
|
+
'STATUS_MATRIX.html',
|
15
|
+
'RELEASE_NOTES.md',
|
16
|
+
'RELATED_WORK.md',
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
task :default => :test
|
data/STATUS_MATRIX.html
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
<h3>Core Schema definition</h3>
|
2
|
+
<p>
|
3
|
+
This document is a work in progress and is updated constantly. It may not reflect the exact state
|
4
|
+
of implementation.
|
5
|
+
</p>
|
6
|
+
<table border="1">
|
7
|
+
<tr>
|
8
|
+
<td>Core Schema definition feature</td>
|
9
|
+
<td>Abailable in Respect ?</td>
|
10
|
+
</tr><tr>
|
11
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor9">5.1. type</a></td>
|
12
|
+
<td style="color:green" align="center">With the various core DSL statements: 'integer', 'string', etc...</td>
|
13
|
+
</tr><tr>
|
14
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#properties">5.2. properties</a></td>
|
15
|
+
<td style="color:green" align="center">Yes</td>
|
16
|
+
</tr><tr>
|
17
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor10">5.3. patternProperties</a></td>
|
18
|
+
<td style="color:orangered" align="center">
|
19
|
+
With a regular expression instead of a string as property name<br>
|
20
|
+
(Ruby regexp instead of ECMA 262)
|
21
|
+
</td>
|
22
|
+
</tr><tr>
|
23
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#additionalProperties">5.4. additionalProperties</a></td>
|
24
|
+
<td style="color:green" align="center">With 'extra' statement or 'required' option</td>
|
25
|
+
</tr><tr>
|
26
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor11">5.5. items</a></td>
|
27
|
+
<td style="color:green" align="center">With 'item' or 'items' statement</td>
|
28
|
+
</tr><tr>
|
29
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#additionalItems">5.6. additionalItems</a></td>
|
30
|
+
<td style="color:green" align="center">With 'extra_items' statement</td>
|
31
|
+
</tr><tr>
|
32
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor12">5.7. required</a></td>
|
33
|
+
<td style="color:green" align="center">Yes</td>
|
34
|
+
</tr><tr>
|
35
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor13">5.8. dependencies</a></td>
|
36
|
+
<td style="color:red" align="center">No</td>
|
37
|
+
</tr><tr>
|
38
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor14">5.9. minimum</a></td>
|
39
|
+
<td style="color:green" align="center">With 'greater_than_or_equal_to' option</td>
|
40
|
+
</tr><tr>
|
41
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor15">5.10. maximum</a></td>
|
42
|
+
<td style="color:green" align="center">With 'less_than_or_equal_to' option</td>
|
43
|
+
</tr><tr>
|
44
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor16">5.11. exclusiveMinimum</a></td>
|
45
|
+
<td style="color:green" align="center">With 'greater_than' option</td>
|
46
|
+
</tr><tr>
|
47
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor17">5.12. exclusiveMaximum</a></td>
|
48
|
+
<td style="color:green" align="center">With 'less_than' option</td>
|
49
|
+
</tr><tr>
|
50
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor18">5.13. minItems</a></td>
|
51
|
+
<td style="color:green" align="center">With 'min_size' option</td>
|
52
|
+
</tr><tr>
|
53
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor19">5.14. maxItems</a></td>
|
54
|
+
<td style="color:green" align="center">With 'max_size' option</td>
|
55
|
+
</tr><tr>
|
56
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#uniqueItems">5.15. uniqueItems</a></td>
|
57
|
+
<td style="color:green" align="center">With 'uniq' option</td>
|
58
|
+
</tr><tr>
|
59
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor20">5.16. pattern</a></td>
|
60
|
+
<td style="color:orangered" align="center">With 'match' option<br>(Ruby regexp instead of ECMA 262)</td>
|
61
|
+
</tr><tr>
|
62
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor21">5.17. minLength</a></td>
|
63
|
+
<td style="color:green" align="center">With 'min_length' option</td>
|
64
|
+
</tr><tr>
|
65
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor22">5.18. maxLength</a></td>
|
66
|
+
<td style="color:green" align="center">With 'max_length' option</td>
|
67
|
+
</tr><tr>
|
68
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor23">5.19. enum</a></td>
|
69
|
+
<td style="color:green" align="center">With 'in' option</td>
|
70
|
+
</tr><tr>
|
71
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor24">5.20. default</a></td>
|
72
|
+
<td style="color:green" align="center">Yes</td>
|
73
|
+
</tr><tr>
|
74
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor25">5.21. title</a></td>
|
75
|
+
<td style="color:green" align="center">Yes</td>
|
76
|
+
</tr><tr>
|
77
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor26">5.22. description</a></td>
|
78
|
+
<td style="color:green" align="center">Yes</td>
|
79
|
+
</tr><tr>
|
80
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: date-time</a></td>
|
81
|
+
<td style="color:orangered" align="center">With 'datetime' parameter<br>(RFC 3399 instead of ISO 8601)</td></tr>
|
82
|
+
</tr><tr>
|
83
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: regex</a></td>
|
84
|
+
<td style="color:orangered" align="center">With 'regexp' parameter<br>(Ruby regexp instead of ECMA 262)</td></tr>
|
85
|
+
</tr><tr>
|
86
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: format</a></td>
|
87
|
+
<td style="color:green" align="center">With 'phone_number' paramter</td>
|
88
|
+
</tr><tr>
|
89
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: uri</a></td>
|
90
|
+
<td style="color:green" align="center">With 'uri' parameter (RFC 2396)</td>
|
91
|
+
</tr><tr>
|
92
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: email</a></td>
|
93
|
+
<td style="color:green" align="center">With 'email' parameter</td>
|
94
|
+
</tr><tr>
|
95
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: ip-address</a></td>
|
96
|
+
<td style="color:green" align="center">With 'ipv4_addr' parameter</td>
|
97
|
+
</tr><tr>
|
98
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: ipv6</a></td>
|
99
|
+
<td style="color:green" align="center">With 'ipv6_addr' parameter</td>
|
100
|
+
</tr><tr>
|
101
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: host-name</a></td>
|
102
|
+
<td style="color:green" align="center">With 'hostname' parameter</td>
|
103
|
+
</tr><tr>
|
104
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: date</a></td>
|
105
|
+
<td style="color:red" align="center">No</td>
|
106
|
+
</tr><tr>
|
107
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: time</a></td>
|
108
|
+
<td style="color:red" align="center">No</td>
|
109
|
+
</tr><tr>
|
110
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: utc-millisec</a></td>
|
111
|
+
<td style="color:red" align="center">No</td>
|
112
|
+
</tr><tr>
|
113
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: color</a></td>
|
114
|
+
<td style="color:red" align="center">No</td>
|
115
|
+
</tr><tr>
|
116
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor27">5.23. format: style</a></td>
|
117
|
+
<td style="color:red" align="center">No</td>
|
118
|
+
</tr><tr>
|
119
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor28">5.24. divisibleBy</a></td>
|
120
|
+
<td style="color:green" align="center">With 'divisible_by' or 'multiple_of' option</td>
|
121
|
+
</tr><tr>
|
122
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor29">5.25. disallow</a></td>
|
123
|
+
<td style="color:red" align="center">No</td>
|
124
|
+
</tr><tr>
|
125
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor30">5.26. extends</a></td>
|
126
|
+
<td style="color:red" align="center">No</td>
|
127
|
+
</tr><tr>
|
128
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor31">5.27. id</a></td>
|
129
|
+
<td style="color:red" align="center">No</td>
|
130
|
+
</tr><tr>
|
131
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor32">5.28. $ref</a></td>
|
132
|
+
<td style="color:red" align="center">No</td>
|
133
|
+
</tr><tr>
|
134
|
+
<td><a href="http://tools.ietf.org/id/draft-zyp-json-schema-03.html#anchor33">5.29. $schema</a></td>
|
135
|
+
<td style="color:red" align="center">No</td>
|
136
|
+
</tr>
|
137
|
+
</table>
|