cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] external files in same directory are not resolved via $ref anymore, since v3.3.0

Open pstorch opened this issue 4 months ago • 3 comments

Describe the bug.

We've externalized parts of the asyncapi contract into separate files and reference them via $ref. These files are located in the same directory.

File: src/contract/asyncapi.yaml:

...
components:
  messages:
    MyMessage:
      title: "My message"
      traits:
        - $ref: "my-event-headers.yaml#/components/messageTraits/event-headers-definition"
      headers:
        type: object
        properties:
          x_origin:
            const: my_project
          x_event_type:
            allOf:
              - $ref: "my-event-models.yaml#/components/schemas/EventTypeName"
              - const: EVENT_TYPE_NAME
          x_grouping_key:
            $ref: "my-event-models.yaml#/components/schemas/Id"
      payload:
        $ref: "my-event-models.yaml#/components/schemas/MyPayload"
      bindings:
        kafka:
          key:
            $ref: "my-event-headers.yaml#/components/schemas/GroupingKeyHeader"
...

Since asyncapi-cli v3.3.0 this doesn't work anymore if all files are in a subdirectory like src/contract. As a workaround we have to copy all files into the current working directory. Then it works. I've also tried to prefix the path reference with ./, but it didn't work either.

Expected behavior

Read all referenced files in the same directory as in version 3.2.0

Screenshots

n.a.

How to Reproduce

Create an asyncapi contract in a subdirectory and reference other yaml files in the same directory. Run the asyncapi-cli generator.

🖥️ Device Information [optional]

  • Operating System (OS):
  • Browser:
  • Browser Version:

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

pstorch avatar Aug 22 '25 08:08 pstorch

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

github-actions[bot] avatar Aug 22 '25 08:08 github-actions[bot]

We are also hit by this issue.

einstux avatar Oct 20 '25 05:10 einstux

Picking up this issue

Kartikayy007 avatar Nov 03 '25 12:11 Kartikayy007

This issue still exists. @neoandmatrix could you please put the screenshots here.

Shurtu-gal avatar Dec 17 '25 15:12 Shurtu-gal

This issue still exists. @neoandmatrix could you please put the screenshots here.

Just tested these and yes the issue persists. I believe it is a problem related with the generator specifically since it was mentioned specifically in the issue. Just to confirm i tried generate command on latest master branch commit and it still fails. Below is screenshot for further reference.

Image

neoandmatrix avatar Dec 17 '25 15:12 neoandmatrix