scala-jsonschema
scala-jsonschema copied to clipboard
README examples need more clarification
The documentation on the front page makes it difficult to pick up as a new user:
import json._
val personSchema: json.Schema[Person] = Json.schema[Person]
isn't going to work because Json isn't found. It isn't imported and searching for a Json type within the repo doesn't help. Perhaps a compilable examples module or be more explicit in your readme?
I see now that you need to depend on a json implementation such as circe or play in order to use this. And this is not stated in the readme. That is api does not come in if you simply depend on core.
hi @JoeCordingley
import json._
val personSchema: json.Schema[Person] = Json.schema[Person]
works fine as is.
But may be broken iа you would import some other json or Json into the scope.
Please check if you have some Play stuff imported. Names may clash in that case.
depending in json-libraries is necessary in 2 cases
- you are willing to convert
Schema[X]into json ast of certain json-lib..JsObject,JObject, etc - or your model have specified default values of types defined as enum, sealed trait, case class. Scala-JsonSchema library doesn't work with values. it's goal is to setup the contract between code and json-schema representation. so for values we use corresponding json-lib.