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

codegen: Permit autogenerating types aliases for endpoints #4213

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

hughsimpson
Copy link
Contributor

@hughsimpson hughsimpson commented Dec 19, 2024

Adds a new openapiGenerateEndpointTypes setting (default false).

If 'true', we will generate type aliases for generated endpoint declarations (see changes to openapi-codegen/sbt-plugin/src/sbt-test/sbt-openapi-codegen/oneOf-json-roundtrip/Expected.scala.txt).

If 'false' the only behavioural change should be that the LUB type is specified explicitly when generating .errorOut(oneOf[LUB](oneOfVariant... stuff (this is actually a little nicer usually -- it means the type will be TheParentType rather than TheParentType with Product with Serializable)

I would find having pre-defined type aliases for all the endpoint types to be extremely useful; locally I have a sourceGenerator step that replaces the lazy val generatedEndpoints = List(...) declaration on generated files with an HList (which is easy to do) to help ensure exhaustivity on implementation; having the type aliases available would make the subsequent 'serverLogic' binding declarations so much nicer, and it's next to impossible to generate them outside of the tapir code generation itself.

@adamw
Copy link
Member

adamw commented Dec 19, 2024

That's quite a big set of changes. Nice work! :)

@adamw adamw merged commit 7f079cf into softwaremill:master Dec 19, 2024
28 checks passed
@hughsimpson hughsimpson deleted the types_for_endpoints branch December 19, 2024 18:38
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

Successfully merging this pull request may close these issues.

2 participants