pacto 0.3.1 → 0.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +29 -7
  4. data/.travis.yml +8 -1
  5. data/CONTRIBUTING.md +3 -6
  6. data/Gemfile +13 -2
  7. data/Guardfile +4 -4
  8. data/Procfile +1 -0
  9. data/README.md +47 -13
  10. data/Rakefile +66 -19
  11. data/TODO.md +33 -10
  12. data/bin/pacto +4 -0
  13. data/changelog.md +30 -0
  14. data/docs/configuration.md +69 -0
  15. data/docs/consumer.md +18 -0
  16. data/docs/cops.md +39 -0
  17. data/docs/forensics.md +66 -0
  18. data/docs/generation.md +65 -0
  19. data/docs/rake_tasks.md +10 -0
  20. data/docs/rspec.md +0 -0
  21. data/docs/samples.md +133 -0
  22. data/docs/server.md +34 -0
  23. data/docs/server_cli.md +18 -0
  24. data/docs/stenographer.md +20 -0
  25. data/features/configuration/strict_matchers.feature +10 -10
  26. data/features/evolve/existing_services.feature +12 -10
  27. data/features/generate/generation.feature +11 -11
  28. data/features/steps/pacto_steps.rb +17 -12
  29. data/features/stub/templates.feature +4 -4
  30. data/features/support/env.rb +21 -9
  31. data/features/validate/meta_validation.feature +9 -17
  32. data/features/validate/validation.feature +5 -6
  33. data/lib/pacto.rb +41 -33
  34. data/lib/pacto/actor.rb +5 -0
  35. data/lib/pacto/actors/from_examples.rb +67 -0
  36. data/lib/pacto/actors/json_generator.rb +20 -0
  37. data/lib/pacto/cli.rb +75 -0
  38. data/lib/pacto/cli/helpers.rb +20 -0
  39. data/lib/pacto/consumer.rb +80 -0
  40. data/lib/pacto/consumer/faraday_driver.rb +34 -0
  41. data/lib/pacto/contract.rb +48 -20
  42. data/lib/pacto/contract_builder.rb +125 -0
  43. data/lib/pacto/contract_factory.rb +31 -12
  44. data/lib/pacto/contract_files.rb +1 -0
  45. data/lib/pacto/contract_set.rb +12 -0
  46. data/lib/pacto/cops.rb +46 -0
  47. data/lib/pacto/cops/body_cop.rb +23 -0
  48. data/lib/pacto/cops/request_body_cop.rb +10 -0
  49. data/lib/pacto/cops/response_body_cop.rb +10 -0
  50. data/lib/pacto/{validators/response_header_validator.rb → cops/response_header_cop.rb} +9 -15
  51. data/lib/pacto/cops/response_status_cop.rb +18 -0
  52. data/lib/pacto/core/configuration.rb +16 -5
  53. data/lib/pacto/core/contract_registry.rb +13 -32
  54. data/lib/pacto/core/hook.rb +1 -0
  55. data/lib/pacto/core/http_middleware.rb +23 -0
  56. data/lib/pacto/core/investigation_registry.rb +60 -0
  57. data/lib/pacto/core/modes.rb +1 -0
  58. data/lib/pacto/core/pacto_request.rb +59 -0
  59. data/lib/pacto/core/pacto_response.rb +41 -0
  60. data/lib/pacto/dash.rb +9 -0
  61. data/lib/pacto/erb_processor.rb +1 -0
  62. data/lib/pacto/exceptions/invalid_contract.rb +1 -0
  63. data/lib/pacto/extensions.rb +3 -16
  64. data/lib/pacto/forensics/investigation_filter.rb +90 -0
  65. data/lib/pacto/forensics/investigation_matcher.rb +80 -0
  66. data/lib/pacto/generator.rb +31 -53
  67. data/lib/pacto/generator/filters.rb +8 -7
  68. data/lib/pacto/generator/hint.rb +26 -0
  69. data/lib/pacto/generator/native_contract_generator.rb +74 -0
  70. data/lib/pacto/hooks/erb_hook.rb +2 -1
  71. data/lib/pacto/investigation.rb +49 -0
  72. data/lib/pacto/logger.rb +1 -0
  73. data/lib/pacto/meta_schema.rb +12 -6
  74. data/lib/pacto/native_contract_factory.rb +60 -0
  75. data/lib/pacto/observers/stenographer.rb +42 -0
  76. data/lib/pacto/provider.rb +27 -0
  77. data/lib/pacto/rake_task.rb +25 -70
  78. data/lib/pacto/request_clause.rb +31 -29
  79. data/lib/pacto/request_pattern.rb +20 -3
  80. data/lib/pacto/resettable.rb +22 -0
  81. data/lib/pacto/response_clause.rb +5 -12
  82. data/lib/pacto/rspec.rb +38 -31
  83. data/lib/pacto/server.rb +4 -0
  84. data/lib/pacto/stubs/uri_pattern.rb +21 -11
  85. data/lib/pacto/stubs/webmock_adapter.rb +69 -34
  86. data/lib/pacto/swagger_contract_factory.rb +90 -0
  87. data/lib/pacto/test_helper.rb +37 -0
  88. data/lib/pacto/ui.rb +32 -2
  89. data/lib/pacto/uri.rb +2 -1
  90. data/lib/pacto/version.rb +2 -1
  91. data/pacto-server.gemspec +24 -0
  92. data/pacto.gemspec +13 -9
  93. data/resources/contract_schema.json +46 -18
  94. data/resources/draft-04.json +150 -0
  95. data/sample_apis/album/cover_api.rb +12 -0
  96. data/sample_apis/config.ru +25 -0
  97. data/sample_apis/echo_api.rb +26 -0
  98. data/sample_apis/files_api.rb +50 -0
  99. data/sample_apis/hello_api.rb +14 -0
  100. data/sample_apis/ping_api.rb +11 -0
  101. data/sample_apis/reverse_api.rb +20 -0
  102. data/samples/README.md +11 -0
  103. data/samples/Rakefile +2 -0
  104. data/samples/configuration.rb +33 -0
  105. data/samples/consumer.rb +15 -0
  106. data/samples/contracts/README.md +1 -0
  107. data/samples/contracts/contract.js +93 -0
  108. data/samples/contracts/get_album_cover.json +48 -0
  109. data/samples/contracts/localhost/api/echo.json +37 -0
  110. data/samples/contracts/localhost/api/ping.json +38 -0
  111. data/samples/cops.rb +30 -0
  112. data/samples/forensics.rb +54 -0
  113. data/samples/generation.rb +48 -0
  114. data/samples/rake_tasks.sh +7 -0
  115. data/samples/rspec.rb +1 -0
  116. data/samples/samples.rb +92 -0
  117. data/samples/scripts/bootstrap +2 -0
  118. data/samples/scripts/wrapper +11 -0
  119. data/samples/server.rb +24 -0
  120. data/samples/server_cli.sh +12 -0
  121. data/samples/stenographer.rb +17 -0
  122. data/spec/coveralls_helper.rb +1 -0
  123. data/spec/fabricators/contract_fabricator.rb +94 -0
  124. data/spec/fabricators/http_fabricator.rb +48 -0
  125. data/spec/fabricators/webmock_fabricator.rb +24 -0
  126. data/spec/{unit/data → fixtures/contracts}/contract.json +2 -2
  127. data/spec/fixtures/contracts/contract_with_examples.json +58 -0
  128. data/spec/{unit/data → fixtures/contracts}/simple_contract.json +5 -3
  129. data/spec/{integration/data → fixtures/contracts}/strict_contract.json +5 -3
  130. data/spec/{integration/data → fixtures/contracts}/templating_contract.json +3 -2
  131. data/spec/{integration/data/simple_contract.json → fixtures/deprecated_contracts/deprecated_contract.json} +2 -1
  132. data/spec/fixtures/swagger/petstore.yaml +101 -0
  133. data/spec/integration/e2e_spec.rb +19 -20
  134. data/spec/integration/forensics/integration_matcher_spec.rb +90 -0
  135. data/spec/integration/rspec_spec.rb +22 -25
  136. data/spec/integration/templating_spec.rb +7 -6
  137. data/spec/pacto/dummy_server.rb +4 -0
  138. data/spec/pacto/{server → dummy_server}/dummy.rb +7 -6
  139. data/spec/pacto/dummy_server/jruby_workaround_helper.rb +23 -0
  140. data/spec/pacto/{server → dummy_server}/playback_servlet.rb +3 -2
  141. data/spec/spec_helper.rb +16 -7
  142. data/spec/unit/actors/from_examples_spec.rb +70 -0
  143. data/spec/unit/actors/json_generator_spec.rb +105 -0
  144. data/spec/unit/pacto/actor_spec.rb +23 -0
  145. data/spec/unit/pacto/configuration_spec.rb +7 -6
  146. data/spec/unit/pacto/consumer/faraday_driver_spec.rb +40 -0
  147. data/spec/unit/pacto/contract_builder_spec.rb +89 -0
  148. data/spec/unit/pacto/contract_factory_spec.rb +62 -11
  149. data/spec/unit/pacto/contract_files_spec.rb +1 -0
  150. data/spec/unit/pacto/contract_set_spec.rb +36 -0
  151. data/spec/unit/pacto/contract_spec.rb +51 -39
  152. data/spec/unit/pacto/cops/body_cop_spec.rb +107 -0
  153. data/spec/unit/pacto/{validators/response_header_validator_spec.rb → cops/response_header_cop_spec.rb} +30 -19
  154. data/spec/unit/pacto/cops/response_status_cop_spec.rb +26 -0
  155. data/spec/unit/pacto/cops_spec.rb +75 -0
  156. data/spec/unit/pacto/core/configuration_spec.rb +6 -5
  157. data/spec/unit/pacto/core/contract_registry_spec.rb +16 -83
  158. data/spec/unit/pacto/core/http_middleware_spec.rb +36 -0
  159. data/spec/unit/pacto/core/investigation_spec.rb +62 -0
  160. data/spec/unit/pacto/core/modes_spec.rb +5 -4
  161. data/spec/unit/pacto/erb_processor_spec.rb +3 -2
  162. data/spec/unit/pacto/extensions_spec.rb +10 -20
  163. data/spec/unit/pacto/generator/filters_spec.rb +11 -10
  164. data/spec/unit/pacto/generator/native_contract_generator_spec.rb +171 -0
  165. data/spec/unit/{hooks → pacto/hooks}/erb_hook_spec.rb +18 -11
  166. data/spec/unit/pacto/investigation_registry_spec.rb +77 -0
  167. data/spec/unit/pacto/logger_spec.rb +6 -5
  168. data/spec/unit/pacto/meta_schema_spec.rb +5 -4
  169. data/spec/unit/pacto/native_contract_factory_spec.rb +26 -0
  170. data/spec/unit/pacto/pacto_spec.rb +13 -28
  171. data/spec/unit/pacto/request_clause_spec.rb +16 -51
  172. data/spec/unit/pacto/request_pattern_spec.rb +6 -5
  173. data/spec/unit/pacto/response_clause_spec.rb +6 -19
  174. data/spec/unit/pacto/server/playback_servlet_spec.rb +21 -18
  175. data/spec/unit/pacto/stubs/observers/stenographer_spec.rb +33 -0
  176. data/spec/unit/pacto/stubs/uri_pattern_spec.rb +39 -11
  177. data/spec/unit/pacto/stubs/webmock_adapter_spec.rb +67 -117
  178. data/spec/unit/pacto/swagger_contract_factory_spec.rb +56 -0
  179. data/spec/unit/pacto/uri_spec.rb +1 -0
  180. data/tasks/release.rake +57 -0
  181. metadata +247 -76
  182. data/.rubocop-todo.yml +0 -24
  183. data/.ruby-gemset +0 -1
  184. data/.ruby-version +0 -1
  185. data/CHANGELOG +0 -12
  186. data/features/validate/body_only.feature +0 -85
  187. data/lib/pacto/contract_list.rb +0 -17
  188. data/lib/pacto/contract_validator.rb +0 -29
  189. data/lib/pacto/core/validation_registry.rb +0 -40
  190. data/lib/pacto/stubs/webmock_helper.rb +0 -69
  191. data/lib/pacto/validation.rb +0 -54
  192. data/lib/pacto/validators/body_validator.rb +0 -49
  193. data/lib/pacto/validators/request_body_validator.rb +0 -26
  194. data/lib/pacto/validators/response_body_validator.rb +0 -26
  195. data/lib/pacto/validators/response_status_validator.rb +0 -24
  196. data/spec/pacto/server.rb +0 -2
  197. data/spec/unit/pacto/contract_list_spec.rb +0 -35
  198. data/spec/unit/pacto/contract_validator_spec.rb +0 -85
  199. data/spec/unit/pacto/core/validation_registry_spec.rb +0 -76
  200. data/spec/unit/pacto/core/validation_spec.rb +0 -60
  201. data/spec/unit/pacto/generator_spec.rb +0 -132
  202. data/spec/unit/pacto/stubs/webmock_helper_spec.rb +0 -20
  203. data/spec/unit/pacto/validators/body_validator_spec.rb +0 -118
  204. data/spec/unit/pacto/validators/response_status_validator_spec.rb +0 -20
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle install
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ # Polytrix should probably support different wrappers for different langauges
4
+ extension="${1##*.}"
5
+ if [ $extension = "rb" ];
6
+ then
7
+ bundle exec ruby "$@"
8
+ elif [ $extension = "sh" ];
9
+ then
10
+ bash "$@"
11
+ fi
@@ -0,0 +1,24 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'pacto/rspec'
3
+ require 'pacto/test_helper'
4
+
5
+ describe 'ping service' do
6
+ include Pacto::TestHelper
7
+
8
+ it 'pongs' do
9
+ with_pacto(
10
+ port: 6000,
11
+ backend_host: 'http://localhost:5000',
12
+ live: true,
13
+ stub: false,
14
+ generate: false,
15
+ directory: 'contracts'
16
+ ) do |pacto_endpoint|
17
+ # call your code
18
+ system "curl #{pacto_endpoint}/api/ping"
19
+ end
20
+
21
+ # check citations
22
+ expect(Pacto).to have_validated(:get, 'http://localhost:5000/api/ping')
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ # # Standalone server
2
+
3
+ # You can run Pacto as a server in order to test non-Ruby projects. In order to get the full set
4
+ # of options, run:
5
+ bundle exec pacto-server -h
6
+
7
+ # You probably want to run with the -sv option, which will display verbose output to stdout. You can
8
+ # run server that proxies to a live endpoint:
9
+ bundle exec pacto-server -sv --port 9000 --live http://example.com &
10
+ bundle exec pacto-server -sv --port 9001 --stub &
11
+
12
+ pkill -f pacto-server
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'pacto'
3
+ Pacto.configure do |c|
4
+ c.contracts_path = 'contracts'
5
+ end
6
+ contracts = Pacto.load_contracts('contracts', 'http://localhost:5000')
7
+ contracts.stub_providers
8
+
9
+ Pacto.simulate_consumer do
10
+ request 'Echo', values: nil, response: { status: 200 } # 0 contract violations
11
+ request 'Ping', values: nil, response: { status: 200 } # 0 contract violations
12
+ request 'Unknown (http://localhost:8000/404)', values: nil, response: { status: 500 } # 0 contract violations
13
+ end
14
+
15
+ Pacto.simulate_consumer :my_consumer do
16
+ playback 'pacto_stenographer.log'
17
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  unless ENV['NO_COVERAGE']
2
3
  require 'simplecov'
