swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.46k stars 8.95k forks source link

SyntaxHighlight always enabled with latest swaggerapi/swagger-ui #8304

Open PriyadarshiniGopalS opened 1 year ago

PriyadarshiniGopalS commented 1 year ago

Q&A (please complete the following information)

Describe the bug you're encountering

I am running swaggerapi/swagger-ui using docker in my local and syntaxHighlighting is not working as expected with syntaxHighlight=false query-parameter. I tried various approaches to disable syntaxHighlighting.

After each approach, I accessed this url http://localhost:8080/?syntaxHighlight=falseand expected syntaxHighlighting to be disabled for all the request & response body. But all are enabled by default.

Approach 1:

  1. use docker-compose.yaml with QUERY_CONFIG_ENABLED: "true"
  2. spin up the container using the command docker compose up.

docker-compose.yaml

version: '3'
services:
    swagger-ui:
        ports:
          - 8080:8080
        image: swaggerapi/swagger-ui:v4.15.5
        restart: always
        environment:
                QUERY_CONFIG_ENABLED: "true"
                URLS: "[
                        { url: 'https://petstore.swagger.io/v2/swagger.json', name: 'Petstore' }
                       ]"

Approach 2:

  1. use docker file
  2. build own image using the command docker build -t <image-name> .
  3. run the docker image docker run -p 8080 <image-name>

Dockerfile

FROM swaggerapi/swagger-ui
ENV QUERY_CONFIG_ENABLED="true"
ENV URLS="[ { url: 'https://petstore.swagger.io/v2/swagger.json', name: 'Petstore' } ]"

Approach 3: (same as approach #2 with swagger-config.json) Followed steps mentioned in Approach2, but query configuration itself is not enabled.

Dockerfile

FROM swaggerapi/swagger-ui
`ENV CONFIG_URL="file:///D:/Argon/Repo/Skyline/SwaggerAPI/swagger-config.json"`
ENV URLS="[ { url: 'https://petstore.swagger.io/v2/swagger.json', name: 'Petstore' } ]"

swagger-config.json

{
    "queryConfigEnabled": true,
    "syntaxHighlight": false,
    "syntaxHighlight.activate": false,
    "displayOperationId":  true
}

Please let me know whether I am missing something here.

char0n commented 1 year ago

Hi @PriyadarshiniGopalS,

I not sure I understand. The title of the issue suggest that the syntax highlighting is not working.

After spinning up the container, I tried accessing the url http://localhost:8080/?syntaxHighlight=false , but still syntaxHighlight was enabled.

Then this sentence suggest that you want to disable the highlighting but it's always enabled.

Can you please maybe elaborate?

PriyadarshiniGopalS commented 1 year ago

Hi @PriyadarshiniGopalS,

I not sure I understand. The title of the issue suggest that the syntax highlighting is not working.

After spinning up the container, I tried accessing the url http://localhost:8080/?syntaxHighlight=false , but still syntaxHighlight was enabled.

Then this sentence suggest that you want to disable the highlighting but it's always enabled.

Can you please maybe elaborate?

Hi @char0n , I am seeing syntaxHighlight always enabled behavior and trying to disable that, but I was not successful.

I updated the title and description for better clarity.