grape-swagger 0.26.1 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +5 -11
- data/.travis.yml +1 -2
- data/CHANGELOG.md +20 -1
- data/Dangerfile +2 -0
- data/Gemfile +5 -2
- data/README.md +70 -17
- data/RELEASING.md +2 -2
- data/Rakefile +2 -1
- data/grape-swagger.gemspec +2 -0
- data/lib/grape-swagger.rb +3 -1
- data/lib/grape-swagger/doc_methods.rb +17 -2
- data/lib/grape-swagger/doc_methods/build_model_definition.rb +2 -0
- data/lib/grape-swagger/doc_methods/data_type.rb +2 -0
- data/lib/grape-swagger/doc_methods/extensions.rb +6 -0
- data/lib/grape-swagger/doc_methods/headers.rb +2 -0
- data/lib/grape-swagger/doc_methods/move_params.rb +7 -5
- data/lib/grape-swagger/doc_methods/operation_id.rb +5 -7
- data/lib/grape-swagger/doc_methods/optional_object.rb +2 -0
- data/lib/grape-swagger/doc_methods/parse_params.rb +3 -3
- data/lib/grape-swagger/doc_methods/path_string.rb +3 -1
- data/lib/grape-swagger/doc_methods/produces_consumes.rb +2 -0
- data/lib/grape-swagger/doc_methods/status_codes.rb +2 -2
- data/lib/grape-swagger/doc_methods/tag_name_description.rb +2 -0
- data/lib/grape-swagger/doc_methods/version.rb +1 -0
- data/lib/grape-swagger/endpoint.rb +36 -18
- data/lib/grape-swagger/errors.rb +2 -0
- data/lib/grape-swagger/model_parsers.rb +2 -0
- data/lib/grape-swagger/rake/oapi_tasks.rb +2 -0
- data/lib/grape-swagger/version.rb +3 -1
- data/spec/issues/403_versions_spec.rb +2 -0
- data/spec/issues/427_entity_as_string_spec.rb +2 -0
- data/spec/issues/430_entity_definitions_spec.rb +2 -0
- data/spec/issues/532_allow_custom_format_spec.rb +3 -1
- data/spec/issues/533_specify_status_code_spec.rb +2 -0
- data/spec/issues/537_enum_values_spec.rb +4 -2
- data/spec/issues/539_array_post_body_spec.rb +2 -0
- data/spec/issues/542_array_of_type_in_post_body_spec.rb +2 -0
- data/spec/issues/553_align_array_put_post_params_spec.rb +2 -0
- data/spec/issues/572_array_post_body_spec.rb +2 -0
- data/spec/issues/579_align_put_post_parameters_spec.rb +179 -0
- data/spec/issues/582_file_response_spec.rb +55 -0
- data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +26 -0
- data/spec/lib/data_type_spec.rb +2 -0
- data/spec/lib/endpoint_spec.rb +2 -0
- data/spec/lib/extensions_spec.rb +2 -0
- data/spec/lib/model_parsers_spec.rb +2 -0
- data/spec/lib/move_params_spec.rb +8 -5
- data/spec/lib/oapi_tasks_spec.rb +2 -0
- data/spec/lib/operation_id_spec.rb +2 -0
- data/spec/lib/optional_object_spec.rb +6 -1
- data/spec/lib/parse_params_spec.rb +2 -0
- data/spec/lib/path_string_spec.rb +10 -1
- data/spec/lib/produces_consumes_spec.rb +2 -0
- data/spec/lib/tag_name_description_spec.rb +10 -7
- data/spec/lib/version_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/empty_model_parser.rb +2 -0
- data/spec/support/grape_version.rb +2 -0
- data/spec/support/mock_parser.rb +2 -0
- data/spec/support/model_parsers/entity_parser.rb +2 -0
- data/spec/support/model_parsers/mock_parser.rb +2 -0
- data/spec/support/model_parsers/representable_parser.rb +2 -0
- data/spec/support/namespace_tags.rb +2 -0
- data/spec/support/the_paths_definitions.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +14 -12
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_spec.rb +2 -0
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +2 -0
- data/spec/swagger_v2/boolean_params_spec.rb +2 -0
- data/spec/swagger_v2/default_api_spec.rb +43 -1
- data/spec/swagger_v2/description_not_initialized.rb +2 -0
- data/spec/swagger_v2/endpoint_versioned_path_spec.rb +2 -0
- data/spec/swagger_v2/errors_spec.rb +2 -0
- data/spec/swagger_v2/float_api_spec.rb +2 -0
- data/spec/swagger_v2/form_params_spec.rb +3 -1
- data/spec/swagger_v2/grape-swagger_spec.rb +2 -0
- data/spec/swagger_v2/hide_api_spec.rb +2 -0
- data/spec/swagger_v2/host.rb +2 -0
- data/spec/swagger_v2/mounted_target_class_spec.rb +2 -0
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +3 -1
- data/spec/swagger_v2/namespace_tags_spec.rb +2 -0
- data/spec/swagger_v2/namespaced_api_spec.rb +2 -0
- data/spec/swagger_v2/nicknamed_api_spec.rb +2 -0
- data/spec/swagger_v2/operation_id_api_spec.rb +2 -0
- data/spec/swagger_v2/param_multi_type_spec.rb +2 -0
- data/spec/swagger_v2/param_type_spec.rb +2 -0
- data/spec/swagger_v2/param_values_spec.rb +2 -0
- data/spec/swagger_v2/params_array_collection_fromat_spec.rb +2 -0
- data/spec/swagger_v2/params_array_spec.rb +2 -0
- data/spec/swagger_v2/params_hash_spec.rb +2 -0
- data/spec/swagger_v2/params_nested_spec.rb +2 -0
- data/spec/swagger_v2/parent_less_namespace.rb +2 -0
- data/spec/swagger_v2/reference_entity.rb +2 -0
- data/spec/swagger_v2/security_requirement_spec.rb +2 -0
- data/spec/swagger_v2/simple_mounted_api_spec.rb +2 -0
- data/spec/version_spec.rb +2 -0
- metadata +8 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
# require 'grape_version'
|
3
5
|
|
@@ -98,7 +100,10 @@ describe 'Default API' do
|
|
98
100
|
license: 'Apache 2',
|
99
101
|
license_url: 'http://test.com',
|
100
102
|
terms_of_service_url: 'http://terms.com',
|
101
|
-
contact_email: 'support@test.com'
|
103
|
+
contact_email: 'support@test.com',
|
104
|
+
x: {
|
105
|
+
logo: 'http://logo.com/img.png'
|
106
|
+
}
|
102
107
|
}
|
103
108
|
end
|
104
109
|
end
|
@@ -131,5 +136,42 @@ describe 'Default API' do
|
|
131
136
|
it 'documents the contact email' do
|
132
137
|
expect(subject['contact']['email']).to eql('support@test.com')
|
133
138
|
end
|
139
|
+
|
140
|
+
it 'documents the extension field' do
|
141
|
+
expect(subject['x-logo']).to eql('http://logo.com/img.png')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'with tags' do
|
146
|
+
def app
|
147
|
+
Class.new(Grape::API) do
|
148
|
+
format :json
|
149
|
+
desc 'This gets something.'
|
150
|
+
get '/something' do
|
151
|
+
{ bla: 'something' }
|
152
|
+
end
|
153
|
+
get '/somethingelse' do
|
154
|
+
{ bla: 'somethingelse' }
|
155
|
+
end
|
156
|
+
|
157
|
+
add_swagger_documentation tags: [
|
158
|
+
{ name: 'something', description: 'customized description' }
|
159
|
+
]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
subject do
|
164
|
+
get '/swagger_doc'
|
165
|
+
JSON.parse(last_response.body)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'documents the customized tag' do
|
169
|
+
expect(subject['tags']).to eql(
|
170
|
+
[
|
171
|
+
{ 'name' => 'somethingelse', 'description' => 'Operations about somethingelses' },
|
172
|
+
{ 'name' => 'something', 'description' => 'customized description' }
|
173
|
+
]
|
174
|
+
)
|
175
|
+
end
|
134
176
|
end
|
135
177
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe 'Form Params' do
|
@@ -33,7 +35,7 @@ describe 'Form Params' do
|
|
33
35
|
params do
|
34
36
|
requires :id, type: Integer, desc: 'id of item'
|
35
37
|
requires :name, type: String, desc: 'name of item'
|
36
|
-
optional :conditions, type: Symbol, desc: 'conditions of item', values:
|
38
|
+
optional :conditions, type: Symbol, desc: 'conditions of item', values: %i(one two)
|
37
39
|
end
|
38
40
|
post '/items/:id' do
|
39
41
|
{}
|
data/spec/swagger_v2/host.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe 'namespace tags check while using prefix and version' do
|
@@ -6,7 +8,7 @@ describe 'namespace tags check while using prefix and version' do
|
|
6
8
|
before :all do
|
7
9
|
module TheApi
|
8
10
|
class NamespaceApi < Grape::API
|
9
|
-
version
|
11
|
+
version %i(v1 v2)
|
10
12
|
end
|
11
13
|
|
12
14
|
class CascadingVersionApi < Grape::API
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Vandecasteele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -85,6 +85,9 @@ files:
|
|
85
85
|
- spec/issues/542_array_of_type_in_post_body_spec.rb
|
86
86
|
- spec/issues/553_align_array_put_post_params_spec.rb
|
87
87
|
- spec/issues/572_array_post_body_spec.rb
|
88
|
+
- spec/issues/579_align_put_post_parameters_spec.rb
|
89
|
+
- spec/issues/582_file_response_spec.rb
|
90
|
+
- spec/issues/587_range_parameter_delimited_by_dash_spec.rb
|
88
91
|
- spec/lib/data_type_spec.rb
|
89
92
|
- spec/lib/endpoint_spec.rb
|
90
93
|
- spec/lib/extensions_spec.rb
|
@@ -191,6 +194,9 @@ test_files:
|
|
191
194
|
- spec/issues/542_array_of_type_in_post_body_spec.rb
|
192
195
|
- spec/issues/553_align_array_put_post_params_spec.rb
|
193
196
|
- spec/issues/572_array_post_body_spec.rb
|
197
|
+
- spec/issues/579_align_put_post_parameters_spec.rb
|
198
|
+
- spec/issues/582_file_response_spec.rb
|
199
|
+
- spec/issues/587_range_parameter_delimited_by_dash_spec.rb
|
194
200
|
- spec/lib/data_type_spec.rb
|
195
201
|
- spec/lib/endpoint_spec.rb
|
196
202
|
- spec/lib/extensions_spec.rb
|