I'm writing a Swagger specification for an future public API that requires a very detailed and clean documentation. Is there a way to reference/link/point to another endpoint at some other location in the swagger.yml file?
For example, here is what I am trying to achieve:
paths:
/my/endpoint:
post:
tags:
- Some tag
summary: Do things
description: >
This endpoint does things.
See /my/otherEndpoint for stuff # Here I would like to have some kind of hyperlink
operationId: doThings
consumes:
- application/json
produces:
- application/json
parameters:
...
responses:
...
/my/otherEndpoint: # This is the endpoint to be referenced to
get:
...
I have found that $ref
does not help because it simply replaces itself with the contents of the reference.
Can Swagger do such a thing?
Swagger UI allows you to deeply link into tags and operations within a spec. When Swagger UI is provided a URL fragment at runtime, it will automatically expand and scroll to a specified tag or operation.
By default, web servers default to the index. html file in the directory, so it will show the Swagger UI file automatically. If the browser doesn't direct to index. html , add it manually: http://localhost:8000/index.html .
Swagger UI provides permalinks for tags and operations if it's configured with the deepLinking: true
option. These permalinks are generated based on the tag names and operationId
(or if there are no operationId
- based on the endpoint names and HTTP verbs).
index.html#/tagName
index.html#/tagName/operationId
You can use these permalinks in your Markdown markup:
description: >
This endpoint does things.
See [/my/otherEndpoint](#/tagName/myOtherEndpointId) for stuff
Notes:
target="_blank"
) - see issue #3473.<a href="#/tagName/operationId">foobar</a>
currently don't work.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With