diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..6abd34f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ +**What this PR does**: + + +**Additional information:** + \ No newline at end of file diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e40dee5..baa5f3e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 98cf47a..7f28bef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/Neuroglia.AsyncApi.sln b/Neuroglia.AsyncApi.sln index 6882bd4..9304da1 100644 --- a/Neuroglia.AsyncApi.sln +++ b/Neuroglia.AsyncApi.sln @@ -31,6 +31,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetLightsApi", "samples\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neuroglia.AsyncApi.AspNetCore", "src\Neuroglia.AsyncApi.AspNetCore\Neuroglia.AsyncApi.AspNetCore.csproj", "{9FF8A714-BFBF-4A09-87E4-57CEF088BFA7}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{4A936028-09D1-4ACD-8383-5B496DAB2E16}" + ProjectSection(SolutionItems) = preProject + .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{1FB272DF-4FE6-4417-B927-98DD5A821EC0}" + ProjectSection(SolutionItems) = preProject + .github\ISSUE_TEMPLATE\bug.yml = .github\ISSUE_TEMPLATE\bug.yml + .github\ISSUE_TEMPLATE\config.yml = .github\ISSUE_TEMPLATE\config.yml + .github\ISSUE_TEMPLATE\feature.yml = .github\ISSUE_TEMPLATE\feature.yml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{90558701-3CBE-40D6-8E4D-A6A059C51213}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +115,7 @@ Global {A139028A-50B1-4D62-B9A9-2D0CD438E2B0} = {4B933DF9-CD24-44B1-AF64-0D5E75B9AB45} {3A707FE1-4AA3-4232-9E7D-88376580EAD5} = {D5DC0A71-F39C-4AA1-A284-66E622868D47} {9FF8A714-BFBF-4A09-87E4-57CEF088BFA7} = {4B933DF9-CD24-44B1-AF64-0D5E75B9AB45} + {1FB272DF-4FE6-4417-B927-98DD5A821EC0} = {4A936028-09D1-4ACD-8383-5B496DAB2E16} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC433DEB-01E5-4328-B0BB-6FFFE8C7363F} diff --git a/README.md b/README.md index 0430f94..055c877 100644 --- a/README.md +++ b/README.md @@ -3,46 +3,49 @@ ## Contents - [Neuroglia AsyncAPI](#neuroglia-asyncapi) - - [Contents](#contents) - - [Summary](#summary) - - [Status](#status) - - [Installation](#installation) - - [Core library](#core-library) - - [Fluent validation library](#fluent-validation-library) - - [Fluent builders library](#fluent-builders-library) - - [Input/Output library](#inputoutput-library) - - [Code-first generation library](#code-first-generation-library) - - [Dependency inject extensions library](#dependency-inject-extensions-library) - - [Cloud event extensions library](#cloud-event-extensions-library) - - [AsyncAPI document serving library](#asyncapi-document-serving-library) - - [AsyncAPI UI](#asyncapi-ui) - - [Usage](#usage) + + [Contents](#contents) + + [Summary](#summary) + + [Status](#status) + + [Installation](#installation) + - [Core library](#core-library) + - [Fluent validation library](#fluent-validation-library) + - [Fluent builders library](#fluent-builders-library) + - [Input/Output library](#inputoutput-library) + - [Code-first generation library](#code-first-generation-library) + - [Dependency inject extensions library](#dependency-inject-extensions-library) + - [Cloud event extensions library](#cloud-event-extensions-library) + - [AsyncAPI document serving library](#asyncapi-document-serving-library) + - [AsyncAPI UI](#asyncapi-ui) + + [Usage](#usage) - [Building an AsyncAPI Document](#building-an-asyncapi-document) + + [AsyncAPI v2](#asyncapi-v2) + + [AsyncAPI v3](#asyncapi-v3) - [Writing an AsyncAPI Document](#writing-an-asyncapi-document) - [Reading an AsyncAPI document](#reading-an-asyncapi-document) - [Generating code-first AsyncAPI documents](#generating-code-first-asyncapi-documents) - - [1. Mark your services with adequate attributes](#1-mark-your-services-with-adequate-attributes) - - [2.1. Generating documents manually](#21-generating-documents-manually) - - [2.2. Generating documents automatically and serve them using ASP](#22-generating-documents-automatically-and-serve-them-using-asp) + + [AsyncAPI v2](#asyncapi-v2-1) + + [AsyncAPI v3](#asyncapi-v3-1) + - [Generating documents manually](#21-generating-documents-manually) + - [Generating documents automatically and serve them using ASP](#22-generating-documents-automatically-and-serve-them-using-asp) - [Using the AsyncAPI UI](#using-the-asyncapi-ui) - - [Samples](#samples) + + [Samples](#samples) - [Streetlights API - Server](#streetlights-api---server) ## Summary -A .NET used to visualize and interact with [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v2.6.0) documents. The UI is built using Razor Pages and Boostrap +A .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 ## Status -`Microsoft.NET.Sdk.Web` + | Name | Description | Latest Release | Spec version | -| :---: | :---: | :---: | :---: | -| [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 | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.Generation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Generation) | Contains extensions and services for code-first generation of `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.CloudEvents](https://www.nuget.org/packages/Neuroglia.AsyncApi.CloudEvents) | Contains fluent extensions to build Cloud Event messages | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.ServiceDependencyExtensions](https://www.nuget.org/packages/Neuroglia.AsyncApi.ServiceDependencyExtensions) | Contains extensions to configure and register `AsyncAPI` services using dependency injection | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.AspNetCore](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore) | Contains an `ASP.NET` middleware used to serve `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.AspNetCore.UI](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore.UI) | Contains the Razor Pages based UI for exploring `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | +|:------|:------------|:--------------:|:------------:| +| [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.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.Generation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Generation) | Contains extensions and services for code-first generation of `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.CloudEvents](https://www.nuget.org/packages/Neuroglia.AsyncApi.CloudEvents) | Contains fluent extensions to build Cloud Event messages | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.ServiceDependencyExtensions](https://www.nuget.org/packages/Neuroglia.AsyncApi.ServiceDependencyExtensions) | Contains extensions to configure and register `AsyncAPI` services using dependency injection | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.AspNetCore](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore) | Contains an `ASP.NET` middleware used to serve `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [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.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | ## Installation @@ -95,7 +98,9 @@ dotnet add package Neuroglia.AsyncApi.AspNetCore.UI ## Usage -### Building an AsyncAPI Document +### Building an AsyncAPI document + +#### AsyncAPI v2 ```csharp var services = new ServiceCollection(); @@ -152,7 +157,13 @@ var document = builder .Build(); ``` -### Writing an AsyncAPI Document +#### AsyncAPI V3 + +```csharp + +``` + +### Writing an AsyncAPI document ```csharp var writer = serviceProvider.GetRequiredService(); @@ -169,17 +180,17 @@ var asyncApi = await reader.ReadAsync(stream, cancellationToken); ### Generating code-first AsyncAPI documents -#### 1. Mark your services with adequate attributes +#### AsyncAPI V2 ```csharp -[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")] +[AsyncApiV2("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")] public class StreetLightsService : BackgroundService { ... //Omitted for brevity - [Channel("light/measured"), PublishOperation(OperationId = "onLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), PublishOperation(OperationId = "onLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] public async Task PublishLightMeasured(LightMeasuredEvent e) { MqttApplicationMessage message = new() @@ -191,7 +202,7 @@ public class StreetLightsService await this.MqttClient.PublishAsync(message); } - [Channel("light/measured"), SubscribeOperation(OperationId = "lightMeasuredEvent", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), SubscribeOperation(OperationId = "lightMeasuredEvent", Summary = "Inform about environmental lighting conditions for a particular streetlight")] protected async Task OnLightMeasured(LightMeasuredEvent e) { this.Logger.LogInformation($"Event received:{Environment.NewLine}{await this.Serializer.SerializeAsync(e)}"); @@ -204,9 +215,15 @@ public class StreetLightsService Note the usage of the following attributes: -- `AsyncApi`: Marks a class for code-first `AsyncAPI` document generation. Used to provide information about the API (licensing, contact, ...) -- `Channel`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to. -- `Operation`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation. +- `AsyncApiV2`: Marks a class for code-first `AsyncAPI` document generation. Used to provide information about the API (licensing, contact, ...) +- `ChannelV2`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to. +- `OperationV2`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation. + +#### AsyncAPI V3 + +```csharp + +``` #### 2.1. Generating documents manually @@ -214,9 +231,13 @@ Note the usage of the following attributes: var generator = serviceProvider.GetRequiredService(); var options = new AsyncApiDocumentGenerationOptions() { - DefaultConfiguration = builder => + DefaultV2Configuration = builder => + { + //Setup V2 documents, by configuring servers, for example + }; + DefaultV3Configuration = builder => { - //Setup the document by configuring servers, for example + //Setup V3 documents, by configuring servers, for example } }; IEnumerable documents = generator.GenerateAsync(typeof(StreetLightsService), options); @@ -239,9 +260,10 @@ public class Startup //Registers and configures the AsyncAPI code-first generation services.AddAsyncApiGeneration(builder => builder.WithMarkupType() - .UseDefaultConfiguration(asyncApi => + .UseDefaultV2Configuration(asyncApi => { - asyncApi.UseServer("mosquitto", server => server + asyncApi + .UseServer("mosquitto", server => server .WithUrl(new Uri("mqtt://test.mosquitto.org")) .WithProtocol(AsyncApiProtocols.Mqtt)); })); @@ -284,12 +306,12 @@ Launch your ASP project, then navigate to `http://localhost:44236/asyncapi`. You ### [Streetlights API - Server](https://github.com/neuroglia-io/AsyncApi/tree/main/samples/StreetLightsApi/Server) -A simple `ASP.NET 5.0` REST API using a MQTT-powered message bus to send and receive information about environmental lighting conditions for a particular streetlight. +A 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. Clone 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: ```yaml -asyncapi: 2.1.0 +asyncapi: 2.6.0 info: title: Streetlights API version: 1.0.0 diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs similarity index 57% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs rename to samples/StreetLightsApi/Messages/AddStreetLightRequest.cs index 3cb0b8b..0b0e196 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs +++ b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs @@ -11,23 +11,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace StreetLightsApi.Messages; /// -/// Holds the data used to render an view +/// Represents a request to add a new street light /// -public record AsyncApiDocumentViewModel +public class AddStreetLightRequest { /// - /// Initializes a new + /// Gets/sets the id of the street to add a new light to /// - /// The to render the view for - public AsyncApiDocumentViewModel(AsyncApiDocument document) => this.Document = document; + public required string StreetId { get; init; } /// - /// Gets the to render the view for + /// Gets/sets the latitude of the light to add /// - public AsyncApiDocument Document { get; } + public required decimal Latitude { get; init; } -} \ No newline at end of file + /// + /// Gets/sets the longitude of the light to add + /// + public required decimal Longitude { get; init; } + +} diff --git a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs index f787e55..1e0dc2e 100644 --- a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs +++ b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs @@ -11,8 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema.Generation; -using Neuroglia.AsyncApi; +using Neuroglia.AsyncApi.v2; namespace StreetLightsApi.Server.Messages; @@ -36,8 +35,6 @@ public class LightMeasuredEvent [Description("The event's metadata")] public IDictionary? Metadata { get; set; } - public List Todos { get; set; } + public List Todo { get; set; } = []; } - -public record Todo(string Name); diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs b/samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs similarity index 69% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs rename to samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs index 6296ac7..ed0ea1d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs +++ b/samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs @@ -11,15 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace StreetLightsApi.Messages; /// -/// Represents the object used to configure a SNS message binding +/// Represents the response to a measure street light luminosity request /// -[DataContract] -public record SnsMessageBindingDefinition - : SnsBindingDefinition, IMessageBindingDefinition +public class MeasureStreetLightLuminosityReply { + /// + /// Gets/sets the street light's lumens + /// + public required long Lumens { get; init; } } \ No newline at end of file diff --git a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs index 0bdcfbe..0e01baf 100644 --- a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs +++ b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs @@ -11,22 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi; -using System.ComponentModel; +using Neuroglia.AsyncApi.v2; -namespace StreetLightsApi.Server.Messages -{ - [Tag("movement", "A tag for movement-related messages"), Tag("sensor", "A tag for sensor-related messages")] - [Message(Name = "MovementDetected")] - public class MovementDetectedEvent - { +namespace StreetLightsApi.Server.Messages; - [Description("The id of the sensor that has detected movement")] - public int SensorId { get; set; } +[Tag("movement", "A tag for movement-related messages"), Tag("sensor", "A tag for sensor-related messages")] +[Message(Name = "MovementDetected")] +public class MovementDetectedEvent +{ - [Description("The date and time at which the event has been created")] - public DateTime SentAt { get; set; } + [Description("The id of the sensor that has detected movement")] + public int SensorId { get; set; } - } + [Description("The date and time at which the event has been created")] + public DateTime SentAt { get; set; } } diff --git a/samples/StreetLightsApi/Messages/TodoItem.cs b/samples/StreetLightsApi/Messages/TodoItem.cs new file mode 100644 index 0000000..fe442da --- /dev/null +++ b/samples/StreetLightsApi/Messages/TodoItem.cs @@ -0,0 +1,34 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace StreetLightsApi.Server.Messages; + +/// +/// Represents a task to do +/// +/// The name of the task to do +public record TodoItem(string Name); + +/// +/// Represents the common headers of messages exchanged by the StreetLights API +/// +public record CommonHeaders +{ + + /// + /// Gets/sets the value of the header that the application's ETag + /// + [Json.Schema.Generation.Required, Json.Schema.Generation.MinLength(1)] + public required string ETag { get; init; } + +} \ No newline at end of file diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 22717c1..1e8c909 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -11,14 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Neuroglia.AsyncApi; -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.Data.Schemas.Json; -using StreetLightsApi.Server.Services; -using System.Net.Mime; +using Json.Schema.Generation; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using StreetLightsApi.Messages; var builder = WebApplication.CreateBuilder(args); @@ -41,7 +36,7 @@ builder.Services.AddAsyncApiUI(); builder.Services.AddAsyncApiGeneration(builder => builder.WithMarkupType() - .UseDefaultConfiguration(asyncApi => + .UseDefaultV2DocumentConfiguration(asyncApi => { asyncApi .WithTermsOfService(new Uri("https://www.websitepolicies.com/blog/sample-terms-service-template")) @@ -54,8 +49,136 @@ ClientId = "StreetLightsAPI:1.0.0", CleanSession = true })); + }) + .UseDefaultV3DocumentConfiguration(asyncApi => + { + asyncApi + .WithTermsOfService(new Uri("https://www.websitepolicies.com/blog/sample-terms-service-template")) + .WithExternalDocumentation(doc => doc + .WithDescription("The exhaustive documentation of the described **API**, its purpose, usage scenarios, and detailed specifications. This documentation includes all relevant architectural diagrams, authentication flows, and code samples, offering a comprehensive reference for developers and integrators.") + .WithUrl(new("https://fakeurl.com"))) + .WithTag(tag => tag + .Use("#/components/tags/kubernetes")) + .WithTag(tag => tag + .WithName("showcase") + .WithDescription("The present document is used to showcase features of the `Neuroglia.AsyncAPI` document generation.")) + .WithServer("mosquitto", server => server + .WithHost("mqtt://test.mosquitto.org") + .WithPathName("/{environment}") + .WithProtocol(AsyncApiProtocol.Mqtt) + .WithDescription("The **Mosquitto test MQTT server**. Use the `env` variable to point to either `production` or `staging`.") + .WithVariable("environment", variable => variable + .WithDescription("Environment to connect to.") + .WithEnumValues("production", "staging")) + .WithBinding(new MqttServerBindingDefinition() + { + ClientId = "StreetLightsAPI:1.0.0", + CleanSession = true + })) + .WithSchemaComponent("addStreetLightRequest", schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithServerComponent("http", server => server + .WithHost("https://test.com") + .WithPathName("/{environment}") + .WithProtocol(AsyncApiProtocol.Http) + .WithDescription("The **HTTP test server**. Use the `env` variable to point to either `production` or `staging`.") + .WithVariable("environment", variable => variable + .WithDescription("Environment to connect to.") + .WithEnumValues("production", "staging")) + .WithBindings(bindings => bindings + .Use("#/components/serverBindings/http"))) + .WithChannelComponent("lightingMeasuredHTTP", channel => channel + .WithDescription("This channel is used to exchange messages about lightning measurements.") + .WithServer("#/components/servers/http") + .WithBindings(bindings => bindings + .Use("#/components/channelBindings/http"))) + .WithOperationComponent("addStreetLight", operation => operation + .WithAction(Neuroglia.AsyncApi.v3.V3OperationAction.Receive) + .WithChannel("#/components/channels/lightingMeasuredHTTP") + .WithDescription("Adds a new **streetlight** to the API.") + .WithTrait(trait => trait + .Use("#/components/operationTraits/commonBindings")) + .WithMessage("#/components/messages/addStreetLightRequest") + .WithBindings(bindings => bindings + .Use("#/components/operationBindings/http"))) + .WithMessageComponent("addStreetLightRequest", message => message + .WithPayloadSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithTrait(trait => trait + .Use("#/components/messageTraits/commonHeaders")) + .WithBindings(bindings => bindings + .Use("#/components/messageBindings/http"))) + .WithMessageComponent("measureStreetLightLuminosityReply", message => message + .WithPayloadSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithBindings(bindings => bindings + .Use("#/components/messageBindings/http"))) + .WithSecuritySchemeComponent("oauth2", security => security + .WithType(SecuritySchemeType.OAuth2) + .WithDescription("The security scheme used to authenticate using **OAUTH2**.") + .WithScope("api") + .WithAuthorizationScheme("Bearer") + .WithOAuthFlows(flows => flows + .WithImplicitFlow(flow => flow + .WithTokenUrl(new Uri("https://fake.com/auth/streetlights/token"))))) + .WithServerVariableComponent("environment", variable => variable + .WithDescription("The variable used to define the **hosting environment**.") + .WithDefaultValue("dev") + .WithEnumValues("dev", "staging", "production") + .WithExample("dev") + .WithExample("staging") + .WithExample("production")) + .WithParameterComponent("environment", parameter => parameter + .WithDescription("The variable used to define the **hosting environment**.") + .WithDefaultValue("dev") + .WithEnumValues("dev", "staging", "production") + .WithExample("dev") + .WithExample("staging") + .WithExample("production")) + .WithCorrelationIdComponent("streetId", correlationId => correlationId + .WithDescription("The parameter used to correlate the **street** a **light** is located in.") + .WithLocation("$message.header#/MQMD/CorrelId")) + .WithReplyComponent("measureStreetLightLuminosityReply", reply => reply + .WithChannel("#/components/channels/lightingMeasuredHTTP") + .WithAddress(address => address.Use("#/components/replyAddresses/measureStreetLightLuminosityReplyAddress")) + .WithMessage("#/components/messages/measureStreetLightLuminosityReply")) + .WithReplyAddressComponent("measureStreetLightLuminosityReplyAddress", address => address + .WithDescription("Represents the **address** to reply to after a **measureStreetLightLuminosityRequest**.") + .WithLocation("$message.header#/replyTo")) + .WithExternalDocumentationComponent("kubernetesTag", doc => doc + .WithDescription("The **external documentation** used to document the `kubernetes` **tag**.") + .WithUrl(new("https://fake.com/tags/kubernetes"))) + .WithTagComponent("kubernetes", tag => tag + .WithName("kubernetes") + .WithDescription("The **tag** used to mark a **server** deployed in `Kubernetes`.") + .WithExternalDocumentation(doc => doc.Use("#/components/externalDocs/kubernetesTag"))) + .WithServerBindingsComponent("http", bindings => bindings + .WithBinding(new HttpServerBindingDefinition())) + .WithChannelBindingsComponent("http", bindings => bindings + .WithBinding(new HttpChannelBindingDefinition())) + .WithOperationBindingsComponent("http", bindings => bindings + .WithBinding(new HttpOperationBindingDefinition() + { + Method = Neuroglia.AsyncApi.Bindings.Http.HttpMethod.POST, + Type = HttpBindingOperationType.Request + })) + .WithMessageBindingsComponent("http", bindings => bindings + .WithBinding(new HttpMessageBindingDefinition())) + .WithOperationTraitComponent("commonBindings", trait => trait + .WithDescription("The **operation trait** used to define the bindings common to all operations defined by the application.") + .WithBinding(new HttpOperationBindingDefinition())) + .WithMessageTraitComponent("commonHeaders", trait => trait + .WithName("Common Headers") + .WithDescription("The **message trait** used to define the common headers used by all the messages exchanged by the application.") + .WithHeadersSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default)))); })); builder.Services.AddAsyncApiDocument(document => document + .UsingAsyncApiV2() .WithTitle("Cloud Event API") .WithVersion("1.0.0") .WithServer("StreetLightsApi", server => server @@ -69,7 +192,7 @@ .WithSubscribeOperation(operation => operation .WithOperationId("ObserveCloudEvents") .WithDescription("Observes cloud events published by the StreetLightsApi") - .WithBinding(new HttpOperationBindingDefinition() { Method = Neuroglia.AsyncApi.v2.Bindings.Http.HttpMethod.POST, Type = HttpBindingOperationType.Response }) + .WithBinding(new HttpOperationBindingDefinition() { Method = Neuroglia.AsyncApi.Bindings.Http.HttpMethod.POST, Type = HttpBindingOperationType.Response }) .WithMessages ( message => message diff --git a/samples/StreetLightsApi/Properties/launchSettings.json b/samples/StreetLightsApi/Properties/launchSettings.json index 76865e1..bc0a0f6 100644 --- a/samples/StreetLightsApi/Properties/launchSettings.json +++ b/samples/StreetLightsApi/Properties/launchSettings.json @@ -14,6 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "applicationUrl": "http://localhost:5055", + "launchUrl": "asyncapi", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/samples/StreetLightsApi/Services/MovementSensorService.cs b/samples/StreetLightsApi/Services/MovementSensorService.cs index 13f488f..77f3504 100644 --- a/samples/StreetLightsApi/Services/MovementSensorService.cs +++ b/samples/StreetLightsApi/Services/MovementSensorService.cs @@ -11,19 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using StreetLightsApi.Server.Messages; -using System.Text; +using Neuroglia.AsyncApi.v2; namespace StreetLightsApi.Server.Services; -[AsyncApi("Movement Sensor API", "1.0.0", Description = "The Movement Sensor API allows you to get remotely notified about movements captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[Neuroglia.AsyncApi.v2.AsyncApi("Movement Sensor API", "1.0.0", Description = "The Movement Sensor API allows you to get remotely notified about movements captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class MovementSensorService(ILogger logger, IJsonSerializer serializer) - : BackgroundService + : BackgroundService { + protected ILogger Logger { get; } = logger; protected IJsonSerializer Serializer { get; } = serializer; diff --git a/samples/StreetLightsApi/Services/StreetLightsService.cs b/samples/StreetLightsApi/Services/StreetLightsService.cs index 230d4be..b570814 100644 --- a/samples/StreetLightsApi/Services/StreetLightsService.cs +++ b/samples/StreetLightsApi/Services/StreetLightsService.cs @@ -11,25 +11,45 @@ // See the License for the specific language governing permissions and // limitations under the License. -using StreetLightsApi.Server.Messages; -using Neuroglia.Serialization; -using System.Text; -using Neuroglia.AsyncApi; -using MQTTnet; -using MQTTnet.Client; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.v2; +using Neuroglia.AsyncApi.v3; namespace StreetLightsApi.Server.Services; -[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")] +/// +/// Represents the Smartylighting Streetlights API, which allows to remotely manage the city lights +/// +/// The service used to perform logging +/// The service used to serialize/deserialize data to/from JSON +[Neuroglia.AsyncApi.v2.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")] +[Neuroglia.AsyncApi.v3.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")] +[Server("http", "http://fake-http-server.com", AsyncApiProtocol.Http, PathName = "/{environment}", Description = "A sample **HTTP** server declared using attributes", Bindings = "#/components/serverBindings/http")] +[ServerVariable("http", "environment", Description = "The **environment** to use.", Enum = ["dev", "stg", "prod"])] +[HttpServerBinding("http")] +[Neuroglia.AsyncApi.v3.Channel("lightingMeasuredMQTT", Address = "streets.{streetName}", Description = "This channel is used to exchange messages about lightning measurements.", Servers = ["#/servers/mosquitto"], Bindings = "#/components/channelBindings/mqtt")] +[MqttChannelBinding("mqtt")] +[ChannelParameter("lightingMeasured", "streetName", Description = "The name of the **street** the lights to get measurements for are located in")] public class StreetLightsService(ILogger logger, IJsonSerializer serializer) : BackgroundService { + + /// + /// Gets the service used to perform logging + /// protected ILogger Logger { get; } = logger; + /// + /// Gets the service used to serialize/deserialize data to/from JSON + /// protected IJsonSerializer Serializer { get; } = serializer; + /// + /// Gets the service used to interact with an MQTT server + /// protected IMqttClient MqttClient { get; private set; } = null!; + /// protected override async Task ExecuteAsync(CancellationToken stoppingToken) { this.MqttClient = new MqttFactory().CreateMqttClient(); @@ -46,8 +66,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.PublishLightMeasured(new() { Id = Guid.NewGuid(), Lumens = 5, SentAt = DateTime.UtcNow }, stoppingToken).ConfigureAwait(false); } - [Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")] - [Channel("light/measured"), PublishOperation(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight")] + /// + /// Publishes the specified + /// + /// The to publish + /// A + /// A new awaitable + [Neuroglia.AsyncApi.v2.Channel("light/measured"), PublishOperation(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight."), Neuroglia.AsyncApi.v2.Tag("light", "A tag for light-related operations"), Neuroglia.AsyncApi.v2.Tag("measurement", "A tag for measurement-related operations")] + [Neuroglia.AsyncApi.v3.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")] public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken cancellationToken = default) { var message = new MqttApplicationMessage() @@ -59,8 +85,13 @@ public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken c await this.MqttClient.PublishAsync(message, cancellationToken); } - [Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")] - [Channel("light/measured"), SubscribeOperation(OperationId = "OnLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + /// + /// Handles the specified + /// + /// The to handle + /// A new awaitable + [Neuroglia.AsyncApi.v2.Channel("light/measured"), SubscribeOperation(OperationId = "OnLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight"), Neuroglia.AsyncApi.v2.Tag("light", "A tag for light-related operations"), Neuroglia.AsyncApi.v2.Tag("measurement", "A tag for measurement-related operations")] + [Neuroglia.AsyncApi.v3.Operation("receiveLightMeasurement", V3OperationAction.Receive, "#/channels/lightingMeasuredMQTT"), Neuroglia.AsyncApi.v3.Tag(Reference = "#/components/tags/measurement")] protected Task OnLightMeasured(LightMeasuredEvent e) { this.Logger.LogInformation("Event received:\r\n{json}", this.Serializer.SerializeToText(e)); diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs index cd30c59..a75c975 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs @@ -11,17 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using System.ComponentModel.DataAnnotations; -using System.Text; +using Neuroglia.AsyncApi.v2; namespace StreetLightsApi.Server.Services; - -[AsyncApi("Temperature Sensor API", "1.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[Neuroglia.AsyncApi.v2.AsyncApi("Temperature Sensor API", "1.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class TemperatureSensorServiceV1(ILogger logger, IJsonSerializer serializer) : BackgroundService { @@ -47,7 +41,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnTemperatureChanged", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("temperature", "A tag for temeprature-related operations"), Tag("sensor", "A tag for sensor-related operations")] + [Tag("temperature", "A tag for temperature-related operations"), Tag("sensor", "A tag for sensor-related operations")] [Channel("temperature/changed"), SubscribeOperation(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] protected Task OnTemperatureChanged([Range(-100, 100)]decimal degrees) { diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs index ab44ed6..f614956 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs @@ -11,16 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using System.ComponentModel.DataAnnotations; -using System.Text; +using Neuroglia.AsyncApi.v2; namespace StreetLightsApi.Server.Services; -[AsyncApi("Temperature Sensor API", "2.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[Neuroglia.AsyncApi.v2.AsyncApi("Temperature Sensor API", "2.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class TemperatureSensorServiceV2(ILogger logger, IJsonSerializer serializer) : BackgroundService { @@ -46,7 +41,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnTemperatureChanged", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("temperature", "A tag for temeprature-related operations"), Tag("sensor", "A tag for sensor-related operations")] + [Tag("temperature", "A tag for temperature-related operations"), Tag("sensor", "A tag for sensor-related operations")] [Channel("temperature/changed"), SubscribeOperation(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] protected async Task OnTemperatureChanged([Range(-100,100)]decimal degrees, DateTime timestamp) { diff --git a/samples/StreetLightsApi/StreetLightType.cs b/samples/StreetLightsApi/StreetLightType.cs index a43d3d4..bd62585 100644 --- a/samples/StreetLightsApi/StreetLightType.cs +++ b/samples/StreetLightsApi/StreetLightType.cs @@ -13,8 +13,17 @@ namespace StreetLightsApi; +/// +/// Enumerates all types of street lights +/// public enum StreetLightType { + /// + /// Indicates an LED light + /// LED, + /// + /// Indicates an HPS light + /// HPS } diff --git a/samples/StreetLightsApi/StreetLightsApi.csproj b/samples/StreetLightsApi/StreetLightsApi.csproj index 8378108..3f13ae3 100644 --- a/samples/StreetLightsApi/StreetLightsApi.csproj +++ b/samples/StreetLightsApi/StreetLightsApi.csproj @@ -1,9 +1,11 @@ - + - net8.0 + net9.0 enable enable + false + True diff --git a/samples/StreetLightsApi/Usings.cs b/samples/StreetLightsApi/Usings.cs new file mode 100644 index 0000000..925dadd --- /dev/null +++ b/samples/StreetLightsApi/Usings.cs @@ -0,0 +1,26 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +global using Json.Schema; +global using MQTTnet; +global using MQTTnet.Client; +global using Neuroglia.AsyncApi; +global using Neuroglia.AsyncApi.Bindings.Http; +global using Neuroglia.Data.Schemas.Json; +global using Neuroglia.Serialization; +global using StreetLightsApi.Server.Messages; +global using StreetLightsApi.Server.Services; +global using System.ComponentModel; +global using System.ComponentModel.DataAnnotations; +global using System.Net.Mime; +global using System.Text; diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs new file mode 100644 index 0000000..f718411 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs @@ -0,0 +1,38 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Text.RegularExpressions; + +namespace Neuroglia.AsyncApi; + +/// +/// Defines extensions for strings +/// +public static class StringExtensions +{ + + /// + /// Wraps placeholders with code tags + /// + /// The input string + /// The resulting string + public static string WrapPlaceholdersWithCodeTags(this string input) + { + if (string.IsNullOrEmpty(input)) return input; + var pattern = @"\{[^}]+\}"; + var replacement = "$&"; + var result = Regex.Replace(input, pattern, replacement); + return result; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs new file mode 100644 index 0000000..8fcc555 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs @@ -0,0 +1,33 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + +/// +/// Holds the data used to render an view +/// +public record V2AsyncApiDocumentViewModel +{ + + /// + /// Initializes a new + /// + /// The to render the view for + public V2AsyncApiDocumentViewModel(V2AsyncApiDocument document) => Document = document; + + /// + /// Gets the to render the view for + /// + public V2AsyncApiDocument Document { get; } + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs similarity index 75% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs index adba399..dd26be1 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs @@ -11,19 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render an view /// -public record BindingDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2BindingDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public BindingDefinitionViewModel(AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { this.Binding = binding; this.ParentRef = parentRef; } + public V2BindingDefinitionViewModel(V2AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { Binding = binding; ParentRef = parentRef; } /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs similarity index 61% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs index f6a1f41..59f17b7 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs @@ -11,21 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render an view +/// Holds the data used to render an view /// -public record ChannelDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2ChannelDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public ChannelDefinitionViewModel(AsyncApiDocument document, ChannelDefinition channel) : base(document) => this.Channel = channel; - + public V2ChannelDefinitionViewModel(V2AsyncApiDocument document, V2ChannelDefinition channel) : base(document) => Channel = channel; + /// - /// Gets the to render + /// Gets the to render /// - public ChannelDefinition Channel { get; } + public V2ChannelDefinition Channel { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs similarity index 58% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs index efeda28..61b271f 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs @@ -11,22 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render an view +/// Holds the data used to render an view /// -public record CorrelationIdDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2CorrelationIdDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public CorrelationIdDefinitionViewModel(AsyncApiDocument document, CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } + public V2CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, V2CorrelationIdDefinition correlationId) : base(document) { CorrelationId = correlationId; } /// - /// Gets the to render + /// Gets the to render /// - public CorrelationIdDefinition CorrelationId { get; } + public V2CorrelationIdDefinition CorrelationId { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs similarity index 64% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs index 8fef8e9..7ccf595 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs @@ -11,22 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// -public record MessageDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2MessageDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public MessageDefinitionViewModel(AsyncApiDocument document, int index, string operationRef, MessageDefinition definition) + public V2MessageDefinitionViewModel(V2AsyncApiDocument document, int index, string operationRef, V2MessageDefinition definition) : base(document) { - this.Index = index; - this.OperationRef = operationRef; - this.Definition = definition; + Index = index; + OperationRef = operationRef; + Definition = definition; } /// @@ -40,8 +40,8 @@ public MessageDefinitionViewModel(AsyncApiDocument document, int index, string o public string OperationRef { get; } /// - /// Gets the to render + /// Gets the to render /// - public MessageDefinition Definition { get; } + public V2MessageDefinition Definition { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs similarity index 75% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs index b175ae6..814c4bd 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record OAuthFlowDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2OAuthFlowDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public OAuthFlowDefinitionViewModel(AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { this.ParentRef = parentRef; this.FlowType = flowType; this.Flow = flow; } + public V2OAuthFlowDefinitionViewModel(V2AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { ParentRef = parentRef; FlowType = flowType; Flow = flow; } /// /// Gets a reference to the 's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs similarity index 50% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs index da8ed96..8be0b93 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs @@ -11,31 +11,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// -public record OperationDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2OperationDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public OperationDefinitionViewModel(AsyncApiDocument document, string channelKey, OperationType operationType, OperationDefinition operation) : base(document) { this.ChannelKey = channelKey; this.OperationType = operationType; this.Operation = operation; } + public V2OperationDefinitionViewModel(V2AsyncApiDocument document, string channelKey, V2OperationType operationType, V2OperationDefinition operation) : base(document) { ChannelKey = channelKey; OperationType = operationType; Operation = operation; } /// - /// Gets the key of the the to render belongs to + /// Gets the key of the the to render belongs to /// public string ChannelKey { get; } /// - /// Gets the type of the to render + /// Gets the type of the to render /// - public OperationType OperationType { get; } + public V2OperationType OperationType { get; } /// - /// Gets the to render + /// Gets the to render /// - public OperationDefinition Operation { get; } + public V2OperationDefinition Operation { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs similarity index 78% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs index f58fdcd..516c16d 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record SchemaViewModel - : AsyncApiDocumentViewModel +public record V2SchemaViewModel + : V2AsyncApiDocumentViewModel { /// - public SchemaViewModel(AsyncApiDocument document, JsonSchema schema) : base(document) => this.Schema = schema; + public V2SchemaViewModel(V2AsyncApiDocument document, JsonSchema schema) : base(document) => Schema = schema; /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs similarity index 77% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs index 28d8709..6423f48 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a security requirement view /// -public record SecurityRequirementViewModel - : AsyncApiDocumentViewModel +public record V2SecurityRequirementViewModel + : V2AsyncApiDocumentViewModel { /// - public SecurityRequirementViewModel(AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { this.ParentRef = parentRef; this.Key = key; this.Requirement = requirement; } + public V2SecurityRequirementViewModel(V2AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { ParentRef = parentRef; Key = key; Requirement = requirement; } /// /// Gets a reference to the requirement's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs similarity index 59% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs index 475ca44..0b0e41b 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs @@ -11,26 +11,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// -public record SecuritySchemeDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2SecuritySchemeDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public SecuritySchemeDefinitionViewModel(AsyncApiDocument document, string parentRef, SecuritySchemeDefinition scheme) : base(document) { this.ParentRef = parentRef; this.Scheme = scheme; } + public V2SecuritySchemeDefinitionViewModel(V2AsyncApiDocument document, string parentRef, V2SecuritySchemeDefinition scheme) : base(document) { ParentRef = parentRef; Scheme = scheme; } /// - /// Gets a reference to the parent component of the to render + /// Gets a reference to the parent component of the to render /// public string ParentRef { get; } /// - /// Gets the to render + /// Gets the to render /// - public SecuritySchemeDefinition Scheme { get; } + public V2SecuritySchemeDefinition Scheme { get; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs similarity index 59% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs index caa2411..e553db2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs @@ -11,26 +11,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// -public record ServerDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2ServerDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public ServerDefinitionViewModel(AsyncApiDocument document, string key, ServerDefinition server) : base(document) { this.Key = key; this.Server = server; } + public V2ServerDefinitionViewModel(V2AsyncApiDocument document, string key, V2ServerDefinition server) : base(document) { Key = key; Server = server; } /// - /// Gets the key of the to render + /// Gets the key of the to render /// public string Key { get; } /// - /// Gets the to render + /// Gets the to render /// - public ServerDefinition Server { get; } + public V2ServerDefinition Server { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs new file mode 100644 index 0000000..1c9d9a8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs @@ -0,0 +1,24 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The to render the view for +public record V3AsyncApiDocumentViewModel(V3AsyncApiDocument Document) +{ + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs new file mode 100644 index 0000000..fdab2f0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// A reference to the component that defines the to render +/// The name of the to render +/// The to render +public record V3BindingDefinitionCollectionViewModel(V3AsyncApiDocument Document, string ComponentReference, string BindingCollectionName, IBindingDefinitionCollection BindingCollection) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs new file mode 100644 index 0000000..07ae64e --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The to render +/// The component the is defined by +public record V3BindingDefinitionViewModel(V3AsyncApiDocument Document, IBindingDefinition Binding, string ParentRef) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs new file mode 100644 index 0000000..4c48aa5 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The document the to render belongs to +/// The path to the to render +/// The name of the to render +/// The to render +public record V3ChannelDefinitionViewModel(V3AsyncApiDocument Document, string Path, string Name, V3ChannelDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs new file mode 100644 index 0000000..938408f --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; + +/// +/// Holds the data used to render an view +/// +/// The the to render belongs to +public record V3ComponentsViewModel(V3AsyncApiDocument Document) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs new file mode 100644 index 0000000..7e0f9f1 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; + +/// +/// Holds the data used to render an view +/// +/// The the to render belongs to +/// The to render +public record V3CorrelationIdDefinitionViewModel(V3AsyncApiDocument Document, V3CorrelationIdDefinition CorrelationId) + : V3AsyncApiDocumentViewModel(Document) +{ + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs new file mode 100644 index 0000000..cb098de --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ExternalDocumentationDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ExternalDocumentationDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs new file mode 100644 index 0000000..9088291 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs @@ -0,0 +1,30 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data required to render a view +/// +/// The that defines the to render +/// The to render +/// The 's context +/// A reference to the component that defines the +/// An containing examples of the to render +public record V3SchemaViewModel(V3AsyncApiDocument Document, SchemaContext Context, V3SchemaDefinition Definition, string ParentReference, IEnumerable? Examples = null) + : V3AsyncApiDocument(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs new file mode 100644 index 0000000..ce2b51b --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +/// The index of the within its parent , if any +public record V3MessageTraitDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3MessageTraitDefinition Definition, int? Index = null) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs new file mode 100644 index 0000000..28e2158 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// A reference to the to render +/// The type of the to render +/// The to render +public record V3OAuthFlowDefinitionViewModel(V3AsyncApiDocument Document, string Reference, string FlowType, OAuthFlowDefinition Flow) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs new file mode 100644 index 0000000..a109bf0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +/// The index of the within its parent , if any +public record V3OperationTraitDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3OperationTraitDefinition Definition, int? Index = null) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs new file mode 100644 index 0000000..2e78126 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs @@ -0,0 +1,27 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ParameterDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ParameterDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs new file mode 100644 index 0000000..b9be681 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// A reference to the +/// The to render +public record V3ReplyAddressDefinitionViewModel(V3AsyncApiDocument Document, string Reference, V3ReplyAddressDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs new file mode 100644 index 0000000..6e43e14 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The to render +/// A reference to the +public record V3ReplyDefinitionViewModel(V3AsyncApiDocument Document, string Reference, V3ReplyDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs new file mode 100644 index 0000000..5e223a1 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs @@ -0,0 +1,31 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +public record V3JsonSchemaViewModel + : V3AsyncApiDocumentViewModel +{ + + /// + public V3JsonSchemaViewModel(V3AsyncApiDocument document, JsonSchema schema) : base(document) => Schema = schema; + + /// + /// Gets the to render + /// + public JsonSchema Schema { get; } + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs new file mode 100644 index 0000000..f46d707 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs @@ -0,0 +1,27 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// A reference to the to render +/// The name of the to render +/// The to render +public record V3SecuritySchemeDefinitionViewModel(V3AsyncApiDocument Document, string Reference, string Name, V3SecuritySchemeDefinition Scheme) + : V3AsyncApiDocument(Document) +{ + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs new file mode 100644 index 0000000..494b19a --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The path to the to render +/// The The name of the to render +/// The to render +public record V3ServerDefinitionViewModel(V3AsyncApiDocument Document, string Path, string Name, V3ServerDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs new file mode 100644 index 0000000..e2928d3 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ServerVariableDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ServerVariableDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs new file mode 100644 index 0000000..047e0a2 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3TagDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3TagDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj b/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj index 4f5694b..897ef9d 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable Library @@ -12,7 +12,7 @@ https://github.com/neuroglia-io/asyncapi git neuroglia asyncapi async api asp ui - 2.6.6 + 3.0.0 en Apache-2.0 true @@ -35,6 +35,7 @@ + diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml index d916935..3f44c83 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml @@ -3,9 +3,10 @@ @model Neuroglia.AsyncApi.AspNetCore.UI.Pages.AsyncApiDocumentModel @inject Microsoft.Extensions.Options.IOptions ServingOptions @{ - var document = this.Model.Document!; - this.ViewBag.Title = document?.Info.Title; + var document = this.Model.Document; + this.ViewBag.Title = document?.Title; } +
@if (document == null) { @@ -20,176 +21,17 @@ } else { -
-
- @document.Info.Title - @document.Info.Version -
- - -
- -
- @if (document.Info.License != null || document.Info.TermsOfService != null) - { -
- @if (document.Info.License != null && document.Info.License.Url != null) - { - @document.Info.License.Name - } - @if (document.Info.TermsOfService != null) - { - Terms of Service - } -
- } - @if (!string.IsNullOrWhiteSpace(document.Info.Description)) - { -

@document.Info.Description

- } -
-
- -
- @if (document.Servers != null) - { - foreach (var server in document.Servers) - { - - } - } -
-
-
- -
- @foreach (var channel in document.Channels) - { - if (channel.Value.Publish != null) - { - - } - if (channel.Value.Subscribe != null) - { - - } - } -
-
- @if (document.Components != null) + switch (document) { -
- -
- @if (document.Components.Schemas != null) - { -
- -
- @{ - var index = 0; - foreach (var schema in document.Components.Schemas) - { - var reference = $"components_schemas_{index}"; - - index++; - } - } -
-
- } - @if(document.Components.Messages != null) - { -
- -
- @{ - var index = 0; - foreach (var message in document.Components.Messages) - { - var reference = $"components_messages_{index}"; - - index++; - } - } -
-
- } - @if(document.Components.SecuritySchemes != null) - { -
- -
- @{ - var index = 0; - foreach (var scheme in document.Components.SecuritySchemes) - { - var reference = $"components_security_schemes_{index}"; - - index++; - } - } -
-
- } -
-
+ case V2AsyncApiDocument: + + break; + case V3AsyncApiDocument: + + break; + default: +

Unsupported Async API Specification version '@document.AsyncApi'

+ break; } }
diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs index 3fb76e1..2c91026 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs @@ -17,12 +17,9 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages; /// -/// Represents the model of the page used to render an +/// Represents the model of the page used to render an /// -/// -/// Initializes a new -/// -/// The service used to access generated s +/// The service used to access generated s public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) : PageModel { @@ -30,26 +27,27 @@ public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) IAsyncApiDocumentProvider Documents { get; } = documents; /// - /// Gets the requested 's title + /// Gets the requested 's title /// public string? RequestedTitle { get; private set; } /// - /// Gets the requested 's version + /// Gets the requested 's version /// public string? RequestedVersion { get; private set; } /// - /// Gets the current + /// Gets the current /// - public AsyncApiDocument? Document { get; private set; } + public IAsyncApiDocument? Document { get; private set; } /// - /// Renders the with the specified title and version + /// Renders the with the specified title and version /// - /// The title of the to render - /// The version of the to render - public void OnGet(string title, string version) + /// The Async API version in which the to render has been written in + /// The title of the to render + /// The version of the to render + public void OnGet(string specVersion, string title, string version) { this.RequestedTitle = title; this.RequestedVersion = version; @@ -61,15 +59,13 @@ public void OnGet(string title, string version) { if (string.IsNullOrWhiteSpace(version)) this.Document = this.Documents - .Where(d => - d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) - .OrderByDescending(d => d.Info.Version) + .Where(d => d.AsyncApi == specVersion && d.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) + .OrderByDescending(d => d.Version) .FirstOrDefault(); else this.Document = this.Documents - .Where(d => - d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) - .FirstOrDefault(d => d.Info.Version.Equals(version, StringComparison.OrdinalIgnoreCase)); + .Where(d => d.AsyncApi == specVersion && d.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) + .FirstOrDefault(d => d.Version.Equals(version, StringComparison.OrdinalIgnoreCase)); } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml index 9af9193..08d7e39 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml @@ -1,6 +1,10 @@ -@inject Neuroglia.AsyncApi.Generation.IAsyncApiDocumentProvider DocumentProvider -@inject Microsoft.Extensions.Options.IOptions Options; +@inject IAsyncApiDocumentProvider DocumentProvider +@inject Microsoft.Extensions.Options.IOptions Options; @{ + if (!this.Context.Request.Query.TryGetValue("specVersion", out var documentSpecVersion)) + { + documentSpecVersion = string.Empty; + } if(!this.Context.Request.Query.TryGetValue("title", out var documentTitle)) { documentTitle = string.Empty; @@ -16,7 +20,7 @@ @ViewBag.Title - Neuroglia AsyncAPI UI - + @@ -90,17 +121,10 @@
@@ -122,12 +146,16 @@