Merge pull request #28645 from dotnet/tdykstra-patch-1

Add note about AddEndpointsApiExplorer
pull/28647/head
Rick Anderson 2023-03-10 10:23:03 -10:00 committed by GitHub
commit cde5233aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -74,6 +74,8 @@ Add the Swagger generator to the services collection in `Program.cs`:
:::code language="csharp" source="web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Snippets/Program.cs" id="snippet_ServicesDefault" highlight="4":::
The call to <xref:Microsoft.Extensions.DependencyInjection.EndpointMetadataApiExplorerServiceCollectionExtensions.AddEndpointsApiExplorer%2A> shown in the preceding example is required only for [minimal APIs](/aspnet/core/fundamentals/minimal-apis/overview). For more information, see [this StackOverflow post](https://stackoverflow.com/a/71933535).
Enable the middleware for serving the generated JSON document and the Swagger UI, also in `Program.cs`:
:::code language="csharp" source="web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Program.cs" id="snippet_Middleware" highlight="3,4":::