Skip to content

External examples not working in the last version #6748

@dbfun

Description

@dbfun

Q&A (please complete the following information)

  • OS: Ubuntu 20.04.1 LTS
  • Browser: Firefox 84.0, Chromium 87.0.4280.88
  • Version: see above
  • Method of installation: official docker image and built from sources
  • Swagger-UI version: v3.38.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Title
servers:
  - url: http://localhost:8089


paths:

  /healthcheck:
    get:
      security: []
      tags:
        - healthcheck
      responses:
        "200":
          description: description
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    default: ok
              examples:
                example1:
                  value:
                    $ref: "./examples/ok.json"

Swagger-UI configuration options: no

docker-compose.yml:

  swagger:
    image: swaggerapi/swagger-ui
    container_name: swagger-docs
    volumes:
      - ./docs/openapi:/srv
    environment:
      - SWAGGER_JSON=/srv/api.yaml
    restart: always
    ports:
      - ${SWAGGER_PORT}:8080
    networks:
      - frontend

To reproduce...

Steps to reproduce the behavior:

  1. Place api.yaml with external examples ($ref: "./examples/ok.json")
  2. Run docker container
  3. Open Swagger and see the result:
{
  "$ref": "./examples/ok.json"
}

without content of the file (./examples/ok.json).

I build swagger:v3.37.1 from repo - no problem. When I use official docker image or build from sourcesswagger: v3.38.0 - has problem.

Expected behavior

I expected to see the file content like this:

{
  "result": "ok",
  "$$ref": "examples/examples/ok.json"
}

but got this:

{
  "$ref": "./examples/ok.json"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions