Skip to content
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

Define formal media type (MIME type) for Swagger Object #110

Closed
philipashlock opened this issue Sep 15, 2014 · 92 comments
Closed

Define formal media type (MIME type) for Swagger Object #110

philipashlock opened this issue Sep 15, 2014 · 92 comments
Assignees
Milestone

Comments

@philipashlock
Copy link

A media type of application/swagger+json has been suggested on the mailing list before. I would recommend formally declaring this as part of the spec.

RAML defines its media type as application/raml+yaml

API Blueprint defines its base media type as application/vnd.apiblueprint.ast plus similar ones for other serializations

@philipashlock
Copy link
Author

For what it's worth, the White House open data policy is currently documenting application/swagger+json for metadata provided by federal agencies: https://project-open-data.cio.gov/v1.1/api/

If this should be changed, please flag it is an issue on https://github.com/project-open-data/project-open-data.github.io/issues

@webron
Copy link
Member

webron commented Jan 29, 2015

👍

@olensmar
Copy link

I'm all for it and would like to go so far and suggest different mime-types for different encodings and Swagger versions

application/swagger-v20+json
application/swagger-v20+yaml
application/swagger-v12+json
application/swagger-v12+xml

(not really sure we need to add xml for 1.2 but it was in the spec as far as I can remember)

since Swagger 1.2 has separate files for resource listings and api declarations I suggest we make the api declaration implicit and have a separate mime-type for the resource listing

application/swagger-v12-resource-listing+json
application/swagger-v12-resource-listing+xml

or alternatively we make both the api declaration and resource listing explicit;

application/swagger-v12-resource-listing+json
application/swagger-v12-api-declaration+json
application/swagger-v12-resource-listing+xml
application/swagger-v12-api-declaration+xml

If we're aligned I can submit this to IANA... let me know your thoughts

/Ole

@dilipkrish
Copy link
Contributor

@olensmar Not really sure we need to separate resource listing and api declaration. Its implicit by definition that if its application/swagger-v12+json we're going to get a document that conforms to the swagger12 spec. likewise for swagger2 also. Its no different that today where application/json covers both documents (files). In the case of swagger 1.2 the protocol to access the resource listing to get to the api declarations is a shared understanding described by the spec.

As an aside, related to swagger-api/swagger-ui#708 would you be able to assist/ hand-hold so I could also register

application/swagger-v20+hal+json

I'm starting to experiment with a few ideas with swagger and hypermedia support. The thinking is that if we could combine HAL with swagger it would give a rich interactive experience. An on-demand swagger-ui if you will, similar to hal browser. I have very rough ideas that I hope to formalize soon. Initially trying to prototype it in spring using springfox.

@olensmar
Copy link

@dilipkrish thanks! I'd love to talk about hypermedia support in swagger, it's getting asked for in every talk I've done on swagger over the last weeks. I personally think that using the extension mechanism is a good starting point; if we can agree on a set of extensions that add hypermedia-related constructs to a Swagger definition those can be used by related tools without having to change the spec itself - and if they gain a lot of traction we could discuss putting it in the next major revision of the spec.

Regarding the mime-type - I still think there are use-cases where it might be good to be able to differ between resource listings and api declarations - but those might be very application-specific so we can leave them out for now. In that case I suggest we just go with:

application/swagger-v20+json
application/swagger-v20+yaml
application/swagger-v12+json
application/swagger-v12+xml

what about also having

application/swagger+json
application/swagger+yaml

as aliases for the latest version of the spec? (2.0) Or is that some kind of anti-pattern that I'm not aware of?

/Ole

@tomchristie
Copy link

Is there any formal progress on a "application/swagger+json" media type? I'm working on generic client tooling right now, and the lack of a media type for swagger is a minor point of awkwardness there (eg can interact with other schema and hypermedia types without having to explicitly specify what type of media they should be interpreted as, but not so with swagger)

@fehguy
Copy link
Contributor

fehguy commented Jan 24, 2016

I think this is a very good idea to add in the next spec version

@cabbonizio
Copy link

+1

1 similar comment
@jharmn
Copy link
Contributor

jharmn commented Feb 5, 2016

+1

@tomchristie
Copy link

Is this worth the OpenAPI.Next Proposal tag, to ensure it gets consideration?

@webron
Copy link
Member

webron commented Feb 8, 2016

Done.

@cdivilly
Copy link

The lack of a registered Media Type for Open API resources is a hindrance so it would be great to get this resolved.

Whatever Media Type name is chosen, it should be registered in the IANA Media Types Registry.

Versioning information should not appear in the Media Type, the version information is present in the resource representation. The vast majority of Media Types in the IANA registry do not transport any version information. You don't want to have to go through the Media Type registration process each time a new version is minted.

Note that the IANA Media Types registry is partitioned into namespaces, it won't be possible to register application/swagger+json, or application/~anything~+json, as they fall in the Standards Tree namespace, which requires a corresponding IETF (or other recognized standards body) specification.

Registration in the Vendor Tree should be fine, so I would recommend:

application/vnd.open-api+json for the JSON representation, and
application/vnd.open-api+yaml for the YAML representation.

Note that RFC 6839 Section 3.1 formalizes the +json suffix convention. There is no registered Media Type for YAML, and therefore no formalization of the +yaml suffix convention, both these issues may be an obstacle to registration of a Media Type for the YAML representation.

@jharmn
Copy link
Contributor

jharmn commented Feb 16, 2016

@darrelmiller I see RFC, IANA and vnd a lot here...chances are you have thoughts.

@darrelmiller
Copy link
Member

@jasonh-n-austin Just pinged someone to find out the right place to get some of the uncertainties ironed out. In theory I don't think we have to be on the vnd tree and I believe recent specs have formalized the suffix issue, but I want to confirm before making a submission.

@tomchristie
Copy link

@darrelmiller 👍 Good stuff.

@darrelmiller
Copy link
Member

Asked the questions to the people who hold the keys to the registry https://mailarchive.ietf.org/arch/msg/media-types/_ijxSwBDdS6MF-sECqhxN1jkXzs

@fehguy
Copy link
Contributor

fehguy commented Mar 9, 2016

Thanks @darrelmiller. Did you manage to find "the form"?

@darrelmiller
Copy link
Member

I know where the submission form is :-). I was hoping I could get a registration in the standards tree without having to submit a spec document to IETF. However, I don't believe the Linux Foundation is considered a "Standards Development Organization" so, our choices are either live with the "vnd" or submit an IETF compliant version of the spec to them when we release new versions. I did at least get confirmation that it could be "Informational" and therefore not require any IETF WG input/consensus.

@cdivilly
Copy link

@darrelmiller Happy to help with drafting the informational RFC if needed, have done some draft RFCs before. The other message I took from that email thread was the case for approving the RFCs for application/openapi+json & application/openapi+yaml would be made stronger by going ahead and using those media types, did I interpret that correctly? Is there agreement within OpenAPI that those are the exact media types that should be registered?

@ralfhandl
Copy link
Contributor

+1 for registering these as the "latest version" media types.
+1 for also registering version-specific media types as proposed by @olensmar application/openapi-v20+json or application/openapi-v3_0+json (no dots allowed in standards-tree subtypes)

@ralfhandl
Copy link
Contributor

+1 for submitting OpenAPI as an IETF RFC as we want to base the JSON dialect of OData's Metadata Format on OpenAPI, so the OpenAPI specification would be a normative reference.

@darrelmiller
Copy link
Member

@cdivilly Thanks for the offer to help. Regarding the deploy first register later, the challenge is if we do something informally, the worst thing that could happen is people start using different approaches. e.g. with/without version number. I'm currently just trying to gather information and get the opinions out in the open, so that when we do make a registration, all the opinions have been heard.

@ralfhandl Can you make your case for including the version? I would prefer not to include the version and just encourage people who are writing OpenAPI parsers to handle the differences internally.
Yes, having OpenAPI as an RFC would definitely make it easier to reference from other RFCs. It would be interesting to investigate what it would take to automate the creation of a mirror spec. The spec is already in markdown, so perhaps it could just be inserted into a kramdown-rfc2629 template.

@dret
Copy link
Contributor

dret commented Aug 30, 2020 via email

@handrews
Copy link
Member

handrews commented Aug 31, 2020

@dret I don't understand how @awwright would be arguing that *a letter is paper*. He provided a very clear breakdown of how he thinks JSON Schema meets each condition in the specification.

Could you please let us know which of his points is incorrect? From my perspective, square paper is a subset of paper. Given a schema language for paper dimensions it could be expressed as something like "xyRatio": "1:1". There are endless possible sizes and ratios of paper, but this constrains the set to those where the X and Y dimensions are the same.

A JSON Schema similarly defines the subset of JSON documents that are acceptable. The schema identifier may (as in "people probably do" not as in RFC 2119 "MAY") in practice be overloaded to indicate further semantics (e.g. this is a "letter"), but that is not part of the JSON Schema specification, and other link relation types are more appropriate for that.

In an API, I would not use a schema to indicate that a document is a letter (or a car, or a planet, or anything else). Because the schema describes the representation syntax, not the semantic usage. The semantic usage should be stable across the lifetime of the API. Some uses may or may not be implemented at different times, but they are still semantically valid. However, the syntax is expected to fluctuate across time. Ideally it wouldn't but we all know that's not how it works.

So I read your explanation and @awwright's detailed examination of the requirements and cannot see a contradiction. Could you please point it out in plain terms, using @awwright's example?

@dret
Copy link
Contributor

dret commented Sep 1, 2020 via email

@awwright
Copy link

awwright commented Sep 1, 2020

HTML is not a profile of SGML/XML

