swagger-api / swagger-api/swagger-ui
“Unrecognized response type; displaying content as text.” for JSON
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)
- OS: Linux
- Browser: Firefox
- Version: unstable
- Method of installation: swagger-ui-dist
- Swagger-UI version: 3.20.0
- Swagger/OpenAPI version: OpenAPI 2.0, swagger-maven-plugin 3.1.7
Describe the bug you're encountering
I get the message “Unrecognized response type; displaying content as text.” for a JSON response. Looking at it in the Firebug debugger, I see that props.contentType is undefined whereas props.content.type is correct ("application/json").
I’d say something like…
contentType ||= content.type
… after the first let in render() in core/components/response-body.jsx might do the trick, but I don’t know the JSX language or can test this myself.
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 in core/components/response-body.jsx and inspect render(), especially how props.contentType and props.content.type are used for a JSON response. Reproduce the warning with the reported Swagger UI and OpenAPI setup, then verify that a response with content type application/json is not displayed as plain text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100