swagger-api / swagger-api/swagger-ui

deepLinking setting not working as expected - does not scroll down properly

Open
#5,480 6 comments 0 reactions 1 assignee View on GitHub

@shockey is already working on this.

Since Jul 30, 2019.

type: integration bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: macOS
  • Browser: Chrome
  • Version: 75.0.3770.100
  • Method of installation: direct js files
  • Swagger-UI version: Newest, I believe
  • Swagger/OpenAPI version: OpenAPI 3
Content & configuration

I have inherited a project from someone else setting up swagger-ui standalone in our website, importing a list of URLs from a JSON file and trying to use deepLinking to jump straight to operations in the page so I can link around from page to page.

Swagger-UI configuration options:
I load up the urlsListFile to grab the data and then drop it into the urls as an array (I would be totally happy with a different way of doing this, but I need to pick the urlsListFile based on version selected in another part of the site)

  jQuery.getJSON(urlsListFile, function( data ) {
    const ui = SwaggerUIBundle({
      urls: data.urls,
      dom_id: '#swagger-ui',
      deepLinking: true,
      presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIStandalonePreset
      ],
      plugins: [
        SwaggerUIBundle.plugins.DownloadUrl
      ],
      supportedSubmitMethods: [],
      layout: "StandaloneLayout"
    });
    
    window.ui = ui;
  })

I got this URL by clicking on the Location section of the Locations API page and it created this for me. I copied and put it in another section of my site.

?urls.primaryName=Locations#/Location
Describe the bug you're encountering

When the page loads up for Locations API, it just stays at the top of the page and does not scroll down to #/Location like I would expect it to.

To reproduce...

This is on a local development environment so I cannot share a link right now, but any suggestions of things to try, parameters to add, etc - would be appreciated.

If someone knows how also, when I do the markup for a link on one of my other pages, it always adds target=_blank which I do not want because I am linking around the same site, how can I get rid of that?

Is it possible that having the urls.primaryName in my URL is causing a problem? All the working examples do not have that.

Expected behavior

When the link is visited to jump from one page directly to the GET call for Location/getLocation - I expect the page to scroll down, just like the example in https://github.com/swagger-api/swagger-ui/issues/4817#issuecomment-415305023 where it goes to /pet/addPet as a direct jump.

Additional context or thoughts

Thanks so much for the help. I have spent a lot of time getting the documentation together for this project and look forward to wrapping up the linking, etc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.