Skip to content

Commit

Permalink
Only include api endpoints in open api document
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Feb 20, 2024
1 parent 27f9cbb commit c22e3e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/PackageRegistryService/OpenAPI/DocGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static void GeneratorSetup (AspNetCoreOpenApiDocumentGeneratorSettings se
);
// fix for WithDescription and WithSummary methods not working with nswag and minimal API endpoints
settings.OperationProcessors.Add(new OperationMetadataProcessor());

// only inclide "api" paths in docs
settings.OperationProcessors.Add(new OperationFilterProcessor());
}
}
}
15 changes: 15 additions & 0 deletions src/PackageRegistryService/OpenAPI/OperationFilterProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using NSwag;
using NSwag.Generation.Processors;
using NSwag.Generation.Processors.Contexts;

namespace PackageRegistryService.OpenAPI
{
// we do not need view endpoints in our OpenAPI documentation
public class OperationFilterProcessor : IOperationProcessor
{
public bool Process(OperationProcessorContext operationProcessorContext)
{
return operationProcessorContext.OperationDescription.Path.StartsWith("/api/");
}
}
}

0 comments on commit c22e3e9

Please sign in to comment.