Skip to content

Bundle does not resolve references in $ref siblings #2768

@onavratil-monetplus

Description

@onavratil-monetplus

Describe the bug

When bundling a schema that contains reference siblings that contain references, the references are not resolved and not included in the resulting bundle. This somehow relates to #1329 but does not involve dereferencing to reproduce.

I.e., bundle will create an invalid bundled API (missing $ref) from a valid source even without dereferencing.

To Reproduce

Use this api.yaml

openapi: 3.1.0
info:
  title: Example
  version: '0.0.1'
  description: Minimum Working Example API Spec
  contact:
    name: XY
servers:
  - url: 'http://localhost:8080'
tags:
   - name: vendors
paths:
  /sample:
    get:
      summary: Sample
      operationId: example1
      tags:
        - vendors
      responses:
        '200':
          description: A basic get example
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/test'
                # !! NOTE REFERENCE TO EXTERNAL FILE IN $ref sibling
                properties:
                  second:
                    $ref: reference.yaml
      description: sample
components:
  schemas:
    test:
      type: object
      title: test schema
      properties:
        first:
          type: integer

basically you dont even need the ref'ed reference.yaml

title: Referenced model
type: string

In any way, the result of running a simple

redocly bundle api.yaml

contains (snippet only)

     #...
      responses:
        '200':
          description: A basic get example
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/test'
                properties:
                  second:
                    $ref: reference.yaml
      description: |
     #...

Expected behavior

The reference is $ref sibling should be resolved just like any other reference

OpenAPI description

Redocly version(s)

2.25.3

Node.js version(s)

v25.5.0

OS, environment

ubuntu wsl

Additional Context

Even though redocly does not really handle $ref siblings well, its bundle capability may be used just to support some other tooling downstream that can handle siblings. However, if bundle breaks nested sibling $refs, it geneerates a problem.

Metadata

Metadata

Assignees

Labels

$refIncorrect behaviour when resolving references.Type: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions