You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article explains how to add OpenAPI metadata in an ASP.NET Core app.
14
+
13
15
## Include OpenAPI metadata for endpoints
14
16
15
17
:::moniker range=">= aspnetcore-10.0"
16
18
17
19
ASP.NET collects metadata from the web app's endpoints and uses it to generate an OpenAPI document.
18
-
In controller-based apps, metadata is collected from attributes like [`[EndpointDescription]`](xref:Microsoft.AspNetCore.Http.EndpointDescriptionAttribute), [`[HttpPost]`](xref:Microsoft.AspNetCore.Mvc.HttpPostAttribute),
19
-
and [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute).
20
-
In minimal APIs, metadata can be collected from attributes, but may also be set by using extension methods
21
-
and other strategies, such as returning <xref:Microsoft.AspNetCore.Http.TypedResults> from route handlers.
20
+
21
+
In controller-based apps, metadata is collected from attributes such as [`[EndpointDescription]`](xref:Microsoft.AspNetCore.Http.EndpointDescriptionAttribute), [`[HttpPost]`](xref:Microsoft.AspNetCore.Mvc.HttpPostAttribute),
22
+
and [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute) when the controller has the [`[ApiController]` attribute](xref:Microsoft.AspNetCore.Mvc.ApiControllerAttribute).
23
+
24
+
In minimal APIs, metadata can be collected from attributes but may also be set by using extension methods and other strategies, such as returning <xref:Microsoft.AspNetCore.Http.TypedResults> from route handlers.
25
+
22
26
The following table provides an overview of the metadata collected and the strategies for setting it.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/openapi/includes/include-metadata9.md
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
:::moniker range="= aspnetcore-9.0"
2
2
3
3
ASP.NET collects metadata from the web app's endpoints and uses it to generate an OpenAPI document.
4
-
In controller-based apps, metadata is collected from attributes like [`[EndpointDescription]`](xref:Microsoft.AspNetCore.Http.EndpointDescriptionAttribute), [`[HttpPost]`](xref:Microsoft.AspNetCore.Mvc.HttpPostAttribute),
5
-
and [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute).
6
-
In minimal APIs, metadata can be collected from attributes, but may also be set by using extension methods
7
-
and other strategies, such as returning <xref:Microsoft.AspNetCore.Http.TypedResults> from route handlers.
4
+
5
+
In controller-based apps, metadata is collected from attributes such as [`[EndpointDescription]`](xref:Microsoft.AspNetCore.Http.EndpointDescriptionAttribute), [`[HttpPost]`](xref:Microsoft.AspNetCore.Mvc.HttpPostAttribute),
6
+
and [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute) when the controller has the [`[ApiController]` attribute](xref:Microsoft.AspNetCore.Mvc.ApiControllerAttribute).
7
+
8
+
In minimal APIs, metadata can be collected from attributes but may also be set by using extension methods and other strategies, such as returning <xref:Microsoft.AspNetCore.Http.TypedResults> from route handlers.
9
+
8
10
The following table provides an overview of the metadata collected and the strategies for setting it.
0 commit comments