Skip to content

Codegen reuse through inheritance #4719

@hughsimpson

Description

@hughsimpson

The use cases would be something like this:
I have 3 api files -- v1, v2, and v3. There are some differences between the three, but for the most part the models are stable between them. To save on compilation time, and to make it simpler to handle the different versions somewhat generically, I would like to be able to declare a dependency map in the build.sbt. Something like:

openapiPackageDependencies := Map(
  "sttp.tapir.generated.v1" -> "sttp.tapir.generated.v2",
  "sttp.tapir.generated.v2" -> "sttp.tapir.generated.v3")

(which would indicate that the 'older' versions had a dependency on the 'newer', so that you were doing conversions with 'latest' as you baseline when working with it. That's how you'd use it for versioning I reckon, but I digress).
The semantics of this would be that, where there was a duplication of the model (including transitive identity in fields), instead of redefining the model, we'd simply create an alias to the duplicate in the other model.

This would, of course, permit inheritance for other reasons.

openapiPackageDependencies := Map(
  "sttp.tapir.generated.component1" -> "sttp.tapir.generated.core",
  "sttp.tapir.generated.component2" -> "sttp.tapir.generated.core")

would also be a use case for this sort of functionality.

Also, we should be able to parse dir structures as well as just single-file openapi.

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