-
-
Notifications
You must be signed in to change notification settings - Fork 37
Use json_schema instead of json-schema #31
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put a comma after the last item of a multiline hash.
|
@seanpdoyle I'd love your feedback on my comments above when you have time. There's no rush -- this is a work in progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
After some debug was discovered that the JSON pointers are not working [1]. This patch make the JSON Pointers working again following the recommendation from @brandur [2]. As a note json_matchers has a issue that they are doing the movement from json-schema to json_schema [3]. [1]: 0852b49#commitcomment-14792738 [2]: brandur/json_schema#41 (comment) [3]: thoughtbot/json_matchers#31
5533850 to
06862a5
Compare
spec/factories.rb
Outdated
| "required": [plural], | ||
| "properties": { | ||
| plural => { | ||
| "$ref": "#/definitions/#{plural}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
lib/json_matchers/matcher.rb
Outdated
| ) | ||
| end | ||
|
|
||
| def document_store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/DuplicateMethods: Method JsonMatchers::Matcher#document_store is defined at both lib/json_matchers/matcher.rb:28 and lib/json_matchers/matcher.rb:48.
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit deprecates support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so in the future we'll need to remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit deprecates support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so in the future we'll need to remove support entirely. Bump gem version to `0.9.0`. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit deprecates support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so in the future we'll need to remove support entirely. Bump gem version to `0.9.0`. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
In preparation for [#31][#31], this commit removes support for global and matcher-specific options, like `strict: true`. The [`json_schema` gem][gem] does not accept similar configuration options, so we'll remove support entirely. [#31]: #31 [gem]: https://github.com/brandur/json_schema#programmatic
8aaaf02 to
5c4a437
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
README.md
Outdated
| To learn more about `$ref`, check out | ||
| [Understanding JSON Schema Structuring][$ref]. | ||
|
|
||
| [$ref]: http://spacetelescope.github.io/understanding-json-schema/structuring.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https now!
lib/json_matchers/matcher.rb
Outdated
| Dir.glob("#{JsonMatchers.schema_root}/**/*.json"). | ||
| map { |path| Pathname.new(path) }. | ||
| map { |schema_path| Parser.new(schema_path).parse }. | ||
| map { |schema| document_store.add_schema(schema) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably an #each here.
d69cf35 to
dfba814
Compare
The problem: * `json_matchers` cannot easily be used concurrently with Heroku's JSON API tools, i.e. `prmd` and `committee`, because `json_matchers` makes different assumptions about the structure of the user's schemata. An example of an incompatibility can be found in #25: `json_matchers` breaks when the `id` property is present within a schema, but the Heroku tools require the presence of the `id` property ([reference](https://github.com/interagent/prmd/blob/master/docs/schemata.md#meta-data)). This is happening because the libraries used to dereference JSON pointers behave differently. `json-schema`, the library we're currently using, appears to conform less strictly to the JSON Schema specification than the library the Heroku tools use, `json_schema`. The solution: * One solution to this problem is to update `json_matchers` to use the same approach to validating schemata as the Heroku tools. This will require the following changes: 1. Use `json_schema` instead of `json-schema` to validate schemata 2. Update documentation to instruct readers to follow Heroku's guidelines for structuring schemata: https://github.com/interagent/prmd/blob/master/docs/schemata.md * In this commit I've replaced `json-schema` with `json_schema` and updated the schemata fixtures in the specs. Per [this json_schema issue](brandur/json_schema#22), in order to dereference JSON pointers referencing schemata in other files we need to access the gem's DocumentStore API directly. This is done in `Matcher#build_and_populate_document_store`.
dfba814 to
e8b3cc2
Compare
The problem
json_matcherscannot easily be used concurrently with Heroku's JSON API tools, i.e.prmdandcommittee, becausejson_matchersmakes different assumptions about the structure of the user's schemata. An example of an incompatibility can be found in Having anidparameter in the schema messes up schema nesting #25:json_matchersbreaks when theidproperty is present within a schema, but the Heroku tools require the presence of theidproperty (reference).json-schema, the library we're currently using, appears to conform less strictly to the JSON Schema specification than the library the Heroku tools use,json_schema.The solution
json_matchersto use the same approach to validating schemata as the Heroku tools. This will require the following changes:json_schemainstead ofjson-schemato validate schemataguidelines for structuring schemata:
https://github.com/interagent/prmd/blob/master/docs/schemata.md
strictoption is no longer supportedjson-schemawithjson_schemaand updated the schemata fixtures in the specs. Per this json_schema issue, in order to dereference JSON pointers referencing schemata in other files we need to access the gem's DocumentStore API directly. This is done inMatcher#add_schemata_to_document_store.