{"id":26591534,"url":"https://github.com/asyncapi/net-sdk","last_synced_at":"2025-04-09T20:04:52.669Z","repository":{"id":43339139,"uuid":"383475660","full_name":"asyncapi/net-sdk","owner":"asyncapi","description":"A .NET SDK for the Async API specification","archived":false,"fork":false,"pushed_at":"2025-04-08T10:29:26.000Z","size":2200,"stargazers_count":71,"open_issues_count":1,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T20:04:47.540Z","etag":null,"topics":["amqp","asyncapi","client","code-first","documentation","dotnet","generator","kafka","mqtt","nats","websocket"],"latest_commit_sha":null,"homepage":"https://www.asyncapi.com/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asyncapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-06T13:19:09.000Z","updated_at":"2025-04-08T10:28:37.000Z","dependencies_parsed_at":"2025-01-07T02:46:19.733Z","dependency_job_id":"a483c7d8-a85c-4dff-9b67-b83ff867d9dc","html_url":"https://github.com/asyncapi/net-sdk","commit_stats":{"total_commits":95,"total_committers":5,"mean_commits":19.0,"dds":0.06315789473684208,"last_synced_commit":"6821765f095a881a8cf129b5b27f1d8e557e3ef0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnet-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnet-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnet-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnet-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asyncapi","download_url":"https://codeload.github.com/asyncapi/net-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103868,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amqp","asyncapi","client","code-first","documentation","dotnet","generator","kafka","mqtt","nats","websocket"],"created_at":"2025-03-23T14:10:58.428Z","updated_at":"2025-04-09T20:04:52.646Z","avatar_url":"https://github.com/asyncapi.png","language":"C#","readme":"﻿# Neuroglia AsyncAPI\n\n## Contents\n\n- [Neuroglia AsyncAPI](#neuroglia-asyncapi)\n  + [Contents](#contents)\n  + [Summary](#summary)\n  + [Status](#status)\n  + [Installation](#installation)\n    - [Core library](#core-library)\n    - [Fluent validation library](#fluent-validation-library)\n    - [Fluent builders library](#fluent-builders-library)\n    - [Input/Output library](#inputoutput-library)\n    - [Code-first generation library](#code-first-generation-library)\n    - [Dependency inject extensions library](#dependency-inject-extensions-library)\n    - [Cloud event extensions library](#cloud-event-extensions-library)\n    - [AsyncAPI document serving library](#asyncapi-document-serving-library)\n    - [AsyncAPI UI](#asyncapi-ui)\n  + [Usage](#usage)\n    - [Build AsyncAPI documents](#build-asyncapi-documents)\n      + [Using AsyncAPI v2](#using-asyncapi-v2)\n      + [Using AsyncAPI v3](#using-asyncapi-v3)\n    - [Write AsyncAPI documents](#write-asyncapi-documents)\n    - [Read AsyncAPI documents](#read-asyncapi-documents)\n    - [Generate code-first AsyncAPI documents](#generate-code-first-asyncapi-documents)\n      + [Using AsyncAPI v2](#using-asyncapi-v2-1)\n      + [Using AsyncAPI v3](#using-asyncapi-v3-1)\n    - [Generate documents explicitly](#generate-documents-explicitly)\n    - [Generate documents implicitly](#generate-documents-implicitly)\n    - [Use the AsyncAPI UI](#use-the-asyncapi-ui)\n    - [Interact with AsyncAPI applications](#interact-with-asyncapi-applications)\n  + [Samples](#samples)\n    - [Streetlights API - Server](#streetlights-api---server)\n\n## Summary\nA .NET used to visualize and interact with [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v3.0.0) documents. The UI is built using Razor Pages and Boostrap\n\n## Status\n\n| Name | Description | Latest Release | Spec version |\n|:------|:------------|:--------------:|:------------:|\n| [Neuroglia.AsyncApi.Core](https://www.nuget.org/packages/Neuroglia.AsyncApi.Core) | Contains `AsyncAPI` models and core services such as fluent builders, validators, reader, writer and code-first generator | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Generation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Generation) | Contains extensions and services for code-first generation of `AsyncAPI` documents | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.CloudEvents](https://www.nuget.org/packages/Neuroglia.AsyncApi.CloudEvents) | Contains fluent extensions to build Cloud Event messages | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.ServiceDependencyExtensions](https://www.nuget.org/packages/Neuroglia.AsyncApi.ServiceDependencyExtensions) | Contains extensions to configure and register `AsyncAPI` services using dependency injection | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.AspNetCore](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore) | Contains an `ASP.NET` middleware used to serve `AsyncAPI` documents | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.AspNetCore.UI](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore.UI) | Contains the Razor Pages based UI for exploring `AsyncAPI` documents | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client) | Contains client services to interact with `AsyncAPI` applications | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.All](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.All) | References all binding handlers, for convenience | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Amqp](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Amqp) | Contains the `AMQP` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Http](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Http) | Contains the `HTTP` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Kafka](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Kafka) | Contains the `Kafka` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Mqtt](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Mqtt) | Contains the `MQTT` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Nats](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Nats) | Contains the `NATS` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Pulsar](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Pulsar) | Contains the `Pulsar` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Redis](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Redis) | Contains the `Redis` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Solace](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Solace) | Contains the `Solace` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.Stomp](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.Stomp) | Contains the `Stomp` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n| [Neuroglia.AsyncApi.Client.Bindings.WebSocket](https://www.nuget.org/packages/Neuroglia.AsyncApi.Client.Bindings.WebSocket) | Contains the `WebSocket` binding handler | [3.0.1](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.1) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) |\n\n## Installation\n\n#### Core library\n```bash\ndotnet add package Neuroglia.AsyncApi.Core\n```\n\n#### Fluent validation library\n```bash\ndotnet add package Neuroglia.AsyncApi.Validation\n```\n\n#### Fluent builders library\n```bash\ndotnet add package Neuroglia.AsyncApi.FluentBuilders\n```\n\n#### Input/Output library\n```bash\ndotnet add package Neuroglia.AsyncApi.Validation\n```\n\n#### Code-first generation library\n```bash\ndotnet add package Neuroglia.AsyncApi.Generation\n```\n\n#### Dependency inject extensions library\n```bash\ndotnet add package Neuroglia.AsyncApi.DependencyInjectionExtensions\n```\n\n#### Cloud event extensions library\n```bash\ndotnet add package Neuroglia.AsyncApi.CloudEvents\n```\n\n#### AsyncAPI document serving library\n```bash\ndotnet add package Neuroglia.AsyncApi.AspNetCore\n```\n*Attention, please note that projects serving the UI MUST use the `Microsoft.NET.Sdk.Web`*\n\n#### AsyncAPI UI\n```bash\ndotnet add package Neuroglia.AsyncApi.AspNetCore.UI\n```\n*Attention, please note that projects serving the UI MUST use the `Microsoft.NET.Sdk.Web`*\n\n#### AsyncAPI client\n```bash\ndotnet add package Neuroglia.AsyncApi.Client\n```\n\n## Usage\n\n### Building an AsyncAPI document\n\n#### AsyncAPI v2\n\n```csharp\nvar services = new ServiceCollection();\nservices.AddAsyncApi();\nvar serviceProvider = services.BuildServiceProvider();\nvar builder = serviceProvider.GetRequiredService\u003cIAsyncApiDocumentBuilder\u003e();\nvar document = builder\n    .UsingAsyncApiV2()\n    .WithTitle(\"Cloud Event API\")\n    .WithVersion(\"1.0.0\")\n    .WithServer(\"StreetLightsApi\", server =\u003e server\n        .WithUrl(new(\"https://streetlights.fake.com\"))\n        .WithProtocol(AsyncApiProtocol.Http, \"2.0\")\n        .WithBinding(new HttpServerBindingDefinition())\n        .WithSecurityRequirement(\"oauth2\"))\n    .WithChannel(\"/events\", channel =\u003e channel\n        .WithDescription(\"The endpoint used to publish and subscribe to cloud events\")\n        .WithBinding(new HttpChannelBindingDefinition())\n        .WithSubscribeOperation(operation =\u003e operation\n            .WithOperationId(\"ObserveCloudEvents\")\n            .WithDescription(\"Observes cloud events published by the StreetLightsApi\")\n            .WithBinding(new HttpOperationBindingDefinition() { Method = Neuroglia.AsyncApi.v2.Bindings.Http.HttpMethod.POST, Type = HttpBindingOperationType.Response })\n            .WithMessages\n            (\n                message =\u003e message\n                    .WithName(\"LightMeasuredEvent\")\n                    .WithDescription(\"The event fired whenever the luminosity of a light has been measured\")\n                    .WithContentType(\"application/cloudevents+json\")\n                    .WithTraitReference(\"cloud-event\")\n                    .WithPayloadSchema(lightMeasuredEventSchema)\n                    .WithCorrelationId(\"$message.payload#/subject\")\n                    .WithTag(tag =\u003e tag\n                        .WithName(\"light\")),\n                message =\u003e message\n                    .WithName(\"MovementDetectedEvent\")\n                    .WithDescription(\"The event fired whenever a movement has been detected by a sensor\")\n                    .WithContentType(\"application/cloudevents+json\")\n                    .WithTraitReference(\"cloud-event\")\n                    .WithPayloadSchema(movementDetectedEventSchema)\n                    .WithCorrelationId(\"$message.payload#/subject\")\n                    .WithTag(tag =\u003e tag\n                        .WithName(\"movement\"))\n            )))\n    .WithMessageTraitComponent(\"cloud-event\", message =\u003e message\n        .WithBinding(new HttpMessageBindingDefinition())\n        .WithContentType(\"application/cloudevents+json\"))\n    .WithSecurityScheme(\"oauth2\", scheme =\u003e scheme\n        .WithType(SecuritySchemeType.OAuth2)\n        .WithDescription(\"The security scheme used to authorize application requests\")\n        .WithAuthorizationScheme(\"Bearer\")\n        .WithOAuthFlows(oauth =\u003e oauth\n            .WithClientCredentialsFlow(flow =\u003e flow\n                .WithAuthorizationUrl(new(\"https://fake.idp.com/token\"))\n                .WithScope(\"api:read\", \"The scope used to read data\")))))\n    .Build();\n```\n\n#### AsyncAPI V3\n\n```csharp\nvar services = new ServiceCollection();\nservices.AddAsyncApi();\nvar serviceProvider = services.BuildServiceProvider();\nvar builder = serviceProvider.GetRequiredService\u003cIAsyncApiDocumentBuilder\u003e();\nvar document = builder\n    .UsingAsyncApiV3()\n    .WithTitle(\"Cloud Event API\")\n    .WithVersion(\"1.0.0\")\n    .WithServer(\"StreetLightsApi\", server =\u003e server\n        .WithHost(\"https://streetlights.fake.com\")\n        .WithProtocol(AsyncApiProtocol.Http, \"2.0\")\n        .WithBinding(new HttpServerBindingDefinition())\n        .WithSecurityRequirement(security =\u003e security\n            .Use(\"#/components/securitySchemes/oauth2\")))\n    .WithChannel(\"events\", channel =\u003e channel\n        .WithServer(\"#/servers/StreetLightsApi\")\n        .WithDescription(\"The endpoint used to publish and subscribe to cloud events\")\n        .WithBinding(new HttpChannelBindingDefinition()))\n    .WithOperation(\"observeCloudEvents\", operation =\u003e operation\n        .WithAction(Neuroglia.AsyncApi.v3.V3OperationAction.Send)\n        .WithChannel(\"#/channels/events\")\n        .WithTitle(\"ObserveCloudEvents\")\n        .WithDescription(\"Observes cloud events published by the StreetLightsApi\")\n        .WithBinding(new HttpOperationBindingDefinition() \n        { \n            Method = Neuroglia.AsyncApi.Bindings.Http.HttpMethod.POST, \n            Type = HttpBindingOperationType.Response \n        })\n        .WithMessage(\"#/components/messages/lightMeasuredEvent\"))\n    .WithMessageComponent(\"lightMeasuredEvent\", message =\u003e message\n        .WithName(\"LightMeasuredEvent\")\n        .WithDescription(\"The event fired whenever the luminosity of a light has been measured\")\n        .WithContentType(\"application/cloudevents+json\")\n        .WithTrait(trait =\u003e trait\n            .Use(\"#/components/messageTraits/cloud-event\"))\n        .WithPayloadSchema(schema =\u003e schema\n            .WithFormat(\"application/schema+json\")\n            .WithSchema(lightMeasuredEventSchema))\n        .WithCorrelationId(setup =\u003e setup\n            .WithLocation(\"$message.payload#/subject\"))\n        .WithTag(tag =\u003e tag\n            .WithName(\"light\")))\n    .WithMessageComponent(\"movementDetectedEvent\", message =\u003e message\n        .WithName(\"MovementDetectedEvent\")\n        .WithDescription(\"The event fired whenever a movement has been detected by a sensor\")\n        .WithContentType(\"application/cloudevents+json\")\n        .WithTrait(trait =\u003e trait\n            .Use(\"#/components/messageTraits/cloud-event\"))\n        .WithPayloadSchema(schema =\u003e schema\n            .WithFormat(\"application/schema+json\")\n            .WithSchema(movementDetectedEventSchema))\n        .WithCorrelationId(setup =\u003e setup\n            .WithLocation(\"$message.payload#/subject\"))\n        .WithTag(tag =\u003e tag\n            .WithName(\"movement\")))\n    .WithMessageTraitComponent(\"cloud-event\", message =\u003e message\n        .WithBinding(new HttpMessageBindingDefinition())\n        .WithContentType(\"application/cloudevents+json\"))\n    .WithSecuritySchemeComponent(\"oauth2\", scheme =\u003e scheme\n        .WithType(SecuritySchemeType.OAuth2)\n        .WithDescription(\"The security scheme used to authorize application requests\")\n        .WithAuthorizationScheme(\"Bearer\")\n        .WithOAuthFlows(oauth =\u003e oauth\n            .WithClientCredentialsFlow(flow =\u003e flow\n                .WithAuthorizationUrl(new(\"https://fake.idp.com/token\"))\n                .WithScope(\"api:read\", \"The scope used to read data\")))));\n```\n\n### Write AsyncAPI documents\n\n```csharp\nvar writer = serviceProvider.GetRequiredService\u003cIAsyncApiDocumentWriter\u003e();\nusing MemoryStream stream = new();\nawait writer.WriteAsync(document, stream, AsyncApiDocumentFormat.Yaml, cancellationToken);\n```\n\n### Read AsyncAPI documents\n\n```csharp\nvar reader = serviceProvider.GetRequiredService\u003cIAsyncApiDocumentReader\u003e();\nvar asyncApi = await reader.ReadAsync(stream, cancellationToken);\n```\n\n### Generate code-first AsyncAPI documents\n\n#### Using AsyncAPI V2\n\n```csharp\n[AsyncApi(\"Streetlights API\", \"1.0.0\", Description = \"The Smartylighting Streetlights API allows you to remotely manage the city lights.\", LicenseName = \"Apache 2.0\", LicenseUrl = \"https://www.apache.org/licenses/LICENSE-2.0\")]\npublic class StreetLightsService\n    : BackgroundService\n{\n\n  ... //Omitted for brevity\n  \n  [Channel(\"light/measured\"), PublishOperation(OperationId = \"onLightMeasured\", Summary = \"Inform about environmental lighting conditions for a particular streetlight\")]\n  public async Task PublishLightMeasured(LightMeasuredEvent e)\n  {\n        ...\n  }\n  \n  [Channel(\"light/measured\"), SubscribeOperation(OperationId = \"lightMeasuredEvent\", Summary = \"Inform about environmental lighting conditions for a particular streetlight\")]\n  protected async Task OnLightMeasured(LightMeasuredEvent e)\n  {\n        ...\n  }\n  \n  ...\n\n}\n```\n\nNote the usage of the following attributes:\n\n- `AsyncApiV2`: Marks a class for code-first `AsyncAPI` document generation. Used to provide information about the API (licensing, contact, ...)\n- `ChannelV2`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to.\n- `OperationV2`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation.\n\n#### Using AsyncAPI V3\n\n```csharp\n[AsyncApi(\"Streetlights API\", \"1.0.0\", Description = \"The **Smartylighting Streetlights API** allows you to remotely manage the city lights.\", LicenseName = \"Apache 2.0\", LicenseUrl = \"https://www.apache.org/licenses/LICENSE-2.0\")]\n[Server(\"http\", \"http://fake-http-server.com\", AsyncApiProtocol.Http, PathName = \"/{environment}\", Description = \"A sample **HTTP** server declared using attributes\", Bindings = \"#/components/serverBindings/http\")]\n[ServerVariable(\"http\", \"environment\", Description = \"The **environment** to use.\", Enum = [\"dev\", \"stg\", \"prod\"])]\n[HttpServerBinding(\"http\")]\n[Channel(\"lightingMeasuredMQTT\", Address = \"streets.{streetName}\", Description = \"This channel is used to exchange messages about lightning measurements.\", Servers = [\"#/servers/mosquitto\"], Bindings = \"#/components/channelBindings/mqtt\")]\n[MqttChannelBinding(\"mqtt\")]\n[ChannelParameter(\"lightingMeasured\", \"streetName\", Description = \"The name of the **street** the lights to get measurements for are located in\")]\npublic class StreetLightsService\n    : BackgroundService\n{\n\n    [Operation(\"sendLightMeasurement\", V3OperationAction.Send, \"#/channels/lightingMeasuredMQTT\", Description = \"Notifies remote **consumers** about environmental lighting conditions for a particular **streetlight**.\"), Neuroglia.AsyncApi.v3.Tag(Reference = \"#/components/tags/measurement\")]\n    public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken cancellationToken = default)\n    {\n        ...\n    }\n\n    [Operation(\"receiveLightMeasurement\", V3OperationAction.Receive, \"#/channels/lightingMeasuredMQTT\"), Neuroglia.AsyncApi.v3.Tag(Reference = \"#/components/tags/measurement\")]\n    protected Task OnLightMeasured(LightMeasuredEvent e)\n    {\n        ...\n    }\n\n}\n```\n\n#### Generate documents explicitly\n\n```csharp\nvar generator = serviceProvider.GetRequiredService\u003cIAsyncApiDocumentGenerator\u003e();\nvar options = new AsyncApiDocumentGenerationOptions()\n{\n    DefaultV2Configuration = builder =\u003e\n    {\n        //Setup V2 documents, by configuring servers, for example\n    };\n    DefaultV3Configuration = builder =\u003e\n    {\n        //Setup V3 documents, by configuring servers, for example\n    }\n};\nIEnumerable\u003cAsyncApiDocument\u003e documents = generator.GenerateAsync(typeof(StreetLightsService), options);\n```\n\n#### Generate documents implicitly\n\n```csharp\nservices.AddAsyncApiGeneration(builder =\u003e \n    builder\n        .WithMarkupType\u003cStreetLightsService\u003e()\n        .UseDefaultV2Configuration(asyncApi =\u003e\n        {\n            //Setup V2 documents, by configuring servers, for example\n        })\n        .UseDefaultV3Configuration(asyncApi =\u003e\n        {\n            //Setup V3 documents, by configuring servers, for example\n        }));\n```\n\n### Use the AsyncAPI UI\n\n#### 1. Configure services\n\n```csharp\n...\nbuilder.Services.AddAsyncApiUI();\n...\n```\n\n#### 2. Map documents\n\n```csharp\n...\nvar app = builder.Build();\napp.UseStaticFiles();\napp.UseRouting();\napp.UseAuthorization();\napp.MapAsyncApiDocuments();\napp.MapRazorPages();\n...\n```\n\n**Note**: Since Razor Pages are used to render the UI, make sure to configure its services and map the pages:\n\n```csharp\n...\nbuilder.Services.AddRazorPages();\n...\nvar app = builder.Build();\n...\napp.MapRazorPages();\n...\n```\n\nYou will also need to register an `IJsonSchemaResolver` and an `HttpClient`:\n```csharp\nservices.AddSingleton\u003cIJsonSchemaResolver, JsonSchemaResolver\u003e();\nservices.AddHttpClient();\n```\n*For reference, please refer to the [sample](#streetlights-api---server).*\n\n#### 3. Enjoy!\n\nLaunch your application, then navigate to `/asyncapi`. You should see something like this:\n\n![AsyncAPI UI - Screenshot](/assets/img/ui.png)\n\n### Interact with AsyncAPI applications\n\n#### Supported bindings\n\n- ✅ AMQP\n- ✅ AMQP1\n- ❌ AnypointMQ\n- ❌ GooglePubSub\n- ✅ HTTP/HTTPS\n- ❌ IBMMQ\n- ❌ JMS\n- ✅ Kafka\n- ❌ Mercure\n- ✅ MQTT\n- ✅ MQTT5\n- ✅ NATS\n- ✅ Pulsar\n- ✅ Redis\n- ❌ SNS\n- ✅ Solace\n- ❌ SQS\n- ✅ Stomp\n- ✅ WS/WSS\n\n⚠️ **Warning:** Security requirements have not yet been implemented.\n\n*We welcome community contributions to help implement and improve additional binding handlers!*\n\n#### Configuring an AsyncAPI Client:\n\nConfigure an AsyncAPI client with all binding handlers:\n\n```csharp\nservices.AddAsyncApiClient(options =\u003e options.AddAllBindingHandlers());\n```\n\nConfigure an AsyncAPI client using specific binding handlers:\n\n```csharp\nservices.AddAsyncApiClient(options =\u003e \n{\n  options.AddHttpBindingHandler();\n  options.AddWebSocketBindingHandler();\n});\n```\n\nThese configurations ensure that your application is set up to handle various communication protocols as defined in your AsyncAPI document.\n\n#### Creating an AsyncAPI Client:\n\nOnce the services are configured, you can create an AsyncAPI client using the client factory:\n\n```csharp\nvar clientFactory = ServiceProvider.GetRequiredService\u003cIAsyncApiClientFactory\u003e();\nawait using var client = clientFactory.CreateFor(asyncApiDocument);\n```\n\nReplace `asyncApiDocument` with your loaded AsyncAPI document instance.\n\n#### Publishing a message:\n\nTo publish a message using the AsyncAPI client, construct the operation parameters with your payload and headers, then call PublishAsync:\n\n```csharp\nvar parameters = new AsyncApiPublishOperationParameters(\"Greet\")\n{\n  Payload = new \n  { \n    Greeting = \"Hello, World!\" \n  },\n  Headers = new\n  {\n    SomeHeader = \"SomeHeaderValue\"\n  }\n};\nawait using var result = await client.PublishAsync(parameters);\n```\n\nThis example publishes a message to the operation named \"Greet\" with a payload and headers. Adjust the operation name, payload, and headers as needed for your application.\n\n#### Subscribing to messages:\n\nTo subscribe and react to messages from an AsyncAPI operation:\n\n```csharp\nawait using var result = await client.SubscribeAsync(new AsyncApiSubscribeOperationParameters(\"Greet\"));\nresult.Messages?.Subscribe(message =\u003e \n{\n    Console.WriteLine(message.Payload?.Greeting);\n});\n```\n\nThis code subscribes to the \"Greet\" operation and prints the \"Greeting\" property of each received message's payload. Modify the operation name and message handling logic based on your specific use case.\n\n## Samples\n\n### [Streetlights API - Server](https://github.com/neuroglia-io/AsyncApi/tree/main/samples/StreetLightsApi/Server)\n\nA simple `ASP.NET 9.0` REST API using a MQTT-powered message bus to send and receive information about environmental lighting conditions for a particular streetlight.\n\nClone the project in your favorite IDE, launch the app, and navigate to `https://localhost:44326/asyncapi/StreetLightsApi/1.0.0`. You should see something like the following:\n\n```yaml\nasyncapi: 2.6.0\ninfo:\n  title: Streetlights API\n  version: 1.0.0\n  description: The Smartylighting Streetlights API allows you to remotely manage the city lights.\n  contact: {}\n  license:\n    name: Apache 2.0\n    url: https://www.apache.org/licenses/LICENSE-2.0\nservers:\n  mosquitto:\n    url: mqtt://test.mosquitto.org/\n    protocol: mqtt\nchannels:\n  light/measured:\n    subscribe:\n      message:\n        payload:\n          type: object\n          properties:\n            id:\n              type: integer\n            lumens:\n              type: integer\n            sentAt:\n              type: string\n              format: date-time\n          required:\n          - Id\n          - Lumens\n          - SentAt\n        name: LightMeasured\n        title: Light Measured\n      operationId: lightMeasuredEvent\n      summary: Inform about environmental lighting conditions for a particular streetlight\n    publish:\n      message:\n        payload:\n          type: object\n          properties:\n            id:\n              type: integer\n            lumens:\n              type: integer\n            sentAt:\n              type: string\n              format: date-time\n          required:\n          - Id\n          - Lumens\n          - SentAt\n        name: LightMeasured\n        title: Light Measured\n      operationId: onLightMeasured\n      summary: Inform about environmental lighting conditions for a particular streetlight\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fnet-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasyncapi%2Fnet-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fnet-sdk/lists"}