grape-swagger 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/README.md +6 -5
- data/grape-swagger.gemspec +5 -5
- data/lib/grape-swagger/doc_methods/extensions.rb +2 -1
- data/lib/grape-swagger/doc_methods/format_data.rb +2 -2
- data/lib/grape-swagger/doc_methods/move_params.rb +1 -0
- data/lib/grape-swagger/doc_methods/parse_params.rb +1 -1
- data/lib/grape-swagger/endpoint.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- metadata +26 -129
- data/.coveralls.yml +0 -1
- data/.github/dependabot.yml +0 -20
- data/.github/workflows/ci.yml +0 -45
- data/.gitignore +0 -45
- data/.rspec +0 -3
- data/.rubocop.yml +0 -136
- data/.rubocop_todo.yml +0 -60
- data/Dangerfile +0 -3
- data/Gemfile +0 -43
- data/Rakefile +0 -20
- data/example/api/endpoints.rb +0 -131
- data/example/api/entities.rb +0 -18
- data/example/config.ru +0 -42
- data/example/example_requests.postman_collection +0 -146
- data/example/splines.png +0 -0
- data/example/swagger-example.png +0 -0
- data/spec/issues/267_nested_namespaces.rb +0 -55
- data/spec/issues/403_versions_spec.rb +0 -124
- data/spec/issues/427_entity_as_string_spec.rb +0 -39
- data/spec/issues/430_entity_definitions_spec.rb +0 -94
- data/spec/issues/532_allow_custom_format_spec.rb +0 -38
- data/spec/issues/533_specify_status_code_spec.rb +0 -78
- data/spec/issues/537_enum_values_spec.rb +0 -50
- data/spec/issues/539_array_post_body_spec.rb +0 -65
- data/spec/issues/542_array_of_type_in_post_body_spec.rb +0 -46
- data/spec/issues/553_align_array_put_post_params_spec.rb +0 -144
- data/spec/issues/572_array_post_body_spec.rb +0 -51
- data/spec/issues/579_align_put_post_parameters_spec.rb +0 -179
- data/spec/issues/582_file_response_spec.rb +0 -55
- data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +0 -26
- data/spec/issues/605_root_route_documentation_spec.rb +0 -23
- data/spec/issues/650_params_array_spec.rb +0 -59
- data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +0 -100
- data/spec/issues/680_keep_204_error_schemas_spec.rb +0 -55
- data/spec/issues/751_deeply_nested_objects_spec.rb +0 -190
- data/spec/issues/776_multiple_presents_spec.rb +0 -59
- data/spec/issues/784_extensions_on_params_spec.rb +0 -38
- data/spec/issues/809_utf8_routes_spec.rb +0 -55
- data/spec/issues/832_array_hash_float_decimal_spec.rb +0 -111
- data/spec/issues/847_route_param_options_spec.rb +0 -37
- data/spec/lib/data_type_spec.rb +0 -111
- data/spec/lib/endpoint/params_parser_spec.rb +0 -124
- data/spec/lib/endpoint_spec.rb +0 -153
- data/spec/lib/extensions_spec.rb +0 -185
- data/spec/lib/format_data_spec.rb +0 -115
- data/spec/lib/model_parsers_spec.rb +0 -104
- data/spec/lib/move_params_spec.rb +0 -444
- data/spec/lib/oapi_tasks_spec.rb +0 -163
- data/spec/lib/operation_id_spec.rb +0 -55
- data/spec/lib/optional_object_spec.rb +0 -47
- data/spec/lib/parse_params_spec.rb +0 -68
- data/spec/lib/path_string_spec.rb +0 -101
- data/spec/lib/produces_consumes_spec.rb +0 -116
- data/spec/lib/tag_name_description_spec.rb +0 -80
- data/spec/lib/version_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -39
- data/spec/support/empty_model_parser.rb +0 -23
- data/spec/support/grape_version.rb +0 -13
- data/spec/support/mock_parser.rb +0 -23
- data/spec/support/model_parsers/entity_parser.rb +0 -334
- data/spec/support/model_parsers/mock_parser.rb +0 -346
- data/spec/support/model_parsers/representable_parser.rb +0 -406
- data/spec/support/namespace_tags.rb +0 -93
- data/spec/support/the_paths_definitions.rb +0 -109
- data/spec/swagger_v2/api_documentation_spec.rb +0 -28
- data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +0 -83
- data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +0 -36
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +0 -79
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +0 -137
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +0 -56
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +0 -64
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +0 -58
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +0 -57
- data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +0 -103
- data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +0 -355
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +0 -217
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +0 -239
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +0 -72
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +0 -143
- data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +0 -135
- data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +0 -216
- data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +0 -55
- data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +0 -153
- data/spec/swagger_v2/api_swagger_v2_spec.rb +0 -237
- data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +0 -93
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +0 -89
- data/spec/swagger_v2/boolean_params_spec.rb +0 -35
- data/spec/swagger_v2/default_api_spec.rb +0 -175
- data/spec/swagger_v2/deprecated_field_spec.rb +0 -25
- data/spec/swagger_v2/description_not_initialized_spec.rb +0 -39
- data/spec/swagger_v2/endpoint_versioned_path_spec.rb +0 -130
- data/spec/swagger_v2/errors_spec.rb +0 -77
- data/spec/swagger_v2/float_api_spec.rb +0 -33
- data/spec/swagger_v2/form_params_spec.rb +0 -67
- data/spec/swagger_v2/grape-swagger_spec.rb +0 -17
- data/spec/swagger_v2/guarded_endpoint_spec.rb +0 -162
- data/spec/swagger_v2/hide_api_spec.rb +0 -147
- data/spec/swagger_v2/host_spec.rb +0 -43
- data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +0 -57
- data/spec/swagger_v2/mount_override_api_spec.rb +0 -58
- data/spec/swagger_v2/mounted_target_class_spec.rb +0 -76
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +0 -122
- data/spec/swagger_v2/namespace_tags_spec.rb +0 -78
- data/spec/swagger_v2/namespaced_api_spec.rb +0 -121
- data/spec/swagger_v2/nicknamed_api_spec.rb +0 -25
- data/spec/swagger_v2/operation_id_api_spec.rb +0 -27
- data/spec/swagger_v2/param_multi_type_spec.rb +0 -77
- data/spec/swagger_v2/param_type_spec.rb +0 -87
- data/spec/swagger_v2/param_values_spec.rb +0 -162
- data/spec/swagger_v2/params_array_collection_format_spec.rb +0 -105
- data/spec/swagger_v2/params_array_spec.rb +0 -203
- data/spec/swagger_v2/params_example_spec.rb +0 -40
- data/spec/swagger_v2/params_hash_spec.rb +0 -71
- data/spec/swagger_v2/params_nested_spec.rb +0 -86
- data/spec/swagger_v2/parent_less_namespace_spec.rb +0 -32
- data/spec/swagger_v2/reference_entity_spec.rb +0 -129
- data/spec/swagger_v2/security_requirement_spec.rb +0 -46
- data/spec/swagger_v2/simple_mounted_api_spec.rb +0 -326
- data/spec/version_spec.rb +0 -10
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'headers' do
|
6
|
-
include_context "#{MODEL_PARSER} swagger example"
|
7
|
-
|
8
|
-
before :all do
|
9
|
-
module TheApi
|
10
|
-
class HeadersApi < Grape::API
|
11
|
-
format :json
|
12
|
-
|
13
|
-
desc 'This returns something',
|
14
|
-
failure: [{ code: 400, model: Entities::ApiError }],
|
15
|
-
headers: {
|
16
|
-
'X-Rate-Limit-Limit' => {
|
17
|
-
'description' => 'The number of allowed requests in the current period',
|
18
|
-
'type' => 'integer'
|
19
|
-
}
|
20
|
-
},
|
21
|
-
|
22
|
-
entity: Entities::UseResponse
|
23
|
-
params do
|
24
|
-
optional :param_x, type: String, desc: 'This is a parameter', documentation: { param_type: 'query' }
|
25
|
-
end
|
26
|
-
get '/use_headers' do
|
27
|
-
{ 'declared_params' => declared(params) }
|
28
|
-
end
|
29
|
-
|
30
|
-
add_swagger_documentation
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def app
|
36
|
-
TheApi::HeadersApi
|
37
|
-
end
|
38
|
-
|
39
|
-
subject do
|
40
|
-
get '/swagger_doc'
|
41
|
-
JSON.parse(last_response.body)
|
42
|
-
end
|
43
|
-
|
44
|
-
specify do
|
45
|
-
parameters = subject['paths']['/use_headers']['get']['parameters']
|
46
|
-
expect(parameters).to include(
|
47
|
-
'in' => 'header',
|
48
|
-
'name' => 'X-Rate-Limit-Limit',
|
49
|
-
'description' => 'The number of allowed requests in the current period',
|
50
|
-
'type' => 'integer',
|
51
|
-
'format' => 'int32',
|
52
|
-
'required' => false
|
53
|
-
)
|
54
|
-
expect(parameters.size).to eq(2)
|
55
|
-
expect(parameters.first['in']).to eq('header')
|
56
|
-
expect(parameters.last['in']).to eq('query')
|
57
|
-
end
|
58
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'hide documentation path' do
|
6
|
-
include_context "#{MODEL_PARSER} swagger example"
|
7
|
-
|
8
|
-
before :all do
|
9
|
-
module TheApi
|
10
|
-
class HideDocumentationApi < Grape::API
|
11
|
-
format :json
|
12
|
-
|
13
|
-
desc 'This returns something',
|
14
|
-
params: Entities::UseResponse.documentation,
|
15
|
-
failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
|
16
|
-
params do
|
17
|
-
requires :foo, type: Integer
|
18
|
-
end
|
19
|
-
get '/params_response' do
|
20
|
-
{ 'declared_params' => declared(params) }
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'This returns something',
|
24
|
-
entity: Entities::UseResponse,
|
25
|
-
failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
|
26
|
-
get '/entity_response' do
|
27
|
-
{ 'declared_params' => declared(params) }
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'This returns something',
|
31
|
-
failure: [{ code: 400, message: 'NotFound', model: Entities::ApiError }]
|
32
|
-
get '/present_response' do
|
33
|
-
foo = OpenStruct.new id: 1, name: 'bar'
|
34
|
-
something = OpenStruct.new description: 'something', item: foo
|
35
|
-
present :somethings, something, with: Entities::UseResponse
|
36
|
-
end
|
37
|
-
|
38
|
-
add_swagger_documentation hide_documentation_path: false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def app
|
44
|
-
TheApi::HideDocumentationApi
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'shows documentation paths' do
|
48
|
-
subject do
|
49
|
-
get '/swagger_doc'
|
50
|
-
JSON.parse(last_response.body)
|
51
|
-
end
|
52
|
-
|
53
|
-
specify do
|
54
|
-
expect(subject['paths'].keys).to include '/swagger_doc', '/swagger_doc/{name}'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'hidden flag enables a single endpoint parameter to be excluded from the documentation' do
|
6
|
-
include_context "#{MODEL_PARSER} swagger example"
|
7
|
-
before :all do
|
8
|
-
module TheApi
|
9
|
-
class HideParamsApi < Grape::API
|
10
|
-
helpers do
|
11
|
-
def resource_owner
|
12
|
-
'123'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
namespace :flat_params_endpoint do
|
17
|
-
desc 'This is a endpoint with a flat parameter hierarchy'
|
18
|
-
params do
|
19
|
-
requires :name, type: String, documentation: { desc: 'name' }
|
20
|
-
optional :favourite_color, type: String, documentation: { desc: 'I should not be anywhere', hidden: true }
|
21
|
-
optional :proc_param, type: String, documentation: { desc: 'I should not be anywhere', hidden: proc { true } }
|
22
|
-
optional :proc_with_token, type: String, documentation: { desc: 'I may be somewhere', hidden: proc { false } }
|
23
|
-
end
|
24
|
-
|
25
|
-
post do
|
26
|
-
{ 'declared_params' => declared(params) }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
namespace :nested_params_endpoint do
|
31
|
-
desc 'This is a endpoint with a nested parameter hierarchy'
|
32
|
-
params do
|
33
|
-
optional :name, type: String, documentation: { desc: 'name' }
|
34
|
-
optional :hidden_attribute, type: Hash do
|
35
|
-
optional :favourite_color, type: String, documentation: { desc: 'I should not be anywhere', hidden: true }
|
36
|
-
end
|
37
|
-
|
38
|
-
optional :attributes, type: Hash do
|
39
|
-
optional :attribute_1, type: String, documentation: { desc: 'Attribute one' }
|
40
|
-
optional :hidden_attribute, type: String, documentation: { desc: 'I should not be anywhere', hidden: true }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
post do
|
45
|
-
{ 'declared_params' => declared(params) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
namespace :required_param_endpoint do
|
50
|
-
desc 'This endpoint has hidden defined for a required parameter'
|
51
|
-
params do
|
52
|
-
requires :name, type: String, documentation: { desc: 'name', hidden: true }
|
53
|
-
end
|
54
|
-
|
55
|
-
post do
|
56
|
-
{ 'declared_params' => declared(params) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
add_swagger_documentation token_owner: 'resource_owner'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
let(:app) { TheApi::HideParamsApi }
|
66
|
-
|
67
|
-
describe 'simple flat parameter hierarchy' do
|
68
|
-
subject do
|
69
|
-
get '/swagger_doc/flat_params_endpoint'
|
70
|
-
JSON.parse(last_response.body)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'ignores parameters that are explicitly hidden' do
|
74
|
-
expect(subject['paths']['/flat_params_endpoint']['post']['parameters'].map { |p| p['name'] }).not_to include('favourite_color', 'proc_param')
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'allows procs to consult the token_owner' do
|
78
|
-
expect(subject['paths']['/flat_params_endpoint']['post']['parameters'].map { |p| p['name'] }).to include('proc_with_token')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe 'nested parameter hierarchy' do
|
83
|
-
subject do
|
84
|
-
get '/swagger_doc/nested_params_endpoint'
|
85
|
-
JSON.parse(last_response.body)
|
86
|
-
end
|
87
|
-
|
88
|
-
specify do
|
89
|
-
expect(subject['paths']['/nested_params_endpoint']['post']['parameters'].map { |p| p['name'] }).not_to include(/hidden_attribute/)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'hidden defined for required parameter' do
|
94
|
-
subject do
|
95
|
-
get '/swagger_doc/required_param_endpoint'
|
96
|
-
JSON.parse(last_response.body)
|
97
|
-
end
|
98
|
-
|
99
|
-
specify do
|
100
|
-
expect(subject['paths']['/required_param_endpoint']['post']['parameters'].map { |p| p['name'] }).to include('name')
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'swagger spec v2.0' do
|
6
|
-
include_context "#{MODEL_PARSER} swagger example"
|
7
|
-
|
8
|
-
def app
|
9
|
-
Class.new(Grape::API) do
|
10
|
-
format :json
|
11
|
-
|
12
|
-
desc 'This creates Thing after a delay',
|
13
|
-
success: { code: 202, message: 'OK', model: Entities::Something }
|
14
|
-
params do
|
15
|
-
requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' }
|
16
|
-
requires :links, type: Array, documentation: { type: 'link', is_array: true }
|
17
|
-
end
|
18
|
-
post '/delay_thing' do
|
19
|
-
status 202
|
20
|
-
end
|
21
|
-
|
22
|
-
version 'v3', using: :path
|
23
|
-
add_swagger_documentation api_version: 'v1',
|
24
|
-
base_path: '/api',
|
25
|
-
info: {
|
26
|
-
title: 'The API title to be displayed on the API homepage.',
|
27
|
-
description: 'A description of the API.',
|
28
|
-
contact_name: 'Contact name',
|
29
|
-
contact_email: 'Contact@email.com',
|
30
|
-
contact_url: 'Contact URL',
|
31
|
-
license: 'The name of the license.',
|
32
|
-
license_url: 'www.The-URL-of-the-license.org',
|
33
|
-
terms_of_service_url: 'www.The-URL-of-the-terms-and-service.com'
|
34
|
-
}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
before do
|
39
|
-
get '/v3/swagger_doc'
|
40
|
-
end
|
41
|
-
|
42
|
-
let(:json) { JSON.parse(last_response.body) }
|
43
|
-
|
44
|
-
it 'only returns one response if ignore_defaults is specified' do
|
45
|
-
expect(json['paths']['/delay_thing']['post']['responses']).to eq('202' => { 'description' => 'OK', 'schema' => { '$ref' => '#/definitions/Something' } })
|
46
|
-
expect(json['paths']['/delay_thing']['post']['responses'].keys).not_to include '201'
|
47
|
-
end
|
48
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'swagger spec v2.0' do
|
6
|
-
describe 'mounted APIs' do
|
7
|
-
include_context "#{MODEL_PARSER} swagger example"
|
8
|
-
|
9
|
-
def app
|
10
|
-
Class.new(Grape::API) do
|
11
|
-
format :json
|
12
|
-
|
13
|
-
# Thing stuff
|
14
|
-
desc 'This gets Things.' do
|
15
|
-
params Entities::Something.documentation
|
16
|
-
http_codes [{ code: 401, message: 'Unauthorized', model: Entities::ApiError }]
|
17
|
-
end
|
18
|
-
get '/thing' do
|
19
|
-
something = OpenStruct.new text: 'something'
|
20
|
-
present something, with: Entities::Something
|
21
|
-
end
|
22
|
-
|
23
|
-
desc 'This gets Things.' do
|
24
|
-
http_codes [
|
25
|
-
{ code: 200, message: 'get Horses', model: Entities::Something },
|
26
|
-
{ code: 401, message: 'HorsesOutError', model: Entities::ApiError }
|
27
|
-
]
|
28
|
-
end
|
29
|
-
get '/thing2' do
|
30
|
-
something = OpenStruct.new text: 'something'
|
31
|
-
present something, with: Entities::Something
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'This gets Thing.' do
|
35
|
-
http_codes [{ code: 200, message: 'getting a single thing' }, { code: 401, message: 'Unauthorized' }]
|
36
|
-
end
|
37
|
-
params do
|
38
|
-
requires :id, type: Integer
|
39
|
-
end
|
40
|
-
get '/thing/:id' do
|
41
|
-
something = OpenStruct.new text: 'something'
|
42
|
-
present something, with: Entities::Something
|
43
|
-
end
|
44
|
-
|
45
|
-
desc 'This creates Thing.',
|
46
|
-
success: Entities::Something
|
47
|
-
params do
|
48
|
-
requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' }
|
49
|
-
requires :links, type: Array, documentation: { type: 'link', is_array: true }
|
50
|
-
end
|
51
|
-
post '/thing', http_codes: [{ code: 422, message: 'Unprocessible Entity' }] do
|
52
|
-
something = OpenStruct.new text: 'something'
|
53
|
-
present something, with: Entities::Something
|
54
|
-
end
|
55
|
-
|
56
|
-
desc 'This updates Thing.',
|
57
|
-
success: Entities::Something
|
58
|
-
params do
|
59
|
-
requires :id, type: Integer
|
60
|
-
optional :text, type: String, desc: 'Content of something.'
|
61
|
-
optional :links, type: Array, documentation: { type: 'link', is_array: true }
|
62
|
-
end
|
63
|
-
put '/thing/:id' do
|
64
|
-
something = OpenStruct.new text: 'something'
|
65
|
-
present something, with: Entities::Something
|
66
|
-
end
|
67
|
-
|
68
|
-
desc 'This deletes Thing.',
|
69
|
-
entity: Entities::Something
|
70
|
-
params do
|
71
|
-
requires :id, type: Integer
|
72
|
-
end
|
73
|
-
delete '/thing/:id' do
|
74
|
-
something = OpenStruct.new text: 'something'
|
75
|
-
present something, with: Entities::Something
|
76
|
-
end
|
77
|
-
|
78
|
-
desc 'dummy route.',
|
79
|
-
failure: [{ code: 401, message: 'Unauthorized' }]
|
80
|
-
params do
|
81
|
-
requires :id, type: Integer
|
82
|
-
end
|
83
|
-
delete '/dummy/:id' do
|
84
|
-
{}
|
85
|
-
end
|
86
|
-
|
87
|
-
namespace :other_thing do
|
88
|
-
desc 'nested route inside namespace',
|
89
|
-
entity: Entities::QueryInput,
|
90
|
-
x: {
|
91
|
-
'amazon-apigateway-auth' => { type: 'none' },
|
92
|
-
'amazon-apigateway-integration' => { type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get' }
|
93
|
-
}
|
94
|
-
|
95
|
-
params do
|
96
|
-
requires :elements, documentation: {
|
97
|
-
type: 'QueryInputElement',
|
98
|
-
desc: 'Set of configuration',
|
99
|
-
param_type: 'body',
|
100
|
-
is_array: true,
|
101
|
-
required: true
|
102
|
-
}
|
103
|
-
end
|
104
|
-
get '/:elements' do
|
105
|
-
present something, with: Entities::QueryInput
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
version 'v3', using: :path
|
110
|
-
add_swagger_documentation base_path: '/api',
|
111
|
-
info: {
|
112
|
-
title: 'The API title to be displayed on the API homepage.',
|
113
|
-
description: 'A description of the API.',
|
114
|
-
contact_name: 'Contact name',
|
115
|
-
contact_email: 'Contact@email.com',
|
116
|
-
contact_url: 'Contact URL',
|
117
|
-
license: 'The name of the license.',
|
118
|
-
license_url: 'www.The-URL-of-the-license.org',
|
119
|
-
terms_of_service_url: 'www.The-URL-of-the-terms-and-service.com'
|
120
|
-
}
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
mounted_paths.each do |expected_path|
|
125
|
-
describe "documents only #{expected_path} paths" do
|
126
|
-
let(:mount_path) { "/v3/swagger_doc#{expected_path}" }
|
127
|
-
subject do
|
128
|
-
get mount_path
|
129
|
-
JSON.parse(last_response.body)['paths']
|
130
|
-
end
|
131
|
-
|
132
|
-
specify do
|
133
|
-
unexpected_paths = mounted_paths - [expected_path]
|
134
|
-
subject.each_key do |path|
|
135
|
-
unexpected_paths.each do |unexpected_path|
|
136
|
-
expect(path).not_to start_with unexpected_path
|
137
|
-
end
|
138
|
-
expect(path).to start_with(expected_path).or include(expected_path)
|
139
|
-
expect(subject[path]).to eql swagger_json['paths'][path]
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|