@@ -12,7 +12,7 @@ V3 is currently in pre-release - so grab that if you need V3
1212[ Wiki and getting started guide] ( https://github.com/ByteBardOrg/AsyncAPI.NET/wiki )
1313
1414## Installation
15- Generally you wan't to use Readers and Bindings.
15+ Generally you want to use Readers and Bindings.
1616They have however been split to allow for different scenarios without polluting with unnecesary packages.
1717
1818Install the NuGet packages:
@@ -38,59 +38,43 @@ Main classes to know:
3838## Writing
3939
4040``` csharp
41- var myFirstAsyncApi = new AsyncApiDocument
42- {
43- Info = new AsyncApiInfo
44- {
45- Title = " my first asyncapi" ,
46- },
47- Channels = new Dictionary <string , AsyncApiChannel >
48- {
49- {
50- " users" , new AsyncApiChannel
51- {
52- Subscribe = new AsyncApiOperation
53- {
54- OperationId = " users" ,
55- Description = " my users channel" ,
56- Message = new List <AsyncApiMessage >
57- {
58- new AsyncApiMessageReference (" #/components/messages/MyMessage" ),
59- },
60- },
61- }
62- },
63- },
64- Components = new AsyncApiComponents
65- {
66- Messages = new Dictionary <string , AsyncApiMessage >
67- {
68- {
69- " MyMessage" , new AsyncApiMessage
70- {
71- Name = " Hello!" ,
72- }
73- },
74- },
75- },
76- };
77-
78- var yaml = myFirstAsyncApi .SerializeAsYaml (AsyncApi );
79-
80- // asyncapi: 2.6.0
81- // info:
82- // title: my first asyncapi
83- // channels:
84- // users:
85- // subscribe:
86- // operationId: users
87- // description: my users channel
88- // message:
89- // $ref: '#/components/messages/MyMessage'
90- // components:
91- // messages:
92- // MyMessage:
93- // name: Hello!
41+ var specification =
42+ """
43+ asyncapi: 3.0.0
44+ info:
45+ title: UsersAPI
46+ version: 1.0.0
47+ externalDocs:
48+ description: Find more info here
49+ url: https://www.asyncapi.com
50+ tags:
51+ - name: e-commerce
52+ servers:
53+ production:
54+ host: "rabbitmq.in.mycompany.com:5672"
55+ pathname: "/production"
56+ protocol: "amqp"
57+ channels:
58+ UserSignup:
59+ address: "user/signedup"
60+ messages:
61+ UserMessage:
62+ payload:
63+ type: object
64+ properties:
65+ displayName:
66+ type: string
67+ description: Name of the user
68+ operations:
69+ ConsumeUserSignups:
70+ action: receive
71+ channel:
72+ $ref: "#/channels/UserSignup"
73+ """ ;
74+ var reader = new AsyncApiStringReader ();
75+ var document = reader .Read (specification , out var diagnostics );
76+ var v2Document = document .SerializeAsYaml (AsyncApiVersion .AsyncApi2_0 );
77+ var v3Document = document .SerializeAsJson (AsyncApiVersion .AsyncApi3_0 );
9478```
9579
9680
0 commit comments