openapi_first 1.0.0.beta1 → 1.0.0.beta3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2248133fb2e0b761fb314629dcbfa7c9a6b7e0ac03b59887fe158968b17ed827
4
- data.tar.gz: b0012d8af3c9dee1fa94334be7890e260f0173946129b53ec8f930f768f8de28
3
+ metadata.gz: 800354f7ac2847fb16987e6961589aaebb84c161f3b76ea652a00a4cf8762fbe
4
+ data.tar.gz: f443b72fa8ce1103bfc5a7b30367ce96f84e0dc7ad137722424cab0ac0c13357
5
5
  SHA512:
6
- metadata.gz: c615c847efcd10cfd145bcc99ede55da2eaa76fe91b9d0ab3fdb159c20b6cc314309f583ba0b784c3e3493a7a534ed1836309807c549bd8c40b226f2f9bf77e9
7
- data.tar.gz: 83c476b9b67ce15ad71e052af8360e013659da13fbbd8f86a55bae9d4bbcf08f4ac291187dfccc5786e957c65d2a3124366f007998c675b4a3e29bccaecf332a
6
+ metadata.gz: e454ee38c95a21915869e5feae0f38f65e0aa9a0a5001b6b752043fa379836164af1bf7eac9bcff192822d66053dda00d6dfa787296cce82bccf346d218f4c6c
7
+ data.tar.gz: 11a0a0ac1e1bbd350d1edfe1dcae4ccae15bcfe2f1863320f30f554c3ad16934b07891c578225d2d7d128c3cb7dafd4093407c1c153713567db4db3d9c99c938
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 1.0.0.beta3
6
+
7
+ - Remove obsolete dependency: deep_merge
8
+ - Remove obsolete dependency: hanami-utils
9
+
10
+ ## 1.0.0.beta2
11
+ - Fixed dependencies. Remove unused code.
12
+
3
13
  ## 1.0.0.beta1
4
14
  - Removed: `OpenapiFirst::Responder` and `OpenapiFirst::RackResponder`
5
15
  - Removed: `OpenapiFirst.app` and `OpenapiFirst.middleware`
data/Gemfile.lock CHANGED
@@ -1,14 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_first (1.0.0.beta1)
5
- deep_merge (>= 1.2.1)
4
+ openapi_first (1.0.0.beta3)
6
5
  hanami-router (~> 2.0.0)
7
- hanami-utils (~> 2.0.0)
8
6
  json_refs (~> 0.1, >= 0.1.7)
9
7
  json_schemer (~> 0.2.16)
10
8
  multi_json (~> 1.14)
11
- mustermann-contrib (~> 3.0.0)
9
+ openapi_parameters (~> 0.2)
12
10
  rack (>= 2.2, < 4.0)
13
11
 
14
12
  GEM
@@ -16,14 +14,7 @@ GEM
16
14
  specs:
17
15
  ast (2.4.2)
18
16
  coderay (1.1.3)
19
- concurrent-ruby (1.2.2)
20
- deep_merge (1.2.2)
21
17
  diff-lcs (1.5.0)
22
- dry-core (1.0.0)
23
- concurrent-ruby (~> 1.0)
24
- zeitwerk (~> 2.6)
25
- dry-transformer (1.0.1)
26
- zeitwerk (~> 2.6)
27
18
  ecma-re-validator (0.4.0)
28
19
  regexp_parser (~> 2.2)
29
20
  hana (1.3.7)
@@ -31,10 +22,6 @@ GEM
31
22
  mustermann (~> 3.0)
32
23
  mustermann-contrib (~> 3.0)
33
24
  rack (~> 2.0)
34
- hanami-utils (2.0.3)
35
- concurrent-ruby (~> 1.0)
36
- dry-core (~> 1.0, < 2)
37
- dry-transformer (~> 1.0, < 2)
38
25
  hansi (0.2.1)
39
26
  json (2.6.3)
