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

Support Union Types in Tapir #3412

Closed
pme123 opened this issue Dec 19, 2023 · 0 comments · Fixed by #3425
Closed

Support Union Types in Tapir #3412

pme123 opened this issue Dec 19, 2023 · 0 comments · Fixed by #3425
Assignees

Comments

@pme123
Copy link

pme123 commented Dec 19, 2023

At the moment it is not possible to use Union Types in Tapir
The following Code does not work:

case class In(
      subStatusKey: SubStatusKeyDocuments | SubStatusKeyGeneral = SubStatusKeyDocuments.`documents-prepared`,
     )
object In:
    given Schema[In] = Schema.derived
    given CirceCodec[In] = deriveCodec
end In

enum SubStatusKeyGeneral derives ConfiguredEnumCodec:
  case canceled
  case finished

object SubStatusKeyGeneral:
  given Schema[SubStatusKeyGeneral] = Schema.derivedEnumeration[T].defaultStringBased
end SubStatusKeyGeneral
...

Expectations

  • If there are Schemas for all of the Union Types, this should work out of the box, otherwise throw an exception which of the types are missing the Schema.
  • The output should look be 'oneOf' the types.
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 a pull request may close this issue.

2 participants