swaggable 0.5.2 → 0.5.3

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: 950abcc534dfbb5b2539b33e20ab050c91ef91c3
4
- data.tar.gz: 58864e41f69769a787de1701863dab7cc82317b9
3
+ metadata.gz: a0ba12b2dc9c54ce2f6920b7d6fd6c45fe056ff5
4
+ data.tar.gz: 27874e95a2cfcdd88f67c3ef2bbd024660c979a3
5
5
  SHA512:
6
- metadata.gz: 4b87287e8876c10e78757bef380a2ff2b8d8f4d225eb2abd439f18566ed895c95bbc22958d1af84ed4ca865f993d7db86368b1b3fc6572a100baed39f481181f
7
- data.tar.gz: 8bc007dce6dbc50d8e6ccc47401f672dfe57d5de8502e02a80a64bbbf60db99646e64a66eef490c36973f1ecaa6b72d0034db70f921212edbbf3b29a0a687723
6
+ metadata.gz: bf44a0e08c55b0f6e948f73d711d7c758b77ae00a90dad0007451c1102265f0c44a928c868827be588504f380797f6c548826af5ab68c260bfcae7e4014712e2
7
+ data.tar.gz: faab31754af448942d0e7f9012c233a28e004c718a750c2adbd450082ecdd5c1f3b40fa1c3921e199ed6b6a20b5f52537a6c7953b0e6c689c50d08b820088cbd
@@ -34,11 +34,11 @@ module Swaggable
34
34
  end
35
35
 
36
36
  def consumes
37
- @consumes ||= []
37
+ @consumes ||= Set.new
38
38
  end
39
39
 
40
40
  def produces
41
- @produces ||= []
41
+ @produces ||= Set.new
42
42
  end
43
43
 
44
44
  def configure &block
@@ -62,9 +62,11 @@ module Swaggable
62
62
  def import_endpoint grape_endpoint, api_endpoint, grape
63
63
  api_endpoint.verb = grape_endpoint.route_method.downcase
64
64
  api_endpoint.summary = grape_endpoint.route_description
65
- api_endpoint.produces << "application/#{grape.format}" if grape.format
66
65
  api_endpoint.path = extract_path(grape_endpoint, grape)
67
66
 
67
+ api_endpoint.produces.merge grape.content_types.values
68
+ api_endpoint.consumes.merge grape.content_types.values
69
+
68
70
  api_endpoint.tags.add_new do |t|
69
71
  t.name = grape.name
70
72
  end
@@ -52,8 +52,8 @@ module Swaggable
52
52
  def serialize_endpoint endpoint
53
53
  {
54
54
  tags: endpoint.tags.map(&:name),
55
- consumes: endpoint.consumes,
56
- produces: endpoint.produces,
55
+ consumes: endpoint.consumes.to_a,
56
+ produces: endpoint.produces.to_a,
57
57
  parameters: endpoint.parameters.map{|p| serialize_parameter p },
58
58
  responses: serialize_responses(endpoint.responses),
59
59
  }.
@@ -1,3 +1,3 @@
1
1
  module Swaggable
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
@@ -34,13 +34,13 @@ RSpec.describe 'Swaggable::EndpointDefinition' do
34
34
  it 'has consumes' do
35
35
  format = double('format')
36
36
  subject.consumes << format
37
- expect(subject.consumes).to eq [format]
37
+ expect(subject.consumes.to_a).to eq [format]
38
38
  end
39
39
 
40
40
  it 'has produces' do
41
41
  format = double('format')
42
42
  subject.produces << format
43
- expect(subject.produces).to eq [format]
43
+ expect(subject.produces.to_a).to eq [format]
44
44
  end
45
45
 
46
46
  it 'has parameters' do
@@ -51,11 +51,20 @@ RSpec.describe 'Swaggable::GrapeAdapter' do
51
51
  expect(api.endpoints.first.summary).to eq 'My endpoint'
52
52
  end
53
53
 
54
- it 'sets format' do
54
+ it 'sets produces' do
55
55
  grape.format :json
56
+ grape.content_type :xml, 'application/xml'
56
57
  grape.post { }
57
58
  do_import
58
- expect(api.endpoints.first.produces).to eq ['application/json']
59
+ expect(api.endpoints.first.produces.to_a).to eq ['application/json', 'application/xml']
60
+ end
61
+
62
+ it 'sets consumes' do
63
+ grape.format :json
64
+ grape.content_type :xml, 'application/xml'
65
+ grape.post { }
66
+ do_import
67
+ expect(api.endpoints.first.consumes.to_a).to eq ['application/json', 'application/xml']
59
68
  end
60
69
 
61
70
  describe 'path' do
@@ -116,8 +116,8 @@ RSpec.describe 'Integration' do
116
116
  expect(api.endpoints.first.parameters.first.name).to eq 'include_comments_count'
117
117
  expect(api.endpoints.first.responses.first).to be api.endpoints.first.responses[200]
118
118
  expect(api.endpoints.first.responses.first.description).to eq 'Success'
119
- expect(api.endpoints.first.consumes).to eq [:json]
120
- expect(api.endpoints.first.produces).to eq [:json]
119
+ expect(api.endpoints.first.consumes.to_a).to eq [:json]
120
+ expect(api.endpoints.first.produces.to_a).to eq [:json]
121
121
  end
122
122
 
123
123
  it 'renders proper swagger JSON' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swaggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Morales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forwarding_dsl