openapi_first 1.0.0.beta5 → 1.0.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -1
  3. data/CHANGELOG.md +23 -2
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +16 -18
  6. data/Gemfile.rack2 +15 -0
  7. data/Gemfile.rack2.lock +99 -0
  8. data/README.md +99 -130
  9. data/lib/openapi_first/body_parser.rb +29 -0
  10. data/lib/openapi_first/configuration.rb +20 -0
  11. data/lib/openapi_first/definition/cookie_parameters.rb +12 -0
  12. data/lib/openapi_first/definition/header_parameters.rb +12 -0
  13. data/lib/openapi_first/definition/operation.rb +116 -0
  14. data/lib/openapi_first/definition/parameters.rb +47 -0
  15. data/lib/openapi_first/definition/path_item.rb +32 -0
  16. data/lib/openapi_first/definition/path_parameters.rb +12 -0
  17. data/lib/openapi_first/definition/query_parameters.rb +12 -0
  18. data/lib/openapi_first/definition/request_body.rb +43 -0
  19. data/lib/openapi_first/definition/response.rb +25 -0
  20. data/lib/openapi_first/definition/responses.rb +83 -0
  21. data/lib/openapi_first/definition.rb +61 -8
  22. data/lib/openapi_first/error_response.rb +22 -27
  23. data/lib/openapi_first/errors.rb +2 -14
  24. data/lib/openapi_first/failure.rb +55 -0
  25. data/lib/openapi_first/middlewares/request_validation.rb +52 -0
  26. data/lib/openapi_first/middlewares/response_validation.rb +35 -0
  27. data/lib/openapi_first/plugins/default/error_response.rb +74 -0
  28. data/lib/openapi_first/plugins/default.rb +11 -0
  29. data/lib/openapi_first/plugins/jsonapi/error_response.rb +58 -0
  30. data/lib/openapi_first/plugins/jsonapi.rb +11 -0
  31. data/lib/openapi_first/plugins.rb +9 -7
  32. data/lib/openapi_first/request_validation/request_body_validator.rb +41 -0
  33. data/lib/openapi_first/request_validation/validator.rb +81 -0
  34. data/lib/openapi_first/response_validation/validator.rb +101 -0
  35. data/lib/openapi_first/runtime_request.rb +84 -0
  36. data/lib/openapi_first/runtime_response.rb +31 -0
  37. data/lib/openapi_first/schema/validation_error.rb +18 -0
  38. data/lib/openapi_first/schema/validation_result.rb +32 -0
  39. data/lib/openapi_first/{json_schema.rb → schema.rb} +9 -5
  40. data/lib/openapi_first/version.rb +1 -1
  41. data/lib/openapi_first.rb +32 -28
  42. data/openapi_first.gemspec +10 -9
  43. metadata +55 -67
  44. data/.rspec +0 -3
  45. data/.rubocop.yml +0 -14
  46. data/Rakefile +0 -15
  47. data/benchmarks/Gemfile +0 -16
  48. data/benchmarks/Gemfile.lock +0 -142
  49. data/benchmarks/README.md +0 -29
  50. data/benchmarks/apps/committee_with_hanami_api.ru +0 -26
  51. data/benchmarks/apps/committee_with_response_validation.ru +0 -29
  52. data/benchmarks/apps/committee_with_sinatra.ru +0 -31
  53. data/benchmarks/apps/grape.ru +0 -21
  54. data/benchmarks/apps/hanami_api.ru +0 -21
  55. data/benchmarks/apps/hanami_router.ru +0 -14
  56. data/benchmarks/apps/openapi.yaml +0 -268
  57. data/benchmarks/apps/openapi_first_with_hanami_api.ru +0 -24
  58. data/benchmarks/apps/openapi_first_with_plain_rack.ru +0 -32
  59. data/benchmarks/apps/openapi_first_with_response_validation.ru +0 -25
  60. data/benchmarks/apps/openapi_first_with_sinatra.ru +0 -29
  61. data/benchmarks/apps/roda.ru +0 -27
  62. data/benchmarks/apps/sinatra.ru +0 -26
  63. data/benchmarks/apps/syro.ru +0 -25
  64. data/benchmarks/benchmark-wrk.sh +0 -3
  65. data/benchmarks/benchmarks.rb +0 -48
  66. data/benchmarks/post.lua +0 -3
  67. data/bin/console +0 -15
  68. data/bin/setup +0 -8
  69. data/examples/README.md +0 -13
  70. data/examples/app.rb +0 -18
  71. data/examples/config.ru +0 -7
  72. data/examples/openapi.yaml +0 -29
  73. data/lib/openapi_first/body_parser_middleware.rb +0 -40
  74. data/lib/openapi_first/config.rb +0 -20
  75. data/lib/openapi_first/error_responses/default.rb +0 -58
  76. data/lib/openapi_first/error_responses/json_api.rb +0 -58
  77. data/lib/openapi_first/json_schema/result.rb +0 -17
  78. data/lib/openapi_first/operation.rb +0 -170
  79. data/lib/openapi_first/request_body_validator.rb +0 -41
  80. data/lib/openapi_first/request_validation.rb +0 -118
  81. data/lib/openapi_first/request_validation_error.rb +0 -31
  82. data/lib/openapi_first/response_validation.rb +0 -93
  83. data/lib/openapi_first/response_validator.rb +0 -21
  84. data/lib/openapi_first/router.rb +0 -102
  85. data/lib/openapi_first/string_keyed_hash.rb +0 -20
  86. data/lib/openapi_first/use_router.rb +0 -18
