openapi_first 1.2.1 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openapi_first/body_parser.rb +1 -0
- data/lib/openapi_first/configuration.rb +3 -1
- data/lib/openapi_first/definition/operation.rb +66 -5
- data/lib/openapi_first/definition/path_item.rb +1 -0
- data/lib/openapi_first/definition/request_body.rb +2 -1
- data/lib/openapi_first/definition/response.rb +7 -0
- data/lib/openapi_first/definition.rb +40 -0
- data/lib/openapi_first/error_response.rb +1 -1
- data/lib/openapi_first/errors.rb +6 -0
- data/lib/openapi_first/failure.rb +13 -2
- data/lib/openapi_first/middlewares/request_validation.rb +2 -5
- data/lib/openapi_first/middlewares/response_validation.rb +1 -4
- data/lib/openapi_first/plugins/default/error_response.rb +4 -4
- data/lib/openapi_first/plugins/default.rb +1 -1
- data/lib/openapi_first/plugins/jsonapi/error_response.rb +3 -2
- data/lib/openapi_first/plugins/jsonapi.rb +1 -1
- data/lib/openapi_first/plugins.rb +1 -0
- data/lib/openapi_first/request_validation/request_body_validator.rb +1 -1
- data/lib/openapi_first/request_validation/validator.rb +1 -0
- data/lib/openapi_first/response_validation/validator.rb +1 -0
- data/lib/openapi_first/runtime_request.rb +63 -3
- data/lib/openapi_first/runtime_response.rb +43 -4
- data/lib/openapi_first/schema/validation_error.rb +2 -0
- data/lib/openapi_first/schema/validation_result.rb +2 -0
- data/lib/openapi_first/schema.rb +1 -0
- data/lib/openapi_first/version.rb +1 -1
- data/lib/openapi_first.rb +8 -0
- metadata +5 -16
- data/.github/CODEOWNERS +0 -1
- data/.github/workflows/ruby.yml +0 -13
- data/.gitignore +0 -11
- data/CHANGELOG.md +0 -279
- data/Gemfile +0 -18
- data/Gemfile.lock +0 -166
- data/Gemfile.rack2 +0 -15
- data/Gemfile.rack2.lock +0 -95
- data/LICENSE.txt +0 -21
- data/README.md +0 -225
- data/openapi_first.gemspec +0 -47
@@ -5,56 +5,95 @@ require_relative 'body_parser'
|
|
5
5
|
require_relative 'response_validation/validator'
|
6
6
|
|
7
7
|
module OpenapiFirst
|
8
|
+
# Represents a response returned by the Rack application and how it relates to the API description.
|
8
9
|
class RuntimeResponse
|
9
10
|
extend Forwardable
|
10
11
|
|
11
12
|
def initialize(operation, rack_response)
|
12
13
|
@operation = operation
|
13
14
|
@rack_response = rack_response
|
15
|
+
@error = nil
|
14
16
|
end
|
15
17
|
|
18
|
+
# @return [Failure, nil] Error object if validation failed.
|
19
|
+
attr_reader :error
|
20
|
+
|
21
|
+
# @attr_reader [Integer] status The HTTP status code of this response.
|
22
|
+
# @attr_reader [String] content_type The content_type of the Rack::Response.
|
16
23
|
def_delegators :@rack_response, :status, :content_type
|
17
|
-
def_delegators :@operation, :name
|
18
24
|
|
25
|
+
# @attr_reader [String] name The name of the operation. Used for generating error messages.
|
26
|
+
def_delegators :@operation, :name # @visibility private
|
27
|
+
|
28
|
+
# Checks if the response is valid. Runs the validation unless it has been run before.
|
29
|
+
# @return [Boolean]
|
30
|
+
def valid?
|
31
|
+
validate unless @validated
|
32
|
+
@error.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# Checks if the response is defined in the API description.
|
36
|
+
# @return [Boolean] Returns true if the response is known, false otherwise.
|
19
37
|
def known?
|
20
38
|
!!response_definition
|
21
39
|
end
|
22
40
|
|
41
|
+
# Checks if the response status is defined in the API description.
|
42
|
+
# @return [Boolean] Returns true if the response status is known, false otherwise.
|
23
43
|
def known_status?
|
24
44
|
@operation.response_status_defined?(status)
|
25
45
|
end
|
26
46
|
|
47
|
+
# Returns the description of the response definition if available.
|
48
|
+
# @return [String, nil] Returns the description of the response, or nil if not available.
|
27
49
|
def description
|
28
50
|
response_definition&.description
|
29
51
|
end
|
30
52
|
|
53
|
+
# Returns the parsed (JSON) body of the response.
|
54
|
+
# @return [Hash, String] Returns the body of the response.
|
31
55
|
def body
|
32
56
|
@body ||= content_type =~ /json/i ? load_json(original_body) : original_body
|
33
57
|
end
|
34
58
|
|
59
|
+
# Returns the headers of the response as defined in the API description.
|
60
|
+
# This only returns the headers that are defined in the API description.
|
61
|
+
# @return [Hash] Returns the headers of the response.
|
35
62
|
def headers
|
36
63
|
@headers ||= unpack_response_headers
|
37
64
|
end
|
38
65
|
|
66
|
+
# Validates the response.
|
67
|
+
# @return [Failure, nil] Returns the validation error, or nil if the response is valid.
|
39
68
|
def validate
|
40
|
-
|
69
|
+
@validated = true
|
70
|
+
@error = ResponseValidation::Validator.new(@operation).validate(self)
|
41
71
|
end
|
42
72
|
|
73
|
+
# Validates the response and raises an error if invalid.
|
74
|
+
# @raise [ResponseNotFoundError, ResponseInvalidError] Raises an error if the response is invalid.
|
43
75
|
def validate!
|
44
76
|
error = validate
|
45
77
|
error&.raise!
|
46
78
|
end
|
47
79
|
|
80
|
+
# Returns the response definition associated with the response.
|
81
|
+
# @return [Definition::Response, nil] Returns the response definition, or nil if not found.
|
48
82
|
def response_definition
|
49
83
|
@response_definition ||= @operation.response_for(status, content_type)
|
50
84
|
end
|
51
85
|
|
52
86
|
private
|
53
87
|
|
88
|
+
# Usually the body responds to #each, but when using manual response validation without the middleware
|
89
|
+
# in Rails request specs the body is a String. So this code handles both cases.
|
54
90
|
def original_body
|
55
91
|
buffered_body = String.new
|
56
|
-
@rack_response.body.each
|
57
|
-
|
92
|
+
if @rack_response.body.respond_to?(:each)
|
93
|
+
@rack_response.body.each { |chunk| buffered_body.to_s << chunk }
|
94
|
+
return buffered_body
|
95
|
+
end
|
96
|
+
@rack_response.body
|
58
97
|
end
|
59
98
|
|
60
99
|
def load_json(string)
|
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
module OpenapiFirst
|
4
4
|
class Schema
|
5
|
+
# One of multiple validation errors. Returned by Schema::ValidationResult#errors.
|
5
6
|
class ValidationError
|
6
7
|
def initialize(json_schemer_error)
|
7
8
|
@error = json_schemer_error
|
8
9
|
end
|
9
10
|
|
10
11
|
def error = @error['error']
|
12
|
+
alias message error
|
11
13
|
def schemer_error = @error
|
12
14
|
def instance_location = @error['data_pointer']
|
13
15
|
def schema_location = @error['schema_pointer']
|
@@ -4,6 +4,7 @@ require_relative 'validation_error'
|
|
4
4
|
|
5
5
|
module OpenapiFirst
|
6
6
|
class Schema
|
7
|
+
# Result of validating data against a schema. Return value of Schema#validate.
|
7
8
|
class ValidationResult
|
8
9
|
def initialize(validation, schema:, data:)
|
9
10
|
@validation = validation
|
@@ -15,6 +16,7 @@ module OpenapiFirst
|
|
15
16
|
|
16
17
|
def error? = @validation.any?
|
17
18
|
|
19
|
+
# Returns an array of ValidationError objects.
|
18
20
|
def errors
|
19
21
|
@errors ||= @validation.map do |err|
|
20
22
|
ValidationError.new(err)
|
data/lib/openapi_first/schema.rb
CHANGED
data/lib/openapi_first.rb
CHANGED
@@ -12,14 +12,18 @@ require_relative 'openapi_first/error_response'
|
|
12
12
|
require_relative 'openapi_first/middlewares/response_validation'
|
13
13
|
require_relative 'openapi_first/middlewares/request_validation'
|
14
14
|
|
15
|
+
# OpenapiFirst is a toolchain to build HTTP APIS based on OpenAPI API descriptions.
|
15
16
|
module OpenapiFirst
|
16
17
|
extend Plugins
|
17
18
|
|
18
19
|
class << self
|
20
|
+
# @return [Configuration]
|
19
21
|
def configuration
|
20
22
|
@configuration ||= Configuration.new
|
21
23
|
end
|
22
24
|
|
25
|
+
# @return [Configuration]
|
26
|
+
# @yield [Configuration]
|
23
27
|
def configure
|
24
28
|
yield configuration
|
25
29
|
end
|
@@ -29,21 +33,25 @@ module OpenapiFirst
|
|
29
33
|
REQUEST = 'openapi.request'
|
30
34
|
|
31
35
|
# Load and dereference an OpenAPI spec file
|
36
|
+
# @return [Definition]
|
32
37
|
def self.load(filepath, only: nil)
|
33
38
|
resolved = bundle(filepath)
|
34
39
|
parse(resolved, only:, filepath:)
|
35
40
|
end
|
36
41
|
|
37
42
|
# Parse a dereferenced Hash
|
43
|
+
# @return [Definition]
|
38
44
|
def self.parse(resolved, only: nil, filepath: nil)
|
39
45
|
resolved['paths'].filter!(&->(key, _) { only.call(key) }) if only
|
40
46
|
Definition.new(resolved, filepath)
|
41
47
|
end
|
42
48
|
|
49
|
+
# @!visibility private
|
43
50
|
def self.bundle(filepath)
|
44
51
|
Bundle.resolve(filepath)
|
45
52
|
end
|
46
53
|
|
54
|
+
# @!visibility private
|
47
55
|
module Bundle
|
48
56
|
def self.resolve(spec_path)
|
49
57
|
Dir.chdir(File.dirname(spec_path)) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_first
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Haller
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_refs
|
@@ -119,16 +119,6 @@ executables: []
|
|
119
119
|
extensions: []
|
120
120
|
extra_rdoc_files: []
|
121
121
|
files:
|
122
|
-
- ".github/CODEOWNERS"
|
123
|
-
- ".github/workflows/ruby.yml"
|
124
|
-
- ".gitignore"
|
125
|
-
- CHANGELOG.md
|
126
|
-
- Gemfile
|
127
|
-
- Gemfile.lock
|
128
|
-
- Gemfile.rack2
|
129
|
-
- Gemfile.rack2.lock
|
130
|
-
- LICENSE.txt
|
131
|
-
- README.md
|
132
122
|
- lib/openapi_first.rb
|
133
123
|
- lib/openapi_first/body_parser.rb
|
134
124
|
- lib/openapi_first/configuration.rb
|
@@ -157,12 +147,11 @@ files:
|
|
157
147
|
- lib/openapi_first/schema/validation_error.rb
|
158
148
|
- lib/openapi_first/schema/validation_result.rb
|
159
149
|
- lib/openapi_first/version.rb
|
160
|
-
- openapi_first.gemspec
|
161
150
|
homepage: https://github.com/ahx/openapi_first
|
162
151
|
licenses:
|
163
152
|
- MIT
|
164
153
|
metadata:
|
165
|
-
|
154
|
+
homepage_uri: https://github.com/ahx/openapi_first
|
166
155
|
source_code_uri: https://github.com/ahx/openapi_first
|
167
156
|
changelog_uri: https://github.com/ahx/openapi_first/blob/main/CHANGELOG.md
|
168
157
|
rubygems_mfa_required: 'true'
|
@@ -184,5 +173,5 @@ requirements: []
|
|
184
173
|
rubygems_version: 3.5.3
|
185
174
|
signing_key:
|
186
175
|
specification_version: 4
|
187
|
-
summary: Implement
|
176
|
+
summary: Implement HTTP APIs based on OpenApi 3.x
|
188
177
|
test_files: []
|
data/.github/CODEOWNERS
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
* @ahx
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
name: Test
|
2
|
-
on: [push, pull_request]
|
3
|
-
jobs:
|
4
|
-
test:
|
5
|
-
runs-on: ubuntu-latest
|
6
|
-
steps:
|
7
|
-
- uses: actions/checkout@v3
|
8
|
-
- uses: ruby/setup-ruby@v1
|
9
|
-
with:
|
10
|
-
ruby-version: '3.1'
|
11
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
12
|
-
- run: BUNDLE_GEMFILE=Gemfile bundle exec rake
|
13
|
-
- run: BUNDLE_GEMFILE=Gemfile.rack2 bundle lock --add-platform x86_64-linux && bundle exec rake
|
data/.gitignore
DELETED
data/CHANGELOG.md
DELETED
@@ -1,279 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## 1.2.0
|
4
|
-
|
5
|
-
- Added `OpenapiFirst.parse(hash)` to load ("parse") a resolved/de-referenced Hash
|
6
|
-
- Added support for unescaped special characters in the path params (https://github.com/ahx/openapi_first/pull/217)
|
7
|
-
- Added `operation` to `RuntimeRequest` by [@MrBananaLord](https://github.com/ahx/openapi_first/pull/216)
|
8
|
-
|
9
|
-
## 1.1.1
|
10
|
-
|
11
|
-
- Fix reading response body for example when running Rails (`ActionDispatch::Response::RackBody`)
|
12
|
-
- Add `known?`, `status`, `body`, `headers`, `content_type` methods to inspect the parsed response (`RuntimeResponse`)
|
13
|
-
- Add `OpenapiFirst::ParseError` which is raised by low-level interfaces like `request.body` if the body could not be parsed.
|
14
|
-
- Add "code" field to errors in JSON:API error response
|
15
|
-
|
16
|
-
## 1.1.0 (yanked)
|
17
|
-
|
18
|
-
## 1.0.0
|
19
|
-
|
20
|
-
- Breaking: The default error uses application/problem+json content-type
|
21
|
-
- Breaking: Moved rack middlewares to OpenapiFirst::Middlewares
|
22
|
-
- Breaking: Rename OpenapiFirst::ResponseInvalid to OpenapiFirst::ResponseInvalidError
|
23
|
-
- Breaking: Remove OpenapiFirst::Router
|
24
|
-
- Breaking: Remove `env[OpenapiFirst::OPERATION]`. Use `env[OpenapiFirst::REQUEST]` instead.
|
25
|
-
- Breaking: Remove `env[OpenapiFirst::REQUEST_BODY]`, `env[OpenapiFirst::PARAMS]`. Use `env[OpenapiFirst::REQUEST].body env[OpenapiFirst::REQUEST].params` instead.
|
26
|
-
- Add interface to validate requests / responses without middlewares (see "Manual validation" in README)
|
27
|
-
- Add OpenapiFirst.configure
|
28
|
-
- Add OpenapiFirst.register, OpenapiFirst.plugin
|
29
|
-
- Fix response header validation with Rack 3
|
30
|
-
- Fixed: Add support for paths like `/{a}..{b}`
|
31
|
-
|
32
|
-
## 1.0.0.beta6
|
33
|
-
|
34
|
-
- Fix: Make response header validation work with rack 3
|
35
|
-
- Refactor router
|
36
|
-
- Remove dependency hanami-router
|
37
|
-
- PathItem and Operation for a request can be found by calling methods on the Definitnion
|
38
|
-
- Fixed https://github.com/ahx/openapi_first/issues/155
|
39
|
-
- Breaking / Regression: A paths like /pets/{from}-{to} if there is a path "/pets/{id}"
|
40
|
-
|
41
|
-
## 1.0.0.beta5
|
42
|
-
|
43
|
-
- Added: `OpenapiFirst::Config.default_options=` to set default options globally
|
44
|
-
- Added: You can define custom error responses by subclassing `OpenapiFirst::ErrorResponse` and register it via `OpenapiFirst.register_error_response(name, MyCustomErrorResponse)`
|
45
|
-
|
46
|
-
## 1.0.0.beta4
|
47
|
-
|
48
|
-
- Update json_schemer to version 2.0
|
49
|
-
- Breaking: Requires Ruby 3.1 or later
|
50
|
-
- Added: Parameters are available at `env[OpenapiFirst::PATH_PARAMS]`, `env[OpenapiFirst::QUERY_PARAMS]`, `env[OpenapiFirst::HEADER_PARAMS]`, `env[OpenapiFirst::COOKIE_PARAMS]` in case you need to access them separately. Merged path and query parameters are still available at `env[OpenapiFirst::PARAMS]`
|
51
|
-
- Breaking / Added: ResponseValidation now validates response headers
|
52
|
-
- Breaking / Added: RequestValidation now validates cookie, path and header parameters
|
53
|
-
- Breaking: multipart File uploads are now read and then validated
|
54
|
-
- Breaking: Remove OpenapiFirst.env method
|
55
|
-
- Breaking: Request validation returns 400 instead of 415 if request body is required, but empty
|
56
|
-
|
57
|
-
## 1.0.0.beta3
|
58
|
-
|
59
|
-
- Remove obsolete dependency: deep_merge
|
60
|
-
- Remove obsolete dependency: hanami-utils
|
61
|
-
|
62
|
-
## 1.0.0.beta2
|
63
|
-
|
64
|
-
- Fixed dependencies. Remove unused code.
|
65
|
-
|
66
|
-
## 1.0.0.beta1
|
67
|
-
|
68
|
-
- Removed: `OpenapiFirst::Responder` and `OpenapiFirst::RackResponder`
|
69
|
-
- Removed: `OpenapiFirst.app` and `OpenapiFirst.middleware`
|
70
|
-
- Removed: `OpenapiFirst::Coverage`
|
71
|
-
- Breaking: Parsed query and path parameters are available at `env[OpenapiFirst::PARAMS]`(or `env['openapi.params']`) instead of `OpenapiFirst::PARAMETERS`.
|
72
|
-
- Breaking: Request body and parameters now use string keys instead of symbols!
|
73
|
-
- Breaking: Query parameters are now parsed exactly like in the API description via the openapi_parameters gem. This means a couple of things:
|
74
|
-
- Query parameters now support `explode: true` (default) and `explode: false` for array and object parameters.
|
75
|
-
- Query parameters with brackets like 'filter[tag]' are no longer deconstructed into nested hashes, but accessible via the `filter[tag]` key.
|
76
|
-
- Query parameters are no longer interpreted as `style: deepObject` by default. If you want to use `style: deepObject`, for example to pass a nested hash as a query parameter like `filter[tag]`, you have to set `style: deepObject` explicitly.
|
77
|
-
- Path parameters are now parsed exactly as in the API description via the openapi_parameters gem.
|
78
|
-
|
79
|
-
## 0.21.0
|
80
|
-
|
81
|
-
- Fix: Query parameter validation does not fail if header parameters are defined (Thanks to [JF Lalonde](https://github.com/JF-Lalonde))
|
82
|
-
- Update Ruby dependency to >= 3.0.5
|
83
|
-
- Handle simple form-data in request bodies (see https://github.com/ahx/openapi_first/issues/149)
|
84
|
-
- Update to hanami-router 2.0.0 stable
|
85
|
-
|
86
|
-
## 0.20.0
|
87
|
-
|
88
|
-
- You can pass a filepath to `spec:` now so you no longer have to call `OpenapiFirst.load` anymore.
|
89
|
-
- Router is optional now.
|
90
|
-
You no longer have to add `Router` to your middleware stack. You still can add it to customize behaviour by setting options, but you no longer have to add it.
|
91
|
-
If you don't add the Router, make sure you pass `spec:` to your request/response validation middleware.
|
92
|
-
- Support "4xx" and "4XX" response definitions.
|
93
|
-
(4XX is defined in the standard, but 2xx is used in the wild as well 🦁.)
|
94
|
-
- Removed warning about missing operationId, because operationId is not used until the Responder is used.
|
95
|
-
- Raise HandlerNotFoundError when handler cannot be found
|
96
|
-
|
97
|
-
## 0.19.0
|
98
|
-
|
99
|
-
- Add `RackResponder`
|
100
|
-
|
101
|
-
- BREAKING CHANGE: Handler classes are now instantiated only once without any arguments and the same instance is called on each following call/request.
|
102
|
-
|
103
|
-
## 0.18.0
|
104
|
-
|
105
|
-
Yanked. No useful changes.
|
106
|
-
|
107
|
-
## 0.17.0
|
108
|
-
|
109
|
-
- BREAKING CHANGE: Use a Hash instead of named arguments for middleware options for better compatibility
|
110
|
-
Using named arguments is actually not supported in Rack.
|
111
|
-
|
112
|
-
## 0.16.1
|
113
|
-
|
114
|
-
- Pin hanami-router version, because alpha6 is broken.
|
115
|
-
|
116
|
-
## 0.16.0
|
117
|
-
|
118
|
-
- Support status code wildcards like "2XX", "4XX"
|
119
|
-
|
120
|
-
## 0.15.0
|
121
|
-
|
122
|
-
- Populate default parameter values
|
123
|
-
|
124
|
-
## 0.14.3
|
125
|
-
|
126
|
-
- Use json_refs to resolve OpenAPI file. This removes oas_parser and ActiveSupport from list of dependencies
|
127
|
-
|
128
|
-
## 0.14.2
|
129
|
-
|
130
|
-
- Empty query parameters are parsed and request validation returns 400 if an empty string is not allowed. Note that this does not look at `allowEmptyValue` in any way, because allowEmptyValue is deprecated.
|
131
|
-
|
132
|
-
## 0.14.1
|
133
|
-
|
134
|
-
- Fix: Don't mix path- and operation-level parameters for request validation
|
135
|
-
|
136
|
-
## 0.14.0
|
137
|
-
|
138
|
-
- Handle custom x-handler field in the API description to find a handler method not based on operationId
|
139
|
-
- Add `resolver` option to provide a custom resolver to find a handler method
|
140
|
-
|
141
|
-
## 0.13.3
|
142
|
-
|
143
|
-
- Better error message if string does not match format
|
144
|
-
- readOnly and writeOnly just works when used inside allOf
|
145
|
-
|
146
|
-
## 0.13.2
|
147
|
-
|
148
|
-
- Return indicator (`source: { parameter: 'list/1' }`) in error response body when array item in query parameter is invalid
|
149
|
-
|
150
|
-
## 0.13.0
|
151
|
-
|
152
|
-
- Add support for arrays in query parameters (style: form, explode: false)
|
153
|
-
- Remove warning when handler is not implemented
|
154
|
-
|
155
|
-
## 0.12.5
|
156
|
-
|
157
|
-
- Add `not_found: :continue` option to Router to make it do nothing if request is unknown
|
158
|
-
|
159
|
-
## 0.12.4
|
160
|
-
|
161
|
-
- content-type is found while ignoring additional content-type parameters (`application/json` is found when request/response content-type is `application/json; charset=UTF8`)
|
162
|
-
- Support wildcard mime-types when finding the content-type
|
163
|
-
|
164
|
-
## 0.12.3
|
165
|
-
|
166
|
-
- Add `response_validation:`, `router_raise_error` options to standalone mode.
|
167
|
-
|
168
|
-
## 0.12.2
|
169
|
-
|
170
|
-
- Allow response to have no media type object specified
|
171
|
-
|
172
|
-
## 0.12.1
|
173
|
-
|
174
|
-
- Fix response when handler returns 404 or 405
|
175
|
-
- Don't validate the response content if status is 204 (no content)
|
176
|
-
|
177
|
-
## 0.12.0
|
178
|
-
|
179
|
-
- Change `ResponseValidator` to raise an exception if it found a problem
|
180
|
-
- Params have symbolized keys now
|
181
|
-
- Remove `not_found` option from Router. Return 405 if HTTP verb is not allowed (via Hanami::Router)
|
182
|
-
- Add `raise_error` option to OpenapiFirst.app (false by default)
|
183
|
-
- Add ResponseValidation to OpenapiFirst.app if raise_error option is true
|
184
|
-
- Rename `raise` option to `raise_error`
|
185
|
-
- Add `raise_error` option to RequestValidation middleware
|
186
|
-
- Raise error if handler could not be found by Responder
|
187
|
-
- Add `Operation#name` that returns a human readable name for an operation
|
188
|
-
|
189
|
-
## 0.11.0
|
190
|
-
|
191
|
-
- Raise error if you forgot to add the Router middleware
|
192
|
-
- Make OpenapiFirst.app raise an error in test env when request path is not specified
|
193
|
-
- Rename OperationResolver to Responder
|
194
|
-
- Add ResponseValidation middleware that validates the response body
|
195
|
-
- Add `raise` option to Router middleware to raise an error if request could not be found in the API description similar to committee's raise option.
|
196
|
-
- Move namespace option from Router to OperationResolver
|
197
|
-
|
198
|
-
## 0.10.2
|
199
|
-
|
200
|
-
- Return 400 if request body has invalid JSON ([issue](https://github.com/ahx/openapi_first/issues/73)) thanks Thomas Frütel
|
201
|
-
|
202
|
-
## 0.10.1
|
203
|
-
|
204
|
-
- Fix duplicated key in `required` when generating JSON schema for `some[thing]` parameters
|
205
|
-
|
206
|
-
## 0.10.0
|
207
|
-
|
208
|
-
- Add support for query parameters named `"some[thing]"` ([issue](https://github.com/ahx/openapi_first/issues/40))
|
209
|
-
|
210
|
-
## 0.9.0
|
211
|
-
|
212
|
-
- Make request validation usable standalone
|
213
|
-
|
214
|
-
## 0.8.0
|
215
|
-
|
216
|
-
- Add merged parameter and request body available to env at `env[OpenapiFirst::INBOX]` in request validation
|
217
|
-
- Path and query parameters with `type: boolean` now get converted to `true`/`false`
|
218
|
-
- Rename `OpenapiFirst::PARAMS` to `OpenapiFirst::PARAMETERS`
|
219
|
-
|
220
|
-
## 0.7.1
|
221
|
-
|
222
|
-
- Add missing `require` to work with new version of `oas_parser`
|
223
|
-
|
224
|
-
## 0.7.0
|
225
|
-
|
226
|
-
- Make use of hanami-router, because it's fast
|
227
|
-
- Remove option `allow_unknown_query_paramerters`
|
228
|
-
- Move the namespace option to Router
|
229
|
-
- Convert numeric path and query parameters to `Integer` or `Float`
|
230
|
-
- Pass the Rack env if your action class' initializers accepts an argument
|
231
|
-
- Respec rack's `env['SCRIPT_NAME']` in router
|
232
|
-
- Add MIT license
|
233
|
-
|
234
|
-
## 0.6.10
|
235
|
-
|
236
|
-
- Bugfix: params.env['unknown'] now returns `nil` as expected. Thanks @tristandruyen.
|
237
|
-
|
238
|
-
## 0.6.9
|
239
|
-
|
240
|
-
- Removed radix tree, because of a bug (https://github.com/namusyaka/r2ree-ruby/issues/2)
|
241
|
-
|
242
|
-
## 0.6.8
|
243
|
-
|
244
|
-
- Performance: About 25% performance increase (i/s) with help of c++ based radix-tree and some optimizations
|
245
|
-
- Update dependencies
|
246
|
-
|
247
|
-
## 0.6.7
|
248
|
-
|
249
|
-
- Fix: version number of oas_parser
|
250
|
-
|
251
|
-
## 0.6.6
|
252
|
-
|
253
|
-
- Remove warnings for Ruby 2.7
|
254
|
-
|
255
|
-
## 0.6.5
|
256
|
-
|
257
|
-
- Merge QueryParameterValidation and ReqestBodyValidation middlewares into RequestValidation
|
258
|
-
- Rename option to `allow_unknown_query_paramerters`
|
259
|
-
|
260
|
-
## 0.6.4
|
261
|
-
|
262
|
-
- Fix: Rewind request body after reading
|
263
|
-
|
264
|
-
## 0.6.3
|
265
|
-
|
266
|
-
- Add option to parse only certain paths from OAS file
|
267
|
-
|
268
|
-
## 0.6.2
|
269
|
-
|
270
|
-
- Add support to map operationIds like `things#index` or `web.things_index`
|
271
|
-
|
272
|
-
## 0.6.1
|
273
|
-
|
274
|
-
- Make ResponseValidator errors easier to read
|
275
|
-
|
276
|
-
## 0.6.0
|
277
|
-
|
278
|
-
- Set the content-type based on the OpenAPI description [#29](https://github.com/ahx/openapi-first/pull/29)
|
279
|
-
- Add CHANGELOG 📝
|
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
gem 'rack', '>= 3.0.0'
|
8
|
-
gem 'rackup'
|
9
|
-
|
10
|
-
group :test, :development do
|
11
|
-
gem 'actionpack'
|
12
|
-
gem 'bundler'
|
13
|
-
gem 'rack-test'
|
14
|
-
gem 'rake'
|
15
|
-
gem 'rspec'
|
16
|
-
gem 'rubocop'
|
17
|
-
gem 'simplecov'
|
18
|
-
end
|