Skip to content

[scala-sttp4] Model named Request shadows sttp.client4.Request - #24682

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
vivekmahajan:fix/scala-sttp4-request-name-collision
Aug 13, 2026
Merged

[scala-sttp4] Model named Request shadows sttp.client4.Request#24682
wing328 merged 1 commit into
OpenAPITools:masterfrom
vivekmahajan:fix/scala-sttp4-request-name-collision

Conversation

@vivekmahajan

@vivekmahajan vivekmahajan commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #24680.

A schema named Request makes the generated scala-sttp4 client fail to compile. Every generated API imports its models explicitly and then wildcard-imports sttp:

import org.openapitools.client.model.Request
import sttp.client4._

In Scala an explicit import outranks a wildcard import regardless of order, so Request resolves to the model, and the unqualified return type fails:

error: org.openapitools.client.model.Request does not take type parameters
  def predict(request: Request): Request[Either[ResponseException[String], Response]] =
                                 ^

Request is a common schema name for RPC-style APIs. The scala-sttp (sttp3) generator already emits the qualified sttp.client3.Request[..., Any] and is unaffected; this change brings scala-sttp4 in line by emitting sttp.client4.Request[...].

Tests: Sttp4CodegenTest#verifyModelNamedRequestDoesNotShadowSttpRequest with a new fixture (sttp4-request-model-name.yaml) declaring schemas named Request and Response, 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 a Request schema — 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 the scala-sttp4 and scala-sttp4-circe samples still compile. No generator options changed, so no doc export changes.

PR checklist


Summary by cubic

Qualifies API method return types in generated scala-sttp4 clients as sttp.client4.Request[...] to avoid collisions when a model is named Request. Fixes compile errors and aligns behavior with scala-sttp.

  • Bug Fixes
    • Added Sttp4CodegenTest#verifyModelNamedRequestDoesNotShadowSttpRequest with a spec using Request/Response models.
    • Regenerated scala-sttp4 and scala-sttp4-circe samples; both compile; no generator options or docs changed.

Written for commit d64ff7c. Summary will update on new commits.

Review in cubic

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
vivekmahajan marked this pull request as ready for review August 12, 2026 07:09

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Re-trigger cubic

@wing328
wing328 merged commit 123b428 into OpenAPITools:master Aug 13, 2026
25 checks passed
@wing328

wing328 commented Aug 13, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][scala-sttp4] A schema named Request shadows sttp.client4.Request and the generated client does not compile

2 participants