swagger-api / swagger-api/swagger-ui

“Unrecognized response type; displaying content as text.” for JSON

Open
#5,038 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: support
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.