-
Notifications
You must be signed in to change notification settings - Fork 4
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
application/openapi+yaml fragment identifier considerations inherits from application/json not application/yaml #71
Comments
RFC 6838 calls out that
The YAML media type registration includes the suffix registration which says
The OpenAPI specification states:
I would think it confusing if the registration for OpenAPI+yaml suggests that yaml anchors are acceptable. I do think the Fragment Identifier considerations in the registrations for application/openapi+json and application/openapi+yaml do need updating as RFC 8259 appears to say nothing about fragment identifiers /cc @ioggstream |
@darrelmiller @ioggstream yes, RFC 8259 §11 specifically avoids defining fragments for JSON, and RFC 6901 §6 explicitly states that JSON Pointer fragments are not usable with I've always been confused about the viability of saying things like:
There are three cases:
This has become an increasingly vexing corner case, particularly as, outside of HTTP and similar systems, there is not always a clear way to associate a media type with a document in the first place. This is even more complex in AsyncAPI given the range of schema formats. |
@MikeRalphson Welcome! Please, see @darrelmiller reply: YAML registration doesn't limit openapi+yaml
FTR it's from OAS3.1, I agree that without content negotiation it's hard...
Can you please reference the section of RFC6901 above? |
Hi @ioggstream & @darrelmiller!
That's not much of an answer I'm afraid 😁 it's just an appeal to authority, but it's a reference to another Draft RFC which isn't finalised yet. My point still stands - the complexity of parsing OAS documents composed of resources with mediatypes This is without considering that many existing bundling implementations simply use a YAML parser to parse both YAML and JSON, but now they're going to need different logic for fragment resolution for each.
My question also still stands and I've highlighted the relevant word. 😄 If OAS documents can't contain YAML aliases (I think that falls under the spec's RECOMMENDED wording, but it's not absolutely clear) then there isn't any problem in having an 'unused' fragment resolution rule for fragments beginning with |
@MikeRalphson Does the answer from #72 provide justification as to the "why"? It would seem unreasonable to force the requirement of alias resolution on every media type that is based on yaml, when as you pointed out, the aliasing information may not be preserved. |
@ioggstream from RFC 6901 §6, bold italics added:
|
Oh, I think this different from
Peace, |
@darrelmiller but we have (to at least some degree) proved that alias information can be retrieved, with some parser implementations. What hasn't been addressed is the complexity issue. |
I agree. But this affects many linked resources that use generic media types (including json-ld, geojson, etc.) in all cases where the specific media type is not used.
Registering and using the right media type for every application contributes to the interoperability of the system. Once all media types are registered, implementers will use the proper media type and things will become simpler. As @handrews says, JSON doesn't default to json-pointers. To process with JSON Pointers you need to ensure beforehand that the resource is OAS (e.g. json-ld has its own fragment identifier). OT: |
@ioggstream yes, raw.githubusercontent is weird. |
I agree and had issues with all kind of resources exposed as text/plain via raw.githubusercontent. I am not sure that the way folks use a platform cannot impact on standards, though. Maybe raw.gh will add media type support one day :) |
I don't understand your rather casual dismissal here, although perhaps I am misreading you. I do not know how else to interpret that line from RFC 6901 §6 other than as a directive to avoid using JSON Pointer fragments with The reason that I bring all of this up is that I've gotten pushback on using JSON Pointer fragments with I would really love to have an answer to this question that will hold up in formal situations. RFC 3986 §4.5 has this to say about the validity of fragment semantics (bold italics added):
|
@handrews I read this statement as the authors of the JSON Pointer specification clarifying that the creation of JSON Pointer didn't suddenly make it the official fragment identifier of JSON Pointer fragments cannot be used with |
@darrelmiller a I think I got the conversation in this PR crossed with something else where people have argued that some other unknown document referenced by an API description file with a URI can use JSON Pointer fragments regardless of the target media type, as long as it appears to be JSON. But if all @ioggstream and everyone else here is talking about is using it for |
I read it as:
I think that anyway we are all on the same page: an oas document should be served using the application/OpenAPI+JSON media type and not the generic application/json Implementations will improve in time. |
@ioggstream I think your explanation makes sense, and point 1 aligns with how I read various standards. Do you have any reference for point 2 or is it just your personal sense of how things ought to work? I agree with 2, I just have never found any standards document that clearly justifies it. I have a reason for pushing this, but I'm going to open a new issue as it is beyond the scope of this one — I'll link it here (#75), please add your answer to the new issue. |
My understanding is based on the following points:
MUST NOT is not that frequent. I will investigate further, though. Thanks for asking. |
@ioggstream That makse sense to me. To be clear, I'm not trying to block anything here, it's more that I want to know if what I am talking about in issue #75 is possible. Because if so, we might want to do that as part of the API media types work. |
@darrelmiller @ioggstream See discussion here re: whether YAML anchors and aliases are explicitly allowed or disallowed by OpenAPI 3.x. |
Apologies I'm coming late to this repo and this may have already been discussed. Feel free to point me to an existing issue/comment.
@dret suggested I raise issues here.
mediatypes/draft-ietf-httpapi-rest-api-mediatypes.md
Lines 164 to 165 in 0d2cef8
I can see why this might possibly be (because OpenAPI recommends not using YAML alias nodes because they aren't directly expressable in JSON, so only one fragment resolution method is required: JSON Pointer), but I can see this causing problems / adding complexity when (say) an OpenAPI bundling tool is resolving references which could be to OAS documents in YAML, plain YAML resources, JSON Schema in YAML etc.
One common consideration is GitHub
raw.
links, which I believe are always served astext/plain
, requiring bundlers to "sniff" content to enable the correct parsing rules. Obviously you need to parse the YAML somehow in order to identify it, in order to parse it correctly so fragments can be extracted.Essentially my question is why doesn't
application/openapi+yaml
inherit fragment resolution rules fromapplication/yaml
?The text was updated successfully, but these errors were encountered: