-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Consider hypermedia for resource listing #97
Comments
Looks well thought out, certainly would like to see this. |
Related discussion here: https://groups.google.com/forum/#!topic/swagger-swaggersocket/Xd5cWuTusVs In summary, initially I was proposing a mediaType based approach for obtaining swagger metadata from resource uri's rather than needing to expose metadata via different (inconsistent uri's). But after reviewing this issue, and taking a closer look at the HTTP Spec, I believe this is the way to go (using OPTIONS). In my mind the body should be returning the swagger meta-data (ideally with a custom media-type, even if Accept header is vanilla json). This approach can be used consistently for both baseUri (resource listing) and for specific resources). To retrieve resource listing my interpretation is that the best approach is the use of OPTIONS on the baseUri "/" or "/api" or whatever it is, not "OPTIONS *" which is a server-level command. It maybe that I'm exposing multiple api's on the same server http://www.shop.com/providerAPI, http://www.shop.com/customerAPI. The only challenge in implementing this new approach is the need to update client support; both UI and code generators need to be able to: Another somewhat related issue is that of nested resources. Given the following resources {baseUri}/a/
|
I don't think using OPTIONS is a wise idea. If using CORS for the preflight request, that request body will return the Swagger resource description? Wouldn't that make the implementation of CORS capabilities in a swagger enabled rest API problematic? |
It is important, and very valuable, for ReST resources to be self-describing. In order to do this either the resource needs to reference it's metadata (via a header maybe), OR the metadata needs to be accessible via a standard or documented mechanism (http method, header, mediaType or separate uri). URI Header/MediaType OPTIONS method |
One way to address this could be to use profiles (http://tools.ietf.org/html/rfc6906). You can return a Link header with a profile link relation type OR if you have a custom media type bake in profile as part of the definition. The href of the profile can then point to a document of any format really for describing the format. It's not violating any REST constraints as profile is discoverable. |
@rgarcia for Options the spec states that "*" is only useful for a ping or no-op method. "Since a server's communication options typically depend on the resource, the "*" request is only useful as a "ping" or "no-op" type of method;" Seems like a stretch to use it for high level server-level metadata and not something expected. |
I would vote much more toward embedding links in a response rather than requiring a user to know they do an Options. It's much more explicit and IMO in the spirit of hypermedia. |
closing as not per design |
A couple of thoughts on swagger and making it a little more hypermedia friendly:
The top-level API documentation (swagger-ui) can group these links however it likes.
NOTE: the "method" attribute and use of URI templates are both (reasonable, IMO) departures from the HTTP Link header spec.
The text was updated successfully, but these errors were encountered: