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
@@ -102,34 +102,45 @@ The output shows any issues with the OpenAPI document. For example:
102
102
103
103
## Support for injecting `IOpenApiDocumentProvider`
104
104
105
-
You can inject <xref:Microsoft.AspNetCore.OpenApi.IOpenApiDocumentProvider> into your services through dependency injection to access OpenAPI documents programmatically, even outside HTTP request contexts.
105
+
Inject <xref:Microsoft.AspNetCore.OpenApi.IOpenApiDocumentProvider> into services to access OpenAPI documents programmatically, even outside HTTP request contexts. The following example customizes version 2 ("`v2`") of the document with title, version, and description information:
Description="This is a custom API description for version 2."
125
+
};
126
+
127
+
returndocument;
120
128
}
121
129
}
122
130
```
123
131
124
-
Register the service in your DI container:
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>:
This enables scenarios such as generating client SDKs, validating API contracts in background processes, or exporting documents to external systems.
131
141
132
142
Support for injecting `IOpenApiDocumentProvider` was introduced in ASP.NET Core in .NET 10. For more information, see [dotnet/aspnetcore #61463](https://github.com/dotnet/aspnetcore/pull/61463).
0 commit comments