Skip to content

Commit 3ed2d01

Browse files
committed
docs: adds a snippet to document yaml reading
Signed-off-by: Vincent Biret <[email protected]>
1 parent 609dc7f commit 3ed2d01

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/upgrade-guide-2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ In v1, instances of `$ref` were resolved in a second pass of the document to ens
2727

2828
In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library to be able to read OpenAPI descriptions in either YAML or JSON. In OpenAPI.NET v2, the core Microsoft.OpenAPI library can both read and write JSON. It is only necessary to use the newly renamed [Microsoft.OpenApi.YamlReader](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) library if you need YAML support. This allows teams who are only working in JSON to avoid the additional dependency and therefore eliminate all non-.NET library references.
2929

30+
Once the dependency is added, the reader needs to be added to the reader settings as demonstrated below
31+
32+
```csharp
33+
var settings = new OpenApiReaderSettings();
34+
settings.AddYamlReader();
35+
36+
var result = OpenApiDocument.LoadAsync(openApiString, settings: settings);
37+
```
38+
3039
## API Enhancements
3140

3241
The v1 library attempted to mimic the pattern of `XmlTextReader` and `JsonTextReader` for the purpose of loading OpenAPI documents from strings, streams and text readers.

0 commit comments

Comments
 (0)