grape-swagger 0.20.3 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +10 -10
  3. data/.travis.yml +8 -3
  4. data/CHANGELOG.md +27 -0
  5. data/Gemfile +2 -0
  6. data/README.md +111 -12
  7. data/UPGRADING.md +9 -0
  8. data/grape-swagger.gemspec +1 -3
  9. data/lib/grape-swagger.rb +8 -1
  10. data/lib/grape-swagger/doc_methods/optional_object.rb +14 -2
  11. data/lib/grape-swagger/doc_methods/parse_params.rb +3 -4
  12. data/lib/grape-swagger/doc_methods/path_string.rb +4 -3
  13. data/lib/grape-swagger/endpoint.rb +25 -55
  14. data/lib/grape-swagger/errors.rb +3 -0
  15. data/lib/grape-swagger/grape/route.rb +2 -1
  16. data/lib/grape-swagger/model_parsers.rb +33 -0
  17. data/lib/grape-swagger/version.rb +1 -1
  18. data/spec/issues/403_versions_spec.rb +20 -4
  19. data/spec/lib/model_parsers_spec.rb +102 -0
  20. data/spec/lib/optional_object_spec.rb +15 -11
  21. data/spec/lib/path_string_spec.rb +72 -18
  22. data/spec/lib/produces_consumes_spec.rb +10 -5
  23. data/spec/spec_helper.rb +4 -2
  24. data/spec/support/empty_model_parser.rb +20 -0
  25. data/spec/support/mock_parser.rb +22 -0
  26. data/spec/support/model_parsers/entity_parser.rb +325 -0
  27. data/spec/support/{api_swagger_v2_result.rb → model_parsers/mock_parser.rb} +186 -60
  28. data/spec/support/model_parsers/representable_parser.rb +394 -0
  29. data/spec/support/the_paths_definitions.rb +7 -3
  30. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +5 -4
  31. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +3 -3
  32. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +1 -1
  33. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +1 -1
  34. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +5 -3
  35. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +1 -1
  36. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +1 -1
  37. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +25 -14
  38. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +22 -12
  39. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +30 -18
  40. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +6 -3
  41. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +13 -40
  42. data/spec/swagger_v2/api_swagger_v2_spec.rb +4 -2
  43. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +6 -36
  44. data/spec/swagger_v2/default_api_spec.rb +10 -2
  45. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +30 -0
  46. data/spec/swagger_v2/errors_spec.rb +75 -0
  47. data/spec/swagger_v2/hide_api_spec.rb +22 -4
  48. data/spec/swagger_v2/mounted_target_class_spec.rb +6 -2
  49. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +6 -3
  50. data/spec/swagger_v2/namespace_tags_spec.rb +6 -3
  51. data/spec/swagger_v2/params_array_spec.rb +4 -2
  52. data/spec/swagger_v2/params_hash_spec.rb +4 -2
  53. data/spec/swagger_v2/params_nested_spec.rb +4 -2
  54. data/spec/swagger_v2/simple_mounted_api_spec.rb +66 -24
  55. metadata +23 -40
  56. data/spec/support/the_api_entities.rb +0 -50
  57. data/spec/swagger_v2/response_model_spec.rb +0 -208
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d7b5486e6ee350258521fef6c57ee68169423f0
4
- data.tar.gz: 105ff9de1347190740ec19228cc5839246758288
3
+ metadata.gz: 21b83f7c1596856df6020d2a6191b69a2a9502af
4
+ data.tar.gz: d3f9532f1a8d5430baa061237d28b8c5fa8fced5
5
5
  SHA512:
