Skip to content

Commit 4ebaeea

Browse files
authored
Surface controller attribute requirement (#35619)
1 parent bf56fff commit 4ebaeea

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

aspnetcore/fundamentals/openapi/include-metadata.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Include OpenAPI metadata in an ASP.NET Core app
33
author: captainsafia
4-
description: Learn how to add OpenAPI metadata in an ASP.NET Core app
4+
description: Learn how to add OpenAPI metadata in an ASP.NET Core app.
55
ms.author: safia
66
monikerRange: '>= aspnetcore-9.0'
77
ms.custom: mvc
@@ -10,15 +10,19 @@ uid: fundamentals/openapi/include-metadata
1010
---
1111
# Include OpenAPI metadata in an ASP.NET Core app
1212

13+
This article explains how to add OpenAPI metadata in an ASP.NET Core app.
14+
1315
## Include OpenAPI metadata for endpoints
1416

1517
:::moniker range=">= aspnetcore-10.0"
1618

1719
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+
2226
The following table provides an overview of the metadata collected and the strategies for setting it.
2327

2428
| Metadata | Attribute | Extension method | Other strategies |

aspnetcore/fundamentals/openapi/includes/include-metadata9.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
:::moniker range="= aspnetcore-9.0"
22

33
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+
810
The following table provides an overview of the metadata collected and the strategies for setting it.
911

1012
| Metadata | Attribute | Extension method | Other strategies |
@@ -582,4 +584,4 @@ A schema transformer can be used to override any default metadata or add additio
582584
* <xref:fundamentals/openapi/using-openapi-documents>
583585
* [OpenAPI specification](https://spec.openapis.org/oas/v3.0.3)
584586

585-
:::moniker-end
587+
:::moniker-end

0 commit comments

Comments
 (0)