Skip to content

v1.10.6 does not support absolute path in $ref #797

Closed as not planned
Closed as not planned

Description

@dvemnt

Describe the bug

The latest version of the parser does not support referencing by absolute path. It works in version 1.9.18.

How to Reproduce

  1. Create Async API doc file with absolute path $ref and file on this path in same folder.
  2. Try to build using HTML template.
asyncapi: "2.4.0"
defaultContentType: application/json

info:
  title: Test Absolute Path
  version: "1.0.0"

channels:
  TestOperation:
    publish:
      message:
        $ref: "/absolute-path/File.yaml"

Expected behavior

Done! ✨
Check out your shiny new generated files at ...

Actual behavior

Something went wrong:
Error: Input is not a corrent AsyncAPI document so it cannot be processed.
    at Generator.generateFromString (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:264:19)
    at async /usr/local/lib/node_modules/@asyncapi/generator/cli.js:157:9
Errors:
[
  {
    "code": "invalid-ref",
    "path": [
      "channels",
      "TestOperation",
      "publish",
      "message",
      "$ref"
    ],
    "message": "ENOENT: no such file or directory, open '/absolute-path/absolute-path/File.yaml'",
    "severity": 0,
    "range": {
      "start": {
        "line": 11,
        "character": 14
      },
      "end": {
        "line": 11,
        "character": 40
      }
    },
    "source": "/absolute-path/asyncapi.yaml"
  }
]

Activity

  1. added
    bug
    on Jun 13, 2023
  2. github-actions commented on Jun 13, 2023

    @github-actions

    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.

  3. amelluk commented on Jun 15, 2023

    @amelluk

    duplicate of asyncapi/generator#963 - I have the same problem :/

  4. dvemnt commented on Jun 15, 2023

    @dvemnt
    Author

    duplicate of asyncapi/generator#963 - I have the same problem :/

    I don't think that's duplicate. asyncapi/generator#963 is about the spec and unsupported place for reference, here is about paths handling.

  5. eivindga commented on Jun 19, 2023

    @eivindga

    As far as I understand, the spec does no longer allow absolute paths in references?

    See also:
    #405

  6. dvemnt commented on Jun 19, 2023

    @dvemnt
    Author

    As far as I understand, the spec does no longer allow absolute paths in references?

    Looks like, the spec still allow absolute paths in references, but generator (or parser) handles such paths in wrong way, as local paths, I think.

  7. derberg commented on Jul 3, 2023

    @derberg
    Member

    sorry but I'm unable to replicate your issue. I created a file that you shared and all was good.

    I also opened a PR to show tests with different local references work asyncapi/generator#1003

    on message level references should and were always possible.

    As far as I understand, the spec does no longer allow absolute paths in references?

    not sure where you got this message from, but spec is definitely still supporting $ref in message object

  8. dvemnt commented on Jul 3, 2023

    @dvemnt
    Author

    Hi, @derberg.
    I don't see absolute references in your PR, only relative references (here and here). And my issue still reproduces.

    Screenshot from 2023-07-03 16-53-22

  9. derberg commented on Jul 3, 2023

    @derberg
    Member

    you're right, sorry, I misunderstood your initial example.

    yes, I can replicate this problem. It is for sure something that should work, and worked before

    As a workaround, add file: to the reference. And I'm moving this issue to parser repo, as it is bug in the repo, and not even the repo but the fact there was a move to another reference parser tool that do not work as expected: https://github.com/stoplightio/json-ref-resolver. So apparently some regression was introduced in functionality

  10. transferred this issue fromasyncapi/generatoron Jul 3, 2023
  11. github-actions commented on Jul 3, 2023

    @github-actions

    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.

  12. github-actions commented on Nov 1, 2023

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴

    It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

    There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

    Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

    Thank you for your patience ❤️

  13. derberg commented on Dec 18, 2023

    @derberg
    Member

    I think the issue is still there

  14. github-actions commented on Apr 17, 2024

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴

    It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

    There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

    Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

    Thank you for your patience ❤️

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

    bugstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions