Share via


OpenApiRouteHandlerBuilderExtensions.Produces 方法

定義

多載

Produces(RouteHandlerBuilder, Int32, Type, String, String[])

IProducesResponseTypeMetadataMetadata 針對 所產生的 builder 所有端點,將 加入 至 。

Produces<TResponse>(RouteHandlerBuilder, Int32, String, String[])

IProducesResponseTypeMetadataMetadata 針對 所產生的 builder 所有端點,將 加入 至 。

Produces(RouteHandlerBuilder, Int32, Type, String, String[])

IProducesResponseTypeMetadataMetadata 針對 所產生的 builder 所有端點,將 加入 至 。

public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder Produces (this Microsoft.AspNetCore.Builder.RouteHandlerBuilder builder, int statusCode, Type? responseType = default, string? contentType = default, params string[] additionalContentTypes);
static member Produces : Microsoft.AspNetCore.Builder.RouteHandlerBuilder * int * Type * string * string[] -> Microsoft.AspNetCore.Builder.RouteHandlerBuilder
<Extension()>
Public Function Produces (builder As RouteHandlerBuilder, statusCode As Integer, Optional responseType As Type = Nothing, Optional contentType As String = Nothing, ParamArray additionalContentTypes As String()) As RouteHandlerBuilder

參數

statusCode
Int32

回應狀態碼。

responseType
Type

回應的類型。 預設值為 null。

contentType
String

回應內容類型。 如果 responseType 不是 Null,則預設為 「application/json」,否則會預設為 null。

additionalContentTypes
String[]

端點針對提供的狀態碼所產生的其他回應內容類型。

傳回

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

適用於

Produces<TResponse>(RouteHandlerBuilder, Int32, String, String[])

IProducesResponseTypeMetadataMetadata 針對 所產生的 builder 所有端點,將 加入 至 。

public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder Produces<TResponse> (this Microsoft.AspNetCore.Builder.RouteHandlerBuilder builder, int statusCode = 200, string? contentType = default, params string[] additionalContentTypes);
static member Produces : Microsoft.AspNetCore.Builder.RouteHandlerBuilder * int * string * string[] -> Microsoft.AspNetCore.Builder.RouteHandlerBuilder
<Extension()>
Public Function Produces(Of TResponse) (builder As RouteHandlerBuilder, Optional statusCode As Integer = 200, Optional contentType As String = Nothing, ParamArray additionalContentTypes As String()) As RouteHandlerBuilder

類型參數

TResponse

回應的類型。

參數

statusCode
Int32

回應狀態碼。 預設值為 Status200OK

contentType
String

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

additionalContentTypes
String[]

端點針對提供的狀態碼所產生的其他回應內容類型。

傳回

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

適用於