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

Allow matching of specific reference resolvement depth #2120

Open
jonaslagoni opened this issue Apr 7, 2022 · 2 comments
Open

Allow matching of specific reference resolvement depth #2120

jonaslagoni opened this issue Apr 7, 2022 · 2 comments
Labels
enhancement New feature or request triaged

Comments

@jonaslagoni
Copy link
Collaborator

User story.
As a user, I want to decide the level of reference matching for a rule.

Is your feature request related to a problem?
In AsyncAPI we can define messages as references:

---
channels:
  some/channel:
    subscribe:
      message:
        $ref: ./some/message.yml

And the message object that is being referenced, can also contain a reference.

---
payload:
  $ref: ./some/schema.yml

I am unable to lint the reference within the referenced message object because I am not able to control the depth at which references should/should not be resolved.

Describe the solution you'd like
The only way I can think this can be solved is through a depth level that you can "target" reference resolvement 🤔 Not quite sure how easy it is to achieve though!

For example, given:

rules:
  ...
  asyncapi-message-payload-must-use-references:
    given: $.channels.[*][subscribe,publish].message
    resolved: "depth-1"

It would resolve the first reference only:

---
channels:
  some/channel:
    subscribe:
      message:
        payload:
          $ref: ./some/schema.yml

Maybe someone have a better way to achieve this? 🤔

@jonaslagoni jonaslagoni added the enhancement New feature or request label Apr 7, 2022
@SirAppSec
Copy link

I'm facing a similar requirement for some specific internal rules, @jonaslagoni, did you find a solution?
I considered custom resolvers, but they seem to require file resolving and this can be a pain to achieve properly.

In my case I just need to know if an object is a de-refrenced object and the ref itself.
I manage to achieve this for the first depth using context.document but it only show the first "depth".
Is it possible to get a graph of references?

@jonaslagoni
Copy link
Collaborator Author

@SirAppSec I have unfortunately not no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

3 participants