Skip to content

Commit

Permalink
Generate NSwag client using .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaspit committed Jan 23, 2024
1 parent d17b3e6 commit e5ab806
Show file tree
Hide file tree
Showing 4 changed files with 480 additions and 262 deletions.
6 changes: 3 additions & 3 deletions src/Serval.ApiServer/Serval.ApiServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Hangfire" Version="1.7.33" />
<PackageReference Include="Hangfire.Mongo" Version="1.9.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.14" />
<PackageReference Include="NSwag.AspNetCore" Version="13.20.0" />
<PackageReference Include="NSwag.MSBuild" Version="13.20.0">
<PackageReference Include="NSwag.AspNetCore" Version="14.0.2" />
<PackageReference Include="NSwag.MSBuild" Version="14.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down Expand Up @@ -50,6 +50,6 @@
</PropertyGroup>

<Target Name="NSwag" AfterTargets="PostBuildEvent" Condition=" '$(Configuration)' == 'Debug' ">
<Exec WorkingDirectory="$(ProjectDir)" EnvironmentVariables="ASPNETCORE_ENVIRONMENT=Development;NSWAG=1" Command="$(NSwagExe_Net60) run nswag.json /variables:Configuration=$(Configuration)" />
<Exec WorkingDirectory="$(ProjectDir)" EnvironmentVariables="ASPNETCORE_ENVIRONMENT=Development;NSWAG=1" Command="$(NSwagExe_Net80) run nswag.json /variables:Configuration=$(Configuration)" />
</Target>
</Project>
8 changes: 4 additions & 4 deletions src/Serval.ApiServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerDocument(o =>
{
o.SchemaType = SchemaType.Swagger2;
o.SchemaSettings.SchemaType = SchemaType.Swagger2;
o.Title = "Serval API";
o.Description = "Natural language processing services for minority language Bible translation.";
o.DocumentName = "v" + version.Major;
o.ApiGroupNames = new[] { "v" + version.Major };
o.Version = version.Major + "." + version.Minor;

o.SchemaNameGenerator = new ServalSchemaNameGenerator();
o.SchemaSettings.SchemaNameGenerator = new ServalSchemaNameGenerator();
o.UseControllerSummaryAsTagDescription = true;
o.AddSecurity(
"bearer",
Expand All @@ -165,7 +165,7 @@ public void ConfigureServices(IServiceCollection services)
);
o.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("bearer"));

o.AllowReferencesWithProperties = true;
o.SchemaSettings.AllowReferencesWithProperties = true;
o.PostProcess = document =>
{
var prefix = "/api/v" + version.Major;
Expand Down Expand Up @@ -223,7 +223,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
document.Servers.First().Url += prefix;
};
});
app.UseSwaggerUi3(settings =>
app.UseSwaggerUi(settings =>
{
settings.OAuth2Client = new OAuth2ClientSettings
{
Expand Down
2 changes: 1 addition & 1 deletion src/Serval.ApiServer/nswag.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runtime": "Net60",
"runtime": "Net80",
"defaultVariables": null,
"documentGenerator": {
"aspNetCoreToOpenApi": {
Expand Down
Loading

0 comments on commit e5ab806

Please sign in to comment.