1

I have swagger files with URLs like https://gitlab.com//blah/blah/Orders_Swagger.json. I'm building some documentation that links to these files; that works fine. Gitlab renders the page with nice formatting. But some swagger files have dozens of APIs and sometimes I want to reference a specific, critical API, not just send the user to the top of the page.

Brian Roe
  • 21
  • 3
  • 1
    I believe GitLab uses Swagger UI as a renderer. Does this answer your question -- [How to link to another endpoint in Swagger UI](https://stackoverflow.com/a/52705899/113116)? – Helen Jan 14 '22 at 07:12
  • I believe the HTML elements for each API have an ID you can anchor to in the URL fragment. For example, this [link](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/api/openapi/openapi.yaml#operations-access_tokens-accessTokens_get) will take you directly to the endpoint at the bottom of the page (GET access token): `https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/api/openapi/openapi.yaml#operations-access_tokens-accessTokens_get` the URL fragment `#operations-access_tokens-accessTokens_get` anchors you to the specific endpoint when the page is loaded. Would that work for you? – sytech Jan 14 '22 at 12:03
  • That's the kind of thing I'm looking for, yes. However, the link you posted just takes me to the top of the page, which I can already do. – Brian Roe Jan 14 '22 at 15:47

1 Answers1

1

Swagger UI supports a "deepLinking=true" configuration parameter. It is set to false by support. Gitlab embeds Swagger UI, but does not provide a way to set this parameter, so it is off at the server level.

However, you can enable it by passing a parameter in the URL: &deepLinking=1

Thus, a full, API-specific URL will look like this: https://gitlab.com/company/blah/blah/Swagger.json?deepLinking=1#/section/targetApiName

Brian Roe
  • 21
  • 3