Skip to content

Commit

Permalink
Changed to .Net 9
Browse files Browse the repository at this point in the history
• Removed Swagger
• Added Scalar
• Added Environment for ScalarUI
  • Loading branch information
androidseb25 committed Dec 24, 2024
1 parent f63dc57 commit b7c1fe5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# See https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 5047
EXPOSE 7221

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG TARGETARCH
WORKDIR /src

Expand Down
29 changes: 14 additions & 15 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using iGotify_Notification_Assist.Services;
using Microsoft.OpenApi.Models;
using Scalar.AspNetCore;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -14,12 +15,7 @@
});

builder.Services.AddSingleton(builder.Configuration);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "iGotify Notification Assist API", Version = "v1" });
});
builder.Services.AddOpenApi();

builder.Services.AddTransient<IStartupFilter, StartUpBuilder>();

Expand All @@ -37,17 +33,20 @@

app.UseRouting();

// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger(c => { c.RouteTemplate = "/swagger/{documentName}/swagger.json"; });
string enableScalarUiString = Environment.GetEnvironmentVariable("ENABLES_SCALAR_UI") ?? "false";

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
if (enableScalarUiString == "true")
{
c.SwaggerEndpoint("/api/swagger/v1/swagger.json", "iGotify Notification Assist API");
c.RoutePrefix = string.Empty;
c.DefaultModelsExpandDepth(-1);
});
app.MapOpenApi();
app.MapScalarApiReference(options =>
{
options.WithTitle("iGotify Notification Assist API")
.WithModels(false)
.WithLayout(ScalarLayout.Classic)
.WithTheme(ScalarTheme.Moon)
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
});
}

//app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

Expand Down
6 changes: 3 additions & 3 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "api/",
"launchUrl": "scalar/v1",
"applicationUrl": "http://localhost:5047",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand All @@ -23,7 +23,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "api/",
"launchUrl": "scalar/v1",
"applicationUrl": "https://localhost:7221;http://localhost:5047",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand All @@ -32,7 +32,7 @@
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/",
"launchUrl": "scalar/v1",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
15 changes: 8 additions & 7 deletions iGotify Notification Assist.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>iGotify_Notification_Assist</RootNamespace>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<Version>1.3.0.0</Version>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<FileVersion>1.3.1.0</FileVersion>
<Version>1.3.1.0</Version>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.44" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="Dapper.Mapper" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scalar.AspNetCore" Version="1.2.71" />
<PackageReference Include="secntfy.nuget" Version="1.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Websocket.Client" Version="5.1.2" />
</ItemGroup>

Expand Down

0 comments on commit b7c1fe5

Please sign in to comment.