Skip to content

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

@true-false-maybe

Description

@true-false-maybe

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions