Skip to content

feat: add new custom resolver to fetch the reference from private repo #1810

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AayushSaini101
Copy link
Collaborator

Resolves: #1796

  • Create a custom resolver to fetch the reference from the private repo
  • Add new command auth add for storing the repo name and repo token.
  • Tests and documents need to be updated

@github-project-automation github-project-automation bot moved this to To Triage in CLI - Kanban Jun 21, 2025
@AayushSaini101 AayushSaini101 changed the title Add new custom resolver to fetch the reference from private repo feaat: add new custom resolver to fetch the reference from private repo Jun 21, 2025
@AayushSaini101 AayushSaini101 changed the title feaat: add new custom resolver to fetch the reference from private repo feat: add new custom resolver to fetch the reference from private repo Jun 21, 2025
Copy link
Contributor

Changeset has been generated for this PR as part of auto-changeset workflow.

Please review the changeset before merging the PR.
---
'@asyncapi/cli': minor
---

feat:  add new custom resolver to fetch the reference from private repo

- 0213926: Add new custom resolver to fetch the reference from private template and add new command auth add

If you are a maintainer or the author of the PR, you can change the changeset by clicking here

Tip

If you don't want auto-changeset to run on this PR, you can add the label skip-changeset to the PR or remove the changeset and change PR title to something other than fix: or feat:.

Copy link

changeset-bot bot commented Jun 21, 2025

🦋 Changeset detected

Latest commit: 181dbb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@AayushSaini101
Copy link
Collaborator Author

AayushSaini101 commented Jun 21, 2025

Tests and documentation need to be updated, i will update after getting ack from this approach : )

  • Spec containing private repo:
image
  • Trying to parse using the existing version of the asyncapi cli:
image

New feature:

  • Add auth value for the github token:
image

Repo URL format: https://github.com/AayushSaini101/AayushSaini101/tree/main

  • Trying to fetch the private ref:
image

cc: @fmvilas @Souvikns @Shurtu-gal

schema: 'https',
order: 1,

canRead: (uri: URI) => uri.hostname() === 'raw.githubusercontent.com',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why checking for GitHub here? 🤔 References can be in many places, not just GitHub, and even in such a case the GitHub deployment might be in a private domain, which is pretty common in medium to large companies.


read: async (uri: URI) => {
const url = uri.toString();
const normalized = normalizeRawGitUrl(uri);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the URL is not pointing to a GitHub repo? This could perfectly be a Schema Registry URL, an S3 bucket, some random URL, or even a GitLab or BitBucket URL.

const token = matched.token.startsWith('$')
? process.env[matched.token.slice(1)] || ''
: matched.token;
headers['Authorization'] = `Bearer ${token}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some systems don't use Bearer tokens. Some might accept jwt or api-key or actually whatever the API designer wants to put there. We shouldn't hardcode it, that's why in my definition of the task I added some alternative examples.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure @fmvilas i will update it

@github-project-automation github-project-automation bot moved this from To Triage to Backlog in CLI - Kanban Jun 21, 2025
@AayushSaini101
Copy link
Collaborator Author

/u

Copy link

sonarqubecloud bot commented Jul 2, 2025

@AayushSaini101
Copy link
Collaborator Author

@fmvilas For the private Github URL should be in this format: like https://api.github.com/repos/AayushSaini101/AayushSaini101/contents/user-signedup.yaml, not direct URL like we simple copy the path of the URL from the private repo, this is the github url, not sure about the private repo, in short we need to compare each and every url and create special check to find whether it is matching with the stored pattern or not, we can start with the github and gitlab pattern then we can slowly slowly add the comparison format as we grow thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

[FEATURE] Pass authentication/authorization to $ref HTTP resolvers
3 participants