diff --git a/samples/Controllers/ApiKeySample/ApiKeySample.csproj b/samples/Controllers/ApiKeySample/ApiKeySample.csproj
index b316ba7..7d849aa 100644
--- a/samples/Controllers/ApiKeySample/ApiKeySample.csproj
+++ b/samples/Controllers/ApiKeySample/ApiKeySample.csproj
@@ -1,18 +1,19 @@
-
- net9.0
- enable
- enable
-
+
+ net9.0
+ enable
+ enable
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/samples/Controllers/ApiKeySample/Program.cs b/samples/Controllers/ApiKeySample/Program.cs
index 48ffda5..903b4e0 100644
--- a/samples/Controllers/ApiKeySample/Program.cs
+++ b/samples/Controllers/ApiKeySample/Program.cs
@@ -32,10 +32,7 @@
builder.Services.AddTransient();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-
-builder.Services.AddSwaggerGen(options =>
+builder.Services.AddOpenApi(options =>
{
options.AddSimpleAuthentication(builder.Configuration);
});
@@ -45,18 +42,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
+app.MapOpenApi();
+
+app.UseSwaggerUI(options =>
{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+ options.SwaggerEndpoint("/openapi/v1.json", app.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/Controllers/BasicAuthenticationSample/BasicAuthenticationSample.csproj b/samples/Controllers/BasicAuthenticationSample/BasicAuthenticationSample.csproj
index b316ba7..7d849aa 100644
--- a/samples/Controllers/BasicAuthenticationSample/BasicAuthenticationSample.csproj
+++ b/samples/Controllers/BasicAuthenticationSample/BasicAuthenticationSample.csproj
@@ -1,18 +1,19 @@
-
- net9.0
- enable
- enable
-
+
+ net9.0
+ enable
+ enable
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/samples/Controllers/BasicAuthenticationSample/Program.cs b/samples/Controllers/BasicAuthenticationSample/Program.cs
index 33bbce4..e60b17e 100644
--- a/samples/Controllers/BasicAuthenticationSample/Program.cs
+++ b/samples/Controllers/BasicAuthenticationSample/Program.cs
@@ -33,10 +33,7 @@
builder.Services.AddTransient();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-
-builder.Services.AddSwaggerGen(options =>
+builder.Services.AddOpenApi(options =>
{
options.AddSimpleAuthentication(builder.Configuration);
});
@@ -46,18 +43,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
+app.MapOpenApi();
+
+app.UseSwaggerUI(options =>
{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+ options.SwaggerEndpoint("/openapi/v1.json", app.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/Controllers/JwtBearerSample/Controllers/AuthController.cs b/samples/Controllers/JwtBearerSample/Controllers/AuthController.cs
index c1be650..ed9977d 100644
--- a/samples/Controllers/JwtBearerSample/Controllers/AuthController.cs
+++ b/samples/Controllers/JwtBearerSample/Controllers/AuthController.cs
@@ -2,7 +2,6 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using SimpleAuthentication.JwtBearer;
-using Swashbuckle.AspNetCore.Annotations;
namespace JwtBearerSample.Controllers;
@@ -14,7 +13,7 @@ public class AuthController(IJwtBearerService jwtBearerService) : ControllerBase
[HttpPost("login")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: "Insert permissions in the scope property (for example: 'profile people:admin')")]
+ [EndpointDescription(description: "Insert permissions in the scope property (for example: 'profile people:admin')")]
public async Task> Login(LoginRequest loginRequest, DateTime? expiration = null)
{
// Check for login rights...
diff --git a/samples/Controllers/JwtBearerSample/Controllers/MeController.cs b/samples/Controllers/JwtBearerSample/Controllers/MeController.cs
index 741dfad..e28699a 100644
--- a/samples/Controllers/JwtBearerSample/Controllers/MeController.cs
+++ b/samples/Controllers/JwtBearerSample/Controllers/MeController.cs
@@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SimpleAuthentication.Permissions;
-using Swashbuckle.AspNetCore.Annotations;
namespace JwtBearerSample.Controllers;
@@ -16,7 +15,7 @@ public class MeController : ControllerBase
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: "This endpoint requires the 'profile' permission")]
+ [EndpointDescription(description: "This endpoint requires the 'profile' permission")]
public ActionResult Get()
=> new User(User.Identity!.Name);
}
diff --git a/samples/Controllers/JwtBearerSample/Controllers/PeopleController.cs b/samples/Controllers/JwtBearerSample/Controllers/PeopleController.cs
index 883039b..d6b8e74 100644
--- a/samples/Controllers/JwtBearerSample/Controllers/PeopleController.cs
+++ b/samples/Controllers/JwtBearerSample/Controllers/PeopleController.cs
@@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SimpleAuthentication.Permissions;
-using Swashbuckle.AspNetCore.Annotations;
namespace JwtBearerSample.Controllers;
@@ -14,35 +13,35 @@ public class PeopleController : ControllerBase
{
[Authorize(Policy = "PeopleRead")] // [Permissions(Permissions.PeopleRead, Permissions.PeopleAdmin)]
[HttpGet]
- [SwaggerOperation(description: $"This endpoint requires the '{Permissions.PeopleRead}' or '{Permissions.PeopleAdmin}' permissions")]
+ [EndpointDescription(description: $"This endpoint requires the '{Permissions.PeopleRead}' or '{Permissions.PeopleAdmin}' permissions")]
public IActionResult GetList() => NoContent();
[Authorize(Policy = "PeopleRead")] // [Permissions(Permissions.PeopleRead, Permissions.PeopleAdmin)]
[HttpGet("{id:int}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: $"This endpoint requires the '{Permissions.PeopleRead}' or '{Permissions.PeopleAdmin}' permissions")]
+ [EndpointDescription(description: $"This endpoint requires the '{Permissions.PeopleRead}' or '{Permissions.PeopleAdmin}' permissions")]
public IActionResult GetPerson(int id) => NoContent();
[Permission(Permissions.PeopleWrite)]
[HttpPost]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: $"This endpoint requires the '{Permissions.PeopleWrite}' permission")]
+ [EndpointDescription(description: $"This endpoint requires the '{Permissions.PeopleWrite}' permission")]
public IActionResult Insert() => NoContent();
[Permission(Permissions.PeopleWrite)]
[HttpPut]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: $"This endpoint requires the '{Permissions.PeopleWrite}' permission")]
+ [EndpointDescription(description: $"This endpoint requires the '{Permissions.PeopleWrite}' permission")]
public IActionResult Update() => NoContent();
[Permission(Permissions.PeopleAdmin)]
[HttpDelete("{id:int}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesDefaultResponseType]
- [SwaggerOperation(description: $"This endpoint requires the '{Permissions.PeopleAdmin}' permission")]
+ [EndpointDescription(description: $"This endpoint requires the '{Permissions.PeopleAdmin}' permission")]
public IActionResult Delete(int id) => NoContent();
}
diff --git a/samples/Controllers/JwtBearerSample/JwtBearerSample.csproj b/samples/Controllers/JwtBearerSample/JwtBearerSample.csproj
index 3268a60..7d849aa 100644
--- a/samples/Controllers/JwtBearerSample/JwtBearerSample.csproj
+++ b/samples/Controllers/JwtBearerSample/JwtBearerSample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/Controllers/JwtBearerSample/Program.cs b/samples/Controllers/JwtBearerSample/Program.cs
index 64cada0..cf54829 100644
--- a/samples/Controllers/JwtBearerSample/Program.cs
+++ b/samples/Controllers/JwtBearerSample/Program.cs
@@ -41,12 +41,8 @@
builder.Services.AddTransient();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-
-builder.Services.AddSwaggerGen(options =>
+builder.Services.AddOpenApi(options =>
{
- options.EnableAnnotations();
options.AddSimpleAuthentication(builder.Configuration);
});
@@ -55,18 +51,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
+app.MapOpenApi();
+
+app.UseSwaggerUI(options =>
{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+ options.SwaggerEndpoint("/openapi/v1.json", app.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/MinimalApis/ApiKeySample/ApiKeySample.csproj b/samples/MinimalApis/ApiKeySample/ApiKeySample.csproj
index f703422..7d849aa 100644
--- a/samples/MinimalApis/ApiKeySample/ApiKeySample.csproj
+++ b/samples/MinimalApis/ApiKeySample/ApiKeySample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/MinimalApis/ApiKeySample/Program.cs b/samples/MinimalApis/ApiKeySample/Program.cs
index aa101c7..be9ea71 100644
--- a/samples/MinimalApis/ApiKeySample/Program.cs
+++ b/samples/MinimalApis/ApiKeySample/Program.cs
@@ -32,10 +32,7 @@
builder.Services.AddTransient();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-
-builder.Services.AddSwaggerGen(options =>
+builder.Services.AddOpenApi(options =>
{
options.AddSimpleAuthentication(builder.Configuration);
});
@@ -45,18 +42,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
+app.MapOpenApi();
+
+app.UseSwaggerUI(options =>
{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+ options.SwaggerEndpoint("/openapi/v1.json", app.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/MinimalApis/BasicAuthenticationSample/BasicAuthenticationSample.csproj b/samples/MinimalApis/BasicAuthenticationSample/BasicAuthenticationSample.csproj
index f703422..7d849aa 100644
--- a/samples/MinimalApis/BasicAuthenticationSample/BasicAuthenticationSample.csproj
+++ b/samples/MinimalApis/BasicAuthenticationSample/BasicAuthenticationSample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/MinimalApis/BasicAuthenticationSample/Program.cs b/samples/MinimalApis/BasicAuthenticationSample/Program.cs
index 9d490c5..1e0ab2f 100644
--- a/samples/MinimalApis/BasicAuthenticationSample/Program.cs
+++ b/samples/MinimalApis/BasicAuthenticationSample/Program.cs
@@ -32,10 +32,7 @@
builder.Services.AddTransient();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-
-builder.Services.AddSwaggerGen(options =>
+builder.Services.AddOpenApi(options =>
{
options.AddSimpleAuthentication(builder.Configuration);
});
@@ -45,18 +42,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
+app.MapOpenApi();
+
+app.UseSwaggerUI(options =>
{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+ options.SwaggerEndpoint("/openapi/v1.json", app.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/MinimalApis/JwtBearerSample/JwtBearerSample.csproj b/samples/MinimalApis/JwtBearerSample/JwtBearerSample.csproj
index f298eeb..678312a 100644
--- a/samples/MinimalApis/JwtBearerSample/JwtBearerSample.csproj
+++ b/samples/MinimalApis/JwtBearerSample/JwtBearerSample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/MinimalApis/JwtBearerSample/Program.cs b/samples/MinimalApis/JwtBearerSample/Program.cs
index 531568a..e66b998 100644
--- a/samples/MinimalApis/JwtBearerSample/Program.cs
+++ b/samples/MinimalApis/JwtBearerSample/Program.cs
@@ -51,22 +51,15 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
-{
- app.MapOpenApi();
+app.MapOpenApi();
- app.UseSwaggerUI(options =>
- {
- options.SwaggerEndpoint("/openapi/v1.json", builder.Environment.ApplicationName);
- });
-}
+app.UseSwaggerUI(options =>
+{
+ options.SwaggerEndpoint("/openapi/v1.json", builder.Environment.ApplicationName);
+});
app.UseAuthentication();
app.UseAuthorization();
diff --git a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj
index 6210d1b..7884956 100644
--- a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj
+++ b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/samples/MinimalApis/Net8JwtBearerSample/Program.cs b/samples/MinimalApis/Net8JwtBearerSample/Program.cs
index 4f61523..bbd2d5b 100644
--- a/samples/MinimalApis/Net8JwtBearerSample/Program.cs
+++ b/samples/MinimalApis/Net8JwtBearerSample/Program.cs
@@ -54,18 +54,11 @@
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
-if (!app.Environment.IsDevelopment())
-{
- app.UseExceptionHandler();
-}
-
+app.UseExceptionHandler();
app.UseStatusCodePages();
-if (app.Environment.IsDevelopment())
-{
- app.UseSwagger();
- app.UseSwaggerUI();
-}
+app.UseSwagger();
+app.UseSwaggerUI();
app.UseAuthentication();
app.UseAuthorization();
diff --git a/src/SimpleAuthentication/SimpleAuthentication.csproj b/src/SimpleAuthentication/SimpleAuthentication.csproj
index d49178e..800ef2c 100644
--- a/src/SimpleAuthentication/SimpleAuthentication.csproj
+++ b/src/SimpleAuthentication/SimpleAuthentication.csproj
@@ -31,11 +31,11 @@
-
+
-
+