swagger-api / swagger-api/swagger-ui

Request to support tag with `/` in deep-linking

Open
#10,566 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.0
info:
 title: test
 version: 1.0.0

paths:
 /test:
   get:
     tags:
       - abc/xyz
     responses:
       '200':
         description: OK
         content:
           text/plain:
             schema:
               type: string

Swagger-UI configuration options:

SwaggerUI({
  'deepLinking' => true,
})
#/abc%2Fxyz/get_test
Is your feature request related to a problem?

When click the get interface, the browser url will display hash like #/abc%2Fxyz/get_test, but after refreshing the page, the browser url will change, like #/abc/xyz.

Describe the solution you'd like

I check the deep-linking code.
Current code decodeURIComponent first for hash, this will change #/abc%2Fxyz/get_test to #/abc/xyz/get_test

https://github.com/swagger-api/swagger-ui/blob/4dea377ca41ca88aaec3939ac7b720b99c17c10e/src/core/plugins/deep-linking/index.js#L13

And then in urlHashArrayFromIsShownKey and isShownKeyFromUrlHashArray, they only get first one or two splice

https://github.com/swagger-api/swagger-ui/blob/4dea377ca41ca88aaec3939ac7b720b99c17c10e/src/core/plugins/deep-linking/layout.js#L185

I think this can be simple changed for support tag has / in.

Possiable change is to split / first,then decodeURIComponent.

Describe alternatives you've considered

I checked the existing configuration and found no relevant configuration.

Swagger-ui also did not make it clear that deep-linking does not support /.

Some API management tools support the / in tag as the basis for grouping, such as ApiFox

Additional context

Nothing

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.

Research direction

Start in src/core/plugins/deep-linking/index.js at the hash decoding, then trace urlHashArrayFromIsShownKey and isShownKeyFromUrlHashArray in src/core/plugins/deep-linking/layout.js. Check how encoded slashes are split and decoded; done means a tag containing / preserves its deep-link URL after the page is refreshed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.