6
- metadata.gz: c22549eeab271d9c11100edb328f91707695632ed36ee4ae201e2e716d1526b9285d068035e356dbaea61098d7d5b6f4c11297af27be3b072c20e7a28ade9ebb
7
- data.tar.gz: d2256e0601621560fb665543731632c2177a16a8b0e0b03c1d5bc356cd5f198b779fd81ae2ffc9fac2ad3445ddc114c76b000d88c14c4c850560cb5ef0c505e3
6
+ metadata.gz: a48aa84a04dcb5b0a6c12fb142e0fefbb92a42f8c363a9a0b34cf3931ea57a60996f2991b5f00e0d5b1154dd4f85b655d16f634101c6913e2cdbd0867ba7d735
7
+ data.tar.gz: 705b3490be3a33bf84ec5bd56df3d7ea9b698b0b2a79eef822facebb22554933fa1ff2a00e462e36f4df8c8af30d0c06f0c11eae9c4fe8c131eecf22e5fb05eb
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-05-06 15:08:19 -0400 using RuboCop version 0.39.0.
3
+ # on 2016-05-11 23:53:37 +0300 using RuboCop version 0.40.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
@@ -23,31 +23,31 @@ Lint/UselessAssignment:
23
23
 
24
24
  # Offense count: 27
25
25
  Metrics/AbcSize:
26
- Max: 68
26
+ Max: 56
27
27
 
28
28
  # Offense count: 3
29
29
  # Configuration parameters: CountComments.
30
30
  Metrics/ClassLength:
31
- Max: 234
31
+ Max: 206
32
32
 
33
- # Offense count: 11
33
+ # Offense count: 10
34
34
  Metrics/CyclomaticComplexity:
35
35
  Max: 16
36
36
 
37
- # Offense count: 624
37
+ # Offense count: 719
38
38
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
39
39
  # URISchemes: http, https
40
40
  Metrics/LineLength:
41
- Max: 487
41
+ Max: 454
42
42
 
43
- # Offense count: 33
43
+ # Offense count: 31
44
44
  # Configuration parameters: CountComments.
45
45
  Metrics/MethodLength:
46
46
  Max: 101
47
47
 
48
- # Offense count: 7
48
+ # Offense count: 6
49
49
  Metrics/PerceivedComplexity:
50
- Max: 19
50
+ Max: 17
51
51
 
52
52
  # Offense count: 4
53
53
  Style/ClassVars:
@@ -55,7 +55,7 @@ Style/ClassVars:
55
55
  - 'example/api/endpoints.rb'
56
56
  - 'lib/grape-swagger/doc_methods.rb'
57
57
 
58
- # Offense count: 24
58
+ # Offense count: 27
59
59
  Style/Documentation:
60
60
  Enabled: false
61
61
 
@@ -4,6 +4,10 @@ sudo: false
4
4
 
5
5
  matrix:
6
6
  include:
7
+ - rvm: 2.3.1
8
+ env: MODEL_PARSER=grape-swagger-entity
9
+ - rvm: 2.3.1
10
+ env: MODEL_PARSER=grape-swagger-representable
7
11
  - rvm: 2.3.1
8
12
  env: GRAPE_VERSION=0.12.0
9
13
  - rvm: 2.3.1
@@ -17,14 +21,15 @@ matrix:
17
21
  - rvm: 2.3.1
18
22
  env: GRAPE_VERSION=HEAD
19
23
  - rvm: 2.3.0
20
- - rvm: 2.2.5
24
+ - rvm: 2.2
21
25
  - rvm: 2.1
26
+ - rvm: ruby-head
22
27
  - rvm: rbx-2
28
+ - rvm: jruby-9.0.5.0
23
29
  - rvm: jruby-19mode
24
- - rvm: ruby-head
25
30
  - rvm: jruby-head
26
31
  allow_failures:
32
+ - rvm: ruby-head
27
33
  - rvm: rbx-2
28
34
  - rvm: jruby-19mode
29
- - rvm: ruby-head
30
35
  - rvm: jruby-head
