Skip to content

Commit d800e21

Browse files
authored
Merge pull request #2438 from microsoft/docs/readme-v2-updates
docs: updates the getting started for v2
2 parents a02d74c + b76cc0e commit d800e21

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

README.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
|Package|Nuget|
77
|--|--|
88
|Models and Writers|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi/) |
9-
|Readers | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Readers.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Readers/) |
9+
|YamlReader | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.YamlReader.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader/) |
1010
|Hidi|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Hidi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi/)
1111

12-
1312
The **OpenAPI.NET** SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.
1413

1514
**See more information on the OpenAPI specification and its history here: <a href="https://www.openapis.org">OpenAPI Initiative</a>**
@@ -19,23 +18,14 @@ Project Objectives:
1918
- Provide a single shared object model in .NET for OpenAPI descriptions.
2019
- Include the most primitive Reader for ingesting OpenAPI JSON and YAML documents in both V2 and V3 formats.
2120
- Provide OpenAPI description writers for both V2 and V3 specification formats.
22-
- Enable developers to create Readers that translate different data formats into OpenAPI descriptions.
21+
- Enable developers to create Readers that translate different data formats into OpenAPI descriptions.
2322

2423
# Installation
2524

2625
- Install core Nuget package [**Microsoft.OpenApi**](https://www.nuget.org/packages/Microsoft.OpenApi)
27-
- Install readers Nuget package [**Microsoft.OpenApi.Readers**](https://www.nuget.org/packages/Microsoft.OpenApi.Readers)
28-
29-
> Note: version 2 of this library, which brings support for OpenAPI 3.1, is currently in preview. Due to early versioning issues with the preview, and package renaming, the installation must be done with a specific version number to get the latest version:
30-
> ```bash
31-
> # x-release-please-start-version
32-
> dotnet add package Microsoft.OpenAPI --version 2.0.0-preview.31
33-
> # x-release-please-end
34-
> # x-release-please-start-version
35-
> dotnet add package Microsoft.OpenAPI.YamlReader --version 2.0.0-preview.31
36-
> # x-release-please-end
37-
> ```
38-
> Until this new version is generally available, dependabot will periodically create pull requests which **downgrade** to preview 9, they should be ignored.
26+
- Install Yaml Reader Nuget package [**Microsoft.OpenApi.YamlReader**](https://www.nuget.org/packages/Microsoft.OpenApi.YamlReader)
27+
28+
> Note: we just released a new major version of the library, which brings support for OpenAPI 3.1!
3929
> You can read more about the changes of this upcoming version [in the upgrade guide](./docs/upgrade-guide-2.md).
4030
4131
# Processors
@@ -89,19 +79,10 @@ var document = new OpenApiDocument
8979
Reading and writing an OpenAPI description
9080

9181
```C#
92-
var httpClient = new HttpClient
93-
{
94-
BaseAddress = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/")
95-
};
96-
97-
var stream = await httpClient.GetStreamAsync("main/examples/v3.0/petstore.yaml");
98-
99-
// Read V3 as YAML
100-
var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic);
82+
var (openApiDocument, _) = await OpenApiDocument.LoadAsync("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/refs/heads/main/_archive_/schemas/v3.0/pass/petstore.yaml");
10183

10284
// Write V2 as JSON
103-
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
104-
85+
var outputString = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0);
10586
```
10687

10788
# Validating/Testing OpenAPI descriptions

release-please-config.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
"type": "xml",
2323
"path": "Directory.Build.props",
2424
"xpath": "//Project/PropertyGroup/Version"
25-
},
26-
{
27-
"type": "generic",
28-
"path": "README.md"
2925
}
3026
]
3127
}

0 commit comments

Comments
 (0)