Skip to content

Commit 7c0f332

Browse files
YAML in OpenAPI (#35247)
1 parent f8bb008 commit 7c0f332

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

aspnetcore/fundamentals/openapi/aspnetcore-openapi.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ Launch the app and navigate to `https://localhost:<port>/openapi/v1.json` to vie
7878

7979
The following sections demonstrate how to customize OpenAPI document generation.
8080

81+
### Generate OpenAPI document in YAML format
82+
83+
The OpenAPI document can be generated in either JSON or YAML format. By default, the OpenAPI document is generated in JSON format. To generate the OpenAPI document in YAML format, specify the endpoint in the MapOpenApi call with a ".yaml" or ".yml" suffix, as shown in the following example:
84+
85+
```csharp
86+
app.MapOpenApi("/openapi/{documentName}.yaml");
87+
```
88+
89+
Generating penAPI documents in YAML format at build time is currently not supported, but planned in a future preview.
90+
8191
### Customize the OpenAPI document name
8292

8393
Each OpenAPI document in an app has a unique name. The default document name that is registered is `v1`.

aspnetcore/release-notes/aspnetcore-10/includes/openApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ options.AddSchemaTransformer((schema, context, cancellationToken) =>
6868

6969
Note that these changes are necessary even when only configuring the OpenAPI version to 3.0.
7070

71-
### OpenAPI in Yaml
71+
### OpenAPI in YAML
7272

7373
ASP.NET now supports serving the generated OpenAPI document in YAML format. YAML can be more concise than JSON, eliminating curly braces and quotation marks when these can be inferred. YAML also supports multi-line strings, which can be useful for long descriptions.
7474

0 commit comments

Comments
 (0)