Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot bundle documents with different base paths #35

Closed
jonaslagoni opened this issue Mar 25, 2022 · 9 comments
Closed

Cannot bundle documents with different base paths #35

jonaslagoni opened this issue Mar 25, 2022 · 9 comments
Labels
bug Something isn't working stale

Comments

@jonaslagoni
Copy link
Member

jonaslagoni commented Mar 25, 2022

Describe the bug

I have the current folder setup:

definitions
  asyncapi.json
  components
    messages
       ...
bundler
  bundlerScript.js

And standing inside the bundler dir executing bundlerScript.js it is unable to locate the references for example messages as ./components/messages/myMessage.json that asyncapi.json uses.

Expected behavior

Expected the setup to work.

I dont quite understand why there is a custom dereference in place before parsing the documents? Otherwise, I could utilize the following custom parser. Although a bit of a hack as there is no real docs what is expected from parser option.

  const bundledDocument = await bundler(
    fileContents,
    {
      parser: {
        parse: (fileContent) => {
          const p = path.resolve(__dirname, '../../definitions')
          return parse(fileContent, {path: p})
        }
      }
    }
  );
@jonaslagoni jonaslagoni added the bug Something isn't working label Mar 25, 2022
@Souvikns
Copy link
Member

the bundlerScript.js has to be in the same folder where the definitions are. I could not find any way to pass basepath in json-schema-ref-parser, currently, the path resolves relatively.

Also according to #26 we won't parse or validate the document.

@jonaslagoni
Copy link
Member Author

the bundlerScript.js has to be in the same folder where the definitions are. I could not find any way to pass basepath in json-schema-ref-parser, currently, the path resolves relatively.

With the current setup, yes that is required 🙂

Also according to #26 we won't parse or validate the document.

That would definitely fix this issue yes 🙂

@github-actions
Copy link

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 ❤️

@github-actions github-actions bot added the stale label Jul 24, 2022
@jonaslagoni
Copy link
Member Author

Still relevant

@github-actions github-actions bot removed the stale label Jul 26, 2022
@github-actions
Copy link

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 ❤️

@github-actions github-actions bot added the stale label Nov 23, 2022
@aeworxet
Copy link
Collaborator

When auditing open issues, Bundler of version v0.3.7 was found to successfully dereference

./messages.yaml#/messages/UserSignedUp
../messages.yaml#/messages/UserSignedUp
../src/messages.yaml#/messages/UserSignedUp

Closing the issue.

@jonaslagoni
Copy link
Member Author

jonaslagoni commented Oct 21, 2023

This issue is not solved, still have the same problem, where there is no way to set the base URL for where references should be resolved.

The current bundle logic still looks for local references in the directory you execute the script from. Without a basedir option this issue will never be solved.

Do reopen the issue, or I will just post another 🙂

@jpdias
Copy link

jpdias commented Jan 22, 2024

Facing the same issue when trying to use the bundler as part of a pipeline. Passing the basePath as an argument for referenced relative paths would address the issue. For now we are doing a workaround by using the process.chdir to the folder where the main AsyncAPI yml is located, do the bundling, and then change back.

@Souvikns Souvikns reopened this Jan 22, 2024
@Souvikns
Copy link
Member

Added a solution with #148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

4 participants