From 12e329f33fe43ecdfe4daeff0d68668b627cec3c Mon Sep 17 00:00:00 2001 From: Edgar Mesquita Date: Thu, 20 Jul 2023 11:32:34 +0100 Subject: [PATCH] fixing xml comments including --- .../eQuantic.Core.Api.Crud.csproj | 6 +++--- .../Extensions/ServiceCollectionExtensions.cs | 12 ++++++++---- .../Options/DocumentationOptions.cs | 3 +++ src/eQuantic.Core.Api/eQuantic.Core.Api.csproj | 6 +++--- .../eQuantic.Core.Application.Crud.csproj | 6 +++--- .../eQuantic.Core.Application.csproj | 6 +++--- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj b/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj index 1029a7b..b72050c 100644 --- a/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj +++ b/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj @@ -4,7 +4,7 @@ eQuantic API CRUD Library 2023 eQuantic.Core.Api.Crud - 1.0.2.0 + 1.0.3.0 eQuantic Systems net7.0 eQuantic.Core.Api.Crud @@ -22,8 +22,8 @@ LICENSE https://github.com/eQuantic/core-api-crud Git - 1.0.2.0 - 1.0.2.0 + 1.0.3.0 + 1.0.3.0 Icon.png latest enable diff --git a/src/eQuantic.Core.Api/Extensions/ServiceCollectionExtensions.cs b/src/eQuantic.Core.Api/Extensions/ServiceCollectionExtensions.cs index 9adef8c..50f2416 100644 --- a/src/eQuantic.Core.Api/Extensions/ServiceCollectionExtensions.cs +++ b/src/eQuantic.Core.Api/Extensions/ServiceCollectionExtensions.cs @@ -18,20 +18,24 @@ public static class ServiceCollectionExtensions /// Adds the api documentation using the specified registry /// /// The service collection + /// The documentation options /// The registry public static IServiceCollection AddApiDocumentation(this IServiceCollection services, Action? options = null) { var docOptions = new DocumentationOptions(); options?.Invoke(docOptions); - - var assembly = Assembly.GetExecutingAssembly(); - var name = assembly.GetName().Name; + + var assembly = docOptions.Assembly ?? Assembly.GetEntryAssembly(); + var name = assembly?.GetName().Name; services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = docOptions.Title, Version = "v1" }); c.DescribeAllParametersInCamelCase(); - c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{name}.xml")); + + if(!string.IsNullOrEmpty(name)) + c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{name}.xml")); + c.EnableAnnotations(); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { diff --git a/src/eQuantic.Core.Api/Options/DocumentationOptions.cs b/src/eQuantic.Core.Api/Options/DocumentationOptions.cs index 3805928..8f15f14 100644 --- a/src/eQuantic.Core.Api/Options/DocumentationOptions.cs +++ b/src/eQuantic.Core.Api/Options/DocumentationOptions.cs @@ -1,6 +1,9 @@ +using System.Reflection; + namespace eQuantic.Core.Api.Options; public class DocumentationOptions { public string? Title { get; set; } + public Assembly? Assembly { get; set; } } \ No newline at end of file diff --git a/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj b/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj index 8da1460..ee9ab96 100644 --- a/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj +++ b/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj @@ -4,7 +4,7 @@ eQuantic API Library 2023 eQuantic.Core.Api - 1.0.2.0 + 1.0.3.0 eQuantic Systems net7.0 eQuantic.Core.Api @@ -22,8 +22,8 @@ LICENSE https://github.com/eQuantic/core-api-crud Git - 1.0.2.0 - 1.0.2.0 + 1.0.3.0 + 1.0.3.0 Icon.png latest enable diff --git a/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj b/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj index 3373b7e..c6ee26c 100644 --- a/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj +++ b/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj @@ -4,7 +4,7 @@ eQuantic Application CRUD Library 2023 eQuantic.Core.Application.Crud - 1.0.2.0 + 1.0.3.0 eQuantic Systems netstandard2.1;net7.0 eQuantic.Core.Application.Crud @@ -22,8 +22,8 @@ LICENSE https://github.com/eQuantic/core-api-crud Git - 1.0.2.0 - 1.0.2.0 + 1.0.3.0 + 1.0.3.0 Icon.png latest enable diff --git a/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj b/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj index 9e26f46..c07af52 100644 --- a/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj +++ b/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj @@ -4,7 +4,7 @@ eQuantic Application Library 2023 eQuantic.Core.Application - 1.0.2.0 + 1.0.3.0 eQuantic Systems netstandard2.1;net7.0 eQuantic.Core.Application @@ -22,8 +22,8 @@ LICENSE https://github.com/eQuantic/core-api-crud Git - 1.0.2.0 - 1.0.2.0 + 1.0.3.0 + 1.0.3.0 Icon.png latest enable