Class Extensions
a set of extension methods for adding swagger support
Inherited Members
Namespace: FastEndpoints.Swagger
Assembly: FastEndpoints.Swagger.dll
Syntax
public static class Extensions
Properties
SelectedJsonNamingPolicy
JsonNamingPolicy chosen for swagger
Declaration
public static JsonNamingPolicy? SelectedJsonNamingPolicy { get; }
Property Value
Type | Description |
---|---|
JsonNamingPolicy |
Methods
AddAuth(OpenApiDocumentGeneratorSettings, string, OpenApiSecurityScheme, IEnumerable<string>?)
add swagger auth for this open api document
Declaration
public static OpenApiDocumentGeneratorSettings AddAuth(this OpenApiDocumentGeneratorSettings s, string schemeName, OpenApiSecurityScheme securityScheme, IEnumerable<string>? globalScopeNames = null)
Parameters
Type | Name | Description |
---|---|---|
OpenApiDocumentGeneratorSettings | s | |
string | schemeName | the authentication scheme |
OpenApiSecurityScheme | securityScheme | an open api security scheme object |
IEnumerable<string> | globalScopeNames | a collection of global scope names |
Returns
Type | Description |
---|---|
OpenApiDocumentGeneratorSettings |
ConfigureDefaults(SwaggerUiSettings, Action<SwaggerUiSettings>?)
configure swagger ui with some sensible defaults for FastEndpoints which can be overridden if needed.
Declaration
public static void ConfigureDefaults(this SwaggerUiSettings s, Action<SwaggerUiSettings>? settings = null)
Parameters
Type | Name | Description |
---|---|---|
SwaggerUiSettings | s | |
Action<SwaggerUiSettings> | settings | provide an action that overrides any of the defaults |
DeActivateTryItOut(SwaggerUiSettings)
the "Try It Out" button is activated by default. call this method to de-activate it by default.
set NSwag.AspNetCore.SwaggerUiSettings.EnableTryItOut to false
to remove the button from ui.
Declaration
public static void DeActivateTryItOut(this SwaggerUiSettings s)
Parameters
Type | Name | Description |
---|---|---|
SwaggerUiSettings | s |
EnableFastEndpoints(AspNetCoreOpenApiDocumentGeneratorSettings, Action<DocumentOptions>)
enable support for FastEndpoints in swagger
Declaration
public static void EnableFastEndpoints(this AspNetCoreOpenApiDocumentGeneratorSettings settings, Action<DocumentOptions> documentOptions)
Parameters
Type | Name | Description |
---|---|---|
AspNetCoreOpenApiDocumentGeneratorSettings | settings | |
Action<DocumentOptions> | documentOptions | the document options |
EnableJWTBearerAuth(AspNetCoreOpenApiDocumentGeneratorSettings)
enable jwt bearer authorization support
Declaration
public static void EnableJWTBearerAuth(this AspNetCoreOpenApiDocumentGeneratorSettings settings)
Parameters
Type | Name | Description |
---|---|---|
AspNetCoreOpenApiDocumentGeneratorSettings | settings |
GetEndpointDefinition(OperationProcessorContext)
gets the EndpointDefinition from the nwag operation processor context if this is a FastEndpoint operation. otherwise returns null.
Declaration
public static EndpointDefinition? GetEndpointDefinition(this OperationProcessorContext ctx)
Parameters
Type | Name | Description |
---|---|---|
OperationProcessorContext | ctx |
Returns
Type | Description |
---|---|
EndpointDefinition |
GetExampleFromMetaData(IProducesResponseTypeMetadata)
gets the example object if any, from a given ProducesResponseTypeMetadata internal class
Declaration
public static object? GetExampleFromMetaData(this IProducesResponseTypeMetadata metadata)
Parameters
Type | Name | Description |
---|---|---|
IProducesResponseTypeMetadata | metadata |
Returns
Type | Description |
---|---|
object |
MarkNonNullablePropsAsRequired(AspNetCoreOpenApiDocumentGeneratorSettings)
mark all non-nullable properties of the schema as required in the swagger document. this may only be needed for TS client generation with OAS3 swagger definitions.
Declaration
public static void MarkNonNullablePropsAsRequired(this AspNetCoreOpenApiDocumentGeneratorSettings x)
Parameters
Type | Name | Description |
---|---|---|
AspNetCoreOpenApiDocumentGeneratorSettings | x |
SwaggerDocument(IServiceCollection, Action<DocumentOptions>?)
enable support for FastEndpoints and create a swagger document.
Declaration
public static IServiceCollection SwaggerDocument(this IServiceCollection services, Action<DocumentOptions>? options = null)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
Action<DocumentOptions> | options | swagger document configuration options |
Returns
Type | Description |
---|---|
IServiceCollection |
UseSwaggerGen(IApplicationBuilder, Action<OpenApiDocumentMiddlewareSettings>?, Action<SwaggerUiSettings>?)
enables the open-api/swagger middleware for fastendpoints.
this method is simply a shortcut for the two calls [app.UseOpenApi()
] and [app.UseSwaggerUi3(c => c.ConfigureDefaults())
]
Declaration
public static IApplicationBuilder UseSwaggerGen(this IApplicationBuilder app, Action<OpenApiDocumentMiddlewareSettings>? config = null, Action<SwaggerUiSettings>? uiConfig = null)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | app | |
Action<OpenApiDocumentMiddlewareSettings> | config | optional config action for the open-api middleware |
Action<SwaggerUiSettings> | uiConfig | optional config action for the swagger-ui |
Returns
Type | Description |
---|---|
IApplicationBuilder |