Skip to content

Commit 4bbbe88

Browse files
committed
Refactor and enhance OpenAPI and middleware handling
Updated PackageTags in .csproj files for better categorization. Removed unused using directives in IQueryDispatcher.cs. Allowed nullable TResult in DispatcherEndpointsBuilder and IDispatcher. Refactored InMemoryDispatcher for nullable TResult and better formatting. Fixed null reference issues in PublicContractsMiddleware and CertificateMiddleware. Added null checks and default values in SecurityOptions and Extensions. Replaced SwaggerOptions with OpenApiSettings and OpenApiSettingsBuilder. Added support for custom operation IDs and server lists in OpenAPI. Introduced a new builder pattern for configuring OpenAPI settings. Added helloworld.bicep for Azure resource deployment.
1 parent 52b5851 commit 4bbbe88

File tree

26 files changed

+398
-163
lines changed

26 files changed

+398
-163
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Get the resource group location
2+
param location string = 'East US'
3+
4+
@description('The name of you Web Site.')
5+
param webSiteName string = 'gnx-website'
6+
7+
param uniqueString string = '{uniqueString(resourceGroup().id)}'
8+
9+
// Generate a unique storage account name
10+
param storageAccountName string = 'helloworldstorage${uniqueString}'
11+
12+
// Create a storage account
13+
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
14+
name: storageAccountName
15+
location: location
16+
sku: {
17+
name: 'Standard_LRS'
18+
}
19+
kind: 'StorageV2'
20+
properties: {
21+
accessTier: 'Hot'
22+
}
23+
}
24+
25+
// Create an App Service Plan
26+
resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = {
27+
name: 'asp-${uniqueString}'
28+
location: location
29+
sku: {
30+
name: 'F1'
31+
tier: 'Free'
32+
}
33+
}
34+
35+
// Create a web app
36+
resource webApp 'Microsoft.Web/sites@2023-12-01' = {
37+
name: webSiteName
38+
location: location
39+
properties: {
40+
serverFarmId: appServicePlan.id
41+
siteConfig: {
42+
appSettings: [
43+
{
44+
name: 'STORAGE_ACCOUNT_NAME'
45+
value: storageAccount.name
46+
}
47+
]
48+
}
49+
}
50+
}

src/Genocs.Auth/Genocs.Auth.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles authentication genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Common/Genocs.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Core/CQRS/Queries/IQueryDispatcher.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Threading.Tasks;
2-
using System.Threading;
3-
4-
namespace Genocs.Core.CQRS.Queries;
1+
namespace Genocs.Core.CQRS.Queries;
52

63
/// <summary>
74
/// The query dispatcher interface.

src/Genocs.Core/Genocs.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Updated to NET8</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.Discovery.Consul/Genocs.Discovery.Consul.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs service-discovery</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.HTTP/Genocs.HTTP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Version>6.1.0</Version>
1212
<MinClientVersion>5.0.0</MinClientVersion>
1313
<Authors>Nocco Giovanni Emanuele</Authors>
14-
<PackageTags>aggregate architecture boilerplate ddd ddd-architecture design-patterns domain-driven-design dotnet dotnetcore dotnet-core microservice microservices solid solid-principles</PackageTags>
14+
<PackageTags>microservice microservices solid solid-principles genocs http-client</PackageTags>
1515
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
1616
<PackageReleaseNotes>Aligned to the ecosystem</PackageReleaseNotes>
1717
<EnableNETAnalyzers>True</EnableNETAnalyzers>

src/Genocs.WebApi.CQRS/Builders/DispatcherEndpointsBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public IDispatcherEndpointsBuilder Get(
3131
public IDispatcherEndpointsBuilder Get<TQuery, TResult>(
3232
string path,
3333
Func<TQuery, HttpContext, Task>? beforeDispatch = null,
34-
Func<TQuery, TResult, HttpContext, Task>? afterDispatch = null,
34+
Func<TQuery, TResult?, HttpContext, Task>? afterDispatch = null,
3535
Action<IEndpointConventionBuilder>? endpoint = null,
3636
bool auth = false,
3737
string? roles = null,

src/Genocs.WebApi.CQRS/Extensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ public static IGenocsBuilder AddInMemoryDispatcher(this IGenocsBuilder builder)
1919
return builder;
2020
}
2121

22-
public static IApplicationBuilder UseDispatcherEndpoints(this IApplicationBuilder app,
23-
Action<IDispatcherEndpointsBuilder> builder, bool useAuthorization = true,
24-
Action<IApplicationBuilder> middleware = null)
22+
public static IApplicationBuilder UseDispatcherEndpoints(
23+
this IApplicationBuilder app,
24+
Action<IDispatcherEndpointsBuilder> builder,
25+
bool useAuthorization = true,
26+
Action<IApplicationBuilder>? middleware = null)
2527
{
2628
var definitions = app.ApplicationServices.GetRequiredService<WebApiEndpointDefinitions>();
2729
app.UseRouting();

src/Genocs.WebApi.CQRS/IDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Task SendAsync<T>(T command, CancellationToken cancellationToken = default)
1212
Task PublishAsync<T>(T @event, CancellationToken cancellationToken = default)
1313
where T : class, IEvent;
1414

15-
Task<TResult> QueryAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
15+
Task<TResult?> QueryAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
1616
}

0 commit comments

Comments
 (0)