Table of Contents

Class SwaggerUIOptionsExtensions

Namespace
Microsoft.AspNetCore.Builder
Assembly
Swashbuckle.AspNetCore.SwaggerUI.dll
public static class SwaggerUIOptionsExtensions
Inheritance
SwaggerUIOptionsExtensions
Inherited Members

Methods

DefaultModelExpandDepth(SwaggerUIOptions, int)

The default expansion depth for the model on the model-example section

public static void DefaultModelExpandDepth(this SwaggerUIOptions options, int depth)

Parameters

options SwaggerUIOptions
depth int

DefaultModelRendering(SwaggerUIOptions, ModelRendering)

Controls how the model is shown when the API is first rendered. (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.)

public static void DefaultModelRendering(this SwaggerUIOptions options, ModelRendering modelRendering)

Parameters

options SwaggerUIOptions
modelRendering ModelRendering

DefaultModelsExpandDepth(SwaggerUIOptions, int)

The default expansion depth for models (set to -1 completely hide the models)

public static void DefaultModelsExpandDepth(this SwaggerUIOptions options, int depth)

Parameters

options SwaggerUIOptions
depth int

DisplayOperationId(SwaggerUIOptions)

Controls the display of operationId in operations list

public static void DisplayOperationId(this SwaggerUIOptions options)

Parameters

options SwaggerUIOptions

DisplayRequestDuration(SwaggerUIOptions)

Controls the display of the request duration (in milliseconds) for Try-It-Out requests

public static void DisplayRequestDuration(this SwaggerUIOptions options)

Parameters

options SwaggerUIOptions

DocExpansion(SwaggerUIOptions, DocExpansion)

Controls the default expansion setting for the operations and tags. It can be 'List' (expands only the tags), 'Full' (expands the tags and operations) or 'None' (expands nothing)

public static void DocExpansion(this SwaggerUIOptions options, DocExpansion docExpansion)

Parameters

options SwaggerUIOptions
docExpansion DocExpansion

EnableDeepLinking(SwaggerUIOptions)

Enables deep linking for tags and operations

public static void EnableDeepLinking(this SwaggerUIOptions options)

Parameters

options SwaggerUIOptions

EnableFilter(SwaggerUIOptions, string)

Enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. If an expression is provided it will be used and applied initially. Filtering is case sensitive matching the filter expression anywhere inside the tag

public static void EnableFilter(this SwaggerUIOptions options, string expression = null)

Parameters

options SwaggerUIOptions
expression string

EnableValidator(SwaggerUIOptions, string)

You can use this parameter to enable the swagger-ui's built-in validator (badge) functionality Setting it to null will disable validation

public static void EnableValidator(this SwaggerUIOptions options, string url = "https://online.swagger.io/validator")

Parameters

options SwaggerUIOptions
url string

InjectJavascript(SwaggerUIOptions, string, string)

Injects additional Javascript files into the index.html page

public static void InjectJavascript(this SwaggerUIOptions options, string path, string type = "text/javascript")

Parameters

options SwaggerUIOptions
path string

A path to the javascript - i.e. the script "src" attribute

type string

The script type - i.e. the script "type" attribute

InjectStylesheet(SwaggerUIOptions, string, string)

Injects additional CSS stylesheets into the index.html page

public static void InjectStylesheet(this SwaggerUIOptions options, string path, string media = "screen")

Parameters

options SwaggerUIOptions
path string

A path to the stylesheet - i.e. the link "href" attribute

media string

The target media - i.e. the link "media" attribute

MaxDisplayedTags(SwaggerUIOptions, int)

Limits the number of tagged operations displayed to at most this many. The default is to show all operations

public static void MaxDisplayedTags(this SwaggerUIOptions options, int count)

Parameters

options SwaggerUIOptions
count int

OAuth2RedirectUrl(SwaggerUIOptions, string)

OAuth redirect URL

public static void OAuth2RedirectUrl(this SwaggerUIOptions options, string url)

Parameters

options SwaggerUIOptions
url string

OAuthAdditionalQueryStringParams(SwaggerUIOptions, Dictionary<string, string>)

Additional query parameters added to authorizationUrl and tokenUrl

public static void OAuthAdditionalQueryStringParams(this SwaggerUIOptions options, Dictionary<string, string> value)

Parameters

options SwaggerUIOptions
value Dictionary<string, string>

OAuthAppName(SwaggerUIOptions, string)

Application name, displayed in authorization popup

public static void OAuthAppName(this SwaggerUIOptions options, string value)

Parameters

options SwaggerUIOptions
value string

OAuthClientId(SwaggerUIOptions, string)

Default clientId

public static void OAuthClientId(this SwaggerUIOptions options, string value)

Parameters

options SwaggerUIOptions
value string

OAuthClientSecret(SwaggerUIOptions, string)

Default clientSecret

public static void OAuthClientSecret(this SwaggerUIOptions options, string value)

Parameters

options SwaggerUIOptions
value string

OAuthRealm(SwaggerUIOptions, string)

realm query parameter (for oauth1) added to authorizationUrl and tokenUrl

public static void OAuthRealm(this SwaggerUIOptions options, string value)

Parameters

options SwaggerUIOptions
value string

OAuthScopeSeparator(SwaggerUIOptions, string)

Scope separator for passing scopes, encoded before calling, default value is a space (encoded value %20)

public static void OAuthScopeSeparator(this SwaggerUIOptions options, string value)

Parameters

options SwaggerUIOptions
value string

OAuthUseBasicAuthenticationWithAccessCodeGrant(SwaggerUIOptions)

Only activated for the accessCode flow. During the authorization_code request to the tokenUrl, pass the Client Password using the HTTP Basic Authentication scheme (Authorization header with Basic base64encoded[client_id:client_secret]). The default is false

public static void OAuthUseBasicAuthenticationWithAccessCodeGrant(this SwaggerUIOptions options)

Parameters

options SwaggerUIOptions

ShowExtensions(SwaggerUIOptions)

Controls the display of vendor extension (x-) fields and values for Operations, Parameters, and Schema

public static void ShowExtensions(this SwaggerUIOptions options)

Parameters

options SwaggerUIOptions

SupportedSubmitMethods(SwaggerUIOptions, params SubmitMethod[])

List of HTTP methods that have the Try it out feature enabled. An empty array disables Try it out for all operations. This does not filter the operations from the display

public static void SupportedSubmitMethods(this SwaggerUIOptions options, params SubmitMethod[] submitMethods)

Parameters

options SwaggerUIOptions
submitMethods SubmitMethod[]

SwaggerEndpoint(SwaggerUIOptions, string, string)

Adds Swagger JSON endpoints. Can be fully-qualified or relative to the UI page

public static void SwaggerEndpoint(this SwaggerUIOptions options, string url, string name)

Parameters

options SwaggerUIOptions
url string

Can be fully qualified or relative to the current host

name string

The description that appears in the document selector drop-down

ValidatorUrl(SwaggerUIOptions, string)

[Obsolete("The validator is disabled by default. Use EnableValidator to enable it")]
public static void ValidatorUrl(this SwaggerUIOptions options, string url)

Parameters

options SwaggerUIOptions
url string