-
Notifications
You must be signed in to change notification settings - Fork 9.1k
v3.2: $self
field (Alternative Approach)
#4556
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
Open
handrews
wants to merge
7
commits into
OAI:v3.2-dev
Choose a base branch
from
handrews:self3
base: v3.2-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75d1ac6
Add `$self` for self-identifying documents
handrews 12d4e74
Fix missing multipart boundary
handrews fb0a559
Move base URI examples to appendix
handrews 71b9436
Improved examples
handrews 837a30b
Fix more example bugs
handrews 2de054b
All example URI paths start with /api/...
handrews fd03f5d
Allow relative `$self`, include examples
handrews 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
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.
I don't understand this sentence.
If I want my OpenAPI Documents to be interoperable, what SHOULD I do when referencing (other) OpenAPI Documents that contain
$self
?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.
@ralfhandl As stated in RFC2119, "SHOULD" and "RECOMMENDED" are equivalent, as are their negations. So anything that is NOT RECOMMENDED is something that you SHOULD NOT do, and therefore you SHOULD do the other thing (in this case, use the
$self
URI as your reference target).I can add a sentence making that explicit if you think it is needed.
This came from a discussion with @karenetheridge about other ambiguities with
$id
. Let's say that you have enabled auto-retrieval of references, treating them as URLs (because you have some reason to believe that will work, like the OAD author said so, out-of-band). If you successfully retrieve a referenced document from X because one$ref
used X, and it has a$self
URI of Y... you've already retrieved it from X. Can you keep referencing it as X or do you have to reference it as Y, even though you know X works because you just got it there?This is a weird case. With JSON Schema, we made a mistake and didn't talk about it, as @karenetheridge pointed out. But intuitively, most people seem to think that if you can use X successfully, and particularly if you already used X as the retrieval URL (actually retrieved, not just supplied as the "yeah if you retrieved this you woudl have gotten it from X" simulated retrieval URI) once and it worked, then X should keep working.
You can come up with a similar situation where the "other" URI is from an encapsulated entity (
multipart/related
example) or even an application-supplied default. These get harder and harder to contrive, but it's possible.I don't want to require (MUST) that implementations support these messy situations. Implementations really SHOULD NOT perform unrestricted retrieval automatically as it's a security nightmare. To say nothing of the weird contortions needed to justify the other possible sources.
But if you are supporting retrieval, you can easily get into this situation where someone uses a retrieval URL that does not match
$self
, and it works, and you have to decide whether to keep letting it work or not.This sentence allows implementations to keep letting that work if they want to, without requiring it. Given the history of
$ref
, particularly in 2.0 (and arguably 3.0) where it is strictly a URL, many tools almost certainly behave this way already. This sentence gives them the flexibility to leave that in place (and keep compatibility for their existing 3.1 customers) while adding the new 3.2 functionality.Does that help? Again, I can tack on "Therefore, for interoperability, OAD authors SHOULD (or even MUST? Techncially it's not interoperable otherwise?) ensure their reference target URIs align with
$self
." or something to that effect if you think it is needed.