diff --git a/AuthorizationServer/AuthorizationServer.csproj b/AuthorizationServer/AuthorizationServer.csproj
index f26a38e..01a7a17 100644
--- a/AuthorizationServer/AuthorizationServer.csproj
+++ b/AuthorizationServer/AuthorizationServer.csproj
@@ -1,7 +1,9 @@
- netcoreapp2.0
+ net8.0
+ enable
+ enable
1.0
@@ -17,13 +19,13 @@
-
-
-
+
+
-
-
-
+
+ true
+ $(NoWarn);1591
+
diff --git a/AuthorizationServer/Controllers/BaseController.cs b/AuthorizationServer/Controllers/BaseController.cs
index 1244330..e8e6fdc 100644
--- a/AuthorizationServer/Controllers/BaseController.cs
+++ b/AuthorizationServer/Controllers/BaseController.cs
@@ -51,8 +51,8 @@ public BaseController(IAuthleteApi api)
///
/// Read the request body as a string.
- ///
- public async Task ReadRequestBodyAsString()
+ /// ı
+ protected async Task ReadRequestBodyAsString()
{
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
{
@@ -72,7 +72,7 @@ public async Task ReadRequestBodyAsString()
///
/// The name of an HTTP header.
///
- public string GetRequestHeaderValue(string headerName)
+ protected string GetRequestHeaderValue(string headerName)
{
StringValues values = Request.Headers[headerName];
diff --git a/AuthorizationServer/Startup.cs b/AuthorizationServer/Startup.cs
index 22ba409..853e485 100644
--- a/AuthorizationServer/Startup.cs
+++ b/AuthorizationServer/Startup.cs
@@ -20,6 +20,9 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.OpenApi.Models;
+using System.Reflection;
using Authlete.Api;
using Authlete.Conf;
@@ -39,10 +42,22 @@ public Startup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
- // AddWebApiConventions() is added by WebApiCompatShim.
- // Calling the method enables Web API implementations
- // to return an HttpResponseMessage instance directly.
- services.AddMvc().AddWebApiConventions();
+ // AddControllers() method registers the services
+ // of Controller type to the service collection,
+ // which will be used to serve MVC-style controller
+ // endpoints in the application.
+ services.AddControllers();
+
+ // Register the Swagger generator
+ services.AddSwaggerGen(c =>
+ {
+ c.SwaggerDoc("v1", new OpenApiInfo { Title = "Authlete Authorization Server", Version = "v1" });
+
+ // Optional: Set the comments path for the Swagger JSON and UI.
+ var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
+ var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
+ c.IncludeXmlComments(xmlPath);
+ });
// Register an instance of IAuthleteApi so controllers
// can refer to it in order to call Authlete Web APIs.
@@ -57,16 +72,36 @@ public void ConfigureServices(IServiceCollection services)
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
+
+ // Enable middleware to serve generated Swagger as a JSON endpoint.
+ app.UseSwagger();
+ app.UsePathBase("/");
+
+ // Enable middleware to serve swagger-ui assets (HTML, JS, CSS, etc.)
+ app.UseSwaggerUI(c =>
+ {
+ c.SwaggerEndpoint("/swagger/v1/swagger.json", "Authlete Authorization Server API");
+ c.RoutePrefix = string.Empty; // To serve the Swagger UI at the app's root
+ });
app.UseDefaultFiles();
app.UseStaticFiles();
- app.UseMvc();
+
+ // Updated to use routing
+ app.UseRouting();
+
+ // Configure endpoints for controllers
+ app.UseEndpoints(endpoints =>
+ {
+ // Ensure this matches your app's routing needs
+ endpoints.MapControllers();
+ });
}