Comments (5)
Hi, apologies for the late reply, picking this up now :)
A possible solution, that is more flexible, is to allow for Channels/Operations and Messages to be declared as independent attributes in multiple classes or methods. In this case, each Message Attribute would specify the Operation it belongs to, and when generating the document, it would update/add the message (stored as a collection) in the specified Operation object.
Can you give a code example of how (ideally) this would look for you (as the library user)?
I understand the issue, but I'm not sure exactly what the best user experience looks like.
Thanks
from saunter.
Ok, this looks good.
As I'm really only experienced with AMQP, I didn't understand the potential design differences with Kafka (and I'm sure there will be more differences with other implementations).
I will start working on this now 😀
from saunter.
Hello again, this is now in master.
See ClassAttributesTests for an example https://github.com/tehmantra/saunter/blob/master/test/Saunter.Tests/Generation/DocumentGeneratorTests/ClassAttributesTests.cs
This will be available on NuGet v0.1.0-alpha-46
https://www.nuget.org/packages/Saunter/0.1.0-alpha-46
from saunter.
Thank you for your reply!
I don't have a perfect solution but I think the best is decoupling channels from the message/method, but keeping the current solution for backward compatibility.
So for channels, I think it should be possible to declare them either on classes or methods.
Using methods attributes would assume the current behavior of associating the Channel attribute with the Operation/Message.
When a Channel is declared as a class attribute, it would assume there is a channel and it might contain multiple messages under the same channel.
By design of the asyncapi spec, a channel can only have one producer and one subscriber, the Operation must be declared also as a class attribute.
So it would require a new Message Attribute, associated with a method(?) (or should be other classes, the message classes?).
The Message would need to reference the OperationId as a key, and by doing so it would aggregate all messages related to the Operation/Channel.
Example:
[AsyncApi]
[Channel(TENANT_INSTANCES_TOPIC, Description = TENANT_TOPIC_DESCRIPTION)]
// OperationId can assume the class name if not specified
[SubscribeOperation([OperationId= "TenantMessageConsumer"], Summary = "Subscribe to domains events about tenants.")]
public class TenantMessageConsumer : ITenantMessageConsumer
{
internal const string TENANT_INSTANCES_TOPIC = "asw.tenant_service.tenants_history";
[Message(typeof(TenantCreated), OperationId= "TenantMessageConsumer", Description = "...")]
void SubscribeTenantCreatedEvent(Guid tenant_id, TenantCreated evnt) {}
[Message(typeof(TenantUpdated), OperationId= "TenantMessageConsumer", Description = "...")]
void SubscribeTenantUpdatedEvent(Guid tenant_id, TenantUpdated evnt) {}
[Message(typeof(TenantRemoved), OperationId= "TenantMessageConsumer", Description = "...")]
void SubscribeTenantRemovedEvent(Guid tenant_id, TenantRemoved evnt) { }
}
from saunter.
Thank you so much!
from saunter.
Related Issues (20)
- js is not served with .net 6 and named documents HOT 4
- Choose which classes should be included in the YML definition
- Issues caused by PathString when running saunter ui behind reverse proxy HOT 5
- Description for Enums are not rendered HOT 1
- Duplicated operation when types of same assembly are informed in MarkerTypes
- Duplicate Attributes Not Allowed HOT 4
- Cannot generate description in json based on remarks
- Usage with worker service?
- Kafka security schemes invalid specification
- DocumentName not propagated in the clone and hence not available in IDocumentFilter
- Allow async api middlewares to be executed where required
- How to specify KAFKA bindings
- Multiple SubscribeOperation for same channel fails
- Nswag 14 MapAsyncApiDocuments failing
- Saunter fork ready HOT 4
- Update README section JSON Schema Settings
- [FEATURE] update logo and project URLs
- [FEATURE] Support AOT Trimmed applications HOT 3
- [FEATURE] Migrate to DTO from AsyncApi.Net HOT 7
- Operation types in the side panel index are not correct HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saunter.