-
Notifications
You must be signed in to change notification settings - Fork 18
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
DRAFT - feat: Add local external file refs #129
Conversation
BREAKING CHANGE: Bindings have been moved to a separate project
We require all PRs to follow Conventional Commits specification.
|
if (pointer.StartsWith("#")) return mapNode.GetReferencedObject<AsyncApiMessage>(ReferenceType.Message, pointer); | ||
|
||
// how can we pass in settings and options for user to inject their own file reader | ||
// is version matching important? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version matching becomes important once we need support for both V2 and V3 which is coming very soon.
But important only on the read side, as we aren't looking to support writing to both version, but rather "upgrade" older versions to the newest.
I see, so multiple asyncapi structures within a single file.
return mapNode.GetReferencedObject<AsyncApiBindings<IChannelBinding>>(ReferenceType.ChannelBindings, pointer); | ||
} | ||
|
||
var referencedContent = File.ReadAllText(pointer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think the right place to implement this, would be here in the deserializers, but rather a mix of GetReferencedObject
and the AsyncApiReferenceResolver
.
There is also a method in the DocumentReader called "ResolveReferences" which is the beginning of the reference resolution story. - this effectively walks all of the references.
What you will notice is that AsyncApiDocument uses AsyncApiReferenceResolver
- which might also be helpful in figuring out the resolution map up front.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VisualBean Will do. Thanks for the context!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpwdec ive made some initial digging into this (just allowing any type of reference and correctly setting the values) without resolving anything (just marking them as unresolved to begin with).
I would also really appreciate if work could be done against the vnext branch, as this has some breaking changes (like changing from yamldotnet to system.text.json)
see #132.
resolving non internal references should feasibly happen in the jsondocumentreader
A few thoughts ive had
Perhaps an A default ReferenceLoader could be made that fetches http and local fragments. The current resolution flow 'ends' with the following method in the private T ResolveReference<T>(AsyncApiReference reference) where T : class, IAsyncApiReferenceable
{
try
{
return this.currentDocument.ResolveReference(reference) as T;
}
catch (AsyncApiException ex)
{
this.errors.Add(new AsyncApiReferenceError(ex));
return null;
}
} Which could feasibly check if the reference
I believe i have solved this in another PR |
5ebfbf8
to
9063f4e
Compare
About the PR
Currently, referenced objects in the AsyncAPI spec when read by the AsyncAPI.NET library can only be parsed using internal document references to the
components
object. While this is very useful, ideally we would utilise the full$ref
functionality afforded to us by referencing external files, both locally and remotely. The advantages of facilitating references outside of a single AsyncAPI file are myriad, but most importantly it:$ref
a producer's definition of their message without need for duplicationThis PR aims to implement the functionality for allowing referencing of local references, i.e. other AsyncAPI objects defined in YAML that exist on the same local file system.
Challenges to solve
Changelog
TODO
Related Issues
TODO