Skip to content

API Explorer Options

Chris Martinez edited this page Jun 12, 2017 · 7 revisions

The ApiExplorerOptions class allows you to configure, customize, and extend the default behaviors when you add API exploration support. The configuration options are specified by providing a callback to the appropriate extension method:

ASP.NET Web API

configuration.AddVersionedApiExplorer( options => { /* configure options */ } );

ASP.NET Web API with OData

configuration.AddODataApiExplorer( options => { /* configure options */ } );

ASP.NET Core

services.AddMvcCore().AddVersionedApiExplorer( options => { /* configure options */ } );

The ApiExplorerOptions class has the following configuration settings:

  • GroupNameFormat
  • DefaultApiVersion
  • DefaultApiVersionParameterDescription
  • AssumeDefaultVersionWhenUnspecified
  • ApiVersionParameterSource
  • UseApiExplorerSettings*

* Applies to ASP.NET Web API with OData only

Group Name Format

The group name format is the format string that is applied to the current API version being explored. This resultant, formatted string is used as the group name for the explored API. The group name is often used in tools such as Swagger and Swashbuckle to logically group APIs together. For more information and examples on the format specifiers for an API version, see the Custom API Version Format Strings topic.

Default API Version

This option defines what the default ApiVersion will be for a service without explicit API version information. The default value is derived from ApiVersioningOptions.DefaultApiVersion and should not be changed.

Default API Version Parameter Description

This option defines what the default description for API version parameters will be. The default value is: "The requested API version".

Assume Default Version When Unspecified

This option enables support for clients to make requests with implicit API versioning. This option is used during API exploration to determine whether the API version parameter is required. The default value is derived from ApiVersioningOptions.AssumeDefaultVersionWhenUnspecified and should not be changed.

API Version Parameter Source

This option configures how the API exploration process discovers API version parameters. The default value derives from ApiVersioningOptions.ApiVersionReader and should not be changed.

Use API Explorer Settings

This option only applies to ASP.NET Web API with OData. OData controllers are not explored by default. The API explorer for OData services does not initially honor this setting so that OData APIs will be discovered. You might decide, however, to use the API explorer settings to explicitly define which OData services should be explored. You must set this property to a value of true in order for the API explorer to respect API explorer settings.

Clone this wiki locally