Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized response type; displaying content as text. #10128

Open
HarshChakalasiya opened this issue Sep 10, 2024 · 0 comments
Open

Unrecognized response type; displaying content as text. #10128

HarshChakalasiya opened this issue Sep 10, 2024 · 0 comments

Comments

@HarshChakalasiya
Copy link

Q&A (please complete the following information)

  • OS: linux
  • Browser: chrome
  • Version: 128
  • Method of installation: npm
  • Swagger-UI version: 5.17.14
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Swagger/OpenAPI definition:

{
  "downloadFile": {
    "get": {
      "tags": [
        "Download Data File"
      ],
      "summary": "Get Download File",
      "operationId": "v1_download_data_file",
      "produces": [
        "application/zip"
      ],
      "parameters": [
        {
          "name": "Content-Type",
          "in": "header",
          "required": true,
          "schema": {
            "type": "string",
            "example": "application/json"
          }
        },
        {
          "name": "Accept",
          "in": "header",
          "required": true,
          "schema": {
            "type": "string",
            "example": "application/zip"
          }
        },
        {
          "required": true,
          "schema": {
            "type": "string",
            "example": "54e72396-57ed-4d35-9066-b3b3b58b0b06"
          },
          "name": "attachment-id",
          "in": "path"
        }
      ],
      "responses": {
        "200": {
          "description": "Successful Response",
          "headers": {
            "Content-Encoding": {
              "name": "Content-Encoding",
              "description": "A Encoding Algorithm used for encoding response",
              "in": "header",
              "schema": {
                "type": "string"
              }
            },
            "Content-Disposition": {
              "name": "Content-Disposition",
              "in": "header",
              "schema": {
                "type": "string"
              }
            }
          },
          "content": {
            "application/zip": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "400": {
          "description": "Failure Response",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "403": {
          "description": "Authorization information is missing or invalid.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    }
  }
}

Swagger-UI configuration options:

SwaggerUI({
  dom_id: '#swaggerUIApp',
      url: this.state.doc,
      deepLinking: true,
})

How can we help?

Hello,

I am hitting one api which gives zip file as response with Content-Disposition, Content-Type response headers. When I am trying to hit that api from postman, I will get the file response and I can download the zip file but in swagger, I am receiving the file response as text with Unrecognized response type; displaying content as text. this error and it is downloaded as text file when I am trying to download it.

Here I pasted the json config file of that swagger route.

I am receiving following response headers values.

  1. Content-Disposition :- attachment; filename=output.zip
  2. Content-Type :- application/zip

So can anyone help to figure it out.

Screenshot from 2024-09-10 13-02-27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant