Skip to content

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

Closed
@haskiindahouse

Description

@haskiindahouse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions