Skip to content

Commit 24bb8b7

Browse files
Apply suggestions from code review
Co-authored-by: Tom Dykstra <[email protected]>
1 parent 0f130fc commit 24bb8b7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

aspnetcore/fundamentals/openapi/buildtime-openapi.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ uid: fundamentals/openapi/buildtime-openapi
1111

1212
# Generate OpenAPI documents at build-time
1313

14-
In a typical web applications, OpenAPI documents are generated at run-time and served via an HTTP request to the application server.
14+
In typical web applications, OpenAPI documents are generated at run-time and served via an HTTP request to the application server.
1515

16-
In some scenarios, it is helpful to generate the OpenAPI document during the application's build step. These scenarios including:
16+
In some scenarios, it's helpful to generate the OpenAPI document during the application's build step. These scenarios include:
1717

18-
- Generating OpenAPI documentation that is committed into source control
19-
- Generating OpenAPI documentation that is used for spec-based integration testing
20-
- Generating OpenAPI documentation that is served statically from the web server
18+
- Generating OpenAPI documentation that is committed into source control.
19+
- Generating OpenAPI documentation that is used for spec-based integration testing.
20+
- Generating OpenAPI documentation that is served statically from the web server.
2121

2222
To add support for generating OpenAPI documents at build time, install the `Microsoft.Extensions.ApiDescription.Server` package:
2323

@@ -42,7 +42,7 @@ Upon installation, this package will automatically generate the Open API documen
4242

4343
```cli
4444
$ dotnet build
45-
$ cat bin/Debub/net9.0/{ProjectName}.json
45+
$ cat bin/Debug/net9.0/{ProjectName}.json
4646
```
4747

4848
## Customizing build-time document generation
@@ -83,8 +83,8 @@ Some applications may be configured to emit multiple OpenAPI documents, for vari
8383

8484
Under the hood, build-time OpenAPI document generation functions by launching the application's entrypoint with an inert server implementation. This is a requirement to produce accurate OpenAPI documents since all information in the OpenAPI document cannot be statically analyzed. Because the application's entrypoint is invoked, any logic in the applications' startup will be invoked. This includes code that injects services into the DI container or reads from configuration. In some scenarios, it's necessary to restrict the codepaths that will run when the application's entry point is being invoked from build-time document generation. These scenarios include:
8585

86-
- Not reading from certain configuration strings
87-
- Not registering database-related services
86+
- Not reading from certain configuration strings.
87+
- Not registering database-related services.
8888

8989
In order to restrict these codepaths from being invoked by the build-time generation pipeline, they can be conditioned behind a check of the entry assembly like so:
9090

@@ -95,6 +95,6 @@ var builder = WebApplication.CreateBuilder();
9595

9696
if (Assembly.GetEntryAssembly()?.GetName().Name != "GetDocument.Insider")
9797
{
98-
builders.Services.AddDefaults();
98+
builder.Services.AddDefaults();
9999
}
100100
```

0 commit comments

Comments
 (0)