swagger-api / swagger-api/swagger-ui
Content type application/octet-stream shouldn't show example for response
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: Fedora
- Browser: Firefox
- Version: 60.0.2
- Method of installation: docker
- Swagger-UI version: 3.17.4
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
An example value of "string" is showed for the application/octet-stream response type.
Example Swagger/OpenAPI definition:
'200':
content:
application/octet-stream:
schema:
type: string
format: binary
Describe the bug you're encountering
For a requestBody of type application/octet-stream, as expected, no example is shown, and instead a message similar to "No example values are available for content type application/octet-stream". This is good since we shouldn't try to convert this content type into json to try to show an example value. For the response however, instead of showing this message in the place of an example value, the example value "string" is shown, which can be misleading to the user.
To reproduce...
Steps to reproduce the behavior:
- Use content type application/octet-stream for a response
- Open swagger-ui page and look at response example value
Expected behavior
I would expect a message similar to "No example values are available for content type application/octet-stream" to be shown in the place of an example value for responses using application/octet-stream.
Additional context or thoughts
Another possible workaround could be the addition of allowing users to hide example values for a response type if they don't want to specify one and don't want the default example value to show up. I'd be ok with either this new option, or the message as described above in 'Expected behaviour' showing up in the place of the current default example value.
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 in Swagger UI using the provided OpenAPI 3.0 response definition and compare response rendering with the requestBody behavior described. The work is done when an application/octet-stream response with type string and format binary no longer displays "string" and instead shows that no example value is available.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100