grape-swagger 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c3b14815684b5e4e77c01b12a1c64029b4cc367
4
- data.tar.gz: ecd30bdba3542f6a776c7f94683aab2a2eb32989
3
+ metadata.gz: a3f8731df44d1ab1e6d42e1a7d564b4af02bd869
4
+ data.tar.gz: 4be17285838269c75ae17474f76f4c50cd9de15d
5
5
  SHA512:
6
- metadata.gz: 5b2baa995bd32ba699ea6ffc21fb3816b5a6742a2b3be229df6a47e3cdf85622a52468899c1e5cee3b7f77973fe5dcedfa1330b390a981d09ebca7a47b6bdfbd
7
- data.tar.gz: 96a44e9923a0921f2f368f6f128681fa40796c3987fc46a7de54aec2599d00f0de33b42db4f19b5062857155fbf7395f50c25c95f112f43c86db0a525b9e0920
6
+ metadata.gz: b4821a7d1447484af17e69003e451f2e009315c81e074843037f229aaf48bbe9e1482413f4a99d2bce972dfadbc546f92982483f7ea6f92711cbdf33be9636cf
7
+ data.tar.gz: 185563d4b0e9e1b2ddcb9930e283f685108b7d710db340136e31f0e37fb1a25904f0138987b2fe6b046e0d6f0fb4bfffca18ff4b1cae0f7a8bd48c9f65b47daf
@@ -1,42 +1,42 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-08-19 12:17:53 -0400 using RuboCop version 0.33.0.
3
+ # on 2016-02-07 23:26:32 +0900 using RuboCop version 0.33.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 10
9
+ # Offense count: 14
10
10
  Metrics/AbcSize:
11
11
  Max: 214
12
12
 
13
13
  # Offense count: 1
14
14
  # Configuration parameters: CountComments.
15
15
  Metrics/ClassLength:
16
- Max: 147
16
+ Max: 150
17
17
 
18
- # Offense count: 6
18
+ # Offense count: 7
19
19
  Metrics/CyclomaticComplexity:
20
20
  Max: 39
21
21
 
22
- # Offense count: 304
22
+ # Offense count: 354
23
23
  # Configuration parameters: AllowURI, URISchemes.
24
24
  Metrics/LineLength:
25
25
  Max: 242
26
26
 
27
- # Offense count: 21
27
+ # Offense count: 24
28
28
  # Configuration parameters: CountComments.
29
29
  Metrics/MethodLength:
30
- Max: 170
30
+ Max: 169
31
31
 
32
32
  # Offense count: 1
33
33
  # Configuration parameters: CountComments.
34
34
  Metrics/ModuleLength:
35
- Max: 470
35
+ Max: 472
36
36
 
37
- # Offense count: 4
37
+ # Offense count: 5
38
38
  Metrics/PerceivedComplexity:
39
- Max: 41
39
+ Max: 40
40
40
 
41
41
  # Offense count: 8
42
42
  Style/ClassVars:
@@ -44,7 +44,7 @@ Style/ClassVars:
44
44
  - 'example/api.rb'
45
45
  - 'lib/grape-swagger/doc_methods.rb'
46
46
 
47
- # Offense count: 90
47
+ # Offense count: 95
48
48
  Style/Documentation:
49
49
  Enabled: false
50
50
 
@@ -3,19 +3,21 @@ language: ruby
3
3
  sudo: false
4
4
 
5
5
  rvm:
6
- - 2.2.2
7
- - 2.1.1
8
- - 2.0.0
9
- - rbx-2.2.10
6
+ - 2.2.3
7
+ - 2.1.7
10
8
  - jruby-19mode
9
+ - jruby-9.0.5.0
10
+ - rbx-2
11
11
 
12
12
  env:
13
- - GRAPE_VERSION=0.8.0
14
- - GRAPE_VERSION=0.9.0
15
13
  - GRAPE_VERSION=0.10.0
16
14
  - GRAPE_VERSION=0.10.1
17
15
  - GRAPE_VERSION=0.11.0
18
16
  - GRAPE_VERSION=0.12.0
