grape-swagger 0.20.2 → 0.20.3
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 +4 -4
- data/.rubocop.yml +0 -3
- data/.rubocop_todo.yml +43 -33
- data/.travis.yml +22 -13
- data/CHANGELOG.md +29 -53
- data/Gemfile +1 -1
- data/README.md +24 -24
- data/example/api/endpoints.rb +28 -29
- data/example/api/entities.rb +1 -1
- data/example/config.ru +5 -7
- data/grape-swagger.gemspec +1 -1
- data/lib/grape-swagger.rb +9 -6
- data/lib/grape-swagger/doc_methods.rb +1 -1
- data/lib/grape-swagger/doc_methods/extensions.rb +3 -3
- data/lib/grape-swagger/doc_methods/headers.rb +1 -1
- data/lib/grape-swagger/doc_methods/move_params.rb +25 -16
- data/lib/grape-swagger/doc_methods/operation_id.rb +2 -2
- data/lib/grape-swagger/doc_methods/parse_params.rb +12 -5
- data/lib/grape-swagger/doc_methods/path_string.rb +1 -1
- data/lib/grape-swagger/doc_methods/status_codes.rb +3 -1
- data/lib/grape-swagger/doc_methods/tag_name_description.rb +1 -1
- data/lib/grape-swagger/endpoint.rb +33 -46
- data/lib/grape-swagger/grape/route.rb +16 -0
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/issues/403_versions_spec.rb +158 -0
- data/spec/lib/data_type_spec.rb +9 -10
- data/spec/lib/endpoint_spec.rb +1 -2
- data/spec/lib/extensions_spec.rb +44 -40
- data/spec/lib/move_params_spec.rb +113 -93
- data/spec/lib/operation_id_spec.rb +42 -12
- data/spec/lib/optional_object_spec.rb +3 -4
- data/spec/lib/path_string_spec.rb +2 -2
- data/spec/lib/produces_consumes_spec.rb +64 -53
- data/spec/markdown/redcarpet_adapter_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/api_swagger_v2_result.rb +122 -128
- data/spec/support/namespace_tags.rb +17 -19
- data/spec/support/the_api_entities.rb +1 -3
- data/spec/support/the_paths_definitions.rb +95 -85
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +1 -1
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +19 -19
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +21 -21
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +34 -32
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +5 -7
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +19 -18
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +9 -10
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +21 -24
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +90 -92
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +54 -54
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +65 -57
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +17 -14
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +79 -123
- data/spec/swagger_v2/api_swagger_v2_spec.rb +33 -34
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +32 -36
- data/spec/swagger_v2/boolean_params_spec.rb +1 -1
- data/spec/swagger_v2/default_api_spec.rb +26 -29
- data/spec/swagger_v2/description_not_initialized.rb +3 -3
- data/spec/swagger_v2/float_api_spec.rb +1 -1
- data/spec/swagger_v2/form_params_spec.rb +4 -4
- data/spec/swagger_v2/hide_api_spec.rb +48 -51
- data/spec/swagger_v2/host.rb +1 -1
- data/spec/swagger_v2/mounted_target_class_spec.rb +31 -33
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +23 -21
- data/spec/swagger_v2/namespace_tags_spec.rb +23 -20
- data/spec/swagger_v2/param_type_spec.rb +5 -6
- data/spec/swagger_v2/param_values_spec.rb +31 -37
- data/spec/swagger_v2/params_array_spec.rb +17 -15
- data/spec/swagger_v2/params_hash_spec.rb +17 -15
- data/spec/swagger_v2/params_nested_spec.rb +12 -10
- data/spec/swagger_v2/reference_entity.rb +9 -9
- data/spec/swagger_v2/response_model_spec.rb +58 -62
- data/spec/swagger_v2/simple_mounted_api_spec.rb +179 -147
- metadata +5 -10
- data/spec/params_entity_spec.rb +0 -49
@@ -7,18 +7,48 @@ describe GrapeSwagger::DocMethods::OperationId do
|
|
7
7
|
specify { expect(subject).to respond_to :build }
|
8
8
|
|
9
9
|
describe 'build' do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
expect(subject.build('GET', 'foo')).to eql 'getFoo'
|
15
|
-
expect(subject.build('GET', '/foo')).to eql 'getFoo'
|
16
|
-
expect(subject.build('GET', 'bar/foo')).to eql 'getBarFoo'
|
17
|
-
expect(subject.build('GET', 'bar/foo{id}')).to eql 'getBarFooId'
|
18
|
-
expect(subject.build('GET', '/bar_foo{id}')).to eql 'getBarFooId'
|
19
|
-
expect(subject.build('GET', '/bar-foo{id}')).to eql 'getBarFooId'
|
20
|
-
expect(subject.build('GET', '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId'
|
10
|
+
if defined?(Grape::VERSION) && Gem::Version.new(::Grape::VERSION) < Gem::Version.new('0.16.0')
|
11
|
+
let(:route) { Grape::Route.new(method: method) }
|
12
|
+
else
|
13
|
+
let(:route) { Grape::Router::Route.new(method, '/path', requirements: {}) }
|
21
14
|
end
|
22
|
-
end
|
23
15
|
|
16
|
+
describe 'GET' do
|
17
|
+
let(:method) { 'GET' }
|
18
|
+
specify { expect(subject.build(route)).to eql 'get' }
|
19
|
+
end
|
20
|
+
describe 'get' do
|
21
|
+
let(:method) { 'get' }
|
22
|
+
specify { expect(subject.build(route)).to eql 'get' }
|
23
|
+
end
|
24
|
+
describe ':get' do
|
25
|
+
let(:method) { :get }
|
26
|
+
specify { expect(subject.build(route)).to eql 'get' }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'path given' do
|
30
|
+
let(:method) { 'GET' }
|
31
|
+
it 'GET with path foo' do
|
32
|
+
expect(subject.build(route, 'foo')).to eql 'getFoo'
|
33
|
+
end
|
34
|
+
it 'GET with path /foo' do
|
35
|
+
expect(subject.build(route, '/foo')).to eql 'getFoo'
|
36
|
+
end
|
37
|
+
it 'GET with path bar/foo' do
|
38
|
+
expect(subject.build(route, 'bar/foo')).to eql 'getBarFoo'
|
39
|
+
end
|
40
|
+
it 'GET with path bar/foo{id}' do
|
41
|
+
expect(subject.build(route, 'bar/foo{id}')).to eql 'getBarFooId'
|
42
|
+
end
|
43
|
+
it 'GET with path /bar_foo{id}' do
|
44
|
+
expect(subject.build(route, '/bar_foo{id}')).to eql 'getBarFooId'
|
45
|
+
end
|
46
|
+
it 'GET with path /bar-foo{id}' do
|
47
|
+
expect(subject.build(route, '/bar-foo{id}')).to eql 'getBarFooId'
|
48
|
+
end
|
49
|
+
it 'GET with path /simple_test/bar-foo{id}' do
|
50
|
+
expect(subject.build(route, '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
24
54
|
end
|
@@ -11,7 +11,7 @@ describe GrapeSwagger::DocMethods::OptionalObject do
|
|
11
11
|
let(:request) { 'somes/request/string' }
|
12
12
|
|
13
13
|
describe 'no option given for key' do
|
14
|
-
let(:options) { {foo: 'foo' }}
|
14
|
+
let(:options) { { foo: 'foo' } }
|
15
15
|
specify do
|
16
16
|
expect(subject.build(key, options)).to be_nil
|
17
17
|
expect(subject.build(key, options, request)).to eql request
|
@@ -21,7 +21,7 @@ describe GrapeSwagger::DocMethods::OptionalObject do
|
|
21
21
|
let(:value) { 'some optional value' }
|
22
22
|
|
23
23
|
describe 'option is a string' do
|
24
|
-
let(:options) { {bar: value }}
|
24
|
+
let(:options) { { bar: value } }
|
25
25
|
specify do
|
26
26
|
expect(subject.build(key, options)).to eql value
|
27
27
|
expect(subject.build(key, options, request)).to eql value
|
@@ -29,12 +29,11 @@ describe GrapeSwagger::DocMethods::OptionalObject do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'option is a proc' do
|
32
|
-
let(:options) { {bar: -> { value } }}
|
32
|
+
let(:options) { { bar: -> { value } } }
|
33
33
|
specify do
|
34
34
|
expect(subject.build(key, options)).to eql value
|
35
35
|
expect(subject.build(key, options, request)).to eql value
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
39
|
end
|
@@ -9,7 +9,7 @@ describe GrapeSwagger::DocMethods::PathString do
|
|
9
9
|
describe 'operation_id_object' do
|
10
10
|
describe 'version' do
|
11
11
|
describe 'defaults: not given, false' do
|
12
|
-
let(:options) {{ add_version: false }}
|
12
|
+
let(:options) { { add_version: false } }
|
13
13
|
|
14
14
|
specify do
|
15
15
|
expect(subject.build('/thing(.json)', options)).to eql ['Thing', '/thing']
|
@@ -22,7 +22,7 @@ describe GrapeSwagger::DocMethods::PathString do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'defaults: given, true' do
|
25
|
-
let(:options) {{ version: 'v1', add_version: true }}
|
25
|
+
let(:options) { { version: 'v1', add_version: true } }
|
26
26
|
|
27
27
|
specify do
|
28
28
|
expect(subject.build('/{version}/thing(.json)', options)).to eql ['Thing', '/v1/thing']
|
@@ -1,98 +1,109 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe GrapeSwagger::DocMethods::ProducesConsumes do
|
4
|
-
describe
|
4
|
+
describe ':json (default)' do
|
5
5
|
subject { described_class.call }
|
6
6
|
|
7
7
|
specify do
|
8
|
-
expect(subject).to eql(
|
8
|
+
expect(subject).to eql(['application/json'])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
describe
|
12
|
+
describe 'accept symbols of' do
|
13
|
+
describe 'single' do
|
14
14
|
subject { described_class.call(:xml) }
|
15
15
|
|
16
16
|
specify do
|
17
|
-
expect(subject).to eql(
|
17
|
+
expect(subject).to eql(['application/xml'])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe 'multiple' do
|
22
22
|
subject { described_class.call(:xml, :serializable_hash, :json, :binary, :txt) }
|
23
23
|
|
24
24
|
specify do
|
25
|
-
expect(subject).to eql(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
expect(subject).to eql(
|
26
|
+
[
|
27
|
+
'application/xml',
|
28
|
+
'application/json',
|
29
|
+
'application/octet-stream',
|
30
|
+
'text/plain'
|
31
|
+
])
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
describe
|
36
|
-
describe
|
36
|
+
describe 'accept mime_types of' do
|
37
|
+
describe 'single' do
|
37
38
|
subject { described_class.call('application/xml') }
|
38
39
|
|
39
40
|
specify do
|
40
|
-
expect(subject).to eql(
|
41
|
+
expect(subject).to eql(['application/xml'])
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
describe
|
45
|
-
subject
|
46
|
-
|
47
|
-
'application/json',
|
48
|
-
'application/octet-stream',
|
49
|
-
'text/plain'
|
50
|
-
) }
|
51
|
-
|
52
|
-
specify do
|
53
|
-
expect(subject).to eql( [
|
45
|
+
describe 'multiple' do
|
46
|
+
subject do
|
47
|
+
described_class.call(
|
54
48
|
'application/xml',
|
55
49
|
'application/json',
|
56
50
|
'application/octet-stream',
|
57
51
|
'text/plain'
|
58
|
-
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
specify do
|
56
|
+
expect(subject).to eql(
|
57
|
+
[
|
58
|
+
'application/xml',
|
59
|
+
'application/json',
|
60
|
+
'application/octet-stream',
|
61
|
+
'text/plain'
|
62
|
+
])
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
63
|
-
describe
|
64
|
-
subject
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'application/octet-stream',
|
69
|
-
:txt
|
70
|
-
) }
|
71
|
-
|
72
|
-
specify do
|
73
|
-
expect(subject).to eql( [
|
74
|
-
'application/xml',
|
67
|
+
describe 'mix it up' do
|
68
|
+
subject do
|
69
|
+
described_class.call(
|
70
|
+
:xml,
|
71
|
+
:serializable_hash,
|
75
72
|
'application/json',
|
76
73
|
'application/octet-stream',
|
77
|
-
|
78
|
-
|
74
|
+
:txt
|
75
|
+
)
|
79
76
|
end
|
80
77
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
specify do
|
79
|
+
expect(subject).to eql(
|
80
|
+
[
|
81
|
+
'application/xml',
|
82
|
+
'application/json',
|
83
|
+
'application/octet-stream',
|
84
|
+
'text/plain'
|
85
|
+
])
|
86
|
+
end
|
87
|
+
|
88
|
+
subject do
|
89
|
+
described_class.call(
|
90
|
+
[
|
91
|
+
:xml,
|
92
|
+
:serializable_hash,
|
93
|
+
'application/json',
|
94
|
+
'application/octet-stream',
|
95
|
+
:txt
|
96
|
+
])
|
97
|
+
end
|
88
98
|
|
89
99
|
specify do
|
90
|
-
expect(subject).to eql(
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
100
|
+
expect(subject).to eql(
|
101
|
+
[
|
102
|
+
'application/xml',
|
103
|
+
'application/json',
|
104
|
+
'application/octet-stream',
|
105
|
+
'text/plain'
|
106
|
+
])
|
96
107
|
end
|
97
108
|
end
|
98
109
|
end
|
@@ -36,7 +36,7 @@ describe GrapeSwagger::Markdown::RedcarpetAdapter, unless: RUBY_PLATFORM.eql?('j
|
|
36
36
|
it 'marks down with the configured options' do
|
37
37
|
text = '# hello world #'
|
38
38
|
extensions = { fenced_code_blocks: true, autolink: true }
|
39
|
-
render_options = { highlighter: :none, no_links: true
|
39
|
+
render_options = { highlighter: :none, no_links: true }
|
40
40
|
expect_any_instance_of(Redcarpet::Markdown).to receive(:render).with(text).and_call_original
|
41
41
|
|
42
42
|
output = GrapeSwagger::Markdown::RedcarpetAdapter.new(extensions: extensions, render_options: render_options).markdown(text)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
RSpec.shared_context
|
2
|
-
|
1
|
+
RSpec.shared_context 'swagger example' do
|
3
2
|
before :all do
|
4
3
|
module Entities
|
5
4
|
class Something < Grape::Entity
|
@@ -11,10 +10,9 @@ RSpec.shared_context "swagger example" do
|
|
11
10
|
|
12
11
|
class EnumValues < Grape::Entity
|
13
12
|
expose :gender, documentation: { type: 'string', desc: 'Content of something.', values: %w(Male Female) }
|
14
|
-
expose :number, documentation: { type: 'integer', desc: 'Content of something.', values: [1, 2]
|
13
|
+
expose :number, documentation: { type: 'integer', desc: 'Content of something.', values: [1, 2] }
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
16
|
class AliasedThing < Grape::Entity
|
19
17
|
expose :something, as: :post, using: Entities::Something, documentation: { type: 'Something', desc: 'Reference to something.' }
|
20
18
|
end
|
@@ -61,143 +59,139 @@ RSpec.shared_context "swagger example" do
|
|
61
59
|
|
62
60
|
let(:swagger_json) do
|
63
61
|
{
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
62
|
+
'info' => {
|
63
|
+
'title' => 'The API title to be displayed on the API homepage.',
|
64
|
+
'description' => 'A description of the API.',
|
65
|
+
'termsOfServiceUrl' => 'www.The-URL-of-the-terms-and-service.com',
|
66
|
+
'contact' => { 'name' => 'Contact name', 'email' => 'Contact@email.com', 'url' => 'Contact URL' },
|
67
|
+
'license' => { 'name' => 'The name of the license.', 'url' => 'www.The-URL-of-the-license.org' },
|
68
|
+
'version' => '0.0.1'
|
71
69
|
},
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
{
|
78
|
-
{
|
79
|
-
{
|
80
|
-
{
|
70
|
+
'swagger' => '2.0',
|
71
|
+
'produces' => ['application/json'],
|
72
|
+
'host' => 'example.org',
|
73
|
+
'basePath' => '/api',
|
74
|
+
'tags' => [
|
75
|
+
{ 'name' => 'other_thing', 'description' => 'Operations about other_things' },
|
76
|
+
{ 'name' => 'thing', 'description' => 'Operations about things' },
|
77
|
+
{ 'name' => 'thing2', 'description' => 'Operations about thing2s' },
|
78
|
+
{ 'name' => 'dummy', 'description' => 'Operations about dummies' }
|
81
79
|
],
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
{
|
101
|
-
{
|
102
|
-
{
|
103
|
-
{"in"=>"query", "name"=>"others", "description"=>nil, "type"=>"text", "required"=>false}
|
80
|
+
'paths' => {
|
81
|
+
'/v3/other_thing/{elements}' => {
|
82
|
+
'get' => {
|
83
|
+
'description' => 'nested route inside namespace',
|
84
|
+
'produces' => ['application/json'],
|
85
|
+
'parameters' => [{ 'in' => 'body', 'name' => 'elements', 'description' => 'Set of configuration', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }],
|
86
|
+
'responses' => { '200' => { 'description' => 'nested route inside namespace', 'schema' => { '$ref' => '#/definitions/QueryInput' } } },
|
87
|
+
'tags' => ['other_thing'],
|
88
|
+
'operationId' => 'getV3OtherThingElements',
|
89
|
+
'x-amazon-apigateway-auth' => { 'type' => 'none' },
|
90
|
+
'x-amazon-apigateway-integration' => { 'type' => 'aws', 'uri' => 'foo_bar_uri', 'httpMethod' => 'get' }
|
91
|
+
} },
|
92
|
+
'/thing' => {
|
93
|
+
'get' => {
|
94
|
+
'description' => 'This gets Things.',
|
95
|
+
'produces' => ['application/json'],
|
96
|
+
'parameters' => [
|
97
|
+
{ 'in' => 'query', 'name' => 'id', 'description' => 'Identity of Something', 'type' => 'integer', 'format' => 'int32', 'required' => false },
|
98
|
+
{ 'in' => 'query', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => false },
|
99
|
+
{ 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'link' }, 'required' => false },
|
100
|
+
{ 'in' => 'query', 'name' => 'others', 'type' => 'text', 'required' => false }
|
104
101
|
],
|
105
|
-
|
106
|
-
|
107
|
-
|
102
|
+
'responses' => { '200' => { 'description' => 'This gets Things.' }, '401' => { 'description' => 'Unauthorized', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
|
103
|
+
'tags' => ['thing'],
|
104
|
+
'operationId' => 'getThing'
|
108
105
|
},
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
{
|
115
|
-
{
|
106
|
+
'post' => {
|
107
|
+
'description' => 'This creates Thing.',
|
108
|
+
'produces' => ['application/json'],
|
109
|
+
'consumes' => ['application/json'],
|
110
|
+
'parameters' => [
|
111
|
+
{ 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => true },
|
112
|
+
{ 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }
|
116
113
|
],
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
"operationId"=>"getThingId"
|
114
|
+
'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessible Entity' } },
|
115
|
+
'tags' => ['thing'],
|
116
|
+
'operationId' => 'postThing'
|
117
|
+
} },
|
118
|
+
'/thing/{id}' => {
|
119
|
+
'get' => {
|
120
|
+
'description' => 'This gets Thing.',
|
121
|
+
'produces' => ['application/json'],
|
122
|
+
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
|
123
|
+
'responses' => { '200' => { 'description' => 'getting a single thing' }, '401' => { 'description' => 'Unauthorized' } },
|
124
|
+
'tags' => ['thing'],
|
125
|
+
'operationId' => 'getThingId'
|
130
126
|
},
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
{
|
137
|
-
{
|
138
|
-
{
|
127
|
+
'put' => {
|
128
|
+
'description' => 'This updates Thing.',
|
129
|
+
'produces' => ['application/json'],
|
130
|
+
'consumes' => ['application/json'],
|
131
|
+
'parameters' => [
|
132
|
+
{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true },
|
133
|
+
{ 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => false },
|
134
|
+
{ 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => false }
|
139
135
|
],
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
'responses' => { '200' => { 'description' => 'This updates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } },
|
137
|
+
'tags' => ['thing'],
|
138
|
+
'operationId' => 'putThingId'
|
143
139
|
},
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
}
|
140
|
+
'delete' => {
|
141
|
+
'description' => 'This deletes Thing.',
|
142
|
+
'produces' => ['application/json'],
|
143
|
+
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
|
144
|
+
'responses' => { '200' => { 'description' => 'This deletes Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } },
|
145
|
+
'tags' => ['thing'],
|
146
|
+
'operationId' => 'deleteThingId'
|
147
|
+
} },
|
148
|
+
'/thing2' => {
|
149
|
+
'get' => {
|
150
|
+
'description' => 'This gets Things.',
|
151
|
+
'produces' => ['application/json'],
|
152
|
+
'responses' => { '200' => { 'description' => 'get Horses', 'schema' => { '$ref' => '#/definitions/Something' } }, '401' => { 'description' => 'HorsesOutError', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
|
153
|
+
'tags' => ['thing2'],
|
154
|
+
'operationId' => 'getThing2'
|
155
|
+
} },
|
156
|
+
'/dummy/{id}' => {
|
157
|
+
'delete' => {
|
158
|
+
'description' => 'dummy route.',
|
159
|
+
'produces' => ['application/json'],
|
160
|
+
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
|
161
|
+
'responses' => { '204' => { 'description' => 'dummy route.' }, '401' => { 'description' => 'Unauthorized' } },
|
162
|
+
'tags' => ['dummy'],
|
163
|
+
'operationId' => 'deleteDummyId'
|
164
|
+
} } },
|
165
|
+
'definitions' => {
|
166
|
+
'QueryInput' => {
|
167
|
+
'type' => 'object',
|
168
|
+
'properties' => { 'elements' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/QueryInputElement' }, 'description' => 'Set of configuration' } },
|
169
|
+
'description' => 'nested route inside namespace'
|
152
170
|
},
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
"produces"=>["application/json"],
|
157
|
-
"responses"=>{"200"=>{"description"=>"get Horses", "schema"=>{"$ref"=>"#/definitions/Something"}}, "401"=>{"description"=>"HorsesOutError", "schema"=>{"$ref"=>"#/definitions/ApiError"}}},
|
158
|
-
"tags"=>["thing2"],
|
159
|
-
"operationId"=>"getThing2"
|
160
|
-
}
|
171
|
+
'QueryInputElement' => {
|
172
|
+
'type' => 'object',
|
173
|
+
'properties' => { 'key' => { 'type' => 'string', 'description' => 'Name of parameter' }, 'value' => { 'type' => 'string', 'description' => 'Value of parameter' } }
|
161
174
|
},
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
"description"=>"nested route inside namespace"},
|
178
|
-
"QueryInputElement"=>{
|
179
|
-
"type"=>"object",
|
180
|
-
"properties"=>{"key"=>{"type"=>"string", "description"=>"Name of parameter"}, "value"=>{"type"=>"string", "description"=>"Value of parameter"}}},
|
181
|
-
"Thing"=>{
|
182
|
-
"type"=>"object",
|
183
|
-
"properties"=>{"id"=>{"type"=>"integer", "format"=>"int32"}, "text"=>{"type"=>"string"}, "links"=>{"type"=>"link"}, "others"=>{"type"=>"text"}},
|
184
|
-
"description"=>"This gets Thing."},
|
185
|
-
"ApiError"=>{
|
186
|
-
"type"=>"object",
|
187
|
-
"properties"=>{"code"=>{"type"=>"integer", "format"=>"int32", "description"=>"status code"}, "message"=>{"type"=>"string", "description"=>"error message"}},
|
188
|
-
"description"=>"This gets Things."},
|
189
|
-
"Something"=>{
|
190
|
-
"type"=>"object",
|
191
|
-
"properties"=>{"id"=>{"type"=>"integer", "format"=>"int32", "description"=>"Identity of Something"}, "text"=>{"type"=>"string", "description"=>"Content of something."}, "links"=>{"type"=>"link"}, "others"=>{"type"=>"text"}},
|
192
|
-
"description"=>"This gets Things."
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
175
|
+
'ApiError' => {
|
176
|
+
'type' => 'object',
|
177
|
+
'properties' => { 'code' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'status code' }, 'message' => { 'type' => 'string', 'description' => 'error message' } },
|
178
|
+
'description' => 'This gets Things.'
|
179
|
+
},
|
180
|
+
'Something' => {
|
181
|
+
'type' => 'object',
|
182
|
+
'properties' => {
|
183
|
+
'id' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'Identity of Something' },
|
184
|
+
'text' => { 'type' => 'string', 'description' => 'Content of something.' },
|
185
|
+
'links' => { 'type' => 'link' },
|
186
|
+
'others' => { 'type' => 'text' }
|
187
|
+
},
|
188
|
+
'description' => 'This gets Things.'
|
189
|
+
} } }
|
196
190
|
end
|
197
191
|
|
198
|
-
let(:http_verbs) { %w
|
192
|
+
let(:http_verbs) { %w(get post put delete) }
|
199
193
|
end
|
200
194
|
|
201
195
|
def mounted_paths
|
202
|
-
%w
|
196
|
+
%w( /thing /other_thing /dummy )
|
203
197
|
end
|