-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Having an id
parameter in the schema messes up schema nesting
#25
Comments
@Graysonwright thanks for uncovering this. What was the test failure message? |
Looks like a PR for fixing an issue related to the supporting the I am experimenting with using |
Here's the error:
|
* `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`. One solution to this problem is to update `json_matchers` to use the same approach to validating schemata as the Heroku tools. 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
* `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`. One solution to this problem is to update `json_matchers` to use the same approach to validating schemata as the Heroku tools. 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 made an attempt at updating the specs.
* `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`. One solution to this problem is to update `json_matchers` to use the same approach to validating schemata as the Heroku tools. 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 made an attempt at updating the specs.
* `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`. One solution to this problem is to update `json_matchers` to use the same approach to validating schemata as the Heroku tools. This would 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 made an attempt at updating the specs.
I was able to replace A good next step would be for @seanpdoyle to take a look at my branch and review Heroku's guidelines for structuring schemata to determine whether we actually want to take the approach of following their guidelines. If it is, we can take another stab at updating the specs. |
@malandrina that all looks good! What are the implications of switching gems? Does the public API change? Would consumers still be able to write somewhat arbitrary schemata, or would they be restricted to to writing schemata that conform to that standard? Is our best approach an all-or-nothing change, or could/would/should we gradually migrate? |
@seanpdoyle great questions!
|
Per our discussion IRL today, we've decided it makes sense to switch to Given that, we need to:
|
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#add_schemata_to_document_store`.
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#add_schemata_to_document_store`.
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#add_schemata_to_document_store`.
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#add_schemata_to_document_store`.
@malandrina @seanpdoyle Is this dead? |
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#add_schemata_to_document_store`.
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#add_schemata_to_document_store`.
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#add_schemata_to_document_store`.
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`.
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`.
Hey @Graysonwright and @malandrina from the past! We were hoping for some clarification on this issue. Specifically, we were able With the old validator, when we specify the nested schema's it 'works with an id' do
nested = create(:schema, name: "nested", json: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "string",
"id": "nested.json"
})
schema = create(:schema, {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"a": { "$ref": "nested.json" }
}
})
response = double(body: '{ "a": "b" }')
expect(response).to match_response_schema(schema)
end That test passes with If you've experimented with the current it 'works with an id' do
nested = create(:schema, name: "nested", json: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "string",
"id": "file:/nested.json"
})
schema = create(:schema, {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"a": { "$ref": "file:/nested.json#" }
}
})
response = double(body: '{ "a": "b" }')
expect(response).to match_response_schema(schema)
end We are unclear on what the purpose of the nested Is there good documentation for this somewhere? Do these workarounds make sense? |
I discovered this bug after generating schemas with
prmd
.Minimal failing spec:
top_level.json
nested.json
Removing the
id
fromnested.json
fixes the spec. Unfortunately,id
is required for compatibility withprmd
. DocumentationThe text was updated successfully, but these errors were encountered: