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

README examples need more clarification #72

Open
JoeCordingley opened this issue Oct 9, 2020 · 3 comments
Open

README examples need more clarification #72

JoeCordingley opened this issue Oct 9, 2020 · 3 comments

Comments

@JoeCordingley
Copy link

JoeCordingley commented Oct 9, 2020

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?

@JoeCordingley
Copy link
Author

JoeCordingley commented Oct 9, 2020

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.

@andyglow
Copy link
Owner

andyglow commented Oct 12, 2020

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.

@andyglow
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants