apiture 0.2.4 → 0.2.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: 6e2623ed6a8ed5d4afb84de3468a2477c7d38d50
4
- data.tar.gz: 8a5b0a97a0580bae322cbf5039ca6a680cc0f025
3
+ metadata.gz: 3c389fe29ffc40784aad87672a5b5a62446b991b
4
+ data.tar.gz: 61498b4c492c87b7595f5ac0de056cd1ce5171d7
5
5
  SHA512:
6
- metadata.gz: e7fd65d16903202142aa64920f1422f539c4c065ce4ef33533d0397e968a10667c870a408d83716dec25ffba25612208aee286cb3c516a4efe7e324f0f9b6243
7
- data.tar.gz: 80634719998c8acdf7546472e8c280ecca41bc0037d99f83f4883c20293bb16962cd76a54d764560ce22dbb5be761bca94837f7ccfa5796839f230889adfedb9
6
+ metadata.gz: 4ba415a71a9fe940c2a7d1ce747d2b7897f8c8dcdf714a5100c1655426406b77f90c1e4b4ffebd3d7f1f08ce03b64bb40bfc3ea9fc23cd72f8d84645dfc1744a
7
+ data.tar.gz: 6f511991995871b52f8c5328dfd9de974caf8459afebca9b594fcdbebc3c7ab821ad5a69b15c77cc045edbacc5c282537c2b1cb9e9ab0a3bacc49031609e6771
@@ -13,6 +13,11 @@ module Apiture
13
13
  class APIBuilder
14
14
  include Apiture::Utils::Inflections
15
15
 
16
+ ACCEPT = 'Accept'.freeze
17
+ CONTENT_TYPE = 'Content-Type'.freeze
18
+ CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded'.freeze
19
+ USER_AGENT = 'User-Agent'.freeze
20
+
16
21
  attr_reader :specification
17
22
 
18
23
  def initialize(specification)
@@ -80,14 +85,18 @@ module Apiture
80
85
  (spec.produces && spec.produces.first)
81
86
 
82
87
  use Apiture::Middleware::Debug
83
- use Apiture::Middleware::SetHeader, 'User-Agent' => "apiture-rb/#{Apiture::VERSION}"
88
+ use Apiture::Middleware::SetHeader, USER_AGENT => "apiture-rb/#{Apiture::VERSION}"
84
89
 
85
90
  if consumes
86
- use Apiture::Middleware::SetHeader, 'Content-Type' => consumes
91
+ use Apiture::Middleware::SetHeader, CONTENT_TYPE => consumes
92
+ else
93
+ if operation.parameters && operation.parameters.detect { |p| p.in == :form }
94
+ use Apiture::Middleware::SetHeader, CONTENT_TYPE => CONTENT_TYPE_FORM_URLENCODED
95
+ end
87
96
  end
88
97
 
89
98
  if produces
90
- use Apiture::Middleware::SetHeader, 'Accept' => produces
99
+ use Apiture::Middleware::SetHeader, ACCEPT => produces
91
100
  end
92
101
 
93
102
  security = operation.security || spec.security
@@ -76,8 +76,12 @@ module Apiture
76
76
  end
77
77
 
78
78
  conn.__send__(request_method) do |req|
79
- req.url env[:url].to_s, env[:params]
80
79
  req.headers.merge!(headers) if headers
80
+
81
+ req.url env[:url].to_s
82
+
83
+ req.params = env[:params]
84
+
81
85
  if body = env[:body]
82
86
  req.body = body
83
87
  end
@@ -1,3 +1,3 @@
1
1
  module Apiture
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calvin Yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler