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

Validator.derivedEnumeration to handle sealed sub-level traits #2810

Merged
merged 3 commits into from
Apr 3, 2023

Conversation

ivan-klass
Copy link
Contributor

Fix Validator.derivedEnumeration for cases like below

sealed trait EnumRoot
sealed trait ABranch extends EnumRoot
sealed trait BBranch extends EnumRoot

case object A1 extends ABranch
case object A2 extends ABranch

case object B1 extends BBranch

Validator.derivedEnumeration[EnumRoot]

Expected

  • Validation one of (A1, A2, B1)

Actual

  • compile error All children must be objects or enum cases

@adamw
Copy link
Member

adamw commented Mar 31, 2023

Thanks! I think we'd need similar changes in the scala-2 version of the macro?

@ivan-klass
Copy link
Contributor Author

Thanks! I think we'd need similar changes in the scala-2 version of the macro?

Sure! Fixed. Also realized that scala-3/sttp/tapir/ValidatorScala3EnumTest.scala wasn't the right place for the test - moved to the shared part.

@adamw adamw merged commit 3a703cb into softwaremill:master Apr 3, 2023
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