3
4
  require 'coveralls'
@@ -0,0 +1,94 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'pacto'
3
+ require 'hashie/mash'
4
+
5
+ # Fabricators for contracts or parts of contracts
6
+
7
+ Fabricator(:contract, from: Pacto::Contract) do
8
+ initialize_with { @_klass.new to_hash } # Hash based initialization
9
+ transient example_count: 0
10
+ name { 'Dummy Contract' }
11
+ file { 'file:///does/not/exist/dummy_contract.json' }
12
+ request { Fabricate(:request_clause).to_hash }
13
+ response { Fabricate(:response_clause).to_hash }
14
+ examples do |attr|
15
+ example_count = attr[:example_count]
16
+ if example_count
17
+ examples = attr[:example_count].times.each_with_object({}) do |i, h|
18
+ name = i.to_s
19
+ h[name] = Fabricate(:an_example, name: name)
20
+ end
21
+ examples
22
+ else
23
+ nil
24
+ end
25
+ end
26
+ end
27
+
28
+ Fabricator(:partial_contract, from: Pacto::Contract) do
29
+ initialize_with { @_klass.new to_hash } # Hash based initialization
30
+ name { 'Dummy Contract' }
31
+ file { 'file:///does/not/exist/dummy_contract.json' }
32
+ request { Fabricate(:request_clause).to_hash }
33
+ end
34
+
35
+ Fabricator(:request_clause, from: Pacto::RequestClause) do
36
+ initialize_with { @_klass.new to_hash } # Hash based initialization
37
+ host { 'example.com' }
38
+ http_method { 'GET' }
39
+ path { '/abcd' }
40
+ headers do
41
+ {
42
+ 'Server' => ['example.com'],
43
+ 'Connection' => ['Close'],
44
+ 'Content-Length' => [1234],
45
+ 'Via' => ['Some Proxy'],
46
+ 'User-Agent' => ['rspec']
47
+ }
48
+ end
49
+ params {}
50
+ end
51
+
52
+ Fabricator(:response_clause, from: Pacto::ResponseClause) do
53
+ initialize_with { @_klass.new to_hash } # Hash based initialization
54
+ status { 200 }
55
+ headers do
56
+ {
57
+ 'Content-Type' => 'application/json'
58
+ }
59
+ end
60
+ schema { Fabricate(:schema).to_hash }
61
+ end
62
+
63
+ Fabricator(:schema, from: Hashie::Mash) do
64
+ transient :version
65
+ initialize_with { @_klass.new to_hash } # Hash based initialization
66
+ type { 'object' }
67
+ required do |attrs|
68
+ attrs[:version] == :draft3 ? true : []
69
+ end
70
+ properties do
71
+ {
72
+ type: 'string'
73
+ }
74
+ end
75
+ end
76
+
77
+ Fabricator(:an_example, from: Hashie::Mash) do
78
+ initialize_with { @_klass.new to_hash } # Hash based initialization
79
+ transient name: 'default'
80
+ request do |attr|
81
+ {
82
+ body: {
83
+ message: "I am example request #{attr[:name]}"
84
+ }
85
+ }
86
+ end
87
+ response do |attr|
88
+ {
89
+ body: {
90
+ message: "I am example response #{attr[:name]}"
91
+ }
92
+ }
93
+ end
94
+ end
@@ -0,0 +1,48 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'pacto'
3
+ require 'hashie/mash'
4
+
5
+ # Fabricators for Pacto objects representing HTTP transactions
6
+
7
+ Fabricator(:pacto_request, from: Pacto::PactoRequest) do
8
+ initialize_with { @_klass.new @_transient_attributes } # Hash based initialization
9
+ # These transient attributes turn into the URI
10
+ transient host: 'example.com'
11
+ transient path: '/abcd'
12
+ transient params: {}
13
+ method { :get }
14
+ uri do |attr|
15
+ Addressable::URI.heuristic_parse(attr[:host]).tap do |uri|
16
+ uri.path = attr[:path]
17
+ uri.query_values = attr[:params]
18
+ end
19
+ end
20
+ headers do
21
+ {
22
+ 'Server' => ['example.com'],
23
+ 'Connection' => ['Close'],
24
+ 'Content-Length' => [1234],
25
+ 'Via' => ['Some Proxy'],
26
+ 'User-Agent' => ['rspec']
27
+ }
28
+ end
29
+ body do |attr|
30
+ case attr[:method]
31
+ when :get, :head, :options
32
+ nil
33
+ else
34
+ '{"data": "something"}'
35
+ end
36
+ end
37
+ end
38
+
39
+ Fabricator(:pacto_response, from: Pacto::PactoResponse) do
40
+ initialize_with { @_klass.new to_hash } # Hash based initialization
41
+ status { 200 }
42
+ headers do
43
+ {
44
+ 'Content-Type' => 'application/json'
45
+ }
46
+ end
47
+ body { '' }
48
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Fabricators for WebMock objects
3
+
4
+ Fabricator(:webmock_request_signature, from: WebMock::RequestSignature) do
5
+ initialize_with do
6
+ uri = _transient_attributes[:uri]
7
+ method = _transient_attributes[:method]
8
+ uri = Addressable::URI.heuristic_parse(uri) unless uri.is_a? Addressable::URI
9
+ WebMock::RequestSignature.new method, uri
10
+ end
11
+ transient method: :get
12
+ transient uri: 'www.example.com'
13
+ end
14
+
15
+ Fabricator(:webmock_request_pattern, from: Pacto::RequestPattern) do
16
+ initialize_with do
17
+ uri = _transient_attributes[:uri]
18
+ method = _transient_attributes[:method]
19
+ uri = Addressable::URI.heuristic_parse(uri) unless uri.is_a? Addressable::URI
20
+ Pacto::RequestPattern.new method, uri
21
+ end
22
+ transient method: :get
23
+ transient uri: 'www.example.com'
24
+ end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "request": {
3
- "method": "GET",
3
+ "http_method": "GET",
4
4
  "path": "/hello_world",
5
5
  "headers": {
6
6
  "Accept": "application/json"
@@ -13,7 +13,7 @@
13
13
  "headers": {
14
14
  "Content-Type": "application/json"
15
15
  },
16
- "body": {
16
+ "schema": {
17
17
  "description": "A simple response",
18
18
  "type": "object",
19
19
  "properties": {
@@ -0,0 +1,58 @@
1
+ {
2
+ "request": {
3
+ "headers": {
4
+ },
5
+ "http_method": "get",
6
+ "path": "/api/echo",
7
+ "schema": {
8
+ "type": "object",
9
+ "required": ["message"],
10
+ "properties": {
11
+ "message": {
12
+ "type": "string"
13
+ }
14
+ }
15
+ }
16
+ },
17
+ "response": {
18
+ "headers": {
19
+ "Content-Type": "application/json"
20
+ },
21
+ "status": 200,
22
+ "schema": {
23
+ "type": "object",
24
+ "required": ["message"],
25
+ "properties": {
26
+ "message": {
27
+ "type": "string"
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "examples": {
33
+ "max": {
34
+ "request": {
35
+ "body": {
36
+ "message": "max"
37
+ }
38
+ },
39
+ "response": {
40
+ "body": {
41
+ "message": "max"
42
+ }
43
+ }
44
+ },
45
+ "12345": {
46
+ "request": {
47
+ "body": {
48
+ "message": 12345
49
+ }
50
+ },
51
+ "response": {
52
+ "body": {
53
+ "message": 12345
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
@@ -1,6 +1,7 @@
1
1
  {
2
+ "name": "Simple Contract",
2
3
  "request": {
3
- "method": "GET",
4
+ "http_method": "GET",
4
5
  "path": "/hello",
5
6
  "headers": {
6
7
  "Accept": "application/json"
@@ -10,8 +11,9 @@
10
11
 
11
12
  "response": {
12
13
  "status": 200,
13
- "headers": { "Content-Type": "application/json" },
14
- "body": {
14
+ "headers": { "Content-Type": "application/json", "Vary": "Accept" },
15
+ "schema": {
16
+ "$schema": "http://json-schema.org/draft-03/schema#",
15
17
  "type": "object",
16
18
  "required": true,
17
19
  "properties": {
@@ -1,6 +1,7 @@
1
1
  {
2
+ "name": "Strict Contract",
2
3
  "request": {
3
- "method": "GET",
4
+ "http_method": "GET",
4
5
  "path": "/strict",
5
6
  "headers": {
6
7
  "Accept": "application/json"
@@ -11,7 +12,8 @@
11
12
  "response": {
12
13
  "status": 200,
13
14
  "headers": { "Content-Type": "application/json" },
14
- "body": {
15
+ "schema": {
16
+ "$schema": "http://json-schema.org/draft-03/schema#",
15
17
  "type": "object",
16
18
  "required": true,
17
19
  "properties": {
@@ -30,4 +32,4 @@
30
32
  }
31
33
  }
32
34
  }
33
- }
35
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "request": {
3
- "method": "GET",
3
+ "http_method": "GET",
4
4
  "path": "/echo",
5
5
  "headers": {
6
6
  "Accept": "application/json",
@@ -14,7 +14,8 @@
14
14
  "response": {
15
15
  "status": 200,
16
16
  "headers": { "Content-Type": "application/json" },
17
- "body": {
17
+ "schema": {
18
+ "$schema": "http://json-schema.org/draft-03/schema#",
18
19
  "type": "object",
19
20
  "required": true,
20
21
  "properties": {
@@ -12,6 +12,7 @@
12
12
  "status": 200,
13
13
  "headers": { "Content-Type": "application/json", "Vary": "Accept" },
14
14
  "body": {
15
+ "$schema": "http://json-schema.org/draft-03/schema#",
15
16
  "type": "object",
16
17
  "required": true,
17
18
  "properties": {
@@ -19,4 +20,4 @@
19
20
  }
20
21
  }
21
22
  }
22
- }
23
+ }
@@ -0,0 +1,101 @@
1
+ swagger: 2.0
2
+ info:
3
+ version: 1.0.0
4
+ title: Swagger Petstore
5
+ license:
6
+ name: MIT
7
+ host: petstore.swagger.wordnik.com
8
+ basePath: /v1
9
+ schemes:
10
+ - http
11
+ consumes:
12
+ - application/json
13
+ produces:
14
+ - application/json
15
+ paths:
16
+ /pets:
17
+ get:
18
+ summary: List all pets
19
+ operationId: listPets
20
+ tags:
21
+ - pets
22
+ parameters:
23
+ - name: limit
24
+ in: query
25
+ description: How many items to return at one time (max 100)
26
+ required: false
27
+ type: integer
28
+ format: int32
29
+ responses:
30
+ 200:
31
+ description: An paged array of pets
32
+ headers:
33
+ - x-next:
34
+ type: string
35
+ description: A link to the next page of responses
36
+ schema:
37
+ $ref: Pets
38
+ default:
39
+ description: unexpected error
40
+ schema:
41
+ $ref: Error
42
+ post:
43
+ summary: Create a pet
44
+ operationId: createPets
45
+ tags:
46
+ - pets
47
+ responses:
48
+ 201:
49
+ description: Null response
50
+ default:
51
+ description: unexpected error
52
+ schema:
53
+ $ref: Error
54
+ /pets/{petId}:
55
+ get:
56
+ summary: Info for a specific pet
57
+ operationId: showPetById
58
+ tags:
59
+ - pets
60
+ parameters:
61
+ - name: petId
62
+ in: path
63
+ description: The id of the pet to retrieve
64
+ type: string
65
+ responses:
66
+ 200:
67
+ description: Expected response to a valid request
68
+ schema:
69
+ $ref: Pets
70
+ default:
71
+ description: unexpected error
72
+ schema:
73
+ $ref: Error
74
+ definitions:
75
+ Pet:
76
+ required:
77
+ - id
78
+ - name
79
+ properties:
80
+ id:
81
+ type: integer
82
+ format: int64
83
+ name:
84
+ type: string
85
+ tag:
86
+ type: string
87
+ Pets:
88
+ type: array
89
+ items:
90
+ $ref: Pet
91
+ Error:
92
+ required:
93
+ - code
94
+ - message
95
+ properties:
96
+ code:
97
+ type: integer
98
+ format: int32
99
+ message:
100
+ type: string
101
+