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 |
AutoTagOverride(IEndpointConventionBuilder, string)
when path based auto-tagging is enabled, you can use this method to specify an override tag name if necessary.
Declaration
public static IEndpointConventionBuilder AutoTagOverride(this IEndpointConventionBuilder b, string tag)
Parameters
Type | Name | Description |
---|---|---|
IEndpointConventionBuilder | b | |
string | tag | the tag name to use instead of the auto tag |
Returns
Type | Description |
---|---|
IEndpointConventionBuilder |
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>, IServiceProvider)
enable support for FastEndpoints in swagger
Declaration
public static void EnableFastEndpoints(this AspNetCoreOpenApiDocumentGeneratorSettings settings, Action<DocumentOptions> documentOptions, IServiceProvider serviceProvider)
Parameters
Type | Name | Description |
---|---|---|
AspNetCoreOpenApiDocumentGeneratorSettings | settings | |
Action<DocumentOptions> | documentOptions | the document options |
IServiceProvider | serviceProvider | the service provider |
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 FastEndpoints.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 |
ShowOperationIDs(SwaggerUiSettings)
displays the swagger operation id in the swagger ui
Declaration
public static void ShowOperationIDs(this SwaggerUiSettings s)
Parameters
Type | Name | Description |
---|---|---|
SwaggerUiSettings | s |
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 |
SwaggerIgnore<T, TProperty>(IRuleBuilderOptions<T, TProperty>, ApplyConditionTo)
disable swagger+fluentvalidation integration for a property rule
Declaration
public static IRuleBuilderOptions<T, TProperty> SwaggerIgnore<T, TProperty>(this IRuleBuilderOptions<T, TProperty> rule, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)
Parameters
Type | Name | Description |
---|---|---|
IRuleBuilderOptions<T, TProperty> | rule | |
ApplyConditionTo | applyConditionTo |
Returns
Type | Description |
---|---|
IRuleBuilderOptions<T, TProperty> |
Type Parameters
Name | Description |
---|---|
T | |
TProperty |
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 |