Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.100
dotnet-version: 8.0.x
- name: Build with dotnet
run: dotnet build --configuration Release
2 changes: 1 addition & 1 deletion .github/workflows/publishtonuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: publish to nuget
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

# Publish
- name: Publish NuGet
Expand Down
58 changes: 28 additions & 30 deletions SampleApp9000/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace SampleApp9000.Controllers
{
[ApiController]
[Route("/test/[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;
namespace SampleApp9000.Controllers;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[ApiController]
[Route("/test/[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return
[
.. Enumerable
.Range(1, 5)
.Select
(
index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
}
)
];
}
}
}
13 changes: 0 additions & 13 deletions SampleApp9000/Extensions/OpenApiServerExtensions.cs

This file was deleted.

27 changes: 13 additions & 14 deletions SampleApp9000/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace SampleApp9000
namespace SampleApp9000;

public class Program
{
public class Program
public static void Main(string[] args)
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
CreateHostBuilder(args).Build().Run();
}
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
10 changes: 9 additions & 1 deletion SampleApp9000/SampleApp9000.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.Servers.Extension" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Swashbuckle.Rebase.Extensions\Swashbuckle.Rebase.Extensions.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>


</Project>
129 changes: 61 additions & 68 deletions SampleApp9000/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,89 +1,82 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.OpenApi.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SampleApp9000.Extensions;
using Microsoft.OpenApi;
using Swashbuckle.Rebase.Extensions;
using Swashbuckle.Servers.Extension.Extensions;

namespace SampleApp9000
namespace SampleApp9000;

public class Startup
{
public class Startup
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }
services.AddControllers();

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
services.AddSwaggerGen(c =>
{
services.AddControllers();

services.AddSwaggerGen(c =>
{
c.SwaggerDoc
(
"sampleapp",
new OpenApiInfo
{
Title = "Sample App 9000",
Version = "1.0.0",
Description = "Provides a simple example of the tool"
}
);
});
}
c.SwaggerDoc
(
"sampleapp",
new OpenApiInfo
{
Title = "Sample App 9000",
Version = "1.0.0",
Description = "Provides a simple example of the tool"
}
);
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();
app.UseHttpsRedirection();

app.UseRouting();
app.UseRouting();

app.UseAuthorization();
app.UseSwagger
(
options =>
app.UseAuthorization();
app.UseSwagger
(
options =>
{
options.PreSerializeFilters.Add((swagger, httpReq) =>
{
options.PreSerializeFilters.Add((swagger, httpReq) =>
if (!string.IsNullOrWhiteSpace(httpReq?.Host.Value))
{
if (!string.IsNullOrWhiteSpace(httpReq?.Host.Value))
{
swagger.Servers.Add
(
new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{{basePath}}" }
.WithVariable("basePath", new OpenApiServerVariable { Default = "/test" })
);
}
});
swagger.Servers ??= [];

options.RemoveRoot("/test");
}
);
swagger.Servers.Add
(
new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{{basePath}}" }
.WithVariable("basePath", new OpenApiServerVariable { Default = "/test" })
);
}
});

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(x =>
{
x.DocumentTitle = "SampleApp9000";
x.SwaggerEndpoint("/swagger/sampleapp/swagger.json", "Sample App 9000");
x.RoutePrefix = string.Empty;
});
options.RemoveRoot("/test");
}
);

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(x =>
{
x.DocumentTitle = "SampleApp9000";
x.SwaggerEndpoint("/swagger/sampleapp/swagger.json", "Sample App 9000");
x.RoutePrefix = string.Empty;
});

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
17 changes: 8 additions & 9 deletions SampleApp9000/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System;

namespace SampleApp9000
namespace SampleApp9000;

public class WeatherForecast
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public DateTime Date { get; set; }

public int TemperatureC { get; set; }
public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
}
}
public string Summary { get; set; }
}
2 changes: 2 additions & 0 deletions Swashbuckle.Rebase.Extensions.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=sampleapp/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Loading