lurker 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -1
- data/Gemfile +1 -0
- data/features/dereferencing_through_inlining.feature +102 -0
- data/features/partials.feature +3 -1
- data/features/step_definitions/additional_cli_steps.rb +19 -0
- data/features/support/files_helper.rb +7 -0
- data/lib/lurker/endpoint.rb +85 -50
- data/lib/lurker/json/concerns/validatable.rb +47 -0
- data/lib/lurker/json/orderer.rb +19 -0
- data/lib/lurker/json/parser/expertise.rb +30 -0
- data/lib/lurker/json/parser/plain_strategy.rb +39 -0
- data/lib/lurker/json/parser/typed_strategy.rb +71 -0
- data/lib/lurker/json/parser.rb +73 -0
- data/lib/lurker/json/reader.rb +28 -0
- data/lib/lurker/json/schema/attribute.rb +115 -0
- data/lib/lurker/json/schema/extensions.rb +19 -0
- data/lib/lurker/json/schema/list.rb +51 -0
- data/lib/lurker/json/schema/object.rb +67 -0
- data/lib/lurker/json/schema/reference.rb +34 -0
- data/lib/lurker/{endpoint → json/schema}/response_codes.rb +13 -16
- data/lib/lurker/json/schema/tuple/all_of.rb +17 -0
- data/lib/lurker/json/schema/tuple/any_of.rb +17 -0
- data/lib/lurker/json/schema/tuple/one_of.rb +17 -0
- data/lib/lurker/json/schema/tuple.rb +38 -0
- data/lib/lurker/json/schema.rb +122 -0
- data/lib/lurker/json/writter.rb +58 -0
- data/lib/lurker/presenters/endpoint_presenter.rb +2 -2
- data/lib/lurker/presenters/schema_presenter.rb +4 -1
- data/lib/lurker/presenters/service_presenter.rb +8 -2
- data/lib/lurker/service.rb +4 -4
- data/lib/lurker/version.rb +1 -1
- data/lib/lurker.rb +19 -8
- data/spec/lurker/json/list_spec.rb +101 -0
- data/spec/lurker/json/schema_spec.rb +126 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/matchers/json_attribute.rb +27 -0
- data/spec/support/matchers/json_object.rb +33 -0
- data/templates/generate_stuff.rb +19 -10
- data.tar.gz.sig +2 -4
- metadata +33 -9
- metadata.gz.sig +0 -0
- data/lib/lurker/endpoint/http_parameters.rb +0 -77
- data/lib/lurker/schema.rb +0 -89
- data/lib/lurker/schema_modifier/array.rb +0 -28
- data/lib/lurker/schema_modifier/atom.rb +0 -97
- data/lib/lurker/schema_modifier/hash.rb +0 -30
- data/lib/lurker/schema_modifier.rb +0 -48
data/lib/lurker/service.rb
CHANGED
@@ -15,9 +15,9 @@ class Lurker::Service
|
|
15
15
|
@service_dir = File.expand_path(service_dir)
|
16
16
|
@service_filename = service_name
|
17
17
|
@schema = if persisted? && (schema = YAML.load_file(service_path)).is_a?(Hash)
|
18
|
-
Lurker::Schema.new(schema)
|
18
|
+
Lurker::Json::Schema.new(schema)
|
19
19
|
else
|
20
|
-
Lurker::Schema.new(
|
20
|
+
Lurker::Json::Schema.new(
|
21
21
|
'name' => service_filename,
|
22
22
|
'basePath' => '',
|
23
23
|
'description' => '',
|
@@ -39,8 +39,8 @@ class Lurker::Service
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def persist!
|
42
|
-
|
43
|
-
@opened_endpoints.each { |
|
42
|
+
Lurker::Json::Writter.write(schema, service_path) unless File.exist?(service_path)
|
43
|
+
@opened_endpoints.each { |ep| ep.persist! if ep.respond_to?(:persist!) }
|
44
44
|
end
|
45
45
|
|
46
46
|
def verify!(verb, path, request_params,
|
data/lib/lurker/version.rb
CHANGED
data/lib/lurker.rb
CHANGED
@@ -48,12 +48,6 @@ module Lurker
|
|
48
48
|
end
|
49
49
|
|
50
50
|
require 'lurker/jaml_descriptor'
|
51
|
-
require 'lurker/schema'
|
52
|
-
require 'lurker/json_schema_hash'
|
53
|
-
require 'lurker/schema_modifier'
|
54
|
-
require 'lurker/schema_modifier/hash'
|
55
|
-
require 'lurker/schema_modifier/array'
|
56
|
-
require 'lurker/schema_modifier/atom'
|
57
51
|
require 'lurker/ref_object'
|
58
52
|
require 'lurker/erb_schema_context'
|
59
53
|
require 'lurker/service'
|
@@ -61,8 +55,6 @@ require 'lurker/validator'
|
|
61
55
|
require 'lurker/validation_error'
|
62
56
|
require 'lurker/utils'
|
63
57
|
require 'lurker/endpoint'
|
64
|
-
require 'lurker/endpoint/response_codes'
|
65
|
-
require 'lurker/endpoint/http_parameters'
|
66
58
|
require 'lurker/rendering_controller'
|
67
59
|
require 'lurker/form_builder'
|
68
60
|
require 'lurker/presenters/json_presenter'
|
@@ -71,6 +63,25 @@ require 'lurker/presenters/service_presenter'
|
|
71
63
|
require 'lurker/presenters/endpoint_presenter'
|
72
64
|
require 'lurker/presenters/schema_presenter'
|
73
65
|
require 'lurker/presenters/response_code_presenter'
|
66
|
+
require 'lurker/json/reader'
|
67
|
+
require 'lurker/json/writter'
|
68
|
+
require 'lurker/json/orderer'
|
69
|
+
require 'lurker/json/parser'
|
70
|
+
require 'lurker/json/parser/expertise'
|
71
|
+
require 'lurker/json/parser/plain_strategy'
|
72
|
+
require 'lurker/json/parser/typed_strategy'
|
73
|
+
require 'lurker/json/concerns/validatable'
|
74
|
+
require 'lurker/json/schema'
|
75
|
+
require 'lurker/json/schema/object'
|
76
|
+
require 'lurker/json/schema/list'
|
77
|
+
require 'lurker/json/schema/attribute'
|
78
|
+
require 'lurker/json/schema/tuple'
|
79
|
+
require 'lurker/json/schema/tuple/all_of'
|
80
|
+
require 'lurker/json/schema/tuple/any_of'
|
81
|
+
require 'lurker/json/schema/tuple/one_of'
|
82
|
+
require 'lurker/json/schema/extensions'
|
83
|
+
require 'lurker/json/schema/response_codes'
|
84
|
+
require 'lurker/json/schema/reference'
|
74
85
|
require 'lurker/spy'
|
75
86
|
require 'lurker/request'
|
76
87
|
require 'lurker/response'
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lurker::Json::List do
|
4
|
+
let(:klass) { described_class }
|
5
|
+
|
6
|
+
describe '#merge!' do
|
7
|
+
context 'when list is an array of attributes' do
|
8
|
+
let(:list) { klass.new([1, 2, 3]) }
|
9
|
+
|
10
|
+
context 'when merge an array' do
|
11
|
+
let(:expected) do
|
12
|
+
{
|
13
|
+
'type' => 'array',
|
14
|
+
'items' => {
|
15
|
+
'description' => '',
|
16
|
+
'type' => 'integer',
|
17
|
+
'example' => 1
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
before { list.merge!([42]) }
|
22
|
+
|
23
|
+
it { expect(list.to_hash).to eq expected }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when merge a fixnum' do
|
27
|
+
let(:expected) do
|
28
|
+
{
|
29
|
+
'type' => 'array',
|
30
|
+
'items' => {
|
31
|
+
'description' => '',
|
32
|
+
'type' => 'integer',
|
33
|
+
'example' => 1
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
before { list.merge!(999) }
|
38
|
+
|
39
|
+
it { expect(list.to_hash).to eq expected }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when merge a string' do
|
43
|
+
let(:expected) do
|
44
|
+
{
|
45
|
+
'type' => 'array',
|
46
|
+
'items' => {
|
47
|
+
'anyOf' => [
|
48
|
+
{
|
49
|
+
'description' => '',
|
50
|
+
'type' => 'integer',
|
51
|
+
'example' => 1
|
52
|
+
},
|
53
|
+
{
|
54
|
+
'description' => '',
|
55
|
+
'type' => 'string',
|
56
|
+
'example' => 'razum2um'
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
before { list.merge!('razum2um') }
|
63
|
+
|
64
|
+
it { expect(list.to_hash).to eq expected }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when merge a hash' do
|
68
|
+
let(:expected) do
|
69
|
+
{
|
70
|
+
'type' => 'array',
|
71
|
+
'items' => {
|
72
|
+
'anyOf' => [
|
73
|
+
{
|
74
|
+
'description' => '',
|
75
|
+
'type' => 'integer',
|
76
|
+
'example' => 1
|
77
|
+
},
|
78
|
+
{
|
79
|
+
'description' => '',
|
80
|
+
'type' => 'object',
|
81
|
+
'additionalProperties' => false,
|
82
|
+
'required' => [],
|
83
|
+
'properties' => {
|
84
|
+
'name' => {
|
85
|
+
'description' => '',
|
86
|
+
'type' => 'string',
|
87
|
+
'example' => 'razum2um'
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
]
|
92
|
+
}
|
93
|
+
}
|
94
|
+
end
|
95
|
+
before { list.merge!('name' => 'razum2um') }
|
96
|
+
|
97
|
+
it { expect(list.to_hash).to eq expected }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lurker::Json::Schema do
|
4
|
+
let(:klass) { described_class }
|
5
|
+
|
6
|
+
describe 'Merge request/response parameters' do
|
7
|
+
let(:schema) { klass.new('responseParameters' => {}) }
|
8
|
+
|
9
|
+
context 'when request parameters is an object' do
|
10
|
+
let(:parameters) do
|
11
|
+
{
|
12
|
+
'id' => 1,
|
13
|
+
'name' => 'Bob',
|
14
|
+
'repos' => [{'id' => 1, 'name' => 'gem-gon'}]
|
15
|
+
}
|
16
|
+
end
|
17
|
+
let(:expected) do
|
18
|
+
{
|
19
|
+
'description' => '',
|
20
|
+
'type' => 'object',
|
21
|
+
'additionalProperties' => false,
|
22
|
+
'required' => [],
|
23
|
+
'properties' => {
|
24
|
+
'id' => {
|
25
|
+
'description' => '',
|
26
|
+
'type' => 'integer',
|
27
|
+
'example' => 1
|
28
|
+
},
|
29
|
+
'name' => {
|
30
|
+
'description' => '',
|
31
|
+
'type' => 'string',
|
32
|
+
'example' => 'Bob'
|
33
|
+
},
|
34
|
+
'repos' => {
|
35
|
+
'type' => 'array',
|
36
|
+
'items' => {
|
37
|
+
'description' => '',
|
38
|
+
'type' => 'object',
|
39
|
+
'additionalProperties' => false,
|
40
|
+
'required' => [],
|
41
|
+
'properties' => {
|
42
|
+
'id' => {
|
43
|
+
'description' => '',
|
44
|
+
'type' => 'integer',
|
45
|
+
'example' => 1
|
46
|
+
},
|
47
|
+
'name' => {
|
48
|
+
'description' => '',
|
49
|
+
'type' => 'string',
|
50
|
+
'example' => 'gem-gon'
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
before { schema['responseParameters'].merge! parameters }
|
59
|
+
|
60
|
+
it { expect(schema['responseParameters'].to_hash).to eq expected }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when request parameters is an array of objects' do
|
64
|
+
let(:parameters) { [{'id' => 1, 'name' => 'Bob'}, {'id' => 2, 'name' => 'Tom'}] }
|
65
|
+
let(:expected) do
|
66
|
+
{
|
67
|
+
'type' => 'array',
|
68
|
+
'items' => {
|
69
|
+
'description' => '',
|
70
|
+
'type' => 'object',
|
71
|
+
'additionalProperties' => false,
|
72
|
+
'required' => [],
|
73
|
+
'properties' => {
|
74
|
+
'id' => {
|
75
|
+
'description' => '',
|
76
|
+
'type' => 'integer',
|
77
|
+
'example' => 1
|
78
|
+
},
|
79
|
+
'name' => {
|
80
|
+
'description' => '',
|
81
|
+
'type' => 'string',
|
82
|
+
'example' => 'Bob'
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
before { schema['responseParameters'].merge! parameters }
|
89
|
+
|
90
|
+
it { expect(schema['responseParameters'].to_hash).to eq expected }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when request parameters is an object with array of strings' do
|
94
|
+
let(:parameters) { {'errors' => {'name' => ['Couldn`t be blank']}} }
|
95
|
+
let(:expected) do
|
96
|
+
{
|
97
|
+
'description' => '',
|
98
|
+
'type' => 'object',
|
99
|
+
'additionalProperties' => false,
|
100
|
+
'required' => [],
|
101
|
+
'properties' => {
|
102
|
+
'errors' => {
|
103
|
+
'description' => '',
|
104
|
+
'type' => 'object',
|
105
|
+
'additionalProperties' => false,
|
106
|
+
'required' => [],
|
107
|
+
'properties' => {
|
108
|
+
'name' => {
|
109
|
+
'type' => 'array',
|
110
|
+
'items' => {
|
111
|
+
'description' => '',
|
112
|
+
'type' => 'string',
|
113
|
+
'example' => 'Couldn`t be blank'
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
before { schema['responseParameters'].merge! parameters }
|
122
|
+
|
123
|
+
it { expect(schema['responseParameters'].to_hash).to eq expected }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,8 @@ SimpleCov.start do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
Dir[File.expand_path '../support/**/*.rb', __FILE__].each { |file| require file }
|
16
|
+
|
15
17
|
RSpec.configure do |config|
|
16
18
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
17
19
|
config.run_all_when_everything_filtered = true
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :be_a_json_attribute do
|
4
|
+
match do |attribute|
|
5
|
+
expect(attribute).to have_key 'type'
|
6
|
+
|
7
|
+
expect(attribute['type']).to eq @type if @type.present?
|
8
|
+
expect(attribute['example']).to eq @example if @example.present?
|
9
|
+
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
chain :with_type do |type|
|
14
|
+
@type = type
|
15
|
+
end
|
16
|
+
|
17
|
+
chain :with_example do |example|
|
18
|
+
@example = example
|
19
|
+
end
|
20
|
+
|
21
|
+
failure_message_for_should do |attribute|
|
22
|
+
"expected that #{attribute.try(:to_hash) || attribute} to be a json attribute".tap do |message|
|
23
|
+
message << " with type '#{@type}'" if @type.present?
|
24
|
+
message << " with example '#{@example}'" if @example.present?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :be_a_json_object do
|
4
|
+
@properties = []
|
5
|
+
|
6
|
+
match do |object|
|
7
|
+
expect(object).to have_key 'type'
|
8
|
+
expect(object).to have_key 'properties'
|
9
|
+
expect(object['type']).to eq 'object'
|
10
|
+
|
11
|
+
if @properties.present?
|
12
|
+
@properties.each do |property|
|
13
|
+
expect(object['properties']).to have_key property
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
chain :with_properties do |*properties|
|
21
|
+
@properties |= properties
|
22
|
+
end
|
23
|
+
|
24
|
+
chain :with_property do |property|
|
25
|
+
@properties << property
|
26
|
+
end
|
27
|
+
|
28
|
+
failure_message_for_should do |object|
|
29
|
+
"expected that #{object.try(:to_hash) || object} to be a json object".tap do |message|
|
30
|
+
message << " with properties #{@properties}" if @properties.present?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/templates/generate_stuff.rb
CHANGED
@@ -59,6 +59,12 @@ route <<-ROUTE
|
|
59
59
|
resources :repos
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
namespace :v3 do
|
64
|
+
resources :users do
|
65
|
+
resources :repos
|
66
|
+
end
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
get '/robots.txt', to: proc { |env| [
|
@@ -90,7 +96,8 @@ file 'config/initializers/serializer.rb', force: true do
|
|
90
96
|
else
|
91
97
|
options[:methods] = attributes.keys.sort + methods
|
92
98
|
end
|
93
|
-
options[:
|
99
|
+
options[:methods] -= Array.wrap(options[:except])
|
100
|
+
options[:only] = options[:except] = []
|
94
101
|
|
95
102
|
super(options)
|
96
103
|
end
|
@@ -259,16 +266,18 @@ file 'app/controllers/api/v1/repos_controller.rb', 'Api::V1::ReposController', f
|
|
259
266
|
CODE
|
260
267
|
end
|
261
268
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
269
|
+
[2, 3].each do |version|
|
270
|
+
file "app/controllers/api/v#{version}/users_controller.rb", "Api::V#{version}::UsersController", force: true do
|
271
|
+
<<-CODE
|
272
|
+
class Api::V#{version}::UsersController < Api::V1::UsersController; end
|
273
|
+
CODE
|
274
|
+
end
|
267
275
|
|
268
|
-
file
|
269
|
-
|
270
|
-
|
271
|
-
|
276
|
+
file "app/controllers/api/v#{version}/repos_controller.rb", "Api::V#{version}::ReposController", force: true do
|
277
|
+
<<-CODE
|
278
|
+
class Api::V#{version}::ReposController < Api::V1::ReposController; end
|
279
|
+
CODE
|
280
|
+
end
|
272
281
|
end
|
273
282
|
|
274
283
|
# FIXME: uninitialized constant User (NameError) in last creation line
|
data.tar.gz.sig
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lurker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Bokov
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
vzKbYclpJ7gENr/xiTjGqA/Md3zJMzmsFrzUXt4RVmo5SaCyZjC6gFfhSr+PODc7
|
31
31
|
ZaSbckvH/+m4boAsg0JkGGFcS3j5fgNmdwgA1A==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-
|
33
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: json
|
@@ -461,6 +461,7 @@ files:
|
|
461
461
|
- features/atom_persistent_within_the_same_type.feature
|
462
462
|
- features/controller_nested_schema_scaffolding.feature
|
463
463
|
- features/controller_schema_scaffolding.feature
|
464
|
+
- features/dereferencing_through_inlining.feature
|
464
465
|
- features/html_generation.feature
|
465
466
|
- features/minitest.feature
|
466
467
|
- features/multidomain_support.feature
|
@@ -472,6 +473,7 @@ files:
|
|
472
473
|
- features/schema_updating_within_test_suite.feature
|
473
474
|
- features/step_definitions/additional_cli_steps.rb
|
474
475
|
- features/support/env.rb
|
476
|
+
- features/support/files_helper.rb
|
475
477
|
- features/test_endpoint.feature
|
476
478
|
- gemfiles/Gemfile32.ci
|
477
479
|
- gemfiles/Gemfile40.ci
|
@@ -481,12 +483,29 @@ files:
|
|
481
483
|
- lib/lurker/capistrano.rb
|
482
484
|
- lib/lurker/cli.rb
|
483
485
|
- lib/lurker/endpoint.rb
|
484
|
-
- lib/lurker/endpoint/http_parameters.rb
|
485
|
-
- lib/lurker/endpoint/response_codes.rb
|
486
486
|
- lib/lurker/engine.rb
|
487
487
|
- lib/lurker/erb_schema_context.rb
|
488
488
|
- lib/lurker/form_builder.rb
|
489
489
|
- lib/lurker/jaml_descriptor.rb
|
490
|
+
- lib/lurker/json/concerns/validatable.rb
|
491
|
+
- lib/lurker/json/orderer.rb
|
492
|
+
- lib/lurker/json/parser.rb
|
493
|
+
- lib/lurker/json/parser/expertise.rb
|
494
|
+
- lib/lurker/json/parser/plain_strategy.rb
|
495
|
+
- lib/lurker/json/parser/typed_strategy.rb
|
496
|
+
- lib/lurker/json/reader.rb
|
497
|
+
- lib/lurker/json/schema.rb
|
498
|
+
- lib/lurker/json/schema/attribute.rb
|
499
|
+
- lib/lurker/json/schema/extensions.rb
|
500
|
+
- lib/lurker/json/schema/list.rb
|
501
|
+
- lib/lurker/json/schema/object.rb
|
502
|
+
- lib/lurker/json/schema/reference.rb
|
503
|
+
- lib/lurker/json/schema/response_codes.rb
|
504
|
+
- lib/lurker/json/schema/tuple.rb
|
505
|
+
- lib/lurker/json/schema/tuple/all_of.rb
|
506
|
+
- lib/lurker/json/schema/tuple/any_of.rb
|
507
|
+
- lib/lurker/json/schema/tuple/one_of.rb
|
508
|
+
- lib/lurker/json/writter.rb
|
490
509
|
- lib/lurker/json_schema_hash.rb
|
491
510
|
- lib/lurker/presenters/base_presenter.rb
|
492
511
|
- lib/lurker/presenters/endpoint_presenter.rb
|
@@ -499,11 +518,6 @@ files:
|
|
499
518
|
- lib/lurker/request.rb
|
500
519
|
- lib/lurker/response.rb
|
501
520
|
- lib/lurker/sandbox.rb
|
502
|
-
- lib/lurker/schema.rb
|
503
|
-
- lib/lurker/schema_modifier.rb
|
504
|
-
- lib/lurker/schema_modifier/array.rb
|
505
|
-
- lib/lurker/schema_modifier/atom.rb
|
506
|
-
- lib/lurker/schema_modifier/hash.rb
|
507
521
|
- lib/lurker/server.rb
|
508
522
|
- lib/lurker/service.rb
|
509
523
|
- lib/lurker/spec_helper.rb
|
@@ -560,8 +574,12 @@ files:
|
|
560
574
|
- lib/lurker/version.rb
|
561
575
|
- lurker.gemspec
|
562
576
|
- spec/lurker/endpoint_spec.rb
|
577
|
+
- spec/lurker/json/list_spec.rb
|
578
|
+
- spec/lurker/json/schema_spec.rb
|
563
579
|
- spec/lurker/yaml_spec.rb
|
564
580
|
- spec/spec_helper.rb
|
581
|
+
- spec/support/matchers/json_attribute.rb
|
582
|
+
- spec/support/matchers/json_object.rb
|
565
583
|
- tasks/build.rake
|
566
584
|
- tasks/deploy.rake
|
567
585
|
- tasks/generate.rake
|
@@ -597,6 +615,7 @@ test_files:
|
|
597
615
|
- features/atom_persistent_within_the_same_type.feature
|
598
616
|
- features/controller_nested_schema_scaffolding.feature
|
599
617
|
- features/controller_schema_scaffolding.feature
|
618
|
+
- features/dereferencing_through_inlining.feature
|
600
619
|
- features/html_generation.feature
|
601
620
|
- features/minitest.feature
|
602
621
|
- features/multidomain_support.feature
|
@@ -608,8 +627,13 @@ test_files:
|
|
608
627
|
- features/schema_updating_within_test_suite.feature
|
609
628
|
- features/step_definitions/additional_cli_steps.rb
|
610
629
|
- features/support/env.rb
|
630
|
+
- features/support/files_helper.rb
|
611
631
|
- features/test_endpoint.feature
|
612
632
|
- spec/lurker/endpoint_spec.rb
|
633
|
+
- spec/lurker/json/list_spec.rb
|
634
|
+
- spec/lurker/json/schema_spec.rb
|
613
635
|
- spec/lurker/yaml_spec.rb
|
614
636
|
- spec/spec_helper.rb
|
637
|
+
- spec/support/matchers/json_attribute.rb
|
638
|
+
- spec/support/matchers/json_object.rb
|
615
639
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module Lurker
|
2
|
-
class Endpoint
|
3
|
-
class HttpParameters
|
4
|
-
extend Forwardable
|
5
|
-
include Lurker::Utils
|
6
|
-
|
7
|
-
ID = 'id'.freeze
|
8
|
-
TYPE = 'type'.freeze
|
9
|
-
OBJECT = 'object'.freeze
|
10
|
-
PROPERTIES = 'properties'.freeze
|
11
|
-
ADDITIONAL_PROPERTIES = 'additionalProperties'.freeze
|
12
|
-
|
13
|
-
delegate [:[], :key?, :keys, :empty?] => :http_parameters
|
14
|
-
|
15
|
-
attr_reader :errors
|
16
|
-
|
17
|
-
def initialize(schema, options = {})
|
18
|
-
@schema = schema
|
19
|
-
|
20
|
-
@schema_key = options.fetch(:schema_key)
|
21
|
-
@schema_id = options.fetch(:schema_id)
|
22
|
-
@human_name = options.fetch(:human_name, @schema_key)
|
23
|
-
|
24
|
-
@schema[@schema_key] ||= {}
|
25
|
-
@errors = []
|
26
|
-
end
|
27
|
-
|
28
|
-
def add(parameters)
|
29
|
-
@schema[@schema_key] = Lurker::SchemaModifier.merge!(
|
30
|
-
Lurker::JsonSchemaHash.new(http_parameters, @schema_id), stringify_keys(parameters)
|
31
|
-
).to_h
|
32
|
-
end
|
33
|
-
|
34
|
-
# TODO : Split the collecting of errors and representations of errors
|
35
|
-
def validate(parameters)
|
36
|
-
errors = Lurker::Validator.new(schemify(http_parameters), stringify_keys(parameters),
|
37
|
-
record_errors: true).validate
|
38
|
-
|
39
|
-
@errors = errors.map { |error| "- #{error}" }
|
40
|
-
@errors.unshift(@human_name) unless @errors.empty?
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def http_parameters
|
46
|
-
@schema[@schema_key]
|
47
|
-
end
|
48
|
-
|
49
|
-
def schemify(object)
|
50
|
-
set_additional_properties_false_on(object).tap do |schema|
|
51
|
-
schema[ID] = "file://#{@schema_id}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_additional_properties_false_on(object)
|
56
|
-
if object.is_a? Hash
|
57
|
-
copy = object.dup
|
58
|
-
|
59
|
-
if object[TYPE] == OBJECT || object.key?(PROPERTIES)
|
60
|
-
copy[ADDITIONAL_PROPERTIES] ||= false
|
61
|
-
end
|
62
|
-
|
63
|
-
object.each do |key, value|
|
64
|
-
next if key == ADDITIONAL_PROPERTIES
|
65
|
-
copy[key] = set_additional_properties_false_on(value)
|
66
|
-
end
|
67
|
-
|
68
|
-
copy
|
69
|
-
elsif object.is_a? Array
|
70
|
-
copy = object.map { |value| set_additional_properties_false_on(value) }
|
71
|
-
else
|
72
|
-
object
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|