Skip to content

AsyncAPI.NET isn't able to load external file #20

Description

@lillo42

Describe the bug

When I set the ReferenceResolution as ReferenceResolutionSetting.ResolveAllReferences and the message payload is referencing an external file, that file is not loaded

To Reproduce

Having an AsyncAPI V3 where the message payload is an external file and mark to resolve all references

var path = Path.Combine(Environment.CurrentDirectory, "V3_TestData", "AsyncApiSchema_MessageInDiffFile.yml");
var reader = new AsyncApiStreamReader(new AsyncApiReaderSettings
{
    ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences,
});

var doc = reader.Read(File.OpenRead(path), out var diag);
Assert.IsEmpty(diag.Errors);

Error:

Something went wrong trying to fetch './AsyncApiSchema_MessagePayload.yml. Could not find file '<READACT>\AsyncAPI.NET\test\ByteBard.AsyncAPI.Tests\bin\Debug\net8.0\AsyncApiSchema_MessagePayload.yml'.'

Expected behaviour

The diagnostic should be empty

Sample document

Async file:

asyncapi: 3.0.0

info:
  title: Streetlights Kafka API
  version: 1.0.0
  description: The Smartylighting Streetlights API allows you to remotely manage the city lights.
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0

channels:
  mychannel:
    messages:
      whatever:
        payload:
          $ref: "./AsyncApiSchema_MessagePayload.yml"

Payload file:

type: object
required:
  - testB
properties:
  testC:
    type: object
    properties:
      testD:
        type: string
        format: uuid
  testB:
    type: boolean
    description: test

Activity

  1. changed the title [-]With AsyncAPI V3, AsyncAPI.NET isn't able to load external file[/-] [+]AsyncAPI.NET isn't able to load external file[/+] on Oct 24, 2025
  2. github-actions commented on Oct 24, 2025

    @github-actions

    Welcome to AsyncAPI.NET. Thank you for reporting your first issue. Please check out our contributors guide.

  3. VisualBean commented on Oct 24, 2025

    @VisualBean
    Contributor

    Oh snap! I'll look into it when I get back near a pc. Thanks you for reporting this.

  4. VisualBean commented on Oct 24, 2025

    @VisualBean
    Contributor

    I was wrong in my first assumption. you never hit the switch case. the uri is relative, and thus throws on the .Scheme call in the switch. I've added a PR to fix it.

  5. VisualBean commented on Oct 25, 2025

    @VisualBean
    Contributor

    Would you like the ability to provide a baseUri for relative uris to be resolved against? or just resolve against the current working dir?

  6. VisualBean commented on Dec 7, 2025

    @VisualBean
    Contributor

    fixed as of 2.1.2 (beta release here https://www.nuget.org/packages/ByteBard.AsyncAPI.NET/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions