Allow references between operations inside descriptions.
See original GitHub issueFor 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:
@Timed
@ApiOperation(value = "Request an access token",
notes = "This method exchanges the code returned in the [link to Auth resource].",
Issue Analytics
- State:
- Created 9 years ago
- Reactions:20
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Using $ref - Swagger
With OpenAPI 3.0, you can reference a definition hosted on any location. ... Actually $ref is only allowed in places where the OpenAPI...
Read more >How To List References on a Resume (With Examples) - Indeed
Here is an example of how you can format your resume list. Consider listing your references in chronological order, starting with the person...
Read more >`.gitlab-ci.yml` keyword reference - GitLab Docs
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >Web Services Description Language (WSDL) 1.1 - W3C
A reference to a WSDL definition is made using a QName. The following types of definitions contained in a WSDL document may be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would prefer link schemes based on
operationId
rather than paths, which I find awkward and also a bit fragile when an API is in early stages.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
operationId
ofupdateThing
gets an HTML anchor name-code-updatething--code-
, and a schemamyThing
gets the anchortocsmything
(i.e. prefixtocs
… for Table of Contents, Schema?). In both cases, [widder]shins converts the IDs to lowercase. (We purposefully avoid defining elements with the same spelling but different case.)Note that we need to support references not just to operations as well as anything in
components
- most notably, schemas, although all components should be supported.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
summary
or the schema’stitle
[Title](operation:updateThing)
[][operation:updateThing)
– uses the operationsummary
for the link title, or theoperationId
if none, else the HTTP verb and path.[Title](schema:schemaName)
[](schema:schemaName)
– uses the schema’stitle
for the link title, or the schema name if none[Title](schema:schemaName.propertyName)
[](schema:schemaName.propertyName)
- title isschemaName.propertyName
(the property’stitle
, if it exists, may not be unique-multiple schemas can have properties with the same title). Allows nesting:thing.fieldA.fieldB.fieldC
[Title](parameter:parameterName)
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
components/parameters
), or other things not covered above, so this simple notation breaks down, but I think those are referenced much less frequently . Thejsonref:
notation may work for these cases.TBD: references to elements in external OpenAPI documents…
@tycho01
description
properties support commonMark syntax in OAS 3.0.x, so simple absolute or relative HTTP(S) links will work, the difficulty is in generalising a link to an operation (or other part of the document). Perhaps it would be possible to use a uri scheme such asjsonref://
and/oroperationId://
which tooling could rewrite to interpret the link in context.