Swagger-ui: Deep linking does not work for operations with tags containing spaces

Created on 16 Jan 2018  路  6Comments  路  Source: swagger-api/swagger-ui

| Q | A
| ------------------------------- | -------
| Bug or feature request? | Bug
| Which Swagger/OpenAPI version? | 2.0
| Which Swagger-UI version? | 3.9.1 (current)
| How did you install Swagger-UI? | Built using npm run build, copied dist folder
| Which browser & version? | Chrome 63.0.3239.132, Edge 41.16299.15.0
| Which operating system? | Windows 10

Demonstration API definition


Change the tag "pet" in the sample petstore.json to be "pet v1" or any other value containing a space.

Expected Behavior



Example operation: POST /pet with the tag "pet v1"
The link http://localhost:3200/#/pet_v1/addPet (replace localhost with whatever the host is) should result in the UI scrolling to the operation POST /pet.

Current Behavior



The UI does not scroll to the linked operation when the operation tag contains a space. In this example, the id of the html element for the operation POST /pet is "operations-pet v1-addPet".

Possible Solution



In this example, the element id of the operation POST /pet is "operations-pet v1-addPet". The space in this id breaks linking. The element id in this example should probably instead be "operations-pet_v1-addPet".

Context



Users expect that the linked operation should be scrolled to.

deep linking lock-bot bug

Most helpful comment

4953 should solve this 馃槃 thanks for the report!

All 6 comments

Also bumped into this. Would be great if it was fixed.

https://github.com/swagger-api/swagger-ui/blob/14473dd51d939adf425b3279cd7b0c0a055d407f/src/core/components/operation.jsx#L97

If I change this line into

let isShownKey = ["operations", tag.replace(/ /g, "_"), operationId]

it starts working. But I think it isn't meant to be solved that way.

Too bad I don't have the spare time to properly get accustomed with the source code to do a proper merge request.

This is causing issues on the CURL the issue was reported on #4263
Also a hash (#) on the tags causes a problem with the links as well:
http://swagger-net-test.azurewebsites.net/swagger/ui/index?filter=Sample

Is there any progress on the pull request? Or any update if this will be fixed soon?

Same question here.any target date to resolve this?

4953 should solve this 馃槃 thanks for the report!

Was this page helpful?
0 / 5 - 0 ratings