mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-13 08:41:27 +00:00
Combine a bunch of helpers together, shuffle some things around
This commit is contained in:
parent
71a97894ad
commit
330c01317d
61 changed files with 327 additions and 371 deletions
21
ProjectLighthouse.Servers.API/SwaggerFilter.cs
Normal file
21
ProjectLighthouse.Servers.API/SwaggerFilter.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.API;
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// A filter for the swagger documentation endpoint.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Makes sure that only endpoints under <c>/api/v1</c> show up.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class SwaggerFilter : IDocumentFilter
|
||||
{
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
List<KeyValuePair<string, OpenApiPathItem>> nonApiRoutes = swaggerDoc.Paths.Where(x => !x.Key.ToLower().StartsWith("/api/v1")).ToList();
|
||||
nonApiRoutes.ForEach(x => swaggerDoc.Paths.Remove(x.Key));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue