Description
If I use Committee::Middleware::RequestValidation, the date-time conversion is done at the same time as the request is processed.
Then, if I run assert_request_schema_confirm, the conversion is already completed and the validation will fail in the following part
https://github.com/ota42y/openapi_parser/blob/v0.12.1/lib/openapi_parser/schema_validators/string_validator.rb#L11
At this time, the value is already converted to DateTime.
Is this a bug?
If you have any solutions, please let me know.
Environment
ruby 2.7.1
rails 6.0.3.2
committee 4.2.0
rspec 3.9.0
application.rb
config.middleware.use Committee::Middleware::RequestValidation, schema_path: schema_path, parse_response_by_content_type: false
OpenAPI 3.0 yaml
/contents:
get:
summary: example
description: example
parameters:
- in: query
name: q
description: filtering
required: false
style: deepObject
schema:
type: object
description: filtering
properties:
start_at_gteq:
type: string
description: start_at greater than or equal
format: date-time
example: "2019-10-01T00:00:00+9:00"
nullable: true
end_at_lteq:
type: string
description: end_at less than or equal
format: date-time
example: "2019-10-31T23:59:59+9:00"
nullable: true
responses:
"200":
description: contents list
...
spec
it "foo" do
get contents_url(q: { start_at_gteq: "2020-01-01", end_at_lteq: "2020-01-31" })
assert_request_schema_confirm
assert_response_schema_confirm
expect(response).to have_http_status(:success)
end
spec result
Committee::InvalidRequest: #/.../schema/properties/end_at_lteq expected string, but received DateTime: 2020-01-31T00:00:00+00:00
0) ContentsController request spec GET #index ...
Failure/Error: assert_request_schema_confirm
Committee::InvalidRequest:
#/.../schema/properties/end_at_lteq expected string, but received DateTime: 2020-01-31T00:00:00+00:00
# ./spec/spec.rb:98:in `block (6 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# OpenAPIParser::ValidateError:
# #/.../schema/properties/end_at_lteq expected string, but received DateTime: 2020-01-31T00:00:00+00:00
# ./spec/spec.rb:98:in `block (6 levels) in <top (required)>'

Description
If I use
Committee::Middleware::RequestValidation, the date-time conversion is done at the same time as the request is processed.Then, if I run
assert_request_schema_confirm, the conversion is already completed and the validation will fail in the following parthttps://github.com/ota42y/openapi_parser/blob/v0.12.1/lib/openapi_parser/schema_validators/string_validator.rb#L11
At this time, the value is already converted to
DateTime.Is this a bug?
If you have any solutions, please let me know.
Environment
application.rb
OpenAPI 3.0 yaml
spec
spec result