You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/images/upgrade-guide-2.md
+32-52Lines changed: 32 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ OpenAPI.NET v2 is a major update to the OpenAPI.NET library. This release includ
14
14
15
15
Since the release of the first version of the OpenAPI.NET library in 2018, there has not been a major version update to the library. With the addition of support for OpenAPI v3.1 it was necessary to make some breaking changes. With this opportunity, we have taken the time to make some other improvements to the library, based on the experience we have gained supporting a large community of users for the last six years .
16
16
17
-
##Performance Improvements
17
+
# Performance Improvements
18
18
19
19
One of the key features of OpenAPI.NET is its performance. This version makes it possible to parse JSON based OpenAPI descriptions even faster. OpenAPI.NET v1 relied on the excellent YamlSharp library for parsing both JSON and YAML files. With OpenAPI.NET v2 we are relying on System.Text.Json for parsing JSON files. For YAML files, we continue to use YamlSharp to parse YAML but then convert to JsonNodes for processing. This allows us to take advantage of the performance improvements in System.Text.Json while still supporting YAML files.
20
20
@@ -24,7 +24,7 @@ In v1, instances of `$ref` were resolved in a second pass of the document to ens
24
24
25
25
## Reduced Dependencies
26
26
27
-
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 readers 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.
27
+
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.
28
28
29
29
## API Enhancements
30
30
@@ -38,9 +38,9 @@ The same pattern can be used for `OpenApiStreamReader` and `OpenApiTextReader`.
A `ReadResult` object acts as a tuple of `OpenApiDiagnostic` and `OpenApiDocument`.
43
+
A `ReadResult` object acts as a tuple of `OpenApiDocument` and `OpenApiDiagnostic`.
44
44
45
45
The challenge with this approach is that the reader classes are not very discoverable and the behaviour is not actually consistent with `*TextReader` pattern that allows incrementally reading the document. This library does not support incrementally reading the OpenAPI Document. It only reads a complete document and returns an `OpenApiDocument` instance.
46
46
@@ -57,7 +57,7 @@ public class OpenApiDocument {
57
57
58
58
This API design allows a developer to use IDE autocomplete to present all the loading options by simply knowning the name of the `OpenApiDocument` class. Each of these methods are layered ontop of the more primitive methods to ensure consistent behaviour.
59
59
60
-
As the YAML format is only supported when including the `Microsoft.OpenApi.Readers` library it was decided not to use an enum for the `format` parameter. We are considering implementing a more [strongly type solution](https://github.com/microsoft/OpenAPI.NET/issues/1952) similar to the way that `HttpMethod` is implemented so that we have a strongly typed experience that is also extensible.
60
+
As the YAML format is only supported when including the `Microsoft.OpenApi.YamlReader` library it was decided not to use an enum for the `format` parameter. We are considering implementing a more [strongly type solution](https://github.com/microsoft/OpenAPI.NET/issues/1952) similar to the way that `HttpMethod` is implemented so that we have a strongly typed experience that is also extensible.
61
61
62
62
Where the loading methods are used without a format property, we will attempt to parse the document using the default JSON reader. If that fails and the Yaml reader is registered, then we will attempt to read as YAML. The goal is always to provide the fastest path with JSON but still maintain the convenience of not having to care whether a URL points to YAML or JSON if you need that flexibility.
63
63
@@ -138,22 +138,22 @@ The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema
138
138
139
139
```csharp
140
140
/// $schema, a JSON Schema dialect identifier. Value must be a URI
141
-
publicvirtualstringSchema { get; set; }
141
+
publicstringSchema { get; set; }
142
142
/// $id - Identifies a schema resource with its canonical URI.
143
-
publicvirtualstringId { get; set; }
143
+
publicstringId { get; set; }
144
144
/// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema.
145
-
publicvirtualstringComment { get; set; }
145
+
publicstringComment { get; set; }
146
146
/// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
/// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance
149
-
publicvirtualstringDynamicRef { get; set; }
149
+
publicstringDynamicRef { get; set; }
150
150
/// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing.
151
-
publicvirtualstringDynamicAnchor { get; set; }
151
+
publicstringDynamicAnchor { get; set; }
152
152
/// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema.
0 commit comments