-
-
Notifications
You must be signed in to change notification settings - Fork 9
[Feature Suggestion] Filter by usage #76
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
Comments
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 ❤️ |
Dear bot, don't close this issue. Sincerely, your human ❤️ |
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 ❤️ |
I suggest all methods on the root document such as
root.channels()
,root.operations()
,root.messages()
, etc return all objects from around the document (including those in components). On the contrary, as the perspective is always from the Application, those methods located in other places rather than the root will return objects associated with such collection; for exampleroot.operations()[0].channels()
will return channels associated with that particular operation.In order to filter by objects in use or not in use by the Application, we could add
.filterByInUse()
andfilterByNotInUse()
methods toservers
,channels
andmessages
.See the following examples:
root.channels().all()
(method that already exists) -> returns channels across the whole documentroot.channels().filterByInUse()
-> returns channels used by the applicationroot.channels().filterByNotInUse()
-> returns channels not used by the applicationcomponents.channels().all()
(method that already exists) -> returns all channels defined as components.components.channels().filterByInUse()
-> returns channels used by the applicationroot.channels().filterByNotInUse()
-> returns channels not used by the applicationroot.channels()[0].servers().all()
(method that already exists) -> returns servers associated to a particular channel.root.channels()[0].servers().filterByInUse()
-> this will return the same asall()
in this case.root.channels()[0].servers().filterByNotInUse()
-> this will return an empty array.In terms of implementation (at least for Spec v2.x.x), we could compare the JSON payload to determine if an object is isolated only in components or used by the application.
The benefit I see is that this decouples even more the API from the document shape, as no matters where the objects are declared (components, root of the document, etc), we would now have standard methods to access those. That means if a BC is introduced within the spec where, i.e.
channels
are not defined anymore in the root document but somewhere else (like components), there will be no BC in the API.Also the use case where some tooling needs to generate all models (like modelina) could benefit from this as well.
Originally posted by @smoya in asyncapi/parser-js#619 (comment)
cc @fmvilas @magicmatatjahu @jonaslagoni
The text was updated successfully, but these errors were encountered: