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 +4 -4
- data/lib/apiture/api_builder.rb +12 -3
- data/lib/apiture/request_context.rb +5 -1
- data/lib/apiture/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c389fe29ffc40784aad87672a5b5a62446b991b
|
4
|
+
data.tar.gz: 61498b4c492c87b7595f5ac0de056cd1ce5171d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba415a71a9fe940c2a7d1ce747d2b7897f8c8dcdf714a5100c1655426406b77f90c1e4b4ffebd3d7f1f08ce03b64bb40bfc3ea9fc23cd72f8d84645dfc1744a
|
7
|
+
data.tar.gz: 6f511991995871b52f8c5328dfd9de974caf8459afebca9b594fcdbebc3c7ab821ad5a69b15c77cc045edbacc5c282537c2b1cb9e9ab0a3bacc49031609e6771
|
data/lib/apiture/api_builder.rb
CHANGED
@@ -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,
|
88
|
+
use Apiture::Middleware::SetHeader, USER_AGENT => "apiture-rb/#{Apiture::VERSION}"
|
84
89
|
|
85
90
|
if consumes
|
86
|
-
use Apiture::Middleware::SetHeader,
|
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,
|
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
|
data/lib/apiture/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|