swagger-api / swagger-api/swagger-ui
Charset of text/plain response is ignored
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- Swagger-UI version: 5.17.14
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.1
info:
title: Test
version: 1.0.0
servers:
- url: http://localhost:8080
paths:
/test:
get:
responses:
"200":
description: OK
Swagger-UI configuration options:
SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
configUrl: "/v3/api-docs/swagger-config",
operationsSorter: "alpha",
tagsSorter: "alpha",
validatorUrl: ""
})
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior:
- Create a webserver listening on
/testand returningtext/plain;charset=Xwith a charset other than UTF-8. - Send a request via Swagger UI.
- In the response body view, the response appears to be decoded with UTF-8.
Expected behavior
I expected the response to be decoded with the charset provided in the Content-Type header.
Additional context or thoughts
Works in other clients like Chrome DevTools.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in Swagger UI with a webserver returning text/plain;charset=X for a non-UTF-8 charset, then trace the response body view's handling of the Content-Type header. Done means the response body is decoded using the charset provided by the header rather than always as UTF-8.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100