data/lib/openapi_first.rb CHANGED
@@ -1,47 +1,51 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+ require 'multi_json'
4
5
  require 'json_refs'
5
- require_relative 'openapi_first/config'
6
+ require_relative 'openapi_first/errors'
7
+ require_relative 'openapi_first/configuration'
6
8
  require_relative 'openapi_first/plugins'
7
9
  require_relative 'openapi_first/definition'
8
10
  require_relative 'openapi_first/version'
9
- require_relative 'openapi_first/errors'
10
- require_relative 'openapi_first/router'
11
- require_relative 'openapi_first/request_validation'
12
- require_relative 'openapi_first/response_validator'
13
- require_relative 'openapi_first/response_validation'
14
- require_relative 'openapi_first/error_responses/default'
15
- require_relative 'openapi_first/error_responses/json_api'
11
+ require_relative 'openapi_first/error_response'
12
+ require_relative 'openapi_first/middlewares/response_validation'
13
+ require_relative 'openapi_first/middlewares/request_validation'
16
14
 
17
15
  module OpenapiFirst
18
- # The OpenAPI operation for the current request
19
- OPERATION = 'openapi.operation'
16
+ extend Plugins
20
17
 
21
- # Merged parsed path and query parameters
22
- PARAMS = 'openapi.params'
18
+ class << self
19
+ def configuration
20
+ @configuration ||= Configuration.new
21
+ end
23
22
 
24
- # Parsed query parameters
25
- QUERY_PARAMS = 'openapi.query'
23
+ def configure
24
+ yield configuration
25
+ end
26
+ end
26
27
 
27
- # Parsed path parameters
28
- PATH_PARAMS = 'openapi.path_params'
28
+ # Key in rack to find instance of RuntimeRequest
29
+ REQUEST = 'openapi.request'
29
30
 
30
- # Parsed header parameters, except for Content-Type, Accept and Authorization
31
- HEADER_PARAMS = 'openapi.headers'
31
+ def self.load(spec_path, only: nil)
32
+ resolved = Bundle.resolve(spec_path)
33
+ resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
34
+ Definition.new(resolved, spec_path)
35
+ end
32
36
 
33
- # Parsed cookie parameter values
34
- COOKIE_PARAMS = 'openapi.cookies'
37
+ module Bundle
38
+ def self.resolve(spec_path)
39
+ Dir.chdir(File.dirname(spec_path)) do
40
+ content = load_file(File.basename(spec_path))
41
+ JsonRefs.call(content, resolve_local_ref: true, resolve_file_ref: true)
42
+ end
43
+ end
35
44
 
