[scala-sttp4] Model named Request shadows sttp.client4.Request - #24682
Merged
wing328 merged 1 commit intoAug 13, 2026
Merged
Conversation
A schema named `Request` produces `import <modelPackage>.Request` in every generated API. An explicit import outranks a wildcard import regardless of order, so it shadows `sttp.client4.Request` from `import sttp.client4._` and the operation's return type resolves to the model: error: org.openapitools.client.model.Request does not take type parameters Qualify the return type as `sttp.client4.Request[...]`, matching what the scala-sttp generator already emits.
vivekmahajan
marked this pull request as ready for review
August 12, 2026 07:09
Member
|
thanks for the PR which has been merged. another way to resolve the issue is to use the model name mapping option: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#name-mapping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24680.
A schema named
Requestmakes the generatedscala-sttp4client fail to compile. Every generated API imports its models explicitly and then wildcard-imports sttp:In Scala an explicit import outranks a wildcard import regardless of order, so
Requestresolves to the model, and the unqualified return type fails:Requestis a common schema name for RPC-style APIs. Thescala-sttp(sttp3) generator already emits the qualifiedsttp.client3.Request[..., Any]and is unaffected; this change bringsscala-sttp4in line by emittingsttp.client4.Request[...].Tests:
Sttp4CodegenTest#verifyModelNamedRequestDoesNotShadowSttpRequestwith a new fixture (sttp4-request-model-name.yaml) declaring schemas namedRequestandResponse, asserting both the explicit model import and the qualified return type. Verified by compiling the generated client for that spec, plus 13 real-world specs that declare aRequestschema — all of which previously failed to compile and now succeed.Samples regenerated via
./bin/generate-samples.sh bin/configs/scala-sttp4*.yaml; the change is confined to API return types, and both thescala-sttp4andscala-sttp4-circesamples still compile. No generator options changed, so no doc export changes.PR checklist
master.Summary by cubic
Qualifies API method return types in generated
scala-sttp4clients assttp.client4.Request[...]to avoid collisions when a model is namedRequest. Fixes compile errors and aligns behavior withscala-sttp.Sttp4CodegenTest#verifyModelNamedRequestDoesNotShadowSttpRequestwith a spec usingRequest/Responsemodels.scala-sttp4andscala-sttp4-circesamples; both compile; no generator options or docs changed.Written for commit d64ff7c. Summary will update on new commits.