swagger-api / swagger-api/swagger-ui

Support for images like png/jpg to be displayed in examples

Open
#10,550 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Content & configuration

Swagger/OpenAPI definition:
the relevant part of the spec:

...
      responses:
        200:
          description: OK
          content:
            image/png:
              schema:
                type: string
                format: binary
              examples:
                image:
                  summary: String?
                  description: String?
                  externalValue: https://example.com/image.png
...

Swagger-UI configuration options: default

SwaggerUI({
   url: './openapi.yml',
   oauth2RedirectUrl: window.location.origin + '/docs/oauth2-redirect',
   dom_id: '#swagger-ui',
   presets: [
       SwaggerUIBundle.presets.apis,
       SwaggerUIBundle.SwaggerUIStandalonePreset
   ],
   layout: "BaseLayout",
   deepLinking: true,
   showExtensions: true,
   showCommonExtensions: true
})
Is your feature request related to a problem?

I want to document an api which returns tiles for a map. The responses are all images for which i have examples, but swagger cannot display them in a pretty way. Currently it just base64-dumps the data.

Describe the solution you'd like

It would be nice if images like png and jpg could be displayed as viewable examples. directly in the examples section.

Describe alternatives you've considered

An alternative solution which would also work would be to provide a link in the examples section, rather than displaying the image/binary data.

Additional context

An example of how it's working/looking currently:

Image

(i use externalValue with a url and the correct headers exist when calling the url)

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 issue in Swagger UI with the supplied OpenAPI response containing an image/png example and externalValue URL. Trace the examples display path and compare the current base64 output with the requested inline image or link behavior; the work is done when PNG and JPG examples are viewable directly in the examples section.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
documentation, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.