36
- # The parsed request body
37
- REQUEST_BODY = 'openapi.parsed_request_body'
45
+ def self.load_file(spec_path)
46
+ return MultiJson.load(File.read(spec_path)) if File.extname(spec_path) == '.json'
38
47
 
39
- def self.load(spec_path, only: nil)
40
- resolved = Dir.chdir(File.dirname(spec_path)) do
41
- content = YAML.load_file(File.basename(spec_path))
42
- JsonRefs.call(content, resolve_local_ref: true, resolve_file_ref: true)
48
+ YAML.unsafe_load_file(spec_path)
43
49
  end
44
- resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
45
- Definition.new(resolved, spec_path)
46
50
  end
47
51
  end
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
17
17
  if spec.respond_to?(:metadata)
18
18
  spec.metadata['https://github.com/ahx/openapi_first'] = spec.homepage
19
19
  spec.metadata['source_code_uri'] = 'https://github.com/ahx/openapi_first'
20
- spec.metadata['changelog_uri'] = 'https://github.com/ahx/openapi_first/blob/master/CHANGELOG.md'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/ahx/openapi_first/blob/main/CHANGELOG.md'
21
+ spec.metadata['rubygems_mfa_required'] = 'true'
21
22
  else
22
23
  raise 'RubyGems 2.0 or newer is required to protect against ' \
23
24
  'public gem pushes.'
@@ -26,21 +27,21 @@ Gem::Specification.new do |spec|
26
27
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
28
  `git ls-files -z`
28
29
  .split("\x0")
29
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
30
- .reject { |f| %w[Dockerfile Jenkinsfile .tool-versions].include?(f) }
30
+ .reject { |f| f.match(%r{^(test|spec|features|benchmarks|examples|bin)/}) }
31
+ .reject do |f|
32
+ %w[Dockerfile Jenkinsfile .tool-versions CODEOWNERS .rspec .rubocop.yml .tool-versions
33
+ Rakefile].include?(f)
34
+ end
31
35
  end
32
36
  spec.bindir = 'exe'
33
37
  spec.require_paths = ['lib']
34
38
 
35
39
  spec.required_ruby_version = '>= 3.1.1'
36
40
 
37
- spec.add_runtime_dependency 'hanami-router', '~> 2.0.0'
38
41
  spec.add_runtime_dependency 'json_refs', '~> 0.1', '>= 0.1.7'
39
- spec.add_runtime_dependency 'json_schemer', '~> 2.0.0'
42
+ spec.add_runtime_dependency 'json_schemer', '~> 2.1.0'
40
43
  spec.add_runtime_dependency 'multi_json', '~> 1.15'
41
- spec.add_runtime_dependency 'openapi_parameters', '>= 0.3.1', '< 2.0'
44
+ spec.add_runtime_dependency 'mustermann-contrib', '~> 3.0.0'
45
+ spec.add_runtime_dependency 'openapi_parameters', '>= 0.3.2', '< 2.0'
42
46
  spec.add_runtime_dependency 'rack', '>= 2.2', '< 4.0'
43
- spec.metadata = {
44
- 'rubygems_mfa_required' => 'true'
45
- }
46
47
  end
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.beta5
4
+ version: 1.0.0
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-11-12 00:00:00.000000000 Z
11
+ date: 2024-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: hanami-router
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 2.0.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 2.0.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: json_refs
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +36,14 @@ dependencies:
50
36
  requirements:
51
37
  - - "~>"
52
38
  - !ruby/object:Gem::Version
53
- version: 2.0.0
39
+ version: 2.1.0
54
40
  type: :runtime
55
41
  prerelease: false
56
42
  version_requirements: !ruby/object:Gem::Requirement
57
43
  requirements:
58
44
  - - "~>"
59
45
  - !ruby/object:Gem::Version
60
- version: 2.0.0
46
+ version: 2.1.0
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: multi_json
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,13 +58,27 @@ dependencies:
72
58
  - - "~>"
73
59
  - !ruby/object:Gem::Version
74
60
  version: '1.15'
61
+ - !ruby/object:Gem::Dependency
62
+ name: mustermann-contrib
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 3.0.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 3.0.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: openapi_parameters
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.3.1
81
+ version: 0.3.2
82
82
  - - "<"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '2.0'
@@ -88,7 +88,7 @@ dependencies:
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: 0.3.1
91
+ version: 0.3.2
92
92
  - - "<"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '2.0'
@@ -122,66 +122,54 @@ files:
122
122
  - ".github/CODEOWNERS"
123
123
  - ".github/workflows/ruby.yml"
124
124
  - ".gitignore"
125
- - ".rspec"
126
- - ".rubocop.yml"
127
125
  - CHANGELOG.md
128
126
  - Gemfile
129
127
  - Gemfile.lock
128
+ - Gemfile.rack2
129
+ - Gemfile.rack2.lock
130
130
  - LICENSE.txt
131
131
  - README.md
132
- - Rakefile
133
- - benchmarks/Gemfile
134
- - benchmarks/Gemfile.lock
135
- - benchmarks/README.md
136
- - benchmarks/apps/committee_with_hanami_api.ru
137
- - benchmarks/apps/committee_with_response_validation.ru
138
- - benchmarks/apps/committee_with_sinatra.ru
139
- - benchmarks/apps/grape.ru
140
- - benchmarks/apps/hanami_api.ru
141
- - benchmarks/apps/hanami_router.ru
142
- - benchmarks/apps/openapi.yaml
143
- - benchmarks/apps/openapi_first_with_hanami_api.ru
144
- - benchmarks/apps/openapi_first_with_plain_rack.ru
145
- - benchmarks/apps/openapi_first_with_response_validation.ru
146
- - benchmarks/apps/openapi_first_with_sinatra.ru
147
- - benchmarks/apps/roda.ru
148
- - benchmarks/apps/sinatra.ru
149
- - benchmarks/apps/syro.ru
150
- - benchmarks/benchmark-wrk.sh
151
- - benchmarks/benchmarks.rb
152
- - benchmarks/post.lua
153
- - bin/console
154
- - bin/setup
155
- - examples/README.md
156
- - examples/app.rb
157
- - examples/config.ru
158
- - examples/openapi.yaml
159
132
  - lib/openapi_first.rb
160
- - lib/openapi_first/body_parser_middleware.rb
161
- - lib/openapi_first/config.rb
133
+ - lib/openapi_first/body_parser.rb
134
+ - lib/openapi_first/configuration.rb
162
135
  - lib/openapi_first/definition.rb
136
+ - lib/openapi_first/definition/cookie_parameters.rb
137
+ - lib/openapi_first/definition/header_parameters.rb
138
+ - lib/openapi_first/definition/operation.rb
139
+ - lib/openapi_first/definition/parameters.rb
140
+ - lib/openapi_first/definition/path_item.rb
141
+ - lib/openapi_first/definition/path_parameters.rb
142
+ - lib/openapi_first/definition/query_parameters.rb
143
+ - lib/openapi_first/definition/request_body.rb
144
+ - lib/openapi_first/definition/response.rb
145
+ - lib/openapi_first/definition/responses.rb
163
146
  - lib/openapi_first/error_response.rb
164
- - lib/openapi_first/error_responses/default.rb
165
- - lib/openapi_first/error_responses/json_api.rb
166
147
  - lib/openapi_first/errors.rb
167
- - lib/openapi_first/json_schema.rb
168
- - lib/openapi_first/json_schema/result.rb
169
- - lib/openapi_first/operation.rb
148
+ - lib/openapi_first/failure.rb
149
+ - lib/openapi_first/middlewares/request_validation.rb
150
+ - lib/openapi_first/middlewares/response_validation.rb
170
151
  - lib/openapi_first/plugins.rb
