swagger-api / swagger-api/swagger-ui
Swagger UI incorrectly identifies EDN request bodies as 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: Mac OS 10.15.7
- Browser: Firefox
- Version: 115
- Method of installation: using https://clojars.org/metosin/ring-swagger-ui
- Swagger-UI version: 4.15.5
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Example Swagger/OpenAPI definition:
"paths": {
"/math/plus": {
"post": {
...
"consumes": [
"application/json",
"application/transit+msgpack",
"application/transit+json",
"application/edn"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "",
"required": true,
"schema": {
"type": "object",
"properties": {
"x": {
"type": "integer",
"format": "int64"
},
"y": {
"type": "integer",
"format": "int64"
}
},
"required": [
"x",
"y"
],
"additionalProperties": false
}
}
]
}
}
}
Describe the bug you're encountering
When user selects application/edn as the Content-Type of a request body, Swagger UI incorrectly treats it as JSON.
To reproduce...
Steps to reproduce the behavior:
- Download this example project https://github.com/metosin/reitit/tree/master/examples/pedestal-swagger
- Run
lein replinside this folder - Execute
(start) - Visit http://localhost:3000/
- Expand the
POST /math/plusendpoint - Set "parameter content type" to
application/edn - Input a body like
{:x 0 :y 1} - Press "Execute"
Expected behavior
Swagger UI simply sends the POST request. The backend can handle improperly formatted EDN data; Swagger does NOT need to validate anything.
Screenshots
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
Reproduce the issue using the metosin/reitit pedestal-swagger example: run lein repl, execute (start), and open the /math/plus endpoint in Swagger UI. Select application/edn and submit {:x 0 :y 1}; done means the request is sent without being treated as JSON or validated as JSON.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100