共用方式為


OpenApiRouteHandlerBuilderExtensions.ProducesValidationProblem 方法

定義

IProducesResponseTypeMetadata針對 所產生的 builder 所有端點,將具有 HttpValidationProblemDetailsMetadata 別的 加入 。

public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder ProducesValidationProblem (this Microsoft.AspNetCore.Builder.RouteHandlerBuilder builder, int statusCode = 400, string? contentType = default);
static member ProducesValidationProblem : Microsoft.AspNetCore.Builder.RouteHandlerBuilder * int * string -> Microsoft.AspNetCore.Builder.RouteHandlerBuilder
<Extension()>
Public Function ProducesValidationProblem (builder As RouteHandlerBuilder, Optional statusCode As Integer = 400, Optional contentType As String = Nothing) As RouteHandlerBuilder

參數

statusCode
Int32

回應狀態碼。 預設值為 Status400BadRequest

contentType
String

回應內容類型。 預設為 「application/problem+json」。

傳回

RouteHandlerBuilder,可用來進一步自訂端點。

適用於