swagger-api / swagger-api/swagger-ui

$ref pointing to a field in the same object is rendered as string

Open
#8,228 3 comments 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

Q&A
  • OS: Linux
  • Browser: Firefox
  • Version: 106.0b9
  • Method of installation: Docker
  • Swagger-UI version: 4.14.3
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

I see the behaviour in the Swagger UI and Swagger Editor.

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  version: 1.0.0
  title: Title
paths:
  /:
    get:
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkScheduled'
components:
  schemas:
    LinkScheduled:
      type: object
      properties:
        feeder:
          type: string
          format: uuid
        fetcher:
          $ref: '#/components/schemas/LinkScheduled/properties/feeder'
Describe the bug you're encountering

$ref pointing to a property in the same object is rendered as string even if it is not a string.
If I open a type in the schema and reload the schema (with „Explore“ button in the Swagger UI) the field is rendered correctly, and the later reloads keep the correct field.

To reproduce...

Steps to reproduce the behavior:

  1. Open the API definition in Swagger UI
  2. Click on „GET /”
  3. Look at the example
  4. See "fetcher": "string"
  5. Click on Schemas -> LinkScheduled
  6. Click on „Explore“ to reload the definition
  7. See "fetcher": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
Expected behavior

The „fetcher“ field is rendered as "fetcher": "3fa85f64-5717-4562-b3fc-2c963f66afa6".

Screenshots

before
after

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 and Swagger Editor with the OpenAPI 3.0 definition from the report. Compare the initial rendering of the fetcher field with the rendering after Schemas → LinkScheduled → Explore; done means the field consistently renders the UUID example without requiring a reload.

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
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.