`oneOf` in path params is causing validation errors when using OAS 3.0
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 222
- Fork
- 27
- Merge trung bình
- 17 giờ 15 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ahx/openapi_first
-
Multipart file uploads fail validation with ActionDispatch::Request (UploadedFile isn't a Hash)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ahx/openapi_first#516 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
ahx/openapi_first#484 · 4 bình luận · 1 reaction ·
-
OpenAPI 3.2 supportCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
ahx/openapi_first#469 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
ahx/openapi_first#425 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ahx/openapi_first#418 · 1 bình luận · 1 reaction ·
Tất cả issue của ahx/openapi_first
Issue tương tự
-
Bug Ruby
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-ruby#3211 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
internetee/registry#2984 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
interest-zsv
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
hitobito/hitobito_zsv#6 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ecosyste-ms/issues#862 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configuredCó thể đã có người làm @mimosa đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày