Redocly / Redocly/redoc

Schemas based on ref get incorrectly replace at bundle time

Open
#2,480 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Describe the bug

A schema referencing another schema via ref will get incorrectly replaced when bundling.

e.g.

Uint64:
  type: string
  example: "1"

GenesisTime:
  $ref: "./primitive.yaml#/Uint64"
  example: "1590832934"
  description: "The genesis_time configured for the beacon node, which is the unix time in seconds at which the Eth2.0 chain began."

...
properties:
  genesis_time:
    $ref: '../../beacon-node-oapi.yaml#/components/schemas/GenesisTime'

will generate

genesis_time:
  type: string
  example: '1'

Expected behavior

I would expect the following to be generated. swagger-cli does.

genesis_time:
  type: string
  example: '1590832934'
  genesis: 'The genesis_time configured for the beacon node, which is the unix time in seconds at which the Eth2.0 chain began.'

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

Reproduce the issue with the YAML schema and nested $ref example from the report, then compare the bundle output with swagger-cli. Trace the bundling path that resolves refs and verify that the referenced schema's local example and description are preserved in the generated genesis_time schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
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.