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

[question] Derivation differences between Scala 2 and 3 #550

Open
cptwunderlich opened this issue Oct 24, 2024 · 3 comments
Open

[question] Derivation differences between Scala 2 and 3 #550

cptwunderlich opened this issue Oct 24, 2024 · 3 comments

Comments

@cptwunderlich
Copy link

I am currently porting our code base from Scala 2 to 3 and we are heavy users of Tapir.

A lot of semi-auto schema derivations broke after the update. From what I can gather, this affects classes, case classes and final case classing implementing AnyVal.

This scastie snippet does not work with Scala 3, but if you change it to Scala 2.13 (and the tapir dependency ofc.) it compiles:
https://scastie.scala-lang.org/BMdIdq6hSRaXrVDNbtjZfg

The code is simply:

import sttp.tapir.Schema

class MyCode(val code: Int) extends AnyVal
val s1: Schema[MyCode] = Schema.derived

The error:

No given instance of type scala.deriving.Mirror.Of[Playground.MyCode] was found for parameter m of method derived in trait SchemaMagnoliaDerivation. Failed to synthesize an instance of type scala.deriving.Mirror.Of[Playground.MyCode]:
	* class MyCode is not a generic product because it is not a case class
	* class MyCode is not a generic sum because it is not a sealed class

My question: Is this to be expected? Is there a way around providing manual schemas for all of these?

@cptwunderlich
Copy link
Author

Ah, I guess #527 answers that - it's not implemented yet.

@adamw
Copy link
Member

adamw commented Oct 24, 2024

Ah ... we should get it implemented then :)

@adamw
Copy link
Member

adamw commented Oct 30, 2024

@cptwunderlich see #552

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

No branches or pull requests

2 participants