From 0a4f4b9dfcb6a9c6b6b942455a534f9b5549777d Mon Sep 17 00:00:00 2001 From: Fernando Araoz Date: Sat, 11 Jan 2025 16:29:43 -0500 Subject: [PATCH] feat: add scalar ui --- Dockerfile | 4 ++-- Dockerfile.alpine | 4 ++-- Program.cs | 9 +++++++-- Properties/launchSettings.json | 27 --------------------------- Trazo.csproj | 1 + docker-compose.yml | 2 +- 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08980e3..99660ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 +FROM mcr.microsoft.com/dotnet/sdk:8.0 WORKDIR /app # Set ASP.NET to actually listen on all interfaces, not just localhost -ENV ASPNETCORE_URLS=http://+:5266 +ENV ASPNETCORE_URLS=http://+:5233 # Allow non-HTTPS because it's just development, who cares ENV ASPNETCORE_ENVIRONMENT=Development diff --git a/Dockerfile.alpine b/Dockerfile.alpine index abb5cb4..076c139 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build WORKDIR /app COPY . . RUN dotnet restore RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine WORKDIR /app COPY --from=build /app/out . diff --git a/Program.cs b/Program.cs index 48863a6..c63fc86 100644 --- a/Program.cs +++ b/Program.cs @@ -1,3 +1,5 @@ +using Scalar.AspNetCore; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -12,8 +14,11 @@ var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { - app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwagger(options => + { + options.RouteTemplate = "openapi/{documentName}.json"; + }); + app.MapScalarApiReference(); } app.UseHttpsRedirection(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 629bb5c..9418b1a 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,41 +1,14 @@ { "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:22703", - "sslPort": 44392 - } - }, "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": true, "launchUrl": "swagger", "applicationUrl": "http://localhost:5233", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:7038;http://localhost:5233", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } } } } diff --git a/Trazo.csproj b/Trazo.csproj index 5419ef0..2326ba1 100644 --- a/Trazo.csproj +++ b/Trazo.csproj @@ -7,6 +7,7 @@ + diff --git a/docker-compose.yml b/docker-compose.yml index bc04db4..923cd1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: context: . dockerfile: Dockerfile ports: - - "5266:5266" + - "5233:5233" volumes: - ./:/app networks: