-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Allow references between operations inside descriptions. #239
Comments
@ryangyoung - following our discussion in the google group, thanks for opening this issue. I'm changing the title of the issue since it refers to swagger-core specifically, and we may need/want to address this in the spec itself (which is why the issue is here and not on swagger-core). The idea is to add support for hyperlinking between operations within the description, to allow for references (not flow). This may mandate the |
It seems most likely that people who are using hyperlinking already implements the |
I would also like to generate links to related URLs/resources solely from the part of the Swagger specification that describes the URL currently being accessed. I think the OP here and I share an intention to use Swagger and HATEOAS to create a truly RESTful API. However rather than decorating paths and/or operations in the way that this issue proposes, I would prefer to permit an optional additional 'links' object inside paths and/or operations. See #440 for details. |
Just to be clear, I am not using Swagger to document an existing API - I'm using it to actually implement the API. I have Python WSGI middleware and applications which configure themselves according to a Swagger specification they load at runtime. This works well so far, but if I want my web service to be RESTful, in responses, I need to include links to other possibly-interesting URLs (so-called HATEOAS). To accomplish this, I either need to hard-code links into the application's responses (ugh), maintain information in an additional DSL outside Swagger which inter-relates the Swagger paths and operations (and keep the two DSL files in sync somehow, not fun), or (my preferred option) somehow teach Swagger to understand that paths and operations can have relationships to other paths and operations. |
parent issue #586 |
I thought descriptions supported GFM syntax? Because that could do hyperlinks at least. Maybe less powerful than you intended here, but it's something. |
@tycho01 description: 'This method exchanges the code returned in the [Auth](jsonref://#/paths/~1auth/get) resource' |
Does anyone have any updates on this issue, has it been resolved? |
does this work for anyone? |
I would prefer link schemes based on Admittedly, supporting references from descriptions (technically, from any text element that supports Markdown) does require tools to process those, i.e. preprocess before handing off to the Markdown -> HTML (or other) rendering. For example, we use shins/widdershins to generate HTML API documents; an operation with Note that we need to support references not just to operations as well as anything in Some possible link notations: My preference would be to make the title optional, as I don't want to have to copy/paste the operation's
Those are the most important to me. [widder]shins or swagger-ui / swagger-editor or other tools would translate those references into whatever anchor generation scheme they use, as well as attaching unique anchor tags to each element (hopefully in a uniform, predictable manner). Certainly with schemas, one may want to reference a named parameter within an operation (instead of in TBD: references to elements in external OpenAPI documents... |
Markdown links could use the fragment delimiter ( |
One issue with using Markdown anchors is that there is no standard anchor pattern across all the possible tools that render (HTML or other) API doc. slate, redoc, swagger-ui, shins etc all appear to do it differently. So what works for one tool won't work if you use a different tools, unless all tools that generate HTML generate anchors the same way. |
@webron just bumping this one for visibility -it's a few years old, but seems doable. Details on my April 2019 reply. |
That's up to the renderer to worry about, though. A browser-based renderer would simply hook into the hashchange event to then direct the scroll position to the matching operation when a supported prefix is found. You'd need to support both operation ids and operation refs, e.g. |
This is why REST includes HATEOAS: to decouple the implementation of the server (the paths) from the client. With this, OAS could finally be used to describe REST APIs. |
Closing as the two main concerns are now tracked elsewhere. See:
|
For documentation purposes, it would be wonderful if we could add href-type links in Swagger annotations. The purpose of these links would be to reference one API call from another for documentation completeness (not for documenting the flow, per se). Similar to the "transfers API" link here: https://stripe.com/docs/api#balance_object
In the annotations, it would be something like:
The text was updated successfully, but these errors were encountered: