Dela via


ApiBehaviorOptions Class

Definition

Options used to configure behavior for types annotated with ApiControllerAttribute.

public ref class ApiBehaviorOptions
public ref class ApiBehaviorOptions : System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Mvc::Infrastructure::ICompatibilitySwitch ^>
public class ApiBehaviorOptions
public class ApiBehaviorOptions : System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Infrastructure.ICompatibilitySwitch>
type ApiBehaviorOptions = class
type ApiBehaviorOptions = class
    interface seq<ICompatibilitySwitch>
    interface IEnumerable
Public Class ApiBehaviorOptions
Public Class ApiBehaviorOptions
Implements IEnumerable(Of ICompatibilitySwitch)
Inheritance
ApiBehaviorOptions
Implements

Constructors

ApiBehaviorOptions()

Creates a new instance of ApiBehaviorOptions.

Properties

AllowInferringBindingSourceForCollectionTypesAsFromQuery

Gets or sets a value that determines if BindingSource for collection types (IsCollectionType).

When true, the binding source for collection types is inferred as Query. Otherwise Body is inferred.

ClientErrorMapping

Gets a map of HTTP status codes to ClientErrorData. Configured values are used to transform IClientErrorActionResult to an ObjectResult instance where the Value is ProblemDetails.

Use of this feature can be disabled by resetting SuppressMapClientErrors.

DisableImplicitFromServicesParameters

Gets or sets a value that determines if parameters are inferred to be from services. This property is only applicable when SuppressInferBindingSourcesForParameters is false.

InvalidModelStateResponseFactory

Delegate invoked on actions annotated with ApiControllerAttribute to convert invalid ModelStateDictionary into an IActionResult

SuppressConsumesConstraintForFormFileParameters

Gets or sets a value that determines if an multipart/form-data consumes action constraint is added to parameters that are bound from form data.

SuppressInferBindingSourcesForParameters

Gets or sets a value that determines if model binding sources are inferred for action parameters on controllers annotated with ApiControllerAttribute is suppressed.

When enabled, the following sources are inferred: Parameters that appear as route values, are assumed to be bound from the path (Path). Parameters of type IFormFile and IFormFileCollection are assumed to be bound from form. Parameters that are complex (IsComplexType) and are registered in the DI Container (IServiceCollection) are assumed to be bound from the services Services, unless this option is explicitly disabled DisableImplicitFromServicesParameters. Parameters that are complex (IsComplexType) are assumed to be bound from the body (Body). All other parameters are assumed to be bound from the query.

SuppressMapClientErrors

Gets or sets a value that determines if controllers with ApiControllerAttribute transform certain client errors.

When false, a result filter is added to API controller actions that transforms IClientErrorActionResult. Otherwise, the filter is suppressed.

By default, ClientErrorMapping is used to map IClientErrorActionResult to a ProblemDetails instance (returned as the value for ObjectResult).

To customize the output of the filter (for e.g. to return a different error type), register a custom implementation of IClientErrorFactory in the service collection.

SuppressModelStateInvalidFilter

Gets or sets a value that determines if the filter that returns an BadRequestObjectResult when ModelState is invalid is suppressed. .

SuppressUseValidationProblemDetailsForInvalidModelStateResponses

Gets or sets a value that determines if controllers annotated with ApiControllerAttribute respond using ValidationProblemDetails in InvalidModelStateResponseFactory.

When true, SuppressModelStateInvalidFilter returns errors in ModelStateDictionary as a ValidationProblemDetails. Otherwise, SuppressModelStateInvalidFilter returns the errors in the format determined by SerializableError.

Explicit Interface Implementations

IEnumerable.GetEnumerator()
IEnumerable<ICompatibilitySwitch>.GetEnumerator()

Applies to