Skip to content

Invalid HTML ID for Operations with tags which contain multiple words #4537

@ChristophWalter

Description

@ChristophWalter

Q&A (please complete the following information)

  • OS: macOS
  • Browser: safari
  • Version: 11.1
  • Method of installation: npm
  • Swagger-UI version: 3.14.1
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

Example Swagger/OpenAPI definition:

Use the Petstore demo and change one of the tags to multiple words, e.g.:

{
  "tags": [
    {
      "name": "pet store"
    }
  ]
  "paths": {
    "/pet": {
      "post": {
        "tags": [
          "pet store"
        ],
      }
    }
  }
}

Swagger-UI configuration options:

Just use the Petstore demo and change the link to your adapted Swaggerfile:

const ui = SwaggerUIBundle({
        url: "http://localhost:8000/swagger.json"
        // ...
})

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. Go to http://localhost:3200/
  2. Open your Developer Tools
  3. Select the first operation of the 'pet store' section with the element inspector
  4. Take a look at the HTML markup of this element:
<div class="opblock opblock-post" id="operations-pet store-addPet">...</div>

Expected behavior

The ID should be a valid HTML ID, like on the operation section itself:

<h4 class="opblock-tag" id="operations-tag-pet_store">...</h4>

Screenshots

invalid html id

Additional context or thoughts

This bug can be easily fixed within /src/core/components/operation.jsx by importing the function createDeepLinkPath() and adapting line 97. Similar as within operations.jsx:

import { createDeepLinkPath } from "core/utils"
let isShownKey = ["operations", createDeepLinkPath(tag), operationId]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions