api_sim 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/basic/Gemfile.lock +14 -12
- data/examples/basic/config.ru +1 -0
- data/lib/api_sim/built_app.rb +9 -9
- data/lib/api_sim/version.rb +1 -1
- data/lib/api_sim/view_helpers.rb +4 -0
- data/lib/api_sim/views/index.html.erb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c78fb49e9b8055b9c57b7d929f14e3ccdc550400
|
4
|
+
data.tar.gz: f366b4b136aa46472c39ec18e2be8e66032e01ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46122772e2556bc430916fa25d89f0cdbbb864ef1d980a6644674da31f7133038ca2b3af48ca393544e0d0077c686e7f811f54cbc0a363ba16827d6bfe639490
|
7
|
+
data.tar.gz: c42b0887edaed2dad8ffde3f39d6bf661607e89828041f2e6cda7729a927f55ec0374b21a6fe9761f7e01f9934b1bfb1c2c72942555be7db33e0acd592edf49a
|
data/examples/basic/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ../..
|
3
3
|
specs:
|
4
|
-
api_sim (
|
4
|
+
api_sim (5.0.0)
|
5
5
|
json-schema (>= 2.5)
|
6
|
+
mustermann (~> 1.0.0.beta2)
|
6
7
|
nokogiri (~> 1.6.7)
|
7
8
|
sinatra (~> 1.0)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
addressable (2.
|
13
|
-
|
14
|
-
|
13
|
+
addressable (2.5.1)
|
14
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
15
|
+
json-schema (2.8.0)
|
16
|
+
addressable (>= 2.4)
|
15
17
|
mini_portile2 (2.1.0)
|
16
|
-
|
18
|
+
mustermann (1.0.0)
|
19
|
+
nokogiri (1.6.8.1)
|
17
20
|
mini_portile2 (~> 2.1.0)
|
18
|
-
|
19
|
-
|
20
|
-
rack (1.6.4)
|
21
|
+
public_suffix (2.0.5)
|
22
|
+
rack (1.6.5)
|
21
23
|
rack-protection (1.5.3)
|
22
24
|
rack
|
23
|
-
sinatra (1.4.
|
25
|
+
sinatra (1.4.8)
|
24
26
|
rack (~> 1.5)
|
25
27
|
rack-protection (~> 1.4)
|
26
28
|
tilt (>= 1.3, < 3)
|
27
|
-
tilt (2.0.
|
29
|
+
tilt (2.0.7)
|
28
30
|
|
29
31
|
PLATFORMS
|
30
32
|
ruby
|
@@ -33,4 +35,4 @@ DEPENDENCIES
|
|
33
35
|
api_sim!
|
34
36
|
|
35
37
|
BUNDLED WITH
|
36
|
-
1.
|
38
|
+
1.14.6
|
data/examples/basic/config.ru
CHANGED
@@ -3,6 +3,7 @@ require 'api_sim'
|
|
3
3
|
ENDPOINT_JSON_SCHEMA = {type: "object", properties: {a: {type: "integer"}}}.to_json
|
4
4
|
|
5
5
|
app = ApiSim.build_app do
|
6
|
+
configure_endpoint 'GET', '/endpoint?queryParam=foo', 'Hi!', 200, {'X-CUSTOM-HEADER' => 'easy as abc'}, ENDPOINT_JSON_SCHEMA
|
6
7
|
configure_endpoint 'GET', '/endpoint', 'Hi!', 200, {'X-CUSTOM-HEADER' => 'easy as abc'}, ENDPOINT_JSON_SCHEMA
|
7
8
|
configure_endpoint 'GET', '/begin/:middle/end', 'You found an any-value path', 200, {'CONTENT-TYPE' => 'application/json'}
|
8
9
|
|
data/lib/api_sim/built_app.rb
CHANGED
@@ -16,8 +16,8 @@ module ApiSim
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.endpoints(endpoints = nil)
|
19
|
-
|
20
|
-
@endpoints
|
19
|
+
@endpoints = endpoints if endpoints
|
20
|
+
return @endpoints
|
21
21
|
end
|
22
22
|
|
23
23
|
get '/' do
|
@@ -25,18 +25,18 @@ module ApiSim
|
|
25
25
|
end
|
26
26
|
|
27
27
|
get '/ui/response/:method/*' do
|
28
|
-
@config = matcher(faux_request(http_method, route, faux_body))
|
28
|
+
@config = matcher(faux_request(method: http_method, path: route, body: faux_body, query: request.query_string))
|
29
29
|
erb :'responses/form.html', layout: :'layout.html'
|
30
30
|
end
|
31
31
|
|
32
32
|
get '/ui/requests/:method/*' do
|
33
|
-
@config = matcher(faux_request(http_method, route, faux_body))
|
33
|
+
@config = matcher(faux_request(method: http_method, path: route, body: faux_body, query: request.query_string))
|
34
34
|
|
35
35
|
erb :'requests/index.html', layout: :'layout.html'
|
36
36
|
end
|
37
37
|
|
38
38
|
post '/ui/response/:method/*' do
|
39
|
-
@config = matcher(faux_request(http_method, route, faux_body))
|
39
|
+
@config = matcher(faux_request(method: http_method, path: route, body: faux_body, query: request.query_string))
|
40
40
|
unless params['schema'].empty?
|
41
41
|
@errors = JSON::Validator.fully_validate(JSON.parse(params['schema']), params['body'])
|
42
42
|
if @errors.any?
|
@@ -72,7 +72,7 @@ module ApiSim
|
|
72
72
|
|
73
73
|
get '/requests/*' do
|
74
74
|
params = API_REQUEST_MATCHER.match(request.path) || halt(404)
|
75
|
-
endpoint = matcher(faux_request(params['method'], params['path']))
|
75
|
+
endpoint = matcher(faux_request(method: params['method'], path: params['path'], query: request.query_string))
|
76
76
|
|
77
77
|
halt(404) unless endpoint
|
78
78
|
endpoint.requests.to_json
|
@@ -112,7 +112,7 @@ module ApiSim
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def mimicked_request
|
115
|
-
faux_request(http_method, route, request.body)
|
115
|
+
faux_request(method: http_method, path: route, body: request.body, query: request.query_string)
|
116
116
|
end
|
117
117
|
|
118
118
|
def http_method
|
@@ -127,9 +127,9 @@ module ApiSim
|
|
127
127
|
self.class.endpoints.select { |matcher| matcher.matches?(request) }
|
128
128
|
end
|
129
129
|
|
130
|
-
def faux_request(method
|
130
|
+
def faux_request(method: '', path: '', body: StringIO.new(''), query: '')
|
131
131
|
body.rewind
|
132
|
-
Rack::Request.new({'rack.input' => body, 'REQUEST_METHOD' => method, 'PATH_INFO' => path})
|
132
|
+
Rack::Request.new({'rack.input' => body, 'REQUEST_METHOD' => method, 'PATH_INFO' => path, 'QUERY_STRING' => query})
|
133
133
|
end
|
134
134
|
|
135
135
|
def faux_body
|
data/lib/api_sim/version.rb
CHANGED
data/lib/api_sim/view_helpers.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
<tbody>
|
13
13
|
<% endpoints.each do |endpoint| %>
|
14
14
|
<tr>
|
15
|
-
<td><%= endpoint.http_method %> <%= endpoint.route %> <%= custom_matcher?(endpoint) %></td>
|
15
|
+
<td><%= endpoint.http_method %> <%= endpoint.route %><%= endpoint_query_string(endpoint) %> <%= custom_matcher?(endpoint) %></td>
|
16
16
|
<td><%= endpoint_match endpoint %></td>
|
17
17
|
<td>
|
18
18
|
<% if endpoint.readonly? %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_sim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.5
|
192
|
+
rubygems_version: 2.4.5
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: A DSL on top of sinatra for building application simulators
|