Skip to content

codegen: various minor fixes and improvements#5374

Merged
adamw merged 10 commits into
softwaremill:masterfrom
hughsimpson:fix_discriminator_field_value_generation
Jul 7, 2026
Merged

codegen: various minor fixes and improvements#5374
adamw merged 10 commits into
softwaremill:masterfrom
hughsimpson:fix_discriminator_field_value_generation

Conversation

@hughsimpson

@hughsimpson hughsimpson commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

A few sundry things:

  • The discriminator of each child of a oneOf is reified as def $discriminatorName: String = "...", but the parent type didn't declare the abstract method, which was irritating. Parent will now declare the method.
  • Fixes a reference bug when inheriting an enum using circe serdes, where parent didn't use enum in json bodies but the child does, and seperateFilesForModels=true
  • Adds a openapiAlwaysGenerateParamSupport boolean flag, so that enums can be defined in an inherited openapi and used in path position, without having to redeclare them (and everything that transitively contains them)
  • Fixes client encoding of non-exploded array params (was using a .map instead of a .flatMap and producing e.g. ?myParam=List(uuid1),List(uuid2) instead of ?myParam=uuid1,uuid2 when encoding)
  • Remove redundant backticks from discriminator method names when the property name is not a reserved name
  • Tries harder to construct type aliases for inline definitions when 'deduplicating' between schemas. It doesn't work as it should but it's better
  • Creates val aliases for 'dedupped' case class definitions

@hughsimpson hughsimpson changed the title codegen: add discrimator field to parent traits of ADTSs codegen: add discriminator field to parent traits of ADTSs Jul 5, 2026
@hughsimpson hughsimpson changed the title codegen: add discriminator field to parent traits of ADTSs codegen: add discriminator field to parent traits of ADTs Jul 5, 2026
@hughsimpson hughsimpson marked this pull request as ready for review July 5, 2026 16:36
@hughsimpson hughsimpson marked this pull request as draft July 5, 2026 18:47
@hughsimpson

hughsimpson commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I don't want to deal with merge conflicts on the other prs 😅 so I'm leaving as a draft for now

EDIT: OK rebased now

@hughsimpson hughsimpson force-pushed the fix_discriminator_field_value_generation branch 2 times, most recently from 80a3f24 to f529f57 Compare July 7, 2026 10:15
@hughsimpson hughsimpson marked this pull request as ready for review July 7, 2026 10:58
EnumExtraParamSupport(enumName, T)
sealed trait ADTWithDiscriminator
sealed trait ADTWithDiscriminator { def `type`: String }
sealed trait ADTWithDiscriminatorNoMapping

@hughsimpson hughsimpson Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The def isn't generated here because the property name is noMapType on this oneOf and the children don't declare that field. I think that's strictly speaking invalid openapi but anyway...

@hughsimpson hughsimpson force-pushed the fix_discriminator_field_value_generation branch from b0eca6a to 6d1ccb3 Compare July 7, 2026 11:51
@hughsimpson hughsimpson changed the title codegen: add discriminator field to parent traits of ADTs codegen: various minor fixes and improvements Jul 7, 2026
@hughsimpson hughsimpson marked this pull request as draft July 7, 2026 11:55
@hughsimpson hughsimpson force-pushed the fix_discriminator_field_value_generation branch from 7301b76 to 70cdeb8 Compare July 7, 2026 12:00
@hughsimpson hughsimpson marked this pull request as ready for review July 7, 2026 12:50
@adamw adamw merged commit 650cca4 into softwaremill:master Jul 7, 2026
16 checks passed
@adamw

adamw commented Jul 7, 2026

Copy link
Copy Markdown
Member

Thank you :)

@hughsimpson hughsimpson deleted the fix_discriminator_field_value_generation branch July 7, 2026 13:51
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