171
- - lib/openapi_first/request_body_validator.rb
172
- - lib/openapi_first/request_validation.rb
173
- - lib/openapi_first/request_validation_error.rb
174
- - lib/openapi_first/response_validation.rb
175
- - lib/openapi_first/response_validator.rb
176
- - lib/openapi_first/router.rb
177
- - lib/openapi_first/string_keyed_hash.rb
178
- - lib/openapi_first/use_router.rb
152
+ - lib/openapi_first/plugins/default.rb
153
+ - lib/openapi_first/plugins/default/error_response.rb
154
+ - lib/openapi_first/plugins/jsonapi.rb
155
+ - lib/openapi_first/plugins/jsonapi/error_response.rb
156
+ - lib/openapi_first/request_validation/request_body_validator.rb
157
+ - lib/openapi_first/request_validation/validator.rb
158
+ - lib/openapi_first/response_validation/validator.rb
159
+ - lib/openapi_first/runtime_request.rb
160
+ - lib/openapi_first/runtime_response.rb
161
+ - lib/openapi_first/schema.rb
162
+ - lib/openapi_first/schema/validation_error.rb
163
+ - lib/openapi_first/schema/validation_result.rb
179
164
  - lib/openapi_first/version.rb
180
165
  - openapi_first.gemspec
181
166
  homepage: https://github.com/ahx/openapi_first
182
167
  licenses:
183
168
  - MIT
184
169
  metadata:
170
+ https://github.com/ahx/openapi_first: https://github.com/ahx/openapi_first
171
+ source_code_uri: https://github.com/ahx/openapi_first
172
+ changelog_uri: https://github.com/ahx/openapi_first/blob/main/CHANGELOG.md
185
173
  rubygems_mfa_required: 'true'
186
174
  post_install_message:
187
175
  rdoc_options: []
@@ -194,11 +182,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
182
  version: 3.1.1
195
183
  required_rubygems_version: !ruby/object:Gem::Requirement
196
184
  requirements:
197
- - - ">"
185
+ - - ">="
198
186
  - !ruby/object:Gem::Version
199
- version: 1.3.1
187
+ version: '0'
200
188
  requirements: []
201
- rubygems_version: 3.3.7
189
+ rubygems_version: 3.5.3
202
190
  signing_key:
203
191
  specification_version: 4