40
27
  json_refs (0.1.7)
@@ -51,7 +38,7 @@ GEM
51
38
  mustermann-contrib (3.0.0)
52
39
  hansi (~> 0.2.0)
53
40
  mustermann (= 3.0.0)
54
- openapi_parameters (0.2.0)
41
+ openapi_parameters (0.2.1)
55
42
  rack (>= 2.2)
56
43
  zeitwerk (~> 2.6)
57
44
  parallel (1.22.1)
@@ -104,7 +91,6 @@ PLATFORMS
104
91
  DEPENDENCIES
105
92
  bundler (~> 2)
106
93
  openapi_first!
107
- openapi_parameters (~> 0.2, <= 2.0.0)
108
94
  pry
109
95
  rack-test (~> 1)
110
96
  rake (~> 13)
data/README.md CHANGED
@@ -2,28 +2,26 @@
2
2
 
3
3
  [![Join the chat at https://gitter.im/openapi_first/community](https://badges.gitter.im/openapi_first/community.svg)](https://gitter.im/openapi_first/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
5
- OpenapiFirst helps to implement HTTP APIs based on an [OpenApi](https://www.openapis.org/) API description. The idea is that you create an API description first, then add code that returns data and implements your business logic and be done.
5
+ OpenapiFirst helps to implement HTTP APIs based on an [OpenAPI](https://www.openapis.org/) API description.
6
6
 
7
- Start with writing an OpenAPI file that describes the API, which you are about to implement. Use a [validator](https://github.com/stoplightio/spectral/) to make sure the file is valid.
7
+ It provides these Rack middlewares:
8
8
 
9
- OpenapiFirst consists of these Rack middlewares:
9
+ - [`OpenapiFirst::RequestValidation`](#request-validation) Validates the request against the API description and returns 400 if the request is invalid.
10
+ - [`OpenapiFirst::ResponseValidation`](#response-validation) Validates the response and raises an exception if the response body is invalid.
11
+ - [`OpenapiFirst::Router`](#openapifirstrouter) – This internal middleware is added automatically when using request/response validation. It adds the OpenAPI operation for the current request to the Rack env.
10
12
 
11
- - [`OpenapiFirst::RequestValidation`](#OpenapiFirst::RequestValidation) – Validates the request against the API description and returns 400 if the request is invalid.
12
- - [`OpenapiFirst::ResponseValidation`](#OpenapiFirst::ResponseValidation) Validates the response and raises an exception if the response body is invalid.
13
- - [`OpenapiFirst::Router`](#OpenapiFirst::Router) – This internal middleware is added automatically when using request/response validation. It adds the OpenAPI operation for the current request to the Rack env or returns 404 if no operation was found.
13
+ ## Request Validation
14
14
 
15
- ## OpenapiFirst::RequestValidation
16
-
17
- This middleware returns a 400 status code with a body that describes the error if the request is not valid.
15
+ The `OpenapiFirst::RequestValidation` middleware returns a 400 status code with a body that describes the error if the request is not valid.
18
16
 
19
17
  ```ruby
20
18
  use OpenapiFirst::RequestValidation, spec: 'openapi.yaml'
21
19
  ```
22
20
 
23
- This will add these fields to the Rack env:
24
- - `env[OpenapiFirst::OPERATION]` – The Operation object for the current request. This is an instance of `OpenapiFirst::Operation`.
21
+ It adds these fields to the Rack env:
25
22
  - `env[OpenapiFirst::PARAMS]` – The parsed parameters (query, path) for the current request (string keyed)
26
23
  - `env[OpenapiFirst::REQUEST_BODY]` – The parsed request body (string keyed)
24
+ - `env[OpenapiFirst::OPERATION]` (Added via Router) – The Operation object for the current request. This is an instance of `OpenapiFirst::Operation`.
27
25
 
28
26
  ### Options and defaults
29
27
 
@@ -54,7 +52,6 @@ content-type: "application/vnd.api+json"
54
52
 
55
53
  ### Parameters
56
54
 
57
-
58
55
  The `RequestValidation` middleware adds `env[OpenapiFirst::PARAMS]` (or `env['openapi.params']` ) with the converted query and path parameters. This only includes the parameters that are defined in the API description. It supports every [`style` and `explode` value as described](https://spec.openapis.org/oas/latest.html#style-examples) in the OpenAPI 3.0 and 3.1 specs. So you can do things these:
59
56
 
60
57
  ```ruby
@@ -85,10 +82,9 @@ Request validation fails if request includes a property with `readOnly: true`.
85
82
 
86
83
  Response validation fails if response body includes a property with `writeOnly: true`.
87
84
 
88
- ## OpenapiFirst::ResponseValidation
89
-
90
- This middleware is especially useful when testing. It _always_ raises an error if the response is not valid.
85
+ ## Response validation
91
86
 
87
+ The `OpenapiFirst::ResponseValidation` middleware is especially useful when testing. It _always_ raises an error if the response is not valid.
92
88
 
93
89
  ```ruby
94
90
  use OpenapiFirst::ResponseValidation, spec: 'openapi.yaml' if ENV['RACK_ENV'] == 'test'
@@ -102,7 +98,7 @@ use OpenapiFirst::ResponseValidation, spec: 'openapi.yaml' if ENV['RACK_ENV'] ==
102
98
 
103
99
  ## OpenapiFirst::Router
104
100
 
105
- This middleware is used automatically, but you can add it to the top of your middleware stack if you want to change configuration.
101
+ This middleware is used automatically, but you can add it to the top of your middleware stack if you want to customize the behavior via options.
106
102
 
107
103
  ```ruby
108
104
  use OpenapiFirst::Router, spec: './openapi/openapi.yaml'
@@ -1,14 +1,12 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- openapi_first (1.0.0.beta1)
5
- deep_merge (>= 1.2.1)
4
+ openapi_first (1.0.0.beta3)
6
5
  hanami-router (~> 2.0.0)
7
- hanami-utils (~> 2.0.0)
8
6
  json_refs (~> 0.1, >= 0.1.7)
9
7
  json_schemer (~> 0.2.16)
10
8
  multi_json (~> 1.14)
11
- mustermann-contrib (~> 3.0.0)
9
+ openapi_parameters (~> 0.2)
12
10
  rack (>= 2.2, < 4.0)
13
11
 
14
12
  GEM
@@ -28,7 +26,6 @@ GEM
28
26
  openapi_parser (~> 1.0)
29
27
  rack (>= 1.5)
30
28
  concurrent-ruby (1.2.2)
31
- deep_merge (1.2.2)
32
29
  dry-core (1.0.0)
33
30
  concurrent-ruby (~> 1.0)
34
31
  zeitwerk (~> 2.6)
@@ -37,8 +34,6 @@ GEM
37
34
  concurrent-ruby (~> 1.0)
38
35
  dry-core (~> 1.0, < 2)
39
36
  zeitwerk (~> 2.6)
40
- dry-transformer (1.0.1)
41
- zeitwerk (~> 2.6)
42
37
  dry-types (1.7.1)
43
38
  concurrent-ruby (~> 1.0)
44
39
  dry-core (~> 1.0)
@@ -61,10 +56,6 @@ GEM
61
56
  mustermann (~> 3.0)
62
57
  mustermann-contrib (~> 3.0)
63
58
  rack (~> 2.0)
64
- hanami-utils (2.0.3)
65
- concurrent-ruby (~> 1.0)
66
- dry-core (~> 1.0, < 2)
67
- dry-transformer (~> 1.0, < 2)
68
59
  hansi (0.2.1)
69
60
  i18n (1.12.0)
70
61
  concurrent-ruby (~> 1.0)
@@ -86,24 +77,27 @@ GEM
86
77
  mustermann (= 3.0.0)
87
78
  mustermann-grape (1.0.2)
88
79
  mustermann (>= 1.0.0)
89
- nio4r (2.5.8)
80
+ nio4r (2.5.9)
81
+ openapi_parameters (0.2.1)
82
+ rack (>= 2.2)
83
+ zeitwerk (~> 2.6)
90
84
  openapi_parser (1.0.0)
91
- puma (6.2.0)
85
+ puma (6.2.2)
92
86
  nio4r (~> 2.0)
93
87
  rack (2.2.6.4)
94
88
  rack-accept (0.4.5)
95
89
  rack (>= 0.4)
96
- rack-protection (3.0.5)
90
+ rack-protection (3.0.6)
97
91
  rack
98
92
  regexp_parser (2.8.0)
99
- roda (3.66.0)
93
+ roda (3.67.0)
100
94
  rack
101
95
  ruby2_keywords (0.0.5)
102
96
  seg (1.2.0)
103
- sinatra (3.0.5)
97
+ sinatra (3.0.6)
104
98
  mustermann (~> 3.0)
105
99
  rack (~> 2.2, >= 2.2.4)
106
- rack-protection (= 3.0.5)
100
+ rack-protection (= 3.0.6)
107
101
  tilt (~> 2.0)
108
102
  syro (3.2.1)
109
103
  rack (>= 1.6.0)
@@ -19,7 +19,6 @@ app = Class.new(Hanami::API) do
19
19
  end
20
20
  end.new
21
21
 
22
- use OpenapiFirst::Router, spec: File.absolute_path('./openapi.yaml', __dir__)
23
- use OpenapiFirst::RequestValidation
22
+ use OpenapiFirst::RequestValidation, spec: File.absolute_path('./openapi.yaml', __dir__)
24
23
 
25
24
  run app
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'multi_json'
4
+ require 'openapi_first'
5
+
6
+ app = Rack::Builder.new do
7
+ use OpenapiFirst::RequestValidation, spec: File.expand_path('./openapi.yaml', __dir__)
8
+
9
+ handlers = {
10
+ 'find_thing' => lambda do |env|
11
+ params = env[OpenapiFirst::PARAMS]
12
+ body = MultiJson.dump(hello: 'world', id: params.fetch('id'))
13
+ [200, { 'Content-Type' => 'application/json' }, [body]]
14
+ end,
15
+ 'find_things' => lambda do |_env|
16
+ body = MultiJson.dump(hello: 'world')
17
+ [200, { 'Content-Type' => 'application/json' }, [body]]
18
+ end,
19
+ 'create_thing' => lambda do |_env|
20
+ body = MultiJson.dump(hello: 'world')
21
+ [201, { 'Content-Type' => 'application/json' }, [body]]
22
+ end
23
+ }
24
+
25
+ not_found = ->(_env) { [404, {}, []] }
26
+
27
+ run lambda do |env|
28
+ handlers.fetch(env[OpenapiFirst::OPERATION]&.operation_id, not_found).call(env)
29
+ end
30
+ end
31
+
32
+ run app
@@ -2,21 +2,24 @@
2
2
 
3
3
  require 'multi_json'
4
4
  require 'openapi_first'
5
+ require 'hanami/api'
5
6
 
6
- namespace = Module.new do
7
- def self.find_thing(params, _res)
8
- { hello: 'world', id: params.fetch(:id) }
7
+ app = Class.new(Hanami::API) do
8
+ get '/hello/:id' do
9
+ json(hello: 'world', id: params.fetch(:id))
9
10
  end
10
11
 
11
- def self.find_things(_params, _res)
12
- [{ hello: 'world' }]
12
+ get '/hello' do
13
+ json([{ hello: 'world' }])
13
14
  end
14
15
 
15
- def self.create_thing(_params, res)
16
- res.status = 201
17
- { hello: 'world' }
16
+ post '/hello' do
17
+ status 201
18
+ json(hello: 'world')
18
19
  end
19
- end
20
+ end.new
20
21
 
21
- oas_path = File.absolute_path('./openapi.yaml', __dir__)
22
- run OpenapiFirst.app(oas_path, namespace: namespace, response_validation: true)
22
+ use OpenapiFirst::RequestValidation, spec: File.absolute_path('./openapi.yaml', __dir__)
23
+ use OpenapiFirst::ResponseValidation
24
+
25
+ run app
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'multi_json'
4
+ require 'openapi_first'
5
+ require 'sinatra'
6
+
7
+ class SinatraWithOpenapiFirstExample < Sinatra::Base
8
+ set :environment, :production
9
+
10
+ get '/hello/:id' do
11
+ content_type :json
12
+ MultiJson.dump(hello: 'world', id: params.fetch('id'))
13
+ end
14
+
15
+ get '/hello' do
16
+ content_type :json
17
+ MultiJson.dump([{ hello: 'world' }])
18
+ end
19
+
20
+ post '/hello' do
21
+ content_type :json
22
+ status 201
23
+ MultiJson.dump(hello: 'world')
24
+ end
25
+ end
26
+
27
+ use OpenapiFirst::RequestValidation, spec: File.absolute_path('./openapi.yaml', __dir__)
28
+
29
+ run SinatraWithOpenapiFirstExample
@@ -1,23 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'hanami/utils/string'
4
- require 'hanami/utils/hash'
5
- require 'deep_merge/core'
6
-
7
3
  module OpenapiFirst
8
4
  module Utils
9
- def self.deep_merge!(dest, source)
10
- DeepMerge.deep_merge!(source, dest)
11
- end
12
-
13
- def self.underscore(string)
14
- Hanami::Utils::String.underscore(string)
15
- end
16
-
17
- def self.classify(string)
18
- Hanami::Utils::String.classify(string)
19
- end
20
-
21
5
  class StringKeyedHash
22
6
  def initialize(original)
23
7
  @orig = original
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiFirst
4
- VERSION = '1.0.0.beta1'
4
+ VERSION = '1.0.0.beta3'
5
5
  end
data/lib/openapi_first.rb CHANGED
@@ -28,22 +28,4 @@ module OpenapiFirst
28
28
  resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
29
29
  Definition.new(resolved, spec_path)
30
30
  end
31
-
32
- def self.app(
33
- spec,
34
- namespace:,
35
- router_raise_error: false,
36
- request_validation_raise_error: false,
37
- response_validation: false
38
- )
39
- spec = OpenapiFirst.load(spec) unless spec.is_a?(Definition)
40
- App.new(
41
- nil,
42
- spec,
43
- namespace: namespace,
44
- router_raise_error: router_raise_error,
45
- request_validation_raise_error: request_validation_raise_error,
46
- response_validation: response_validation
47
- )
48
- end
49
31
  end
@@ -34,17 +34,14 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.required_ruby_version = '>= 3.0.5'
36
36
 
37
- spec.add_runtime_dependency 'deep_merge', '>= 1.2.1'
38
37
  spec.add_runtime_dependency 'hanami-router', '~> 2.0.0'
39
- spec.add_runtime_dependency 'hanami-utils', '~> 2.0.0'
40
38
  spec.add_runtime_dependency 'json_refs', '~> 0.1', '>= 0.1.7'
41
39
  spec.add_runtime_dependency 'json_schemer', '~> 0.2.16'
42
40
  spec.add_runtime_dependency 'multi_json', '~> 1.14'
43
- spec.add_runtime_dependency 'mustermann-contrib', '~> 3.0.0'
41
+ spec.add_runtime_dependency 'openapi_parameters', '~> 0.2'
44
42
  spec.add_runtime_dependency 'rack', '>= 2.2', '< 4.0'
45
43
 
46
44
  spec.add_development_dependency 'bundler', '~> 2'
47
- spec.add_development_dependency 'openapi_parameters', '~> 0.2', '<= 2.0.0'
48
45
  spec.add_development_dependency 'rack-test', '~> 1'
49
46
  spec.add_development_dependency 'rake', '~> 13'
50
47
  spec.add_development_dependency 'rspec', '~> 3'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_first
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: deep_merge
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.2.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.2.1
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: hanami-router
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +24,6 @@ dependencies:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: 2.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: hanami-utils
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 2.0.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 2.0.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: json_refs
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -101,19 +73,19 @@ dependencies:
101
73
  - !ruby/object:Gem::Version
102
74
  version: '1.14'
103
75
  - !ruby/object:Gem::Dependency
104
- name: mustermann-contrib
76
+ name: openapi_parameters
105
77
  requirement: !ruby/object:Gem::Requirement
106
78
  requirements:
107
79
  - - "~>"
108
80
  - !ruby/object:Gem::Version
109
- version: 3.0.0
81
+ version: '0.2'
110
82
  type: :runtime
111
83
  prerelease: false
112
84
  version_requirements: !ruby/object:Gem::Requirement
113
85
  requirements:
114
86
  - - "~>"
115
87
  - !ruby/object:Gem::Version
116
- version: 3.0.0
88
+ version: '0.2'
117
89
  - !ruby/object:Gem::Dependency
118
90
  name: rack
119
91
  requirement: !ruby/object:Gem::Requirement
@@ -148,26 +120,6 @@ dependencies:
148
120
  - - "~>"
149
121
  - !ruby/object:Gem::Version
150
122
  version: '2'
151
- - !ruby/object:Gem::Dependency
152
- name: openapi_parameters
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: '0.2'
158
- - - "<="
159
- - !ruby/object:Gem::Version
160
- version: 2.0.0
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - "~>"
166
- - !ruby/object:Gem::Version
167
- version: '0.2'
168
- - - "<="
169
- - !ruby/object:Gem::Version
170
- version: 2.0.0
171
123
  - !ruby/object:Gem::Dependency
172
124
  name: rack-test
173
125
  requirement: !ruby/object:Gem::Requirement
@@ -231,16 +183,17 @@ files:
231
183
  - benchmarks/Gemfile
232
184
  - benchmarks/Gemfile.lock
233
185
  - benchmarks/README.md
234
- - benchmarks/apps/committee.ru
186
+ - benchmarks/apps/committee_with_hanami_api.ru
235
187
  - benchmarks/apps/committee_with_response_validation.ru
236
188
  - benchmarks/apps/committee_with_sinatra.ru
237
189
  - benchmarks/apps/grape.ru
238
190
  - benchmarks/apps/hanami_api.ru
239
191
  - benchmarks/apps/hanami_router.ru
240
192
  - benchmarks/apps/openapi.yaml
241
- - benchmarks/apps/openapi_first.ru
242
193
  - benchmarks/apps/openapi_first_with_hanami_api.ru
194
+ - benchmarks/apps/openapi_first_with_plain_rack.ru
243
195
  - benchmarks/apps/openapi_first_with_response_validation.ru
196
+ - benchmarks/apps/openapi_first_with_sinatra.ru
244
197
  - benchmarks/apps/roda.ru
245
198
  - benchmarks/apps/sinatra.ru
246
199
  - benchmarks/apps/syro.ru
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'multi_json'
4
- require 'openapi_first'
5
-
6
- namespace = Module.new do
7
- def self.find_thing(params, _res)
8
- { hello: 'world', id: params.fetch('id') }
9
- end
10
-
11
- def self.find_things(_params, _res)
12
- [{ hello: 'world' }]
13
- end
14
-
15
- def self.create_thing(_params, res)
16
- res.status = 201
17
- { hello: 'world' }
18
- end
19
- end
20
-
21
- oas_path = File.absolute_path('./openapi.yaml', __dir__)
22
- run OpenapiFirst.app(oas_path, namespace: namespace)