8

Is it possible to link to a specific path displayed in Swagger UI, such as to /work/2.1 on the image below?

This is my swagger ui relative path

I want to link to individual paths from an external web page.

Helen
  • 87,344
  • 17
  • 243
  • 314
Sujay
  • 95
  • 1
  • 5
  • Do you mean something like operation permalinks? As in, a link that automatically navigates to / expands a specific operation in Swagger UI? – Helen Jul 17 '17 at 16:42
  • Yes. Like perma links that would literally take me to a particular path in swagger ui. – Sujay Jul 18 '17 at 18:13

2 Answers2

10

Yes, Swagger UI has permalinks for operations and tags. To get a permalink, expand an operation or tag and copy the URL in the address bar. Permalinks look like this:

index.html#/tagName
index.html#/tagName/operationId

When someone opens such a permalink in a browser, the corresponding tag or operation is automatically expanded and also scrolled to the top if needed. Example:
https://petstore.swagger.io/#/store/getInventory


In Swagger UI 2.2 permalinks are enabled by default.

If you use UI 3.x, you need version 3.0.19 or later, and you need to add deepLinking: true to the Swagger UI init code in your index.html:

const ui = SwaggerUIBundle({
  url: "http://petstore.swagger.io/v2/swagger.json",
  deepLinking: true,  // <------
Helen
  • 87,344
  • 17
  • 243
  • 314
  • Thank you Helen! I am sorry about confusing the question but the answer was exactly what I was looking for. I tried it and was able to work with it. Thanks again. :) – Sujay Jul 28 '17 at 14:51
0

Added Deep Link support to SwaggerUI:

app.UseSwaggerUI(c =>
{
    ...
    c.EnableDeepLinking();
});
Maxim
  • 1
  • 1