`oneOf` in path params is causing validation errors when using OAS 3.0
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
The bug is in path parameter handling: lib/openapi_first/validators/request_parameters.rb around line 15 receives the path as a string when the schema uses oneOf, but as an integer when it uses type: integer. Start by reproducing with the spec in the issue and checking how the path value is coerced before validation. Done means GET /accounts/1 passes for a oneOf integer/enum path parameter, with a regression test added to the request validation specs.
Written by the indexing model from the issue text.
Description
I have the following spec:
openapi: 3.0.1
paths:
/accounts/{id}:
get:
operationId: getAccountId
summary: Get the details of an account
parameters:
- name: id
in: path
required: true
schema:
oneOf:
- type: integer
- type: string
enum: [current]
When validating e.g. GET /accounts/1 request, I get an Path segment is invalid: value at '/id' is not an integer. value at '/id' is not one of: ["current"] error.
The following schema for the path parameter already reproduces the issue:
oneOf:
- type: integer
The following schema does not give a validation error:
type: integer
The parsed_request in /lib/openapi_first/validators/request_parameters.rb:15 in the case of a schema using oneOf:
#<data OpenapiFirst::ParsedRequest path={"id"=>"1"}, ...>, without oneOf: #<data OpenapiFirst::ParsedRequest path={"id"=>1}, ...>, that could cause the path param to be invalid.
I believe the spec above using the schema with the oneOf is valid and should not give validation errors for requests like GET /accounts/1.
- Dominant language
- Ruby
- Stars
- 222
- Forks
- 27
- Avg merge
- 17h 15m
- Merged PRs (30d)
- 6
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ahx/openapi_first
-
Multipart file uploads fail validation with ActionDispatch::Request (UploadedFile isn't a Hash)Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ahx/openapi_first#516 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ahx/openapi_first#484 · 4 comments · 1 reaction ·
-
OpenAPI 3.2 supportMay be free again A pull request for this issue was closed without being merged. Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
ahx/openapi_first#469 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
ahx/openapi_first#425 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ahx/openapi_first#418 · 1 comment · 1 reaction ·
All issues in ahx/openapi_first
Similar issues
-
Bug Ruby
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-ruby#3211 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
internetee/registry#2984 ·
Maintainers usually reply within 6 days
-
interest-zsv
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
hitobito/hitobito_zsv#6 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ecosyste-ms/issues#862 ·
Maintainers usually reply within 1 day
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configuredPossibly taken @mimosa claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day