-
Notifications
You must be signed in to change notification settings - Fork 421
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
Validation and schema: where does the "validation" key belongs? #174
Comments
First, let's note that there are two locations where the
How it was doneRegarding the collection object, I found it consistent to put it in
The schema is the collection data, it is completely consistent :) Because data is just the name we gave to the main payload of response, and has no further semantics. That's what kinto.js reads when it receives the response. Plus it was very easy to implement, since completely in the rails of current cliquet resource code. As for the record, since we wanted to have a way to filter records by schema version, it had to become a record attribute. In cliquet, we store the data content in the storage backend (which allows filtering) and the permissions in the permissions backend. Removing the oddNow. I fully understand your concern : keeping the application specific properties in But IMO, in order to remain consistent, we should then also move Collection would look like this: {
"id": "087-7u8097908708",
"last_modified": 456789986,
"fingerprint": "11:D5:D2:0A:9A:F8:D9:FC:23:6E:5C",
"data": {
"author": "Bozo the clown",
},
"permissions": {
"write": ["fxa:00567y09"]
},
"schema": {
....json-schema...
}
} Same idea for records: {
"id": "087-7u8097908708",
"last_modified": 78945144,
"fingerprint": "11:D5:D2:0A:9A:F8:D9:FC:23:6E:5C",
"data": {
"title": "F Society",
"url": "http://thefreedictionary.com/decentralize",
},
"permissions": {
"write": ["fxa:00567y09"]
},
"schema": 456789986
} But, hey, this is not a minor task. It does not look like one of our priority either. And it would break kinto.js AFAIK. Even though I find it attractive, I am not sure I want to put a foot in this energy absorbing swirl :) This is pretty huge. PragmatismIn order to implement your idea without inverting too much effort, we could :
But, does it really bring any value ? Will it be fondamentally better ? What are our criterias to evaluate that ? Please note that it would be a lot cleaner if we refactor some part of cliquet resource schema manipulation in order to achieve this. Otherwise payload validation (especially for PATCH request) will have even more ugly parts. I would be motivated to do it though. |
Thanks for your answer 👍 We had a parallel discussion about the location of I was concerned about the complexity it adds to the API, and that's the reason why I like your proposal: it separates the metadata from the data itself, without adding yet another namespace. I would propose that we do that by iterations:
This change would impact both Kinto.js, and Syncto. If we have to break the API, better do it sooner than later: nobody is currently using this protocol for something that shipped. If we want/have to wait, we'll need to think handle backward compatibility, which isn't a concern we have right now. Also, there is something I don't get: why are you saying this is that complex? What do you identify as the potential implementation problems? |
We talked about this in a meeting. The current implementation has the advantage to keep We came with the following conclusion:
|
I would vote for closing this issue in favor of #256 |
A recent pull request introduced schema validation to Kinto. That is a really nice feature and I'm happy to see it shipped.
However, it seems odd to me to have the schema defined inside the
data
attribute. After some discussions with @Natim and @n1k0 it seems that we could all agree on the fact that we expected it to be at the same level than thedata
attribute. e.g.It seems the rationale for putting it inside the data (as it is right now) is to not break the protocol. However, I believe putting it alongside the
data
key doesn't break the protocol either: adding features to kinto by adding values next todata
andpermissions
seems a reasonable choice: the cliquet protocol would sill be respected in this case.@leplatrem what are your thoughts about this? Are we missing the point of having this defined inside the
data
attribute?The text was updated successfully, but these errors were encountered: