[BUG][Java] Nested <OperationId>Request class collides with request body model, breaking existing methods
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- java, openapi
- Bereich
- backend-api-design, tooling
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Java
- Sterne
- 26.9k
- Forks
- 7.8k
- Ø Merge
- 2 T. 10 Std.
- Gemergte PRs (30 T.)
- 180
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus OpenAPITools/openapi-generator
-
Issue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
OpenAPITools/openapi-generator#25643 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Evtl. vergeben @Inf1mum hat das vor 2 Tagen übernommen. OffenIssue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
OpenAPITools/openapi-generator#25567 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceEvtl. vergeben @Inf1mum hat das vor 9 Tagen übernommen. OffenIssue: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
OpenAPITools/openapi-generator#25524 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. OffenEnhancement: Feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in OpenAPITools/openapi-generator
Ähnliche Issues
-
bug emitter:client:csharp
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/typespec#12572 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationEvtl. vergeben @amalsaidov hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
needs-area-label
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
area/ai area/backend component/zeebe kind/task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag