Skip to content

codegen: generate enum schemas for enums - #5453

Merged
adamw merged 2 commits into
softwaremill:masterfrom
hughsimpson:fix_enum_schema_derivation_in_codegen
Aug 7, 2026
Merged

codegen: generate enum schemas for enums#5453
adamw merged 2 commits into
softwaremill:masterfrom
hughsimpson:fix_enum_schema_derivation_in_codegen

Conversation

@hughsimpson

@hughsimpson hughsimpson commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

We were using derived for pretty much all schemas (with some exceptions for ADT types). This is wrong for enums, which need derivedEnumeration.defaultStringBased instead. For most codegen usecases this is probably pretty irrelevant; but if, like me, you're trying to reuse some generated schemas in websocket apis, and generating AsyncApi from that, it ends up generating some bad schemas for enums, which is sad.

Updates plugin tests to reflect updated schema gen, and adds new tests that enums roundtrip through tapir and are emitting appropriately in regenerated docs for both scala 2 and scala 3. Sadly a couple of tests now no longer work for scala 2 because the runtime compiler doesn't like the enum macro; but scala 3 tests still work and this is all covered by the sbt plugin tests so no great loss.

@hughsimpson
hughsimpson marked this pull request as ready for review August 7, 2026 10:18
@hughsimpson hughsimpson changed the title codegen: generate enum schemas for enums (WIP) codegen: generate enum schemas for enums Aug 7, 2026
@adamw
adamw merged commit bfd3b8a into softwaremill:master Aug 7, 2026
16 checks passed
@adamw

adamw commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thanks!

@hughsimpson
hughsimpson deleted the fix_enum_schema_derivation_in_codegen branch August 7, 2026 12:50
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