feat: add scalar ui

This commit is contained in:
Fernando Araoz 2025-01-11 16:29:43 -05:00
parent e8ec8f8e5c
commit 0a4f4b9dfc
6 changed files with 13 additions and 34 deletions

View File

@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0 FROM mcr.microsoft.com/dotnet/sdk:8.0
WORKDIR /app WORKDIR /app
# Set ASP.NET to actually listen on all interfaces, not just localhost # 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 # Allow non-HTTPS because it's just development, who cares
ENV ASPNETCORE_ENVIRONMENT=Development ENV ASPNETCORE_ENVIRONMENT=Development

View File

@ -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 WORKDIR /app
COPY . . COPY . .
RUN dotnet restore RUN dotnet restore
RUN dotnet publish -c Release -o out 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 WORKDIR /app
COPY --from=build /app/out . COPY --from=build /app/out .

View File

@ -1,3 +1,5 @@
using Scalar.AspNetCore;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
@ -12,8 +14,11 @@ var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger(options =>
app.UseSwaggerUI(); {
options.RouteTemplate = "openapi/{documentName}.json";
});
app.MapScalarApiReference();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();

View File

@ -1,41 +1,14 @@
{ {
"$schema": "http://json.schemastore.org/launchsettings.json", "$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:22703",
"sslPort": 44392
}
},
"profiles": { "profiles": {
"http": { "http": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "http://localhost:5233", "applicationUrl": "http://localhost:5233",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "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"
}
} }
} }
} }

View File

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Scalar.AspNetCore" Version="1.2.*" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup> </ItemGroup>

View File

@ -5,7 +5,7 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "5266:5266" - "5233:5233"
volumes: volumes:
- ./:/app - ./:/app
networks: networks: