[BUG][Java] Nested <OperationId>Request class collides with request body model, breaking existing methods
Maintainer thường phản hồi trong vòng 1 ngày
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
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java, openapi
- Lĩnh vực
- backend-api-design, tooling
Hướng nghiên cứu
Read Java/libraries/webclient/single_request_parameter.mustache and inspect the Java WebClient generator tests for useSingleRequestParameter. The issue includes a minimal OpenAPI spec shape, though it has not been run separately; generate a client with that shape and inspect the *Api class. Done means the generated nested request class no longer shadows the body model and positional callers can still pass that model.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
With useSingleRequestParameter set to true or static, the Java client generates a nested class named <OperationId>Request inside each *Api class. When a request body model has that same name, the nested class shadows the model inside the *Api class:
- The existing positional method's body parameter now resolves to the nested class, so existing callers that pass the model no longer compile.
- The nested class's body field is typed as the nested class itself, so there is no way to send the real body.
Enabling the option is expected to be additive (the positional methods are still generated), but in this case it breaks the existing API.
openapi-generator version
Seen with 7.14.0 and 7.27.0 (Gradle plugin). On master, Java/libraries/webclient/single_request_parameter.mustache uses the same <OperationId>Request naming with no collision handling.
OpenAPI declaration file content or url
Minimal spec showing the shape (an operation updateFoo whose request body model is UpdateFooRequest). The behaviour was observed on a larger spec with the same pattern; this reduced version has not been run separately.
openapi: 3.0.3
info: { title: repro, version: "1" }
paths:
/foo/{id}:
patch:
operationId: updateFoo
parameters:
- { name: id, in: path, required: true, schema: { type: string } }
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/UpdateFooRequest' }
responses:
'200': { description: ok }
components:
schemas:
UpdateFooRequest:
type: object
properties:
name: { type: string }
Generation Details
generatorName: java, library: webclient, useSingleRequestParameter: static (same result with true).
Steps to reproduce
- Generate a Java
webclientclient from the spec above withuseSingleRequestParameterset tostaticortrue. - Look at the generated
*Apiclass.
Actual: a nested public static class UpdateFooRequest containing private UpdateFooRequest updateFooRequest. The positional updateFoo(String id, UpdateFooRequest updateFooRequest) now resolves to the nested class, so code passing the model UpdateFooRequest fails with incompatible types: <model>.UpdateFooRequest cannot be converted to <Api>.UpdateFooRequest.
Expected: no shadowing, for example by giving the request class a non-colliding name (such as UpdateFooRequestParams) or by using fully qualified model names in signatures when a collision exists.
Related issues/PRs
#19827 (adds the option to WebClient), #20679, #24568. I did not find an existing issue for this collision.
- Ngôn ngữ chính
- Java
- Star
- 26.9k
- Fork
- 7.8k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọ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 OpenAPITools/openapi-generator
-
Issue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
OpenAPITools/openapi-generator#25643 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Có thể đã có người làm @Inf1mum đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25567 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceCó thể đã có người làm @Inf1mum đã nhận 9 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
OpenAPITools/openapi-generator#25524 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởEnhancement: Feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationCó thể đã có người làm @amalsaidov đã nhận hôm nay. Đang mở
Độ 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
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/ai area/backend component/zeebe kind/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày