grape-swagger 0.10.0 → 0.10.1

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: 80476f6e354bf1964123a1f592e8a6ca9fd38d54
4
- data.tar.gz: b9c15ab8ac8cacbd87e69e187a1afd2a838ff7d7
3
+ metadata.gz: 5cfbc79e708b79d924566658b3638c783fb3aed7
4
+ data.tar.gz: 9e83444251591329c9017ffc0c2a721474f8775a
5
5
  SHA512:
6
- metadata.gz: 4f6d6e3da7140010e92a6a94a716572cf2da3093bc2233c172c6a9d0caa420a4108da068d73a145ae901dd61cc2c754c22974881cab22a5959fb55439fdfaeb1
7
- data.tar.gz: 04db505e755cf5fa4f72684becaa3ad2a580a1f83baf566fb8c7407f2c1b425f809d813b1151c7b286f0f4ed90e587307be53c15f3ab9ef90b579af4d5c8d803
6
+ metadata.gz: a69ba696f61ea547d04b345c56ecebe9219f132d8a4c4054efbec31eb72d85767952d630b91bfb9f08ab5af47941e01a90d5bb9c7b738502d4b13bfc16bb5040
7
+ data.tar.gz: f29dc09e59558e2a60c03bf887dfeee5ef8d4ff505d81a50dcd62c6cda8b5359b684d10b175a828982e4ac062ffe33e3190b29d23a92e720918f2e1f643a740c
data/.rubocop_todo.yml CHANGED
@@ -1,32 +1,32 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-02-26 15:04:26 +0100 using RuboCop version 0.27.0.
2
+ # on 2015-03-11 10:53:03 -0400 using RuboCop version 0.27.0.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 9
8
+ # Offense count: 10
9
9
  Metrics/AbcSize:
10
10
  Max: 347
11
11
 
12
12
  # Offense count: 1
13
13
  # Configuration parameters: CountComments.
14
14
  Metrics/ClassLength:
15
- Max: 485
15
+ Max: 486
16
16
 
17
17
  # Offense count: 6
18
18
  Metrics/CyclomaticComplexity:
19
19
  Max: 99
20
20
 
21
- # Offense count: 289
21
+ # Offense count: 294
22
22
  # Configuration parameters: AllowURI, URISchemes.
23
23
  Metrics/LineLength:
24
24
  Max: 254
25
25
 
26
- # Offense count: 17
26
+ # Offense count: 20
27
27
  # Configuration parameters: CountComments.
28
28
  Metrics/MethodLength:
29
- Max: 368
29
+ Max: 369
30
30
 
31
31
  # Offense count: 5
32
32
  Metrics/PerceivedComplexity:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.10.1 (March 11, 2015)
2
+
3
+ * [#227](https://github.com/tim-vandecasteele/grape-swagger/issues/227): Fix: nested routes under prefix not documented - [@dblock](https://github.com/dblock).
4
+ * [#226](https://github.com/tim-vandecasteele/grape-swagger/issues/226): Fix: be defensive with nil exposure types - [@dblock](https://github.com/dblock).
5
+
1
6
  ### 0.10.0 (March 10, 2015)
2
7
 
3
8
  #### Features
data/UPGRADING.md CHANGED
@@ -3,11 +3,11 @@ Upgrading Grape-swagger
3
3
 
4
4
  ### Upgrading to >= 0.9.0
5
5
 
6
- #### Changes in Configuration
6
+ #### Grape-Swagger-Rails
7
7
 
8
8
  If you're using [grape-swagger-rails](https://github.com/BrandyMint/grape-swagger-rails), remove the `.json` extension from `GrapeSwaggerRails.options.url`.
9
9
 
10
- For example, change
10
+ For example, change
11
11
 
12
12
  ```ruby
13
13
  GrapeSwaggerRails.options.url = '/api/v1/swagger_doc.json'
@@ -21,6 +21,10 @@ GrapeSwaggerRails.options.url = '/api/v1/swagger_doc'
21
21
 
22
22
  See [#187](https://github.com/tim-vandecasteele/grape-swagger/issues/187) for more information.
23
23
 
24
+ #### Grape 0.10.0
25
+
26
+ If your API uses Grape 0.10.0 or newer with a single `format :json` directive, add `hide_format: true` to `add_swagger_documentation`. Otherwise nested routes will render with `.json` links to your API documentation, which will fail with a 404 Not Found.
27
+
24
28
  ### Upgrading to >= 0.8.0
25
29
 
26
30
  #### Changes in Configuration
@@ -1,3 +1,3 @@
1
1
  module GrapeSwagger
2
- VERSION = '0.10.0'
2
+ VERSION = '0.10.1'
3
3
  end
data/lib/grape-swagger.rb CHANGED
@@ -68,7 +68,7 @@ module Grape
68
68
  parent_route = @combined_routes[parent_route_name]
69
69
  # fetch all routes that are within the current namespace
70
70
  namespace_routes = parent_route.collect do |route|
71
- route if (route.route_path.start_with?("/#{name}") || route.route_path.start_with?("/:version/#{name}")) &&
71
+ route if (route.route_path.start_with?(route.route_prefix ? "/#{route.route_prefix}/#{name}" : "/#{name}") || route.route_path.start_with?((route.route_prefix ? "/#{route.route_prefix}/:version/#{name}" : "/:version/#{name}"))) &&
72
72
  (route.instance_variable_get(:@options)[:namespace] == "/#{name}" || route.instance_variable_get(:@options)[:namespace] == "/:version/#{name}")
73
73
  end.compact
74
74
 
@@ -332,8 +332,9 @@ module Grape
332
332
 
333
333
  type = if p[:type]
334
334
  p.delete(:type)
335
- elsif (entity = model.exposures[property_name][:using])
336
- parse_entity_name(entity)
335
+ else
336
+ exposure = model.exposures[property_name]
337
+ parse_entity_name(exposure[:using]) if exposure
337
338
  end
338
339
 
339
340
  if p.delete(:is_array)
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'API with minimally documented models' do
4
+ def app
5
+ entity_klass = Class.new do
6
+ def self.exposures
7
+ {}
8
+ end
9
+
10
+ def self.documentation
11
+ {
12
+ bar: { type: String },
13
+ foo: {}
14
+ }
15
+ end
16
+
17
+ def self.entity_name
18
+ 'Foo'
19
+ end
20
+ end
21
+
22
+ Class.new(Grape::API) do
23
+ format :json
24
+
25
+ get :foo do
26
+ end
27
+
28
+ add_swagger_documentation \
29
+ format: :json,
30
+ models: [Class.new(entity_klass)]
31
+ end
32
+ end
33
+
34
+ subject do
35
+ get '/swagger_doc/foo'
36
+ JSON.parse(last_response.body)['models']
37
+ end
38
+
39
+ it 'returns model' do
40
+ expect(subject).to eq(
41
+ 'Foo' => {
42
+ 'id' => 'Foo',
43
+ 'properties' => {
44
+ 'bar' => { 'type' => 'string' },
45
+ 'foo' => { '$ref' => nil }
46
+ }
47
+ }
48
+ )
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'API with Prefix and Namespace' do
4
+ def app
5
+ Class.new(Grape::API) do
6
+ format :json
7
+ prefix 'api'
8
+
9
+ namespace :status do
10
+ desc 'Retrieve status.'
11
+ get do
12
+ end
13
+ end
14
+
15
+ add_swagger_documentation
16
+ end
17
+ end
18
+
19
+ subject do
20
+ get '/api/swagger_doc'
21
+ expect(last_response.status).to eq 200
22
+ body = JSON.parse last_response.body
23
+ body['apis']
24
+ end
25
+
26
+ it 'gets array types' do
27
+ expect(subject).to eq([
28
+ { 'path' => '/status.{format}', 'description' => 'Operations about statuses' },
29
+ { 'path' => '/swagger_doc.{format}', 'description' => 'Operations about swagger_docs' }
30
+ ])
31
+ end
32
+ end
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.10.0
4
+ version: 0.10.1
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-03-10 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -230,7 +230,9 @@ files:
230
230
  - spec/api_models_spec.rb
231
231
  - spec/api_paths_spec.rb
232
232
  - spec/api_root_spec.rb
233
+ - spec/api_with_nil_types.rb
233
234
  - spec/api_with_path_versioning_spec.rb
235
+ - spec/api_with_prefix_and_namespace_spec.rb
234
236
  - spec/api_with_standalone_namespace_spec.rb
235
237
  - spec/array_params_spec.rb
236
238
  - spec/boolean_params_spec.rb
@@ -284,7 +286,9 @@ test_files:
284
286
  - spec/api_models_spec.rb
285
287
  - spec/api_paths_spec.rb
286
288
  - spec/api_root_spec.rb
289
+ - spec/api_with_nil_types.rb
287
290
  - spec/api_with_path_versioning_spec.rb
291
+ - spec/api_with_prefix_and_namespace_spec.rb
288
292
  - spec/api_with_standalone_namespace_spec.rb
289
293
  - spec/array_params_spec.rb
290
294
  - spec/boolean_params_spec.rb