-
-
Notifications
You must be signed in to change notification settings - Fork 312
Explain "targetSchema" and HTTP PATCH. #277
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If I'm reading this correctly, proper HTTP semantics when combined with targetSchema suggest that you should be able to read and write (PUT) the same fields? I mean the target shcema properties can use
readOnly
, but we didn't always have that, right?Just making I'm infurring the correct implications from the wording.
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, that's correct, except that
"readOnly"
has been part of Hyper-Schema since the beginning (when it was folded in with core and validation in one draft).But yes, in HTTP performing a GET and then PUT-ing the result of the GET directly back should be a successful no-op (aside from things like auto-updated timestamps).
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.
We did adjust the definition of
"readOnly"
to clarify that it means "under the control of the server" and not "you are forbidden from including this field in PUTs" (the latter would force violation of HTTP semantics so that would be bad).The server can decide whether it needs to detect changes to such fields and raise errors (400 or 409), or whether to silently ignore things. For instance a field that is present to reflect state changes elsewhere probably should never raise an error because of the following scenario:
On that last put, "x" will still have value "y" but on the server, its value is now "z". So that could look like a change. But as a "readOnly" field, the server is allowed to ignore that apparent change.
A resource can also offer different levels of enforcement using the "Prefer" header value's "handling=strict" or "handling=lenient" options.
The above x/y/z/w example probably shouldn't cause an error either way, but for a field that is not likely to change out from under you during a GET/modify/PUT, in lenient mode you could silently ignore changes, while returning a 409 or 400 in strict mode.