Skip to content

Commit 5057ea5

Browse files
Copilotwadepickett
andauthored
Correct AddOpenApi() service registration syntax (#36731)
* Initial plan * Fix incorrect service registration syntax for AddOpenApi() calls Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com> * Fix typo in OpenAPI documents registration section --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com> Co-authored-by: Wade Pickett <wpickett@microsoft.com>
1 parent 3428a56 commit 5057ea5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

aspnetcore/fundamentals/openapi/using-openapi-documents.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
title: Use the generated OpenAPI documents
3+
ai-usage: ai-assisted
34
author: captainsafia
45
description: Learn how to use OpenAPI documents in an ASP.NET Core app.
5-
ms.author: safia
66
monikerRange: '>= aspnetcore-6.0'
7+
ms.author: safia
78
ms.custom: mvc
8-
ms.date: 01/13/2026
9+
ms.date: 02/02/2026
910
uid: fundamentals/openapi/using-openapi-documents
1011
---
1112
# Use openAPI documents
@@ -129,11 +130,11 @@ public class CustomDocumentService(
129130
}
130131
```
131132

132-
Register the service in your DI container. Note that service key should match the document name passed to <xref:Microsoft.Extensions.DependencyInjection.OpenApiServiceCollectionExtensions.AddOpenApi%2A>:
133+
Register the service in your DI container. Note that the service key should match the document name passed to <xref:Microsoft.Extensions.DependencyInjection.OpenApiServiceCollectionExtensions.AddOpenApi%2A>:
133134

134135
```csharp
135-
builder.AddOpenApi(); // Adds "v1" by default
136-
builder.AddOpenApi("v2");
136+
builder.Services.AddOpenApi(); // Adds "v1" by default
137+
builder.Services.AddOpenApi("v2");
137138
builder.Services.AddScoped<CustomDocumentService>();
138139
```
139140

0 commit comments

Comments
 (0)