Skip to content

[BUG] Disable derefencing of $ref by default. #1098

@manisharma07

Description

@manisharma07

Describe the bug.

asyncapi/parser version: 3.4.0

Currently, By default $ref is dereferenced during parsing or validation. We need to disable this default behaviour.
We tried couple of ways to disable it, however, we could not achieve it.

const parser = new Parser();
const data = await parser.validate(spec, {
resolve: {
http: false,
https: false,
file: false
}
)};

parser.validate(spec, {
resolve: {
external: false
}
}

resolve: {
external: false,
file: {

      resolve: () => {

        throw new Error('File resolution blocked');

      }

    },

    http: {

      resolve: () => {

        throw new Error('HTTP resolution blocked');

      }

    }

  }

Expected behavior

$ref pointing to external references (http, https, file etc) should be disabled by default.

Screenshots

During validate method calls, we could observe that http calls were made when trying to de-refence the $refs in the schemas.

How to Reproduce

Take any sample async api specification that has an external reference pointing to http endPoint.
const data = await new Parser().validate(spec);
During this validate call, by default dereferencing takes place, including http calls.

🖥️ Device Information [optional]

  • Operating System (OS): Mac
  • Browser: Google Chrome
  • Browser Version: 138.

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions