andyglow / scala-jsonschema

Scala JSON Schema
Other
123 stars 38 forks source link

Fix support for enums with a wrapped val #232

Closed bjornbak closed 2 years ago

bjornbak commented 2 years ago

Describe the bug We are have enums with a wrapped val in our codebase the same as AnyFooBar in https://github.com/andyglow/scala-jsonschema/blob/master/api/src/test/scala/com/github/andyglow/jsonschema/SchemaMacroSpec.scala#L329-L331 but when I upgrade from 0.6.2 to 0.7.6 get the error below.

To Reproduce

Adding this to AsCirceSpec

  property("Check that Schema.asCirce translates AnyFooBar") {
    json.Json
      .schema[List[AnyFooBar]]
      .asCirce(Draft07(id = ""))
      .toString() 
  }

reproduces the error:

[info] - Check that Schema.asCirce translates AnyFooBar *** FAILED ***
[info]   scala.NotImplementedError: an implementation is missing
[info]   at scala.Predef$.$qmark$qmark$qmark(Predef.scala:288)
[info]   at json.Schema$value$minusclass.jsonType(Schema.scala:553)
[info]   at com.github.andyglow.jsonschema.AsDraftSupport.$anonfun$mkOneOf$2(AsDraftSupport.scala:110)
[info]   at scala.Option.map(Option.scala:230)
[info]   at com.github.andyglow.jsonschema.AsDraftSupport.mkOneOf(AsDraftSupport.scala:110)
[info]   at com.github.andyglow.jsonschema.AsDraftSupport.mkOneOf$(AsDraftSupport.scala:104)
[info]   at com.github.andyglow.jsonschema.AsDraft07.mkOneOf(AsDraft07.scala:8)
[info]   at com.github.andyglow.jsonschema.AsDraftSupport$$anonfun$inferSpecifics$1.applyOrElse(AsDraftSupport.scala:172)
[info]   at com.github.andyglow.jsonschema.AsDraftSupport$$anonfun$inferSpecifics$1.applyOrElse(AsDraftSupport.scala:166)
[info]   at scala.PartialFunction$Lifted.apply(PartialFunction.scala:228)

Expected behavior A clear and concise description of what you expected to happen.

Actual results See "To Reproduce"

Versions:

Additional context Add any other context about the problem here.

andyglow commented 2 years ago

@bjornbak thank you for reporting it its being fixed with #234

bjornbak commented 2 years ago

Yes, it working with 0.7.7, thanks!