Swagger-ui: `Example.externalValue` is not displayed

Created on 29 Jun 2019  路  11Comments  路  Source: swagger-api/swagger-ui

Example Swagger/OpenAPI definition

openapi: 3.0.0

paths:
  /:
    post:
      requestBody:
        content:
          image/png:
            schema:
              type: string
              format: binary
            examples:
              KittenImage:
                externalValue: "https://placekitten.com/200/300"
      responses:
        "200":
          description: OK!

Current behavior

image

Expected behavior

I should be able to use the externally-referenced image as an example value for my endpoint (provided that Swagger UI is able to reach the resource).

Additional context or thoughts

5427.

rendering 3.x feature

Most helpful comment

I have the same problem. I prefer to keep my examples in external .json files (same with models) so as not to clutter the spec itself too much. Any idea where this is in the priority stack please?

All 11 comments

I don't know if this is the appropriate issue, but instead of binary image, I simply want external JSON to display. Is this already planned?

openapi: 3.0.2
info:
  description: 'myapp'
  version: '2.0.0'
  title: 'myapp 2.0 Rest API'
servers:
  - url: http://localhost:8080/rest
    description: Local Environment
  - url: https://app-dev.myapp.foo/rest
    description: Development Environment
paths:
  /rest/companies:
    get:
      summary: 'Get all companies'
      description: 'foo'
      produces:
        - 'application/json'
      responses:
        '200':
          description: 'successful operation'
          content:
            application/json:
              schema:
                type: 'array'
                items:
                  $ref: '#/components/schemas/Company'
              examples:
                jsonObject:
                  summary: This is an example in Company
                  externalValue: 'https://static.myapp.foo/examples/rest_companies_example.json
components:
  schemas:
    Company:
      type: 'object'
      properties:
        id:
          type: 'integer'
          format: 'int64'
        name:
          type: 'string'

I build my self a quick hack, that works for me for now

https://github.com/swagger-api/swagger-ui/compare/47b992f51c36a85648442c4a246466f83339c9c3...clouless:feature/examplesExternalValue

Same for me, would like to embed external json, but it's simply empty...

@shockey Thank you for opening this issue! Do you know an approx. ETA for this?

I have the same problem. I prefer to keep my examples in external .json files (same with models) so as not to clutter the spec itself too much. Any idea where this is in the priority stack please?

Same here. externalValue does not display the pointed json

Same here. externalValue does not work for me. It displays an empty field. Was there a 3.0.x OpenAPI version which it worked? Or is there some other way to do it without setting it manually?

Echoing this issue. Would be helpful to finally have externalValue work with example.

The documentation says that there is possible to use externalValue. Please update the documentation or fix a bug.

Has someone found a way to bypass this issue and somehow use externalValue?

Anything that can be done to get this on the roadmap?

Any workaround for this issue? Please share the details when we should expect the fix.

Was this page helpful?
0 / 5 - 0 ratings