-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
docs: intent API #263
docs: intent API #263
Conversation
Emulated breaking changesWe needed to test the intents based on different changes from asyncapi/shape-up-process#93 3.0.0-fakeAssumptions:
Intents:
3.0.0-fake2Because this makes it possible to define multiple schema formats per message, it is no longer a 1:1 (message:schemaFormat) but a 1:* and breaks the return values
3.0.0-fake3Because this makes it possible to define multiple operations per channel, it is no longer 1:1 (channel:operation) but a 1:* and breaks the return values
3.0.0-fake4Because this makes it possible to define multiple messages under a channel, and those messages can contain operations we no longer have a 1:1 (channel:operation) but a 1:* and breaks the return values
ConclusionAs you can see we have a problem with the cardinality of return values in general.. The only apparent solution is to return an array of values, always, to be safe. But this is affecting the toolings using the parser making it more difficult... |
Taking this as an example of what would happen in case we return an array of strings:
The issue about returning an array of strings here is that the user won't be able to link the data it gets from each of those methods ever. I think that, if we end up having such a change on our spec, then the TL;DR. At this point, considering having a good balance between API usability and resiliency, I would consider those breaking changes as unavoidable. |
Awesome works guys! Sorry for late response. I read docs in PR and issue description/comments and I have problem with:
As I understand intents like So: Intents like Currently I render spec in React component and I see that the additional API proposed in PR for the React component itself is redundant, but as I wrote, to someone/for some template it may be useful, but guys :P please try to create as fewer intents as possible that are created due to the way you look at the spec rather than the data the spec has (byt this I like |
I don't want to be a party pooper here but overall, it looks that to use the parser I will not only need to know the spec by also some additional vocabulary ( this is my first impression, which is by default pushing me away. The initial intent of new API was to make parser API not reflect the spec but the intents of the user. I think it directly means there will be many methods. So I guess my point of view is totally different too what @magicmatatjahu shared. It is better to have "200" methods here rather than have "200" helpers spread in different tools. As long as the names are consistent and you thanks to it you can easily navigate through them with auto-suggestions from IDE, this is ok imho. I think that next to the proposal we need to see some code samples how it is used, as I did with this comment: current state that clearly shows I need to get all the channels and and to "if" statements to get what I need
and what we could have to make it much easier to consume the spec through the parser (a bit modified comparing to my initial comment from the issue. Extremely useful helper like
doesn't matter where operationId will be. And even if we change To conclude - parser should be resilient to spec changes as much as possible + speed the work on templates, make it nicer, less complicated. But yeah, would be great to see your proposal used on some existing code from templates, to see what will change, and if for good or bad |
Thanks for the feedback @derberg, @magicmatatjahu!
In my opinion, we have to @magicmatatjahu, otherwise what is the point of an intent API if it requires the parsers a major version update when the spec updates? If we only go halfway then there is no point in doing it, it would create more confusion than good.
@derberg correct, but IMO you would need to anyway since the parser and the spec no longer follow 1:1. So to understand the parser you would need to read the documentation anyway.
@derberg I am working on actually integrating this suggested API so we can see the changes it would have. |
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 think it's looking great and you're making great progress here. It's never easy to design an API and you're scratching your head a lot 😄 That's really good 👏
My advice is that you forget about AsyncAPI for a moment and design the API with generic concepts that may or may not map directly to the AsyncAPI spec. For instance, think of someone creating an EDA. The main concepts that come to the top of my head are:
- My application
- Other applications
- The broker
- The topics on the broker
- The messages on those topics
- The messages my app publish to these topics
- The messages my app subscribe to on these topics
- The messages other apps can publish to these topics
- The messages other apps can subscribe to on these topics
Now try to map these to AsyncAPI:
- My application => AsyncAPI file
- Other applications => Other apps consuming my AsyncAPI file
- The broker => Server
- The topics on the broker => Channels (without publish/subscribe info)
- The messages on those topics => Channel.*.message (where * is either publish/subscribe but we hide it at this level)
- The messages my app publish to these topics => Channel.subscribe.message
- The messages my app subscribe to on these topics => Channel.publish.message
- The messages other apps can publish to these topics => Channel.publish.message
- The messages other apps can subscribe to on these topics => Channel.subscribe.message
Hope it helps! Keep up the great work! 💪
docs/API.md
Outdated
- `AsyncAPIDocument.hasContentType('<content type>')` : boolean (outcome of comment(s): [799481319](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-799481319)) | ||
- `AsyncAPIDocument.channels()` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) | ||
- **(HELP NEEDED)** `AsyncAPIDocument.channelsSubscribes('<role>')` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) | ||
- **(HELP NEEDED)** `AsyncAPIDocument.channelsPublishes('<role>')` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) |
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.
- **(HELP NEEDED)** `AsyncAPIDocument.channelsPublishes('<role>')` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) | |
- **(HELP NEEDED)** `AsyncAPIDocument.clientPublishableChannels()` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) | |
- **(HELP NEEDED)** `AsyncAPIDocument.publishingChannels()` : Channel[] (outcome of comment(s): [800282407](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800282407), [800935961](https://github.com/asyncapi/shape-up-process/issues/84#issuecomment-800935961)) |
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.
Same as above comment.
@fmvilas thanks for the feedback!
That is basically also what we did, but I guess the description does not clarify this well enough 🤔 The idea was to separate the entities completely from the spec and simply think about what concepts make sense and which relationships they have with each other. I'll see if I can change the description to state this separation better then it is. |
1240c9d
to
6da2123
Compare
6da2123
to
7d1c09b
Compare
After playing around a bit with the API these are some of the thoughts I had. Improvements to the API
Breaking changesIt seems like we solved the problems of the breaking changes we had in the last suggestion 👏 3.0.0-fakeSince we already return an array of operations, this will not break the parser API. 3.0.0-fake2Does not break the parser API since we can add support function such as 3.0.0-fake3Still works since we have a bidirectional flow of channels, messages, and operations already. 3.0.0-fake4Still works since we have a bidirectional flow of channels, messages, and operations already. |
@smoya and I discussed it and would like to suggest making the association between servers and operations such as:
Thoughts: Will there be any problems with the generator in terms of the template parameter
@smoya and I agreed we should add this.
@smoya and I discussed this and came up with a suggestion for adding the following:
Why add both Thoughts? |
Bindings are a bit weird to use, especially if you want to get nested properties such as We have two choices at the moment, either Would it make sense to have a binding intent such as |
@jonaslagoni and I are gonna move with the mocking of the API based on the previous suggestions. |
feat: add markdown-template required methods
538a467
to
54ba918
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
This PR suggests the new intent API for the parser.
It is implicit that all properties will have their own intents in the end but are not added for simplicity.
Looking for feedback
Next steps
Related issue(s)