swagger-api / swagger-api/swagger-ui

Consumes */* in OpenAPI breaks Swagger UI

Open
#6,742 9 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

Consumes set to / in OpenAPI spec, breaks swagger ui request.

For example in Kubernetes:

curl -X DELETE "HOST/api/v1/namespaces/test-namespace/pods/test-pod?propagationPolicy=Background" -H "accept: application/json" -H "Content-Type: /" -d "{ "propagationPolicy": "Background"}"

breaks in app because it takes / literally, instead you should be able to choose from:

  • application/json
  • application/yaml
  • application/vnd.kubernetes.protobuf

Such curl requests will results in:

"message": "the body of the request was in an unknown format - accepted media types include: application/json, application/yaml, application/vnd.kubernetes.protobuf",
"reason": "UnsupportedMediaType",

Is there a way to add custom content-types when / is matched?

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 by reproducing the Kubernetes DELETE request in Swagger UI from an OpenAPI spec whose consumes value is /. Trace how Swagger UI turns the matched media type into the request Content-Type, then verify that supported custom content types can be selected and sent instead of /.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.