Skip to content

Redocly CLI incorrectly resolves $refs in examples #1371

@tatomyr

Description

@tatomyr

Describe the bug

Consider the following example:

openapi: 3.1.0
paths:
  /test:
    get:
       responses:
          '200':
             content:
               application/json:
                  schema: 
                    type: array
                    items: 
                      type: object
                  examples:
                     Test:
                        value:
                           $ref: path/to/exmple.json

When bundling, the content of the referenced file will be injected into the value.

Expected behavior

According to the spec and the refs guide, this behaviour is incorrect and the value should be taken literally, without resolving the $ref.

Note It is possible to use a Reference Object instead of Example Object (see the examples).

Note There's no restrictions on resolving $refs in the example property.

Redocly Version(s)

1.6.0

Additional context

The linter behaviour is correct though. See this issue for more details: #1369

Another issue with the $refs resolving: #1101

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions