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

Dereferencing rules #579

Closed
char0n opened this issue Jul 11, 2021 · 6 comments
Closed

Dereferencing rules #579

char0n opened this issue Jul 11, 2021 · 6 comments

Comments

@char0n
Copy link
Collaborator

char0n commented Jul 11, 2021

Hello everybody,

This issue is specifically about AsyncApi 2.0.0, but applies to v2.1.0 respectively. I'm working on a dereferencing tool a bumped to another issue regarding JSON Schema dereference. We've already stipulated in #552 that whenever the $ref field is intercepted in Schema Object, this Schema Object becomes a Reference Object and not a Schema Object with $ref keyword. This effectively means that dereference is purely guided using rules around Reference Object.

Never the less, the File Structure section contains following sentence:

The A2S representation of the API is made of a single file. However, parts of the definitions can be split into separate files, at the discretion of the user. This is applicable for $ref fields in the specification as follows from the JSON Schema definitions.

The interesting part is the second (last) sentence. It's not very clear what this sentence actually tries to tell us.

There can be two possible interpretations (that I can see):

  1. $ref fields follow rules around JSON Schema dereference

As stipulated in #552 this in not true.

  1. $ref fields supports only referencing JSON Schemas

Again this in not true. $ref field can only be present (and have semantics) in Reference Object and Reference Object can reference other specification objects (Security Scheme, Parameter, Message, etc..).

IMHO this sentence mandates a major change in wording to clarify it's true meaning.

We can take inspiration from OpenApi 3.1:

An AsyncAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the author. In the latter case, Reference Objects are used.

@magicmatatjahu
Copy link
Member

@char0n Hi! I think that this sentence points to logic how it works in the JSON Schema (...This is applicable for $ref fields...), I mean, referencing between files, but doesn't tell that it's only used for Schema Objects, but also for another part of spec - something like an example in correlation to another "tool", which is JSON Schema.

@magicmatatjahu
Copy link
Member

@char0n Do you have any suggestions to improve the description of dereferencing rules?

@char0n
Copy link
Collaborator Author

char0n commented Jul 26, 2021

Hi @magicmatatjahu,

Hi! I think that this sentence points to logic how it works in the JSON Schema (...This is applicable for $ref fields...)

How it works in JSON Schema is completely different how Reference Object works in AsyncApi spec. That's my whole point. This is why this sentence is confusing for the reader and opens door for different interpretations.

I mean, referencing between files

In AsyncApi, referencing is defined exclusively by Reference Object and not by JSON Schema rules. Even JSON Schema uses Reference Object to process references and transclution.

I've already provided my suggestion in my first comment:

I'd replace this sentence:

The A2S representation of the API is made of a single file. However, parts of the definitions can be split into separate files, at the discretion of the user. This is applicable for $ref fields in the specification as follows from the JSON Schema definitions.

with the following one:

An AsyncAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the author. In the latter case, Reference Objects is used.

If agreed I can issue a PR.

@char0n
Copy link
Collaborator Author

char0n commented Aug 4, 2021

I've issued a PR with the clarification: #602

@github-actions
Copy link

github-actions bot commented Oct 4, 2021

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions github-actions bot added the stale label Oct 4, 2021
@char0n
Copy link
Collaborator Author

char0n commented Oct 4, 2021

Attached PR has been merged, closing this.

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

No branches or pull requests

2 participants