@@ -1,3 +1,30 @@
1
+ ### Next
2
+
3
+ #### Features
4
+
5
+ * Your contribution here.
6
+
7
+ #### Fixes
8
+
9
+ * Your contribution here.
10
+
11
+ ### 0.21.0 (June 1, 2016)
12
+
13
+ #### Features
14
+
15
+ * [#413](https://github.com/ruby-grape/grape-swagger/pull/413): Move all model parsing logic to separate gems `grape-swagger-entity` and added representable parser `grape-swagger` - [@Bugagazavr](https://github.com/Bugagazavr).
16
+ * [#434](https://github.com/ruby-grape/grape-swagger/pull/434): Add summary to the operation object generator to be more compliant with [OpenAPI v2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object) - [@aschuster3](https://github.com/aschuster3).
17
+ * [#441](https://github.com/ruby-grape/grape-swagger/pull/441): Accepting `String`, `lambda` and `proc` for `host` and `base_path` - [@LeFnord](https://github.com/LeFnord).
18
+ * Your contribution here.
19
+
20
+ #### Fixes
21
+
22
+ * [#416](https://github.com/ruby-grape/grape-swagger/pull/416): Support recursive models - [@lest](https://github.com/lest).
23
+ * [#419](https://github.com/ruby-grape/grape-swagger/pull/419): Replaced github ref to rubygems for external gems - [@Bugagazavr](https://github.com/Bugagazavr).
24
+ * [#420](https://github.com/ruby-grape/grape-swagger/pull/420): Raise SwaggerSpec exception if swagger spec isn't satisfied, when no parser for model is registered or response model is empty - [@Bugagazavr](https://github.com/Bugagazavr).
25
+ * [#438](https://github.com/ruby-grape/grape-swagger/pull/438): Route version was missing in :options passed to PathString, so Endpoint.path_and_definitions_objects wasn't returning a versioned path when required - [@texpert](https://github.com/texpert).
26
+ * Your contribution here.
27
+
1
28
  ### 0.20.3 (May 9, 2016)
2
29
 
3
30
  #### Features
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ when 'HEAD'
8
8
  else
9
9
  gem 'grape', version
10
10
  end
11
+
12
+ gem ENV['MODEL_PARSER'] if ENV.key?('MODEL_PARSER')
data/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  * [Swagger-Spec](#swagger-spec)
12
12
  * [Installation](#install)
13
13
  * [Usage](#usage)
14
+ * [Model Parsers](#model_parsers)
14
15
  * [Configure](#configure)
15
16
  * [Routes Configuration](#routes)
16
17
  * [Markdown](#md_usage)
@@ -27,12 +28,13 @@ The grape-swagger gem provides an autogenerated documentation for your [Grape](h
27
28
 
28
29
  These screenshot is based on the [Hussars](https://github.com/LeFnord/hussars) sample app.
29
30
 
30
-
31
31
  <a name="related" />
32
32
  ## Related Projects
33
33
 
34
34
  * [Grape](https://github.com/ruby-grape/grape)
35
- * [Grape Entity](https://github.com/ruby-grape/grape-entity)
35
+ * [Grape Swagger Entity](https://github.com/ruby-grape/grape-swagger-entity)
36
+ * [Grape Entity](https://github.com/ruby-grape/grape-entity)
37
+ * [Grape Swagger Representable](https://github.com/ruby-grape/grape-swagger-representable)
36
38
  * [Swagger UI](https://github.com/wordnik/swagger-ui)
37
39
 
38
40
 
@@ -41,18 +43,20 @@ These screenshot is based on the [Hussars](https://github.com/LeFnord/hussars) s
41
43
 
42
44
  The following versions of grape, grape-entity and grape-swagger can currently be used together.
43
45
 
44
- grape-swagger | swagger spec | grape | grape-entity
45
- --------------|--------------|-------------------------|-------------
46
- 0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0
47
- 0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0
48
- 0.20.1 | 2.0 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1
49
- 0.20.3 | 2.0 | >= 0.12.0 ... ~> 0.16.2 | ~> 0.5.1
46
+ grape-swagger | swagger spec | grape | grape-entity | representable |
47
+ --------------|--------------|-------------------------|--------------|---------------|
48
+ 0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | n/a |
49
+ 0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | n/a |
50
+ 0.20.1 | 2.0 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1 | n/a |
51
+ 0.20.3 | 2.0 | >= 0.12.0 ... ~> 0.16.2 | ~> 0.5.1 | n/a |
52
+ 0.21.0 (next) | 2.0 | >= 0.12.0 ... <= 0.16.2 | <= 0.5.1 | >= 2.4.1 |
50
53
 
51
54
  <a name="swagger-spec" />
52
55
  ## Swagger-Spec
53
56
 
54
- Grape-swagger generates documentation per [Swagger Spec 2.0](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md).
57
+ Grape-swagger generates documentation per [Swagger / OpenAPI Spec 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md).
55
58
 
59
+ <!-- validating: http://bigstickcarpet.com/swagger-parser/www/index.html -->
56
60
 
57
61
  <a name="install" />
58
62
  ## Installation
@@ -71,7 +75,7 @@ Please see [UPGRADING](UPGRADING.md) when upgrading from a previous version.
71
75
  <a name="usage" />
72
76
  ## Usage
73
77
 
74
- Mount all your different APIs (with ```Grape::API``` superclass) on a root node. In the root class definition, include ```add_swagger_documentation```, this sets up the system and registers the documentation on '/swagger_doc'. See [example/api.rb](example/api.rb) for a simple demo.
78
+ Mount all your different APIs (with ```Grape::API``` superclass) on a root node. In the root class definition, include ```add_swagger_documentation```, this sets up the system and registers the documentation on '/swagger_doc'. See [example/config.ru](example/config.ru) for a simple demo.
75
79
 
76
80
 
77
81
  ```ruby
@@ -91,6 +95,68 @@ end
91
95
  To explore your API, either download [Swagger UI](https://github.com/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc).
92
96
 
93
97
 
98
+ <a name="model_parsers" />
99
+ ## Model Parsers
100
+
101
+ Since 0.21.0, `Grape::Entity` is not a part of grape-swagger, you need to add `grape-swagger-entity` manually to your Gemfile.
102
+ Also added support for [representable](https://github.com/apotonick/representable) via `grape-swagger-representable`.
103
+
104
+ ```ruby
105
+ # For Grape::Entity ( https://github.com/ruby-grape/grape-entity )
106
+ gem 'grape-swagger-entity'
107
+ # For representable ( https://github.com/apotonick/representable )
108
+ gem 'grape-swagger-representable'
109
+ ```
110
+
111
+ If you are not using Rails, make sure to load the parser inside your application initialization logic, e.g., via `require 'grape-swagger/entity'` or `require 'grape-swagger/representable`.
112
+
113
+ ### Custom Model Parsers
114
+
115
+ You can create your own model parser, for example for [roar](https://github.com/apotonick/roar).
116
+
117
+ ```rb
118
+ module GrapeSwagger
119
+ module Roar
120
+ class Parser
121
+ attr_reader :model
122
+ attr_reader :endpoint
123
+
124
+ def initialize(model, endpoint)
125
+ @model = model
126
+ @endpoint = endpoint
127
+ end
128
+
129
+ def call
130
+ # Parse your model and return hash with model schema for swagger
131
+ end
132
+ end
133
+ end
134
+ end
135
+ ```
136
+
137
+ Then you should register your custom parser.
138
+
139
+ ```rb
140
+ GrapeSwagger.model_parsers.register(GrapeSwagger::Roar::Parser, Roar::Decorator)
141
+ ```
142
+
143
+ To control model parsers sequence, you can insert your parser before or after another parser.
144
+
145
+ #### insert_before
146
+
147
+ ```rb
148
+ GrapeSwagger.model_parsers.insert_before(GrapeSwagger::Representable::Parser, GrapeSwagger::Roar::Parser, Roar::Decorator)
149
+ ```
150
+
151
+ #### insert_after
152
+
153
+ ```rb
154
+ GrapeSwagger.model_parsers.insert_after(GrapeSwagger::Roar::Parser, GrapeSwagger::Representable::Parser, Representable::Decorator)
155
+ ```
156
+
157
+ As we know, `Roar::Decorator` uses as superclass `Representable::Decorator`, this allow to avoid problem when Roar objects will be processed by `GrapeSwagger::Representable::Parser`, instead `GrapeSwagger::Roar::Parser`.
158
+
159
+
94
160
  ### CORS
95
161
 
96
162
  If you use the online demo, make sure your API supports foreign requests by enabling CORS in Grape, otherwise you'll see the API description, but requests on the API won't return. Use [rack-cors](https://github.com/cyu/rack-cors) to enable CORS.
@@ -135,7 +201,12 @@ You can pass a hash with optional configuration settings to ```add_swagger_docum
135
201
  *not all configuration options supported yet*, but is WIP
136
202
 
137
203
 
138
- `host` and `base_path` are also accepting a `proc` to evaluate.
204
+ The `host` and `base_path` options also accept a `proc` or `lambda` to evaluate, which is passed a [request](http://www.rubydoc.info/github/rack/rack/Rack/Request) object:
205
+
206
+ ```ruby
207
+ add_swagger_documentation \
208
+ base_path: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' }
209
+ ```
139
210
 
140
211
  <a name="host" />
141
212
  #### host:
@@ -153,6 +224,8 @@ add_swagger_documentation \
153
224
  base_path: '/super/api'
154
225
  ```
155
226
 
227
+ `host` and `base_path` are also accepting a `proc` or `lambda`
228
+
156
229
  <a name="mount_path" />
157
230
  #### mount_path:
158
231
  The path where the API documentation is loaded, default is: `/swagger_doc`.
@@ -381,6 +454,32 @@ end
381
454
  ```
382
455
 
383
456
 
457
+ #### Overriding the route summary
458
+
459
+ By default, the route summary is filled with the value supplied to `desc`.
460
+
461
+ ```ruby
462
+ namespace 'order' do
463
+ desc 'This will be your summary'
464
+ get :order_id do
465
+ ...
466
+ end
467
+ end
468
+ ```
469
+
470
+ To override the summary, add `summary: '[string]'` after the description.
471
+
472
+ ```ruby
473
+ namespace 'order' do
474
+ desc 'This will be your summary',
475
+ summary: 'Now this is your summary!'
476
+ get :order_id do
477
+ ...
478
+ end
479
+ end
480
+ ```
481
+
482
+
384
483
  #### Expose nested namespace as standalone route
385
484
 
386
485
  Use the `nested: false` property in the `swagger` option to make nested namespaces appear as standalone resources.
@@ -441,7 +540,7 @@ Grape allows for an additional documentation hash to be passed to a parameter.
441
540
  ```ruby
442
541
  params do
443
542
  requires :id, type: Integer, desc: 'Coffee ID'
444
- requires :temperature, type: Integer, desc: 'Temperature of the coffee in celcius', documentation: { example: 72 }
543
+ requires :temperature, type: Integer, desc: 'Temperature of the coffee in celcius', documentation: { default: 72 }
445
544
  end
446
545
  ```
447
546
 
@@ -1,6 +1,15 @@
1
1
  Upgrading Grape-swagger
2
2
  =======================
3
3
 
4
+ ### Upgrading to >= 0.21.0
5
+
6
+ With grape >= 0.21.0, `grape-entity` support moved to separate gem `grape-swagger-entity`, if you use grape entity, update your Gemfile:
7
+
8
+ ```ruby
9
+ gem 'grape-swagger'
10
+ gem 'grape-swagger-entity'
11
+ ```
12
+
4
13
  ### Upgrading to >= 0.10.2
5
14
 
6
15
  With grape >= 0.12.0, support for `notes` is replaced by passing a block `detail` option specified. For future compatibility, update your code:
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.license = 'MIT'
13
13
 
14
14
  s.add_runtime_dependency 'grape', '>= 0.12.0'
15
- s.add_runtime_dependency 'grape-entity'
16
- s.add_runtime_dependency 'awesome_print'
17
15
 
18
16
  s.add_development_dependency 'rake'
19
17
  s.add_development_dependency 'shoulda'
@@ -22,7 +20,7 @@ Gem::Specification.new do |s|
22
20
  s.add_development_dependency 'bundler'
23
21
  s.add_development_dependency 'rack-test'
24
22
  s.add_development_dependency 'rack-cors'
25
- s.add_development_dependency 'rubocop'
23
+ s.add_development_dependency 'rubocop', '0.40.0'
26
24
  s.add_development_dependency 'kramdown'
27
25
  s.add_development_dependency 'redcarpet' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
28
26
  s.add_development_dependency 'rouge' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
@@ -7,11 +7,18 @@ require 'grape-swagger/endpoint'
7
7
  require 'grape-swagger/errors'
8
8
 
9
9
  require 'grape-swagger/doc_methods'
10
+ require 'grape-swagger/model_parsers'
10
11
 
11
12
  require 'grape-swagger/markdown/kramdown_adapter'
12
13
  require 'grape-swagger/markdown/redcarpet_adapter'
13
14
 
14
- require 'awesome_print'
15
+ module GrapeSwagger
16
+ class << self
17
+ def model_parsers
18
+ @model_parsers ||= GrapeSwagger::ModelParsers.new
19
+ end
20
+ end
21
+ end
15
22
 
16
23
  module Grape
17
24
  class API
@@ -4,11 +4,23 @@ module GrapeSwagger
4
4
  class << self
5
5
  def build(key, options, request = nil)
6
6
  if options[key]
7
- options[key].is_a?(Proc) ? options[key].call : options[key]
7
+ return evaluate(key, options, request) if options[key].is_a?(Proc)
8
+ options[key]
8
9
  else
9
- request
10
+ request.send(default_values[key])
10
11
  end
11
12
  end
13
+
14
+ def evaluate(key, options, request)
15
+ options[key].arity == 0 ? options[key].call : options[key].call(request)
16
+ end
17
+
18
+ def default_values
19
+ {
20
+ host: 'host_with_port',
21
+ base_path: 'script_name'
22
+ }
23
+ end
12
24
  end
13
25
  end
14
26
  end
@@ -79,12 +79,11 @@ module GrapeSwagger
79
79
 
80
80
  def param_type(value_type)
81
81
  param_type = value_type[:param_type] || value_type[:in]
82
- case
83
- when value_type[:path].include?("{#{value_type[:param_name]}}")
82
+ if value_type[:path].include?("{#{value_type[:param_name]}}")
84
83
  'path'
85
- when param_type
84
+ elsif param_type
86
85
  param_type
87
- when %w(POST PUT PATCH).include?(value_type[:method])
86
+ elsif %w(POST PUT PATCH).include?(value_type[:method])
88
87
  GrapeSwagger::DocMethods::DataType.request_primitive?(value_type[:data_type]) ? 'formData' : 'body'
89
88
  else
90
89
  'query'
@@ -2,7 +2,8 @@ module GrapeSwagger
2
2
  module DocMethods
3
3
  class PathString
4
4
  class << self
5
- def build(path, options = {})
5
+ def build(route, options = {})
6
+ path = route.path
6
7
  # always removing format
7
8
  path.sub!(/\(\.\w+?\)$/, '')
8
9
  path.sub!('(.:format)', '')
@@ -13,8 +14,8 @@ module GrapeSwagger
13
14
  # set item from path, this could be used for the definitions object
14
15
  item = path.gsub(%r{/{(.+?)}}, '').split('/').last.singularize.underscore.camelize || 'Item'
15
16
 
16
- if options[:version] && options[:add_version]
17
- path.sub!('{version}', options[:version].to_s)
17
+ if route.version && options[:add_version]
18
+ path.sub!('{version}', route.version.to_s)
18
19
  else
19
20
  path.sub!('/{version}', '')
20
21
  end