-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convenience extensions for OpenAPI
- Loading branch information
1 parent
099d732
commit a4eaeb5
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using GenHTTP.Api.Content; | ||
using GenHTTP.Modules.OpenApi.Discovery; | ||
|
||
namespace GenHTTP.Modules.OpenApi; | ||
|
||
public static class Extensions | ||
{ | ||
|
||
/// <summary> | ||
/// Adds a pre-configured concern to the given builder. | ||
/// </summary> | ||
/// <remarks> | ||
/// The generated concern will crawl through the inner handler chain and analyze the following | ||
/// types of content: Layouts, Concerns, Functional Handlers, Webservices, Controllers. | ||
/// </remarks> | ||
public static T AddOpenApi<T>(this T builder) where T : IHandlerBuilder<T> | ||
=> builder.AddOpenApi(ApiDiscovery.Default()); | ||
|
||
/// <summary> | ||
/// Creates a concern that will use the given discovery configuration to search for API endpoints | ||
/// to be added to the generated OpenAPI specification. | ||
/// </summary> | ||
/// <param name="registry">The explorer registry to be used to analyze the handler chain</param> | ||
public static T AddOpenApi<T>(this T builder, ApiDiscoveryRegistryBuilder registry) where T : IHandlerBuilder<T> | ||
{ | ||
builder.Add(ApiDescription.With(registry)); | ||
return builder; | ||
} | ||
|
||
} |