Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Multiple OpenAPI Schemas Not Processed Correctly in Tapir Codegen #4388

Open
haskiindahouse opened this issue Mar 1, 2025 · 1 comment

Comments

@haskiindahouse
Copy link

Multiple OpenAPI Schemas Not Processed Correctly in Tapir Codegen

Environment:

Tapir version: 1.11.16
Scala version: 3.3.5
SBT version: 1.10.1
Issue Description:
When attempting to generate tapir-clients using multiple OpenAPI YAML files, the code generation fails during compilation. Despite following the instructions from the official Tapir documentation, the process cannot locate the expected files, resulting in a FileNotFoundException.

Steps to Reproduce:

Project Setup:

Create a new Scala project with the following build.sbt configuration:

ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.3.5"

enablePlugins(OpenapiCodegenPlugin)

openapiAdditionalPackages := List(
  "sttp.tapir.generated.v1.bot" -> baseDirectory.value / "bot.openapi.yml",
  "sttp.tapir.generated.v1.scrapper" -> baseDirectory.value / "scrapper.openapi.yml"
)

val bot      = project.settings(libraryDependencies ++= Dependencies.allDeps)
val scrapper = project.settings(libraryDependencies ++= Dependencies.allDeps)

File Placement:

Place two OpenAPI YAML files in the project root:
bot.openapi.yml
scrapper.openapi.yml
Compilation:
Run sbt compile.
Observed Behavior:
The compilation fails with the following error:
[error] (Compile / managedSources) java.io.FileNotFoundException: /Users/haskiindahouse/scala-haskiindahouse/swagger.yaml (No such file or directory)
Notice that the error references swagger.yaml instead of either of the provided YAML files.

Expected Behavior:

Both specified OpenAPI YAML files should be processed correctly, and the tapir-clients should be generated without a file not found error.

Additional Information:

The error suggests that the code generation plugin might be defaulting to look for a file named swagger.yaml even when multiple schemas are specified.
If further logs or debugging details are needed to troubleshoot this issue, please let me know.

Questions:

  • Is this behavior a known limitation when using multiple OpenAPI schemas?
  • Are there any recommended workarounds or additional configuration steps to support multiple YAML files?

Thank you for your assistance in resolving this issue. Please let me know if additional information is required.

@adamw
Copy link
Member

adamw commented Mar 3, 2025

Maybe @hughsimpson could help? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants