News features
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
|
||||
<PackageVersion Include="MediatR" Version="12.4.1" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="9.0.0" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
|
||||
@@ -57,18 +58,18 @@
|
||||
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
|
||||
<PackageVersion Include="OwaspHeaders.Core" Version="9.4.3" />
|
||||
<PackageVersion Include="Polly" Version="8.5.0" />
|
||||
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.9" />
|
||||
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9" />
|
||||
<PackageVersion Include="Roslynator.CodeFixes" Version="4.12.9" />
|
||||
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9" />
|
||||
<PackageVersion Include="Roslynator.Refactorings" Version="4.12.9" />
|
||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.10" />
|
||||
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.10" />
|
||||
<PackageVersion Include="Roslynator.CodeFixes" Version="4.12.10" />
|
||||
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.10" />
|
||||
<PackageVersion Include="Roslynator.Refactorings" Version="4.12.10" />
|
||||
<PackageVersion Include="Scalar.AspNetCore" Version="1.2.63" />
|
||||
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
|
||||
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
|
||||
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
|
||||
<PackageVersion Include="xunit" Version="2.9.2" />
|
||||
<PackageVersion Include="xunit.analyzers" Version="1.17.0" />
|
||||
<PackageVersion Include="xunit.analyzers" Version="1.18.0" />
|
||||
<PackageVersion Include="xunit.categories" Version="2.0.8" />
|
||||
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -26,14 +26,19 @@ If you liked this project, learned something, give it a star. Thank you!
|
||||
|
||||
## **Technologies**
|
||||
|
||||
- ~~ASP.NET Core 8~~
|
||||
- ASP.NET Core 9
|
||||
- ~~Entity Framework Core 8~~
|
||||
- Entity Framework Core 9
|
||||
- **EF Compiled Queries** (https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/ef/language-reference/compiled-queries-linq-to-entities)
|
||||
- Unit & Integration Tests + xUnit + FluentAssertions
|
||||
- Polly
|
||||
- AutoMapper
|
||||
- FluentValidator
|
||||
- MediatR
|
||||
- Swagger UI
|
||||
- ~~Swagger UI~~
|
||||
- OpenApi
|
||||
- **Scalar** - Interactive API Reference from OpenAPI/Swagger (https://github.com/scalar/scalar)
|
||||
- HealthChecks
|
||||
- SQL Server
|
||||
- MongoDB
|
||||
@@ -73,7 +78,7 @@ docker-compose up --build --abort-on-container-exit --remove-orphans
|
||||
Now just open the url in the browser:
|
||||
|
||||
```csharp
|
||||
http://localhost:{port}/swagger/
|
||||
http://localhost:{port}/scalar/v1
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<DockerTargetOS>Linux</DockerTargetOS>
|
||||
<ProjectGuid>24ef58f6-cbf8-4910-a17c-e8de7ed96a87</ProjectGuid>
|
||||
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
||||
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
|
||||
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/scalar/v1</DockerServiceUrl>
|
||||
<DockerServiceName>shop-webapi</DockerServiceName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
@@ -9,7 +7,6 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Shop.Core.AppSettings;
|
||||
using Shop.Core.Extensions;
|
||||
using Shop.Infrastructure;
|
||||
@@ -28,32 +25,6 @@ internal static class ServicesCollectionExtensions
|
||||
private static readonly string[] DbRelationalTags = ["database", "ef-core", "sql-server", "relational"];
|
||||
private static readonly string[] DbNoSqlTags = ["database", "mongodb", "no-sql"];
|
||||
|
||||
public static void AddSwagger(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(swaggerOptions =>
|
||||
{
|
||||
swaggerOptions.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "Shop (e-commerce)",
|
||||
Description = "ASP.NET Core C# CQRS Event Sourcing, REST API, DDD, SOLID Principles and Clean Architecture",
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "Jean Gatto",
|
||||
Email = "jean_gatto@hotmail.com"
|
||||
},
|
||||
License = new OpenApiLicense
|
||||
{
|
||||
Name = "MIT License"
|
||||
}
|
||||
});
|
||||
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||
swaggerOptions.IncludeXmlComments(xmlPath, true);
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddHealthChecks(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var options = configuration.GetOptions<ConnectionOptions>();
|
||||
|
||||
@@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using OwaspHeaders.Core.Extensions;
|
||||
using Scalar.AspNetCore;
|
||||
using Shop.Application;
|
||||
using Shop.Core;
|
||||
using Shop.Core.Extensions;
|
||||
@@ -49,7 +50,7 @@ builder.Services
|
||||
explorerOptions.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
builder.Services.AddSwagger();
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddDataProtection();
|
||||
builder.Services.AddControllers()
|
||||
.ConfigureApiBehaviorOptions(behaviorOptions =>
|
||||
@@ -104,7 +105,9 @@ var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHealthChecks("/health", new HealthCheckOptions
|
||||
{
|
||||
@@ -112,9 +115,9 @@ app.UseHealthChecks("/health", new HealthCheckOptions
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
app.UseErrorHandling();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseResponseCompression();
|
||||
app.UseHttpsRedirection();
|
||||
app.UseSecureHeadersMiddleware();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"launchUrl": "scalar/v1",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
@@ -15,7 +15,7 @@
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"launchUrl": "scalar/v1",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
@@ -26,7 +26,7 @@
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"launchUrl": "scalar/v1",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
@@ -35,7 +35,7 @@
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "https://+:443;http://+:80"
|
||||
},
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<PackageReference Include="AutoMapper" />
|
||||
<PackageReference Include="CorrelationId" />
|
||||
<PackageReference Include="MediatR" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -60,7 +61,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" />
|
||||
<PackageReference Include="Scalar.AspNetCore" />
|
||||
<PackageReference Include="System.Text.RegularExpressions" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -78,6 +79,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="D:\.nuget\packages\owaspheaders.core\8.1.0\contentFiles\any\net9.0\README.md" />
|
||||
<Content Remove="D:\.nuget\packages\owaspheaders.core\9.4.3\contentFiles\any\net9.0\README.md" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user