scala-jsonschema
scala-jsonschema copied to clipboard
Derived Schema doesn't work with empty case class and case objects
Describe the bug DerivedSchema doesn't work with case classes without fields and case object types
To Reproduce
abstract class WithSchema[T: DerivedSchema] {
def schema: Schema[T] = implicitly[DerivedSchema[T]].schema
}
object ExampleApp extends App {
class MessageSchema extends WithSchema[Message]
println(
JsonFormatter.format(
AsValue.schema(
new MessageSchema().schema,
Version.Draft04()
)
)
)
}
case class Test() // Empty case class
case class Message(test: Test)
and second example:
case object Test
case class Message(test: Test.type)
Expected behavior
Code runs without any errors
Actual results
Compiler fails with
could not find implicit value for evidence parameter of type json.schema.derived.DerivedSchema[Message]
Versions:
- jsonschema version - 0.7.9
- scala version - 2.13.10
Additional context First case from what i know is completely valid example for json schema. Second case is stupid, but still :)
Also it would be nice if macros would print some errors into console during compilation stage.
What are use cases for empty case classes and objects that are not part of sum types?
To be honest with you - never :) Just found randomly and wanted to share. But some compilation errors would be nice.
gotcha. thank you
closing it now in favor of #291