204
192
  summary: Implement REST APIs based on OpenApi 3.x
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,14 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 3.1.1
3
- NewCops: enable
4
- SuggestExtensions: false
5
- Style/Documentation:
6
- Enabled: false
7
- Style/ExponentialNotation:
8
- Enabled: true
9
- Metrics/BlockLength:
10
- Exclude:
11
- - "spec/**/*.rb"
12
- - "*.gemspec"
13
- Metrics/MethodLength:
14
- Max: 20
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
-
7
- RuboCop::RakeTask.new
8
-
9
- task :version do
10
- puts Gem::Specification.load('openapi_first.gemspec').version
11
- end
12
-
13
- RSpec::Core::RakeTask.new(:spec)
14
-
15
- task default: %i[spec rubocop]
data/benchmarks/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'benchmark-ips'
6
- gem 'benchmark-memory'
7
- gem 'committee'
8
- gem 'grape'
9
- gem 'hanami-api'
10
- gem 'hanami-router'
11
- gem 'multi_json'
12
- gem 'openapi_first', path: '../'
13
- gem 'puma'
14
- gem 'roda'
15
- gem 'sinatra'
16
- gem 'syro'
@@ -1,142 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- openapi_first (1.0.0.beta5)
5
- hanami-router (~> 2.0.0)
6
- json_refs (~> 0.1, >= 0.1.7)
7
- json_schemer (~> 2.0.0)
8
- multi_json (~> 1.15)
9
- openapi_parameters (>= 0.3.1, < 2.0)
10
- rack (>= 2.2, < 4.0)
11
-
12
- GEM
13
- remote: https://rubygems.org/
14
- specs:
15
- activesupport (7.1.2)
16
- base64
17
- bigdecimal
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- connection_pool (>= 2.2.5)
20
- drb
21
- i18n (>= 1.6, < 2)
22
- minitest (>= 5.1)
23
- mutex_m
24
- tzinfo (~> 2.0)
25
- base64 (0.2.0)
26
- benchmark-ips (2.12.0)
27
- benchmark-memory (0.2.0)
28
- memory_profiler (~> 1)
29
- bigdecimal (3.1.4)
30
- builder (3.2.4)
31
- committee (5.0.0)
32
- json_schema (~> 0.14, >= 0.14.3)
33
- openapi_parser (~> 1.0)
34
- rack (>= 1.5)
35
- concurrent-ruby (1.2.2)
36
- connection_pool (2.4.1)
37
- drb (2.2.0)
38
- ruby2_keywords
39
- dry-core (1.0.1)
40
- concurrent-ruby (~> 1.0)
41
- zeitwerk (~> 2.6)
42
- dry-inflector (1.0.0)
43
- dry-logic (1.5.0)
44
- concurrent-ruby (~> 1.0)
45
- dry-core (~> 1.0, < 2)
46
- zeitwerk (~> 2.6)
47
- dry-types (1.7.1)
48
- concurrent-ruby (~> 1.0)
49
- dry-core (~> 1.0)
50
- dry-inflector (~> 1.0)
51
- dry-logic (~> 1.4)
52
- zeitwerk (~> 2.6)
53
- grape (2.0.0)
54
- activesupport (>= 5)
55
- builder
56
- dry-types (>= 1.1)
57
- mustermann-grape (~> 1.0.0)
58
- rack (>= 1.3.0)
59
- rack-accept
60
- hana (1.3.7)
61
- hanami-api (0.3.0)
62
- hanami-router (~> 2.0)
63
- hanami-router (2.0.2)
64
- mustermann (~> 3.0)
65
- mustermann-contrib (~> 3.0)
66
- rack (~> 2.0)
67
- hansi (0.2.1)
68
- i18n (1.14.1)
69
- concurrent-ruby (~> 1.0)
70
- json_refs (0.1.8)
71
- hana
72
- json_schema (0.21.0)
73
- json_schemer (2.0.0)
74
- hana (~> 1.3)
75
- regexp_parser (~> 2.0)
76
- simpleidn (~> 0.2)
77
- memory_profiler (1.0.1)
78
- minitest (5.20.0)
79
- multi_json (1.15.0)
80
- mustermann (3.0.0)
81
- ruby2_keywords (~> 0.0.1)
82
- mustermann-contrib (3.0.0)
83
- hansi (~> 0.2.0)
84
- mustermann (= 3.0.0)
85
- mustermann-grape (1.0.2)
86
- mustermann (>= 1.0.0)
87
- mutex_m (0.2.0)
88
- nio4r (2.5.9)
89
- openapi_parameters (0.3.1)
90
- rack (>= 2.2)
91
- zeitwerk (~> 2.6)
92
- openapi_parser (1.0.0)
93
- puma (6.4.0)
94
- nio4r (~> 2.0)
95
- rack (2.2.8)
96
- rack-accept (0.4.5)
97
- rack (>= 0.4)
98
- rack-protection (3.1.0)
99
- rack (~> 2.2, >= 2.2.4)
100
- regexp_parser (2.8.2)
101
- roda (3.73.0)
102
- rack
103
- ruby2_keywords (0.0.5)
104
- seg (1.2.0)
105
- simpleidn (0.2.1)
106
- unf (~> 0.1.4)
107
- sinatra (3.1.0)
108
- mustermann (~> 3.0)
109
- rack (~> 2.2, >= 2.2.4)
110
- rack-protection (= 3.1.0)
111
- tilt (~> 2.0)
112
- syro (3.2.1)
113
- rack (>= 1.6.0)
114
- seg
115
- tilt (2.3.0)
116
- tzinfo (2.0.6)
117
- concurrent-ruby (~> 1.0)
118
- unf (0.1.4)
119
- unf_ext
120
- unf_ext (0.0.9)
121
- zeitwerk (2.6.12)
122
-
123
- PLATFORMS
124
- arm64-darwin-21
125
- x86_64-linux
126
-
127
- DEPENDENCIES
128
- benchmark-ips
129
- benchmark-memory
130
- committee
131
- grape
132
- hanami-api
133
- hanami-router
134
- multi_json
135
- openapi_first!
136
- puma
137
- roda
138
- sinatra
139
- syro
140
-
141
- BUNDLED WITH
142
- 2.3.10
data/benchmarks/README.md DELETED
@@ -1,29 +0,0 @@
1
- # How to run these bechmarks
2
-
3
- ## Setup
4
-
5
- ```bash
6
- cd benchmarks
7
- bundle install
8
- ```
9
-
10
- ## Run Ruby benchmarks
11
-
12
- This compares ips and memory usage for all apps defined in /apps
13
-
14
- ```bash
15
- bundle exec ruby benchmarks.rb
16
- ```
17
-
18
- ## Run benchmark using [wrk](https://github.com/wg/wrk)
19
-
20
- 1. Start the example app
21
- Example: openapi_first
22
- ```bash
23
- bundle exec puma apps/openapi_first_with_response_validation.ru
24
- ```
25
-
26
- 2. Run wrk
27
- ```bash
28
- ./benchmark-wrk.sh
29
- ```
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'multi_json'
4
- require 'committee'
5
- require 'hanami/api'
6
-
7
- app = Class.new(Hanami::API) do
8
- get '/hello/:id' do
9
- json(hello: 'world', id: params.fetch(:id))
10
- end
11
-
12
- get '/hello' do
13
- json([{ hello: 'world' }])
14
- end
15
-
16
- post '/hello' do
17
- status 201
18
- json(hello: 'world')
19
- end
20
- end.new
21
-
22
- use Committee::Middleware::RequestValidation,
23
- schema_path: File.absolute_path('./openapi.yaml', __dir__),
24
- parse_response_by_content_type: true
25
-
26
- run app
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'multi_json'
4
- require 'committee'
5
- require 'hanami/api'
6
-
7
- app = Class.new(Hanami::API) do
8
- get '/hello/:id' do
9
- json(hello: 'world', id: params.fetch(:id))
10
- end
11
-
12
- get '/hello' do
13
- json([{ hello: 'world' }])
14
- end
15
-
16
- post '/hello' do
17
- status 201
18
- json(hello: 'world')
19
- end
20
- end.new
21
-
22
- use Committee::Middleware::RequestValidation,
23
- schema_path: File.absolute_path('./openapi.yaml', __dir__),
24
- parse_response_by_content_type: true
25
-
26
- use Committee::Middleware::ResponseValidation,
27
- schema_path: File.absolute_path('./openapi.yaml', __dir__)
28
-
29
- run app
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'multi_json'
4
- require 'committee'
5
- require 'sinatra'
6
-
7
- class SinatraWithCommiteeExample < 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 Committee::Middleware::RequestValidation,
28
- schema_path: File.absolute_path('./openapi.yaml', __dir__),
29
- parse_response_by_content_type: true
30
-
31
- run SinatraWithCommiteeExample
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'grape'
4
-
5
- class GrapeExample < Grape::API
6
- format :json
7
-
8
- get :hello do
9
- [{ hello: 'world' }]
10
- end
11
-
12
- post :hello do
13
- { hello: 'world' }
14
- end
15
-
16
- get 'hello/:id' do
17
- { hello: 'world', id: params[:id] }
18
- end
19
- end
20
-
21
- run GrapeExample
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'multi_json'
4
- require 'hanami/api'
5
-
6
- app = Class.new(Hanami::API) do
7
- get '/hello/:id' do
8
- json(hello: 'world', id: params.fetch(:id))
9
- end
10
-
11
- get '/hello' do
12
- json([{ hello: 'world' }])
13
- end
14
-
15
- post '/hello' do
16
- status 201
17
- json(hello: 'world')
18
- end
19
- end.new
20
-
21
- run app