-
Notifications
You must be signed in to change notification settings - Fork 77
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
Recursive type in endpoint input causes misleading error #181
Labels
bug
Something isn't working
Comments
Generated before recursion: //Hello.scala
package demo.smithy
import smithy4s.syntax._
case class Hello(id: String)
object Hello extends smithy4s.ShapeTag.Companion[Hello] {
val id: smithy4s.ShapeId = smithy4s.ShapeId("demo.smithy", "Hello")
val hints : smithy4s.Hints = smithy4s.Hints(
id,
)
val schema: smithy4s.Schema[Hello] = struct(
string.required[Hello]("id", _.id).withHints(smithy.api.Required()),
){
Hello.apply
}.withHints(hints)
implicit val staticSchema : schematic.Static[smithy4s.Schema[Hello]] = schematic.Static(schema)
}
//HelloInput.scala
package demo.smithy
import smithy4s.syntax._
case class HelloInput(hello: Hello)
object HelloInput extends smithy4s.ShapeTag.Companion[HelloInput] {
val id: smithy4s.ShapeId = smithy4s.ShapeId("demo.smithy", "HelloInput")
val hints : smithy4s.Hints = smithy4s.Hints(
id,
)
val schema: smithy4s.Schema[HelloInput] = struct(
Hello.schema.required[HelloInput]("hello", _.hello).withHints(smithy.api.Required(), smithy.api.HttpPayload()),
){
HelloInput.apply
}.withHints(hints)
implicit val staticSchema : schematic.Static[smithy4s.Schema[HelloInput]] = schematic.Static(schema)
} After recursion: //Hello.scala
package demo.smithy
import smithy4s.syntax._
case class Hello(id: String, next: Option[Hello] = None)
object Hello extends smithy4s.ShapeTag.Companion[Hello] {
val id: smithy4s.ShapeId = smithy4s.ShapeId("demo.smithy", "Hello")
val hints : smithy4s.Hints = smithy4s.Hints(
id,
)
val schema: smithy4s.Schema[Hello] = recursive(struct(
string.required[Hello]("id", _.id).withHints(smithy.api.Required()),
Hello.schema.optional[Hello]("next", _.next),
){
Hello.apply
}.withHints(hints))
implicit val staticSchema : schematic.Static[smithy4s.Schema[Hello]] = schematic.Static(schema)
}
//HelloInput.scala
package demo.smithy
import smithy4s.syntax._
case class HelloInput(hello: Hello)
object HelloInput extends smithy4s.ShapeTag.Companion[HelloInput] {
val id: smithy4s.ShapeId = smithy4s.ShapeId("demo.smithy", "HelloInput")
val hints : smithy4s.Hints = smithy4s.Hints(
id,
)
val schema: smithy4s.Schema[HelloInput] = recursive(struct(
Hello.schema.required[HelloInput]("hello", _.hello).withHints(smithy.api.Required(), smithy.api.HttpPayload()),
){
HelloInput.apply
}.withHints(hints))
implicit val staticSchema : schematic.Static[smithy4s.Schema[HelloInput]] = schematic.Static(schema)
} First thing that surprises me is that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on 0.12.11.
For this spec:
For this Scala:
Run
sbt run
.If you remove the recursive call in the
Hello
shape, it works. If you keep it:The text was updated successfully, but these errors were encountered: