swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

fix deep link by proper tag extraction when slash is in tag

Open hotsoycandy opened this issue 11 months ago • 1 comments

Description

Extract tag properly when there's a slash in the tag

For example. when the tag is "my-service/common", the deep link is not working for now.

the issue(#5875) that describes this bug also exists.

Motivation and Context

Deep linking is not working when I write a tag with slash.

How Has This Been Tested?

Yes. In my local environment.

openapi: 3.0.0
paths:
  /health:
    get:
      operationId: HealthController_check
      parameters: []
      responses:
        '200':
          description: The Health Check is successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
                  info:
                    type: object
                    example:
                      database:
                        status: up
                    additionalProperties:
                      type: object
                      required:
                        - status
                      properties:
                        status:
                          type: string
                      additionalProperties: true
                    nullable: true
                  error:
                    type: object
                    example: {}
                    additionalProperties:
                      type: object
                      required:
                        - status
                      properties:
                        status:
                          type: string
                      additionalProperties: true
                    nullable: true
                  details:
                    type: object
                    example:
                      database:
                        status: up
                    additionalProperties:
                      type: object
                      required:
                        - status
                      properties:
                        status:
                          type: string
                      additionalProperties: true
      tags:
        - my-service/common
info:
  title: Supplier service
  description: ''
  version: '3.0'
  contact: {}
tags: []
components:
  schemas: {}

Screenshots (if appropriate):

The link that I used for test: http://localhost:3101/api-docs#/my-service%2Fcommon/HealthController_check

I fixed and tested it locally with chrome source override

before before

after after

Checklist

My PR contains...

  • [ ] No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • [ ] Dependency changes (any modification to dependencies in package.json)
  • [x] Bug fixes (non-breaking change which fixes an issue)
  • [ ] Improvements (misc. changes to existing features)
  • [ ] Features (non-breaking change which adds functionality)

My changes...

  • [ ] are breaking changes to a public API (config options, System API, major UI change, etc).
  • [ ] are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • [ ] are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • [x] are not breaking changes.

Documentation

  • [x] My changes do not require a change to the project documentation.
  • [ ] My changes require a change to the project documentation.
  • [ ] If yes to above: I have updated the documentation accordingly.

Automated tests

  • [x] My changes can not or do not need to be tested.
  • [ ] My changes can and should be tested by unit and/or integration tests.
  • [ ] If yes to above: I have added tests to cover my changes.
  • [ ] If yes to above: I have taken care to cover edge cases in my tests.
  • [ ] All new and existing tests passed.

hotsoycandy avatar Feb 24 '25 09:02 hotsoycandy

I tested this with a change in the docs/samples/src/swagger-config.yaml where I changed pet/list to pet-list, this is the snippet tags:

  • name: "pet-list" description: "Everything about your Pets"

paths: /pet: get: tags: - "pet-list" summary: "Returns all pets" responses: "200": description: OK,

and also changed the url in dist/swagger-initializer.js to url: "./openapi.yaml", for testing purposes and this worked.

Mathias02 avatar Apr 08 '25 14:04 Mathias02

@hotsoycandy looks good! could you add test for the changes?

lukaszzazulak avatar Jul 02 '25 13:07 lukaszzazulak