Besides the fact HTML is a separate media type, is there any reason this should be the case? An XML processor can read an application/xhtml+xml document without any knowledge of what HTML is. It can even perform some simple changes, like collapsing whitespace, or refactoring namespace declarations.

It seems the issue is XML semantics are so generic, there's not much else you can do with it.

But suppose I know the XML document is HTML, then there's more I can do with it.

And suppose I know the HTML document is hCard, or RDFa. Then there's even more I can do with it. Being able to express this seems to be the primary benefit of profiles.

think along the lines of HTML (a schema) and the good old STRICT and LOOSE profiles of it (two ways to constrain the HTML schema).

So you consider a DTD to be a kind of profile? Isn't a DTD a kind of schema?

@handrews
Copy link
Member

handrews commented Sep 1, 2020

clearly you want to use these terms in a different way, and that's your
right. i happen to think that this is not very helpful, but that's just
me having a different opinion.

@dret, i'm pretty distressed by this accusation. Several years ago, we stopped using profile specifically because you asked us not to, on the grounds that it was not appropriate. We have not started using it again. It's demonstrably clear and documented in GitHub that we have, in fact, gone out of our way to respect your views of what this means.

In the intervening years, other things have happened with "profile", and you yourself have indicated some sort of shift in views (as noted and linked to above). @awwright raised the idea that maybe given how things have changed, we should check in and align with the overall community meaning of "profile", whatever that happens to be now.

All we want is to be aligned with the common accepted usage. We don't want to be a weird outlier to an established pattern. We don't want to be that one project abusing an otherwise well-defined term, and we don't want to be that one project that re-invented the wheel (e.g. by replacing "profile" with "schema" for both media type parameters and link relation types, if it turns out that "profile" is the industry-wide consensus. Which we are not assuming).

I am bothered that you are ascribing ill will to us here.

yes, you can implement a profile using a schema language. but we're not
arguing over implementations here but over what the two terms mean (the
concept of a profile and the concept of a schema).

That's not what we asked, and we're not trying to argue with you. We're trying to understand, but instead of giving a clear answer in terms of the concrete example, you criticize us and give oblique arguments that don't clearly relate to what we need to understand.

@awwright and I are both trying our best to figure this out and we cannot. There is a simple question on the table. You should be able to tell us which of those seven points is wrong. Or if it's not outright wrong (is that what you mean by "yes you can implement a schema..."?), then clearly something is at least bothering you about at least one of those seven points.

Which point is it, and what is the problem?

Don't point to other media types or create new examples. There's a seven-point attempt to meet your own definition. Where did we go wrong?

@dret
Copy link
Contributor

dret commented Sep 1, 2020 via email

@dret
Copy link
Contributor

dret commented Sep 1, 2020 via email

@handrews
Copy link
Member

handrews commented Sep 1, 2020

Why can't you just answer the question?

@handrews
Copy link
Member

handrews commented Sep 1, 2020

@dret this is maddening. Just tell us 1, 2, 3, 4, 5, 6, 7 which point(s) are wrong?

@awwright
Copy link

awwright commented Sep 1, 2020

Ok, I gather that it's entirely possible to use a JSON Schema to define profiles of an application/json document. It might be the case a JSON Schema isn't necessarily a profile, but it can certainly be the case.

Before we get too far off topic, I think the question becomes, can we use profiles to distinguish version? If a profile is required to correctly interpret an OpenAPI media type, we don't gain anything over just using application/json with a profile.

@handrews
Copy link
Member

handrews commented Sep 1, 2020

@dret

concepts are fuzzy, people have opinions and preferences, and you may have to simply accept that.

Why do you think we don't? I'm not asking you for a certificate of compliance to wave at other people. I'm just asking, in your own personal opinion, which of the seven points is incorrect? You have indicated that you do not agree with our interpretation, therefore one of those steps must be a problem in your own opinion, which we promise not to use to bludgeon anyone else or whatever it is you think we're doing. I am begging you to tell us which one.

@peteraritchie
Copy link

Is this effectively resolved by https://datatracker.ietf.org/doc/html/draft-polli-rest-api-mediatypes?

@ioggstream
Copy link
Contributor

ioggstream commented Jan 6, 2022

Not solved yet, but we started working on https://datatracker.ietf.org/doc/draft-ietf-httpapi-rest-api-mediatypes/

@landsman
Copy link

Is this dead?

@dret
Copy link
Contributor

dret commented Sep 20, 2023 via email

@ioggstream
Copy link
Contributor

Dear all, the work on this is ongoing. Yet, laying down something meaningful is not easy as it seems.

People interested in contributing to this issue can spend some time reading and providing feedback here https://github.com/ietf-wg-httpapi/mediatypes/labels/rest-api

Have a nice day,
R:

@handrews
Copy link
Member

As @ioggstream noted above, this work is going on at https://github.com/ietf-wg-httpapi/mediatypes and should be tracked there. I'm going to close this out to reduce clutter here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests