json_schema_rails 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +16 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Guardfile +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +121 -0
- data/Rakefile +17 -0
- data/json_schema_rails.gemspec +29 -0
- data/lib/generators/schema/action/USAGE +22 -0
- data/lib/generators/schema/action/action_generator.rb +52 -0
- data/lib/generators/schema/action/templates/schema.yml.erb +31 -0
- data/lib/generators/schema/controller/USAGE +13 -0
- data/lib/generators/schema/controller/controller_generator.rb +27 -0
- data/lib/generators/schema/controller/templates/schema.yml.erb +7 -0
- data/lib/json_schema_rails/errors.rb +44 -0
- data/lib/json_schema_rails/helpers.rb +38 -0
- data/lib/json_schema_rails/loaders/base.rb +72 -0
- data/lib/json_schema_rails/loaders/directory.rb +39 -0
- data/lib/json_schema_rails/loaders/hyper_schema.rb +68 -0
- data/lib/json_schema_rails/loaders.rb +7 -0
- data/lib/json_schema_rails/railtie.rb +25 -0
- data/lib/json_schema_rails/schema_validator.rb +91 -0
- data/lib/json_schema_rails/version.rb +3 -0
- data/lib/json_schema_rails.rb +43 -0
- data/lib/tasks/schema_tasks.rake +37 -0
- data/schemas/core-schema.json +150 -0
- data/schemas/hyper-schema.json +168 -0
- data/schemas/strict/core-schema.json +151 -0
- data/schemas/strict/hyper-schema.json +169 -0
- data/spec/dummy_apps/rails3/README.rdoc +261 -0
- data/spec/dummy_apps/rails3/Rakefile +7 -0
- data/spec/dummy_apps/rails3/app/assets/images/rails.png +0 -0
- data/spec/dummy_apps/rails3/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_apps/rails3/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy_apps/rails3/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_apps/rails3/app/controllers/posts_controller.rb +11 -0
- data/spec/dummy_apps/rails3/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_apps/rails3/app/schemas/posts/create.yml +20 -0
- data/spec/dummy_apps/rails3/app/schemas/posts/update.json +29 -0
- data/spec/dummy_apps/rails3/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_apps/rails3/config/application.rb +68 -0
- data/spec/dummy_apps/rails3/config/boot.rb +6 -0
- data/spec/dummy_apps/rails3/config/database.yml +25 -0
- data/spec/dummy_apps/rails3/config/environment.rb +5 -0
- data/spec/dummy_apps/rails3/config/environments/development.rb +37 -0
- data/spec/dummy_apps/rails3/config/environments/production.rb +67 -0
- data/spec/dummy_apps/rails3/config/environments/test.rb +37 -0
- data/spec/dummy_apps/rails3/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_apps/rails3/config/initializers/inflections.rb +15 -0
- data/spec/dummy_apps/rails3/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_apps/rails3/config/initializers/secret_token.rb +7 -0
- data/spec/dummy_apps/rails3/config/initializers/session_store.rb +8 -0
- data/spec/dummy_apps/rails3/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_apps/rails3/config/locales/en.yml +5 -0
- data/spec/dummy_apps/rails3/config/routes.rb +60 -0
- data/spec/dummy_apps/rails3/config.ru +4 -0
- data/spec/dummy_apps/rails3/db/seeds.rb +7 -0
- data/spec/dummy_apps/rails3/doc/README_FOR_APP +2 -0
- data/spec/dummy_apps/rails3/public/404.html +26 -0
- data/spec/dummy_apps/rails3/public/422.html +26 -0
- data/spec/dummy_apps/rails3/public/500.html +25 -0
- data/spec/dummy_apps/rails3/public/favicon.ico +0 -0
- data/spec/dummy_apps/rails3/public/index.html +241 -0
- data/spec/dummy_apps/rails3/public/robots.txt +5 -0
- data/spec/dummy_apps/rails3/script/rails +6 -0
- data/spec/dummy_apps/rails4/README.rdoc +28 -0
- data/spec/dummy_apps/rails4/Rakefile +6 -0
- data/spec/dummy_apps/rails4/app/assets/images/.keep +0 -0
- data/spec/dummy_apps/rails4/app/assets/javascripts/application.js +13 -0
- data/spec/dummy_apps/rails4/app/assets/javascripts/posts.js +2 -0
- data/spec/dummy_apps/rails4/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy_apps/rails4/app/assets/stylesheets/posts.css +4 -0
- data/spec/dummy_apps/rails4/app/controllers/application_controller.rb +5 -0
- data/spec/dummy_apps/rails4/app/controllers/concerns/.keep +0 -0
- data/spec/dummy_apps/rails4/app/controllers/posts_controller.rb +11 -0
- data/spec/dummy_apps/rails4/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_apps/rails4/app/mailers/.keep +0 -0
- data/spec/dummy_apps/rails4/app/models/.keep +0 -0
- data/spec/dummy_apps/rails4/app/models/concerns/.keep +0 -0
- data/spec/dummy_apps/rails4/app/schemas/posts/create.yml +20 -0
- data/spec/dummy_apps/rails4/app/schemas/posts/update.json +29 -0
- data/spec/dummy_apps/rails4/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_apps/rails4/bin/bundle +3 -0
- data/spec/dummy_apps/rails4/bin/rails +4 -0
- data/spec/dummy_apps/rails4/bin/rake +4 -0
- data/spec/dummy_apps/rails4/config/application.rb +29 -0
- data/spec/dummy_apps/rails4/config/boot.rb +5 -0
- data/spec/dummy_apps/rails4/config/environment.rb +5 -0
- data/spec/dummy_apps/rails4/config/environments/development.rb +34 -0
- data/spec/dummy_apps/rails4/config/environments/production.rb +80 -0
- data/spec/dummy_apps/rails4/config/environments/test.rb +39 -0
- data/spec/dummy_apps/rails4/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_apps/rails4/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy_apps/rails4/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_apps/rails4/config/initializers/inflections.rb +16 -0
- data/spec/dummy_apps/rails4/config/initializers/mime_types.rb +4 -0
- data/spec/dummy_apps/rails4/config/initializers/session_store.rb +3 -0
- data/spec/dummy_apps/rails4/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy_apps/rails4/config/locales/en.yml +23 -0
- data/spec/dummy_apps/rails4/config/routes.rb +58 -0
- data/spec/dummy_apps/rails4/config/secrets.yml +22 -0
- data/spec/dummy_apps/rails4/config.ru +4 -0
- data/spec/dummy_apps/rails4/lib/assets/.keep +0 -0
- data/spec/dummy_apps/rails4/log/.keep +0 -0
- data/spec/dummy_apps/rails4/public/404.html +67 -0
- data/spec/dummy_apps/rails4/public/422.html +67 -0
- data/spec/dummy_apps/rails4/public/500.html +66 -0
- data/spec/dummy_apps/rails4/public/favicon.ico +0 -0
- data/spec/fixtures/hyper_schema.yml +42 -0
- data/spec/fixtures/schemas/invalid_schema.yml +15 -0
- data/spec/fixtures/schemas/posts/create.yml +20 -0
- data/spec/fixtures/schemas/posts/search.json +13 -0
- data/spec/fixtures/schemas/posts/update.yaml +20 -0
- data/spec/fixtures/schemas/syntax_error.json +5 -0
- data/spec/lib/json_schema_rails/loaders/directory_spec.rb +59 -0
- data/spec/lib/json_schema_rails/loaders/hyper_schema_spec.rb +40 -0
- data/spec/lib/json_schema_rails/schema_validator_spec.rb +57 -0
- data/spec/lib/json_schema_rails_spec.rb +123 -0
- data/spec/railtie/controllers/posts_controller_spec.rb +43 -0
- data/spec/spec_helper.rb +28 -0
- metadata +406 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require "json_schema_rails/helpers"
|
2
|
+
|
3
|
+
module JsonSchemaRails
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer "json_schema_rails.set_schema_loader" do |app|
|
6
|
+
if schema_file = Dir[app.root.join('app', 'schema.*')].first
|
7
|
+
loader = JsonSchemaRails::Loaders::HyperSchema.new(schema_file)
|
8
|
+
else
|
9
|
+
loader = JsonSchemaRails::Loaders::Directory.new(app.root.join('app', 'schemas').to_path)
|
10
|
+
end
|
11
|
+
loader.cache = false if Rails.env.development?
|
12
|
+
JsonSchemaRails.schema_loader = loader
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "json_schema_rails.include_helpers" do
|
16
|
+
ActiveSupport.on_load :action_controller do
|
17
|
+
include ::JsonSchemaRails::Helpers
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
rake_tasks do
|
22
|
+
load File.expand_path("../../tasks/schema_tasks.rake", __FILE__)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module JsonSchemaRails
|
2
|
+
class SchemaValidator
|
3
|
+
DEFAULT_SCHEMA_URI = 'http://json-schema.org/draft-04/schema'
|
4
|
+
|
5
|
+
attr_reader :meta_schemas
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@meta_schemas = MetaSchemas.new
|
9
|
+
@loader = Loader.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def use_core_schemas!(options = {})
|
13
|
+
schemas_dir = File.expand_path('../../../schemas', __FILE__)
|
14
|
+
if options[:loose]
|
15
|
+
add_meta_schema_file Dir[File.join(schemas_dir, '*.json')]
|
16
|
+
else
|
17
|
+
add_meta_schema_file Dir[File.join(schemas_dir, 'strict', '*.json')]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate(schema_file)
|
22
|
+
content = @loader.render_schema_content(schema_file)
|
23
|
+
|
24
|
+
meta_schema_uri = content["$schema"] || content[:"$schema"] || DEFAULT_SCHEMA_URI
|
25
|
+
unless meta_schema_uri
|
26
|
+
raise JsonSchemaRails::SchemaNotFound, "No $schema specified"
|
27
|
+
end
|
28
|
+
|
29
|
+
meta_schema = @meta_schemas.lookup!(meta_schema_uri)
|
30
|
+
valid, errors = meta_schema.validate(content)
|
31
|
+
raise ValidationError.from_errors(errors, meta_schema) unless valid
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def add_meta_schema_file(*meta_schema_files)
|
38
|
+
meta_schema_files.flatten.each do |file|
|
39
|
+
@meta_schemas << @loader.load_schema!(file)
|
40
|
+
end
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
class MetaSchemas
|
45
|
+
include Enumerable
|
46
|
+
|
47
|
+
def initialize
|
48
|
+
@store = JsonSchema::DocumentStore.new
|
49
|
+
@expander = JsonSchema::ReferenceExpander.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def <<(schema)
|
53
|
+
Array(schema).each do |file|
|
54
|
+
schema.expand_references!(store: @store)
|
55
|
+
@store.add_schema(schema)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def [](schema_uri)
|
60
|
+
@store.lookup_schema(schema_uri.sub(/#+$/, ''))
|
61
|
+
end
|
62
|
+
|
63
|
+
def lookup!(schema_uri)
|
64
|
+
self[schema_uri] or
|
65
|
+
raise JsonSchemaRails::SchemaNotFound, "Unknown $schema: #{schema_uri}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def each
|
69
|
+
@store.each { |k, v| yield v }
|
70
|
+
end
|
71
|
+
|
72
|
+
def size
|
73
|
+
reduce(0) { |sum, n| sum + 1 }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Loader < Loaders::Base
|
78
|
+
def initialize
|
79
|
+
super(cache: false)
|
80
|
+
end
|
81
|
+
|
82
|
+
def load_schema!(schema_path)
|
83
|
+
load_schema_file(schema_path)
|
84
|
+
end
|
85
|
+
|
86
|
+
def render_schema_content(schema_path)
|
87
|
+
load_schema_content(schema_path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "json_schema_rails/version"
|
2
|
+
require "json_schema_rails/errors"
|
3
|
+
require "json_schema_rails/loaders"
|
4
|
+
require "json_schema_rails/schema_validator"
|
5
|
+
require "json_schema_rails/railtie" if defined?(Rails)
|
6
|
+
|
7
|
+
module JsonSchemaRails
|
8
|
+
def self.schema_loader
|
9
|
+
@schema_loader ||= Loaders::Directory.new('app/schemas')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.schema_loader=(loader)
|
13
|
+
@schema_loader = loader
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.validate(schema_name, data)
|
17
|
+
schema = lookup_schema!(schema_name)
|
18
|
+
schema.validate(data)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.validate!(schema_name, data)
|
22
|
+
schema = lookup_schema!(schema_name)
|
23
|
+
valid, errors = schema.validate(data)
|
24
|
+
unless valid
|
25
|
+
raise ValidationError.from_errors(errors, schema, schema_name)
|
26
|
+
end
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.lookup_schema(schema_name)
|
31
|
+
lookup_schema!(schema_name)
|
32
|
+
rescue SchemaNotFound
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.lookup_schema!(schema_name)
|
37
|
+
Array(schema_name).each do |name|
|
38
|
+
schema = schema_loader.load_schema(name)
|
39
|
+
return schema if schema
|
40
|
+
end
|
41
|
+
raise SchemaNotFound
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "json_schema_rails/schema_validator"
|
3
|
+
|
4
|
+
namespace :schema do
|
5
|
+
desc "Check syntax of schema files"
|
6
|
+
task :check do
|
7
|
+
validator = JsonSchemaRails::SchemaValidator.new.use_core_schemas!
|
8
|
+
|
9
|
+
find_root = defined?(Rails) ? Rails.root : Pathname.pwd
|
10
|
+
schema_paths = Dir[
|
11
|
+
find_root.join('app', 'schema.*'),
|
12
|
+
find_root.join('app', 'schemas', '**', '*.{json,yml,yaml}')
|
13
|
+
]
|
14
|
+
if schema_paths.empty?
|
15
|
+
puts "No schema files found"
|
16
|
+
next
|
17
|
+
end
|
18
|
+
|
19
|
+
error_count = 0
|
20
|
+
schema_paths.each do |path|
|
21
|
+
begin
|
22
|
+
validator.validate(path)
|
23
|
+
rescue JsonSchemaRails::Error => e
|
24
|
+
relpath = Pathname.new(path).relative_path_from(find_root)
|
25
|
+
puts "#{relpath}: #{e.message}"
|
26
|
+
error_count += 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if error_count == 0
|
31
|
+
STDERR.puts "All schema files has passed validation!"
|
32
|
+
else
|
33
|
+
STDERR.puts
|
34
|
+
abort "#{error_count} file(s) have failed for validation"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
{
|
2
|
+
"id": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
4
|
+
"description": "Core schema meta-schema",
|
5
|
+
"definitions": {
|
6
|
+
"schemaArray": {
|
7
|
+
"type": "array",
|
8
|
+
"minItems": 1,
|
9
|
+
"items": { "$ref": "#" }
|
10
|
+
},
|
11
|
+
"positiveInteger": {
|
12
|
+
"type": "integer",
|
13
|
+
"minimum": 0
|
14
|
+
},
|
15
|
+
"positiveIntegerDefault0": {
|
16
|
+
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
|
17
|
+
},
|
18
|
+
"simpleTypes": {
|
19
|
+
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
|
20
|
+
},
|
21
|
+
"stringArray": {
|
22
|
+
"type": "array",
|
23
|
+
"items": { "type": "string" },
|
24
|
+
"minItems": 1,
|
25
|
+
"uniqueItems": true
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"type": "object",
|
29
|
+
"properties": {
|
30
|
+
"id": {
|
31
|
+
"type": "string",
|
32
|
+
"format": "uri"
|
33
|
+
},
|
34
|
+
"$schema": {
|
35
|
+
"type": "string",
|
36
|
+
"format": "uri"
|
37
|
+
},
|
38
|
+
"title": {
|
39
|
+
"type": "string"
|
40
|
+
},
|
41
|
+
"description": {
|
42
|
+
"type": "string"
|
43
|
+
},
|
44
|
+
"default": {},
|
45
|
+
"multipleOf": {
|
46
|
+
"type": "number",
|
47
|
+
"minimum": 0,
|
48
|
+
"exclusiveMinimum": true
|
49
|
+
},
|
50
|
+
"maximum": {
|
51
|
+
"type": "number"
|
52
|
+
},
|
53
|
+
"exclusiveMaximum": {
|
54
|
+
"type": "boolean",
|
55
|
+
"default": false
|
56
|
+
},
|
57
|
+
"minimum": {
|
58
|
+
"type": "number"
|
59
|
+
},
|
60
|
+
"exclusiveMinimum": {
|
61
|
+
"type": "boolean",
|
62
|
+
"default": false
|
63
|
+
},
|
64
|
+
"maxLength": { "$ref": "#/definitions/positiveInteger" },
|
65
|
+
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
66
|
+
"pattern": {
|
67
|
+
"type": "string",
|
68
|
+
"format": "regex"
|
69
|
+
},
|
70
|
+
"additionalItems": {
|
71
|
+
"anyOf": [
|
72
|
+
{ "type": "boolean" },
|
73
|
+
{ "$ref": "#" }
|
74
|
+
],
|
75
|
+
"default": {}
|
76
|
+
},
|
77
|
+
"items": {
|
78
|
+
"anyOf": [
|
79
|
+
{ "$ref": "#" },
|
80
|
+
{ "$ref": "#/definitions/schemaArray" }
|
81
|
+
],
|
82
|
+
"default": {}
|
83
|
+
},
|
84
|
+
"maxItems": { "$ref": "#/definitions/positiveInteger" },
|
85
|
+
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
86
|
+
"uniqueItems": {
|
87
|
+
"type": "boolean",
|
88
|
+
"default": false
|
89
|
+
},
|
90
|
+
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
|
91
|
+
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
92
|
+
"required": { "$ref": "#/definitions/stringArray" },
|
93
|
+
"additionalProperties": {
|
94
|
+
"anyOf": [
|
95
|
+
{ "type": "boolean" },
|
96
|
+
{ "$ref": "#" }
|
97
|
+
],
|
98
|
+
"default": {}
|
99
|
+
},
|
100
|
+
"definitions": {
|
101
|
+
"type": "object",
|
102
|
+
"additionalProperties": { "$ref": "#" },
|
103
|
+
"default": {}
|
104
|
+
},
|
105
|
+
"properties": {
|
106
|
+
"type": "object",
|
107
|
+
"additionalProperties": { "$ref": "#" },
|
108
|
+
"default": {}
|
109
|
+
},
|
110
|
+
"patternProperties": {
|
111
|
+
"type": "object",
|
112
|
+
"additionalProperties": { "$ref": "#" },
|
113
|
+
"default": {}
|
114
|
+
},
|
115
|
+
"dependencies": {
|
116
|
+
"type": "object",
|
117
|
+
"additionalProperties": {
|
118
|
+
"anyOf": [
|
119
|
+
{ "$ref": "#" },
|
120
|
+
{ "$ref": "#/definitions/stringArray" }
|
121
|
+
]
|
122
|
+
}
|
123
|
+
},
|
124
|
+
"enum": {
|
125
|
+
"type": "array",
|
126
|
+
"minItems": 1,
|
127
|
+
"uniqueItems": true
|
128
|
+
},
|
129
|
+
"type": {
|
130
|
+
"anyOf": [
|
131
|
+
{ "$ref": "#/definitions/simpleTypes" },
|
132
|
+
{
|
133
|
+
"type": "array",
|
134
|
+
"items": { "$ref": "#/definitions/simpleTypes" },
|
135
|
+
"minItems": 1,
|
136
|
+
"uniqueItems": true
|
137
|
+
}
|
138
|
+
]
|
139
|
+
},
|
140
|
+
"allOf": { "$ref": "#/definitions/schemaArray" },
|
141
|
+
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
142
|
+
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
143
|
+
"not": { "$ref": "#" }
|
144
|
+
},
|
145
|
+
"dependencies": {
|
146
|
+
"exclusiveMaximum": [ "maximum" ],
|
147
|
+
"exclusiveMinimum": [ "minimum" ]
|
148
|
+
},
|
149
|
+
"default": {}
|
150
|
+
}
|
@@ -0,0 +1,168 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
|
3
|
+
"id": "http://json-schema.org/draft-04/hyper-schema#",
|
4
|
+
"title": "JSON Hyper-Schema",
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "http://json-schema.org/draft-04/schema#"
|
8
|
+
}
|
9
|
+
],
|
10
|
+
"properties": {
|
11
|
+
"additionalItems": {
|
12
|
+
"anyOf": [
|
13
|
+
{
|
14
|
+
"type": "boolean"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"$ref": "#"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
},
|
21
|
+
"additionalProperties": {
|
22
|
+
"anyOf": [
|
23
|
+
{
|
24
|
+
"type": "boolean"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"$ref": "#"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
},
|
31
|
+
"dependencies": {
|
32
|
+
"additionalProperties": {
|
33
|
+
"anyOf": [
|
34
|
+
{
|
35
|
+
"$ref": "#"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"type": "array"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
},
|
43
|
+
"items": {
|
44
|
+
"anyOf": [
|
45
|
+
{
|
46
|
+
"$ref": "#"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"$ref": "#/definitions/schemaArray"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
},
|
53
|
+
"definitions": {
|
54
|
+
"additionalProperties": {
|
55
|
+
"$ref": "#"
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"patternProperties": {
|
59
|
+
"additionalProperties": {
|
60
|
+
"$ref": "#"
|
61
|
+
}
|
62
|
+
},
|
63
|
+
"properties": {
|
64
|
+
"additionalProperties": {
|
65
|
+
"$ref": "#"
|
66
|
+
}
|
67
|
+
},
|
68
|
+
"allOf": {
|
69
|
+
"$ref": "#/definitions/schemaArray"
|
70
|
+
},
|
71
|
+
"anyOf": {
|
72
|
+
"$ref": "#/definitions/schemaArray"
|
73
|
+
},
|
74
|
+
"oneOf": {
|
75
|
+
"$ref": "#/definitions/schemaArray"
|
76
|
+
},
|
77
|
+
"not": {
|
78
|
+
"$ref": "#"
|
79
|
+
},
|
80
|
+
|
81
|
+
"links": {
|
82
|
+
"type": "array",
|
83
|
+
"items": {
|
84
|
+
"$ref": "#/definitions/linkDescription"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"fragmentResolution": {
|
88
|
+
"type": "string"
|
89
|
+
},
|
90
|
+
"media": {
|
91
|
+
"type": "object",
|
92
|
+
"properties": {
|
93
|
+
"type": {
|
94
|
+
"description": "A media type, as described in RFC 2046",
|
95
|
+
"type": "string"
|
96
|
+
},
|
97
|
+
"binaryEncoding": {
|
98
|
+
"description": "A content encoding scheme, as described in RFC 2045",
|
99
|
+
"type": "string"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
},
|
103
|
+
"pathStart": {
|
104
|
+
"description": "Instances' URIs must start with this value for this schema to apply to them",
|
105
|
+
"type": "string",
|
106
|
+
"format": "uri"
|
107
|
+
}
|
108
|
+
},
|
109
|
+
"definitions": {
|
110
|
+
"schemaArray": {
|
111
|
+
"type": "array",
|
112
|
+
"items": {
|
113
|
+
"$ref": "#"
|
114
|
+
}
|
115
|
+
},
|
116
|
+
"linkDescription": {
|
117
|
+
"title": "Link Description Object",
|
118
|
+
"type": "object",
|
119
|
+
"required": [ "href", "rel" ],
|
120
|
+
"properties": {
|
121
|
+
"href": {
|
122
|
+
"description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",
|
123
|
+
"type": "string"
|
124
|
+
},
|
125
|
+
"rel": {
|
126
|
+
"description": "relation to the target resource of the link",
|
127
|
+
"type": "string"
|
128
|
+
},
|
129
|
+
"title": {
|
130
|
+
"description": "a title for the link",
|
131
|
+
"type": "string"
|
132
|
+
},
|
133
|
+
"targetSchema": {
|
134
|
+
"description": "JSON Schema describing the link target",
|
135
|
+
"$ref": "#"
|
136
|
+
},
|
137
|
+
"mediaType": {
|
138
|
+
"description": "media type (as defined by RFC 2046) describing the link target",
|
139
|
+
"type": "string"
|
140
|
+
},
|
141
|
+
"method": {
|
142
|
+
"description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")",
|
143
|
+
"type": "string"
|
144
|
+
},
|
145
|
+
"encType": {
|
146
|
+
"description": "The media type in which to submit data along with the request",
|
147
|
+
"type": "string",
|
148
|
+
"default": "application/json"
|
149
|
+
},
|
150
|
+
"schema": {
|
151
|
+
"description": "Schema describing the data to submit along with the request",
|
152
|
+
"$ref": "#"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"links": [
|
158
|
+
{
|
159
|
+
"rel": "self",
|
160
|
+
"href": "{+id}"
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"rel": "full",
|
164
|
+
"href": "{+($ref)}"
|
165
|
+
}
|
166
|
+
]
|
167
|
+
}
|
168
|
+
|
@@ -0,0 +1,151 @@
|
|
1
|
+
{
|
2
|
+
"id": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
4
|
+
"description": "Core schema meta-schema",
|
5
|
+
"additionalProperties": false,
|
6
|
+
"definitions": {
|
7
|
+
"schemaArray": {
|
8
|
+
"type": "array",
|
9
|
+
"minItems": 1,
|
10
|
+
"items": { "$ref": "#" }
|
11
|
+
},
|
12
|
+
"positiveInteger": {
|
13
|
+
"type": "integer",
|
14
|
+
"minimum": 0
|
15
|
+
},
|
16
|
+
"positiveIntegerDefault0": {
|
17
|
+
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
|
18
|
+
},
|
19
|
+
"simpleTypes": {
|
20
|
+
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
|
21
|
+
},
|
22
|
+
"stringArray": {
|
23
|
+
"type": "array",
|
24
|
+
"items": { "type": "string" },
|
25
|
+
"minItems": 1,
|
26
|
+
"uniqueItems": true
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"type": "object",
|
30
|
+
"properties": {
|
31
|
+
"id": {
|
32
|
+
"type": "string",
|
33
|
+
"format": "uri"
|
34
|
+
},
|
35
|
+
"$schema": {
|
36
|
+
"type": "string",
|
37
|
+
"format": "uri"
|
38
|
+
},
|
39
|
+
"title": {
|
40
|
+
"type": "string"
|
41
|
+
},
|
42
|
+
"description": {
|
43
|
+
"type": "string"
|
44
|
+
},
|
45
|
+
"default": {},
|
46
|
+
"multipleOf": {
|
47
|
+
"type": "number",
|
48
|
+
"minimum": 0,
|
49
|
+
"exclusiveMinimum": true
|
50
|
+
},
|
51
|
+
"maximum": {
|
52
|
+
"type": "number"
|
53
|
+
},
|
54
|
+
"exclusiveMaximum": {
|
55
|
+
"type": "boolean",
|
56
|
+
"default": false
|
57
|
+
},
|
58
|
+
"minimum": {
|
59
|
+
"type": "number"
|
60
|
+
},
|
61
|
+
"exclusiveMinimum": {
|
62
|
+
"type": "boolean",
|
63
|
+
"default": false
|
64
|
+
},
|
65
|
+
"maxLength": { "$ref": "#/definitions/positiveInteger" },
|
66
|
+
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
67
|
+
"pattern": {
|
68
|
+
"type": "string",
|
69
|
+
"format": "regex"
|
70
|
+
},
|
71
|
+
"additionalItems": {
|
72
|
+
"anyOf": [
|
73
|
+
{ "type": "boolean" },
|
74
|
+
{ "$ref": "#" }
|
75
|
+
],
|
76
|
+
"default": {}
|
77
|
+
},
|
78
|
+
"items": {
|
79
|
+
"anyOf": [
|
80
|
+
{ "$ref": "#" },
|
81
|
+
{ "$ref": "#/definitions/schemaArray" }
|
82
|
+
],
|
83
|
+
"default": {}
|
84
|
+
},
|
85
|
+
"maxItems": { "$ref": "#/definitions/positiveInteger" },
|
86
|
+
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
87
|
+
"uniqueItems": {
|
88
|
+
"type": "boolean",
|
89
|
+
"default": false
|
90
|
+
},
|
91
|
+
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
|
92
|
+
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
93
|
+
"required": { "$ref": "#/definitions/stringArray" },
|
94
|
+
"additionalProperties": {
|
95
|
+
"anyOf": [
|
96
|
+
{ "type": "boolean" },
|
97
|
+
{ "$ref": "#" }
|
98
|
+
],
|
99
|
+
"default": {}
|
100
|
+
},
|
101
|
+
"definitions": {
|
102
|
+
"type": "object",
|
103
|
+
"additionalProperties": { "$ref": "#" },
|
104
|
+
"default": {}
|
105
|
+
},
|
106
|
+
"properties": {
|
107
|
+
"type": "object",
|
108
|
+
"additionalProperties": { "$ref": "#" },
|
109
|
+
"default": {}
|
110
|
+
},
|
111
|
+
"patternProperties": {
|
112
|
+
"type": "object",
|
113
|
+
"additionalProperties": { "$ref": "#" },
|
114
|
+
"default": {}
|
115
|
+
},
|
116
|
+
"dependencies": {
|
117
|
+
"type": "object",
|
118
|
+
"additionalProperties": {
|
119
|
+
"anyOf": [
|
120
|
+
{ "$ref": "#" },
|
121
|
+
{ "$ref": "#/definitions/stringArray" }
|
122
|
+
]
|
123
|
+
}
|
124
|
+
},
|
125
|
+
"enum": {
|
126
|
+
"type": "array",
|
127
|
+
"minItems": 1,
|
128
|
+
"uniqueItems": true
|
129
|
+
},
|
130
|
+
"type": {
|
131
|
+
"anyOf": [
|
132
|
+
{ "$ref": "#/definitions/simpleTypes" },
|
133
|
+
{
|
134
|
+
"type": "array",
|
135
|
+
"items": { "$ref": "#/definitions/simpleTypes" },
|
136
|
+
"minItems": 1,
|
137
|
+
"uniqueItems": true
|
138
|
+
}
|
139
|
+
]
|
140
|
+
},
|
141
|
+
"allOf": { "$ref": "#/definitions/schemaArray" },
|
142
|
+
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
143
|
+
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
144
|
+
"not": { "$ref": "#" }
|
145
|
+
},
|
146
|
+
"dependencies": {
|
147
|
+
"exclusiveMaximum": [ "maximum" ],
|
148
|
+
"exclusiveMinimum": [ "minimum" ]
|
149
|
+
},
|
150
|
+
"default": {}
|
151
|
+
}
|