19
17
  - GRAPE_VERSION=0.13.0
20
18
  - GRAPE_VERSION=0.14.0
21
- - GRAPE_VERSION=HEAD
19
+ # - GRAPE_VERSION=HEAD
20
+
21
+ matrix:
22
+ allow_failures:
23
+ - rvm: rbx-2
@@ -1,3 +1,13 @@
1
+ ### 0.10.5 (2016-04-12)
2
+
3
+ * [#338](https://github.com/ruby-grape/grape-swagger/pull/338): Fixed handling of nested Array parameters - [@itoufo](https://github.com/itoufo).
4
+ * [#347](https://github.com/ruby-grape/grape-swagger/pull/347): Fixed typeref when both :using and :as are provided in exposure but no :type in documentation - [@c910335](https://github.com/c910335).
5
+
6
+ #### Fixes
7
+
8
+ * [#322](https://github.com/ruby-grape/grape-swagger/pull/322): Entity's `entity_name` takes predence over root - [@gekola](https://github.com/gekola).
9
+ * [#321](https://github.com/ruby-grape/grape-swagger/pull/321): Fixed handling paths containing uppercase letters - [@gekola](https://github.com/gekola).
10
+
1
11
  ### 0.10.4 (December 7, 2015)
2
12
 
3
13
  * [#315](https://github.com/ruby-grape/grape-swagger/pull/315): Require `grape-entity` < 0.5.0 - [@dblock](https://github.com/dblock).
@@ -120,13 +130,13 @@
120
130
 
121
131
  * Added Rails 4 support - [@jrhe](https://github.com/jrhe).
122
132
  * Fix: document APIs at root level - [@dblock](https://github.com/dblock).
123
- * Added support for procs in basepath - [@ruby-grape](https://github.com/ruby-grape).
133
+ * Added support for procs in basepath - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
124
134
  * Support both `:desc` and `:description` when describing parameters - [@dblock](https://github.com/dblock).
125
135
  * Fix: allow parameters such as `name[]` - [@dblock](https://github.com/dblock).
126
136
 
127
137
  ### 0.5.0 (March 28, 2013)
128
138
 
129
- * Added Grape 0.5.0 support - [@ruby-grape](https://github.com/ruby-grape).
139
+ * Added Grape 0.5.0 support - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
130
140
 
131
141
  ### 0.4.0 (March 28, 2013)
132
142
 
@@ -135,28 +145,28 @@
135
145
  ### 0.3.0 (October 19, 2012)
136
146
 
137
147
  * Added version support - [@agileanimal](https://github.com/agileanimal), [@fknappe](https://github.com/fknappe).
138
- * Added support for nested parameters - [@ruby-grape](https://github.com/ruby-grape).
148
+ * Added support for nested parameters - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
139
149
  * Added basic support for specifying parameters that need to be passed in the header - [@agileanimal](https://github.com/agileanimal).
140
- * Add possibility to hide the documentation paths in the generated swagger documentation - [@ruby-grape](https://github.com/ruby-grape).
150
+ * Add possibility to hide the documentation paths in the generated swagger documentation - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
141
151
 
142
152
  ### 0.2.1 (August 17, 2012)
143
153
 
144
- * Added support for markdown in notes field - [@ruby-grape](https://github.com/ruby-grape).
154
+ * Added support for markdown in notes field - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
145
155
  * Fix: compatibility with Rails - [@qwert666](https://github.com/qwert666).
146
- * Fix: swagger UI history - [@ruby-grape](https://github.com/ruby-grape).
156
+ * Fix: swagger UI history - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
147
157
 
148
158
  ### 0.2.0 (July 27, 2012)
149
159
 
150
- * Use resource as root for swagger - [@ruby-grape](https://github.com/ruby-grape).
151
- * Added support for file uploads, and proper `paramType` - [@ruby-grape](https://github.com/ruby-grape).
160
+ * Use resource as root for swagger - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
161
+ * Added support for file uploads, and proper `paramType` - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
152
162
  * Added tests - [@nathanvda](https://github.com/nathanvda).
153
163
 
154
164
  ### 0.1.0 (July 19, 2012)
155
165
 
156
- * Added some configurability to the generated documentation - [@ruby-grape](https://github.com/ruby-grape).
157
- * Adapted to rails plugin structure - [@ruby-grape](https://github.com/ruby-grape).
158
- * Allowed cross origin, so swagger can be used from official site - [@ruby-grape](https://github.com/ruby-grape).
166
+ * Added some configurability to the generated documentation - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
167
+ * Adapted to rails plugin structure - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
168
+ * Allowed cross origin, so swagger can be used from official site - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
159
169
 
160
170
  ### 0.0.0 (July 19, 2012)
161
171
 
162
- * Initial public release - [@ruby-grape](https://github.com/ruby-grape).
172
+ * Initial public release - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- case version = ENV['GRAPE_VERSION'] || '~> 0.9.0'
5
+ case version = ENV['GRAPE_VERSION'] || '~> 0.10.0'
6
6
  when 'HEAD'
7
7
  gem 'grape', github: 'ruby-grape/grape'
8
8
  else
data/README.md CHANGED
@@ -1,7 +1,14 @@
1
+ **these branch generates a swagger file, which is conform to the 1.2 spec**
2
+
3
+ compatible versions:
4
+
5
+ - `grape <~ 0.14.0`
6
+ - `grape-entity < 0.5.0`
7
+
1
8
  # grape-swagger
2
9
 
3
10
  [![Gem Version](https://badge.fury.io/rb/grape-swagger.svg)](http://badge.fury.io/rb/grape-swagger)
4
- [![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=master)](https://travis-ci.org/ruby-grape/grape-swagger)
11
+ [![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=swagger-1.2)](https://travis-ci.org/ruby-grape/grape-swagger)
5
12
  [![Dependency Status](https://gemnasium.com/ruby-grape/grape-swagger.svg)](https://gemnasium.com/ruby-grape/grape-swagger)
6
13
  [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-swagger.svg)](https://codeclimate.com/github/ruby-grape/grape-swagger)
7
14
 
@@ -194,7 +201,7 @@ desc 'Conditionally hide this endpoint', hidden: lambda { ENV['EXPERIMENTAL'] !=
194
201
 
195
202
  ## Overriding Auto-Generated Nicknames
196
203
 
197
- You can specify a swagger nickname to use instead of the auto generated name by adding `:nickname 'string'``` in the description of the endpoint.
204
+ You can specify a swagger nickname to use instead of the auto generated name by adding `:nickname 'string'` in the description of the endpoint.
198
205
 
199
206
  ``` ruby
200
207
  desc 'Get a full list of pets', nickname: 'getAllPets'
@@ -1,16 +1,17 @@
1
1
  # Releasing Grape-Swagger
2
2
 
3
- There're no particular rules about when to release grape-swagger. Release bug fixes frequenty, features not so frequently and breaking API changes rarely.
3
+ There're no particular rules about when to release grape-swagger. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
4
 
5
5
  ### Release
6
6
 
7
- Run tests, check that all tests succeed locally.
7
+ Run tests and rubocop, check that all tests succeed locally.
8
8
 
9
9
  ```
10
10
  bundle install
11
- rake
11
+ bundle exec rake
12
12
  ```
13
13
 
14
+
14
15
  Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape-swagger) for all supported platforms.
15
16
 
16
17
  Increment the version, modify [lib/grape-swagger/version.rb](lib/grape-swagger/version.rb).
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'A simple way to add auto generated documentation to your Grape API that can be displayed with Swagger.'
12
12
  s.license = 'MIT'
13
13
 
14
- s.add_runtime_dependency 'grape', '>= 0.8.0'
14
+ s.add_runtime_dependency 'grape', '>= 0.10.0'
15
15
  s.add_runtime_dependency 'grape-entity', '< 0.5.0'
16
16
 
17
17
  s.add_development_dependency 'rake'
@@ -30,7 +30,6 @@ module Grape
30
30
  next unless route_match
31
31
  resource = route_match.captures.first
32
32
  next if resource.empty?
33
- resource.downcase!
34
33
  @target_class.combined_routes[resource] ||= []
35
34
  next if documentation_class.hide_documentation_path && route.route_path.match(/#{documentation_class.mount_path}($|\/|\(\.)/)
36
35
  @target_class.combined_routes[resource] << route
@@ -151,25 +150,29 @@ module Grape
151
150
 
152
151
  def parse_array_params(params)
153
152
  modified_params = {}
154
- array_param = nil
153
+ array_keys = []
155
154
  params.each_key do |k|
155
+ new_key, modified_params = parse_array_key(array_keys, k, modified_params)
156
156
  if params[k].is_a?(Hash) && params[k][:type] == 'Array'
157
- array_param = k
158
- modified_params[k] = params[k]
159
- else
160
- new_key = k
161
- unless array_param.nil?
162
- if k.to_s.start_with?(array_param.to_s + '[')
163
- new_key = array_param.to_s + '[]' + k.to_s.split(array_param)[1]
164
- modified_params.delete array_param
165
- end
166
- end
167
- modified_params[new_key] = params[k]
157
+ array_keys.push(new_key)
168
158
  end
159
+ modified_params[new_key] = params[k]
169
160
  end
170
161
  modified_params
171
162
  end
172
163
 
164
+ def parse_array_key(array_keys, key, modified_params)
165
+ unless array_keys.blank?
166
+ array_keys.each do |array_key|
167
+ if key.to_s.start_with?(array_key.to_s + '[')
168
+ key = array_key.to_s + '[]' + key.to_s.split(array_key)[1]
169
+ modified_params.delete array_key
170
+ end
171
+ end
172
+ end
173
+ [key, modified_params]
174
+ end
175
+
173
176
  def parse_enum_or_range_values(values)
174
177
  case values
175
178
  when Range
@@ -226,6 +226,8 @@ module GrapeSwagger
226
226
  def parse_entity_name(model)
227
227
  if model.respond_to?(:entity_name)
228
228
  model.entity_name
229
+ elsif (root = model.instance_variable_get(:@root))
230
+ root
229
231
  else
230
232
  name = model.to_s
231
233
  entity_parts = name.split('::')
@@ -238,7 +240,7 @@ module GrapeSwagger
238
240
  scope = options[:scope]
239
241
  result = {}
240
242
  models.each do |model|
241
- name = (model.instance_variable_get(:@root) || parse_entity_name(model))
243
+ name = parse_entity_name(model)
242
244
  properties = {}
243
245
  required = []
244
246
 
@@ -250,16 +252,17 @@ module GrapeSwagger
250
252
  end
251
253
  i18n_keys << :default
252
254
 
253
- model.documentation.each do |property_name, property_info|
254
- p = property_info.dup
255
+ model.exposures.each do |property_name, property_info|
256
+ next unless property_info.key? :documentation
257
+ property_name = property_info[:as] if property_info.key? :as
258
+ p = property_info[:documentation].dup
255
259
 
256
260
  required << property_name.to_s if p.delete(:required)
257
261
 
258
262
  type = if p[:type]
259
263
  p.delete(:type)
260
264
  else
261
- exposure = model.exposures[property_name]
262
- parse_entity_name(exposure[:using]) if exposure
265
+ parse_entity_name(property_info[:using])
263
266
  end
264
267
 
265
268
  if p.delete(:is_array)
@@ -420,7 +423,7 @@ module GrapeSwagger
420
423
  params do
421
424
  optional :locale, type: Symbol, desc: 'Locale of API documentation'
422
425
  end
423
- get @@mount_path do
426
+ get "#{@@mount_path}" do
424
427
  I18n.locale = params[:locale] || I18n.default_locale
425
428
  header['Access-Control-Allow-Origin'] = '*'
426
429
  header['Access-Control-Request-Method'] = '*'
@@ -1,3 +1,3 @@
1
1
  module GrapeSwagger
2
- VERSION = '0.10.4'
2
+ VERSION = '0.10.5'
3
3
  end
@@ -50,6 +50,10 @@ describe 'API Models' do
50
50
  class AliasedThing < Grape::Entity
51
51
  expose :something, as: :post, using: Entities::Something, documentation: { type: 'Something', desc: 'Reference to something.' }
52
52
  end
53
+
54
+ class AliasedThingWithoutType < Grape::Entity
55
+ expose :something, as: :post, using: Entities::Something, documentation: { desc: 'Reference to something without type.' }
56
+ end
53
57
  end
54
58
 
55
59
  module Entities
@@ -99,6 +103,14 @@ describe 'API Models' do
99
103
  root 'things', 'thing'
100
104
  expose :text, documentation: { type: 'string', desc: 'Content of something.' }
101
105
  end
106
+
107
+ class ThingWithRootAndEntityName < Grape::Entity
108
+ root 'things', 'thing'
109
+
110
+ def self.entity_name
111
+ 'TheThing'
112
+ end
113
+ end
102
114
  end
103
115
 
104
116
  def app
@@ -138,6 +150,12 @@ describe 'API Models' do
138
150
  present something, with: Entities::AliasedThing
139
151
  end
140
152
 
153
+ desc 'This also gets an aliased thing', entity: Entities::AliasedThingWithoutType
154
+ get '/aliased_thing_without_type' do
155
+ something = OpenStruct.new(something: OpenStruct.new(text: 'something'))
156
+ present something, with: Entities::AliasedThingWithoutType
157
+ end
158
+
141
159
  desc 'This gets all nested entities.', entity: Entities::FirstLevel
142
160
  get '/nesting' do
143
161
  fourth_level = OpenStruct.new text: 'something'
@@ -162,6 +180,12 @@ describe 'API Models' do
162
180
  present thing, with: Entities::ThingWithRoot
163
181
  end
164
182
 
183
+ desc 'This gets thing with root and entity name', entity: Entities::ThingWithRootAndEntityName
184
+ get '/thing_with_root_and_entity_name' do
185
+ thing = Object.new
186
+ present thing, with: Entities::ThingWithRootAndEntityName
187
+ end
188
+
165
189
  add_swagger_documentation
166
190
  end
167
191
  end
@@ -188,9 +212,11 @@ describe 'API Models' do
188
212
  { 'path' => '/somethingelse.{format}', 'description' => 'Operations about somethingelses' },
189
213
  { 'path' => '/enum_description_in_entity.{format}', 'description' => 'Operations about enum_description_in_entities' },
190
214
  { 'path' => '/aliasedthing.{format}', 'description' => 'Operations about aliasedthings' },
215
+ { 'path' => '/aliased_thing_without_type.{format}', 'description' => 'Operations about aliased_thing_without_types' },
191
216
  { 'path' => '/nesting.{format}', 'description' => 'Operations about nestings' },
192
217
  { 'path' => '/multiple_entities.{format}', 'description' => 'Operations about multiple_entities' },
193
218
  { 'path' => '/thing_with_root.{format}', 'description' => 'Operations about thing_with_roots' },
219
+ { 'path' => '/thing_with_root_and_entity_name.{format}', 'description' => 'Operations about thing_with_root_and_entity_names' },
194
220
  { 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
195
221
  ]
196
222
  end
@@ -291,6 +317,25 @@ describe 'API Models' do
291
317
  )
292
318
  end
293
319
 
320
+ it 'includes referenced models in those with aliased references and omitted types.' do
321
+ get '/swagger_doc/aliased_thing_without_type'
322
+ result = JSON.parse(last_response.body)
323
+ expect(result['models']['AliasedThingWithoutType']).to eq(
324
+ 'id' => 'AliasedThingWithoutType',
325
+ 'properties' => {
326
+ 'post' => { '$ref' => 'Something', 'description' => 'Reference to something without type.' }
327
+ }
328
+ )
329
+
330
+ expect(result['models']['Something']).to eq(
331
+ 'id' => 'Something',
332
+ 'properties' => {
333
+ 'text' => { 'type' => 'string', 'description' => 'Content of something.' },
334
+ 'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } }
335
+ }
336
+ )
337
+ end
338
+
294
339
  it 'includes all entities with four levels of nesting' do
295
340
  get '/swagger_doc/nesting'
296
341
  result = JSON.parse(last_response.body)
@@ -305,9 +350,15 @@ describe 'API Models' do
305
350
  expect(result['models']).to include('QueryInput', 'QueryInputElement', 'QueryResult')
306
351
  end
307
352
 
308
- it 'includes an id equal to the model name' do
353
+ it 'includes an id equal to the model name (defined with root)' do
309
354
  get '/swagger_doc/thing_with_root'
310
355
  result = JSON.parse(last_response.body)
311
356
  expect(result['models']['thing']['id']).to eq('thing')
312
357
  end
358
+
359
+ it 'prefers entity_name for id over root' do
360
+ get 'swagger_doc/thing_with_root_and_entity_name'
361
+ result = JSON.parse(last_response.body)
362
+ expect(result['models']['TheThing']['id']).to eq('TheThing')
363
+ end
313
364
  end
@@ -26,6 +26,17 @@ describe 'Array Params' do
26
26
  get :raw_array_integers do
27
27
  end
28
28
 
29
+ params do
30
+ requires :a_array, type: Array do
31
+ requires :param_1, type: Integer
32
+ requires :b_array, type: Array do
33
+ requires :param_2, type: String
34
+ end
35
+ end
36
+ end
37
+ post :nested_array do
38
+ end
39
+
29
40
  add_swagger_documentation
30
41
  end
31
42
  end
@@ -60,4 +71,15 @@ describe 'Array Params' do
60
71
  { 'paramType' => 'query', 'name' => 'raw_array', 'description' => '', 'type' => 'array', 'required' => false, 'allowMultiple' => false, 'items' => { 'type' => 'integer', 'format' => 'int32' } }
61
72
  ]
62
73
  end
74
+
75
+ it 'get nested array integer' do
76
+ get '/swagger_doc/nested_array'
77
+ expect(last_response.status).to eq 200
78
+ body = JSON.parse last_response.body
79
+ parameters = body['apis'].first['operations'].first['parameters']
80
+ expect(parameters).to eq [
81
+ { 'paramType' => 'form', 'name' => 'a_array[][param_1]', 'description' => '', 'type' => 'integer', 'required' => true, 'allowMultiple' => false, 'format' => 'int32' },
82
+ { 'paramType' => 'form', 'name' => 'a_array[][b_array][][param_2]', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false }
83
+ ]
84
+ end
63
85
  end
@@ -17,6 +17,7 @@ describe GrapeSwagger::Markdown::KramdownAdapter do
17
17
  end
18
18
 
19
19
  it 'raises an GrapeSwagger::Errors::MarkdownDependencyMissingError if module can not be required' do
20
+ pending
20
21
  expect_any_instance_of(Kernel).to receive(:require).with('kramdown').and_raise(LoadError)
21
22
 
22
23
  expect { GrapeSwagger::Markdown::KramdownAdapter.new }.to raise_error(GrapeSwagger::Errors::MarkdownDependencyMissingError, 'Missing required dependency: kramdown')
@@ -44,4 +44,24 @@ describe 'namespace' do
44
44
  expect(subject['description']).to eql('Description for aspace')
45
45
  end
46
46
  end
47
+
48
+ context 'with camelcase endpoints' do
49
+ def app
50
+ Class.new(Grape::API) do
51
+ namespace :SomeSpace, desc: 'Description for some space' do
52
+ get '/'
53
+ end
54
+ add_swagger_documentation format: :json
55
+ end
56
+ end
57
+
58
+ subject do
59
+ get '/swagger_doc'
60
+ JSON.parse(last_response.body)['apis'][0]
61
+ end
62
+
63
+ it 'shows the namespace description in the json spec' do
64
+ expect(subject['description']).to eql('Description for some space')
65
+ end
66
+ end
47
67
  end
@@ -23,6 +23,12 @@ describe 'a simple mounted api' do
23
23
  { bla: 'something' }
24
24
  end
25
25
 
26
+ desc 'This gets something for URL in camelcase.',
27
+ notes: '_test_'
28
+ get '/SimpleTest' do
29
+ { bla: 'something else' }
30
+ end
31
+
26
32
  desc 'this gets something else',
27
33
  headers: {
28
34
  'XAuthToken' => { description: 'A required header.', required: true },
@@ -76,6 +82,7 @@ describe 'a simple mounted api' do
76
82
  'apis' => [
77
83
  { 'path' => '/simple.{format}', 'description' => 'Operations about simples' },
78
84
  { 'path' => '/simple-test.{format}', 'description' => 'Operations about simple-tests' },
85
+ { 'path' => '/SimpleTest.{format}', 'description' => 'Operations about SimpleTests' },
79
86
  { 'path' => '/simple_with_headers.{format}', 'description' => 'Operations about simple_with_headers' },
80
87
  { 'path' => '/items.{format}', 'description' => 'Operations about items' },
81
88
  { 'path' => '/custom.{format}', 'description' => 'Operations about customs' },
@@ -129,6 +136,28 @@ describe 'a simple mounted api' do
129
136
  )
130
137
  end
131
138
 
139
+ it 'uses camelcase' do
140
+ get '/swagger_doc/SimpleTest.json'
141
+ expect(JSON.parse(last_response.body)).to eq(
142
+ 'apiVersion' => '0.1',
143
+ 'swaggerVersion' => '1.2',
144
+ 'basePath' => 'http://example.org',
145
+ 'resourcePath' => '/SimpleTest',
146
+ 'produces' => Grape::ContentTypes::CONTENT_TYPES.values.uniq,
147
+ 'apis' => [{
148
+ 'path' => '/SimpleTest.{format}',
149
+ 'operations' => [{
150
+ 'notes' => '_test_',
151
+ 'summary' => 'This gets something for URL in camelcase.',
152
+ 'nickname' => 'GET-SimpleTest---format-',
153
+ 'method' => 'GET',
154
+ 'parameters' => [],
155
+ 'type' => 'void'
156
+ }]
157
+ }]
158
+ )
159
+ end
160
+
132
161
  it 'includes headers' do
133
162
  get '/swagger_doc/simple_with_headers.json'
134
163
  expect(JSON.parse(last_response.body)['apis']).to eq [{
@@ -19,6 +19,8 @@ require 'i18n_helper'
19
19
 
20
20
  RSpec.configure do |config|
21
21
  require 'rspec/expectations'
22
+ require 'rspec/support'
23
+
22
24
  config.include RSpec::Matchers
23
25
  config.mock_with :rspec
24
26
  config.include Rack::Test::Methods
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Vandecasteele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.10.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: grape-entity
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - <
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.5.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - <
38
+ - - "<"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: shoulda
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rack-test
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack-cors
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
@@ -154,42 +154,42 @@ dependencies:
154
154
  name: kramdown
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: 1.4.1
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.4.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: redcarpet
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ~>
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
173
  version: 3.1.2
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ~>
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 3.1.2
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rouge
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ~>
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
187
  version: 1.6.1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ~>
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 1.6.1
195
195
  description:
@@ -199,13 +199,13 @@ executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
- - .document
203
- - .gitignore
204
- - .rspec
205
- - .rubocop.yml
206
- - .rubocop_todo.yml
207
- - .ruby-gemset
208
- - .travis.yml
202
+ - ".document"
203
+ - ".gitignore"
204
+ - ".rspec"
205
+ - ".rubocop.yml"
206
+ - ".rubocop_todo.yml"
207
+ - ".ruby-gemset"
208
+ - ".travis.yml"
209
209
  - CHANGELOG.md
210
210
  - CONTRIBUTING.md
211
211
  - Gemfile
@@ -272,17 +272,17 @@ require_paths:
272
272
  - lib
273
273
  required_ruby_version: !ruby/object:Gem::Requirement
274
274
  requirements:
275
- - - '>='
275
+ - - ">="
276
276
  - !ruby/object:Gem::Version
277
277
  version: '0'
278
278
  required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  requirements:
280
- - - '>='
280
+ - - ">="
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
284
  rubyforge_project:
285
- rubygems_version: 2.4.5
285
+ rubygems_version: 2.5.1
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: A simple way to add auto generated documentation to your Grape API that can