Skip to content

Commit c7a58f0

Browse files
authored
Add warning for ASP.NET Core version < 10.0
- Remove trailing and unnecessary white space - Typo correction of British English `behaviour` to American English `behavior` - Fix basic markdown lint issues
1 parent 15ece47 commit c7a58f0

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

docs/upgrade-guide-2.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
---
2-
title: Upgrade guide to OpenAPI.NET 2.1
3-
description: Learn how to upgrade your OpenAPI.NET version from 1.6 to 2.0
2+
title: Upgrade guide to OpenAPI.NET 2.0
3+
description: Learn how to upgrade your OpenAPI.NET version from 1.6 to 2.0
44
author: rachit.malik
55
ms.author: malikrachit
66
ms.topic: conceptual
77
---
88

99
# Introduction
1010

11-
We are excited to announce the new version of the OpenAPI.NET library!
11+
We are excited to announce the new version of the OpenAPI.NET library!
1212
OpenAPI.NET v2 is a major update to the OpenAPI.NET library. This release includes a number of performance improvements, API enhancements, and support for OpenAPI v3.1.
1313

14+
> [!WARNING]
15+
> If you are using this library with ASP.NET Core version `< 10.0` then you must remain on version `1.x` as it's not compatible.
16+
1417
## The biggest update ever
1518

16-
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 .
19+
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.
1720

1821
## Performance Improvements
1922

2023
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.
2124

2225
In v1, instances of `$ref` were resolved in a second pass of the document to ensure the target of the reference has been parsed before attempting to resolve it. In v2, reference targets are lazily resolved when reference objects are accessed. This improves load time performance for documents that make heavy use of references.
2326

24-
[How does this change the behaviour of external references?]
27+
[How does this change the behavior of external references?]
2528

2629
### Results
2730

@@ -100,10 +103,10 @@ In OpenAPI v1, it was necessary to include the Microsoft.OpenApi.Readers library
100103
Once the dependency is added, the reader needs to be added to the reader settings as demonstrated below
101104

102105
```csharp
103-
var settings = new OpenApiReaderSettings();
106+
var settings = new OpenApiReaderSettings();
104107
settings.AddYamlReader();
105108

106-
var result = OpenApiDocument.LoadAsync(openApiString, settings: settings);
109+
var result = OpenApiDocument.LoadAsync(openApiString, settings: settings);
107110
```
108111

109112
## API Enhancements
@@ -130,7 +133,7 @@ var diagnostics = result.Diagnostics;
130133

131134
A `ReadResult` object acts as a tuple of `OpenApiDocument` and `OpenApiDiagnostic`.
132135

133-
The challenge with this approach is that the reader classes are not very discoverable and the behaviour is not actually consistent with the `*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.
136+
The challenge with this approach is that the reader classes are not very discoverable and the behavior is not actually consistent with the `*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.
134137

135138
In the v2 library we are moving to the pattern used by classes like `XDocument` where a set of static `Load` and `Parse` methods are used as factory methods.
136139

@@ -143,11 +146,11 @@ public class OpenApiDocument {
143146
}
144147
```
145148

146-
This API design allows a developer to use IDE autocomplete to present all the loading options by simply knowing the name of the `OpenApiDocument` class. Each of these methods are layered on top of the more primitive methods to ensure consistent behaviour.
149+
This API design allows a developer to use IDE autocomplete to present all the loading options by simply knowing the name of the `OpenApiDocument` class. Each of these methods are layered on top of the more primitive methods to ensure consistent behavior.
147150

148151
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 typed 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.
149152

150-
When the loading methods are used without a format parameter, 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.
153+
When the loading methods are used without a format parameter, 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.
151154

152155
### Additional exceptions
153156

@@ -349,6 +352,7 @@ public class OpenApiSchema : IMetadataContainer, IOpenApiExtensible, IOpenApiRef
349352
There are a number of new features in OpenAPI v3.1 that are now supported in OpenAPI.NET.
350353

351354
### JsonSchema Dialect and BaseUri in OpenApiDocument
355+
352356
To enable full compatibility with JSON Schema, the `OpenApiDocument` class now supports a `JsonSchemaDialect` property. This property specifies the JSON Schema dialect used throughout the document, using a URI. By explicitly declaring the dialect, tooling can be directed to use a JSON Schema version other than the default [2020-12 draft](https://json-schema.org/draft/2020-12/json-schema-core.html). However, OpenAPI.NET does not guarantee compatibility with versions other than 2020-12.
353357

354358
In addition, a `BaseUri` property has been added to represent the identity of the OpenAPI document. If the document’s identity is not provided or cannot be determined at based on its location, this property will be set to a generated placeholder URI.
@@ -510,7 +514,7 @@ string json = await document.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, OpenA
510514

511515
```csharp
512516
// Before (1.6)
513-
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json);
517+
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json);
514518

515519
// After (2.0)
516520
var outputString = await openApiDocument.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
@@ -521,6 +525,7 @@ var outputString = await openApiDocument.SerializeAsync(OpenApiSpecVersion.OpenA
521525
In v2.0, the Type property in `OpenApiSchema` is now defined as a flaggable enum, allowing consumers to swap nullable for type arrays.
522526

523527
**Example:**
528+
524529
```csharp
525530
// v1.6.x
526531
var schema = new OpenApiSchema
@@ -533,7 +538,7 @@ var schema = new OpenApiSchema
533538
// bitwise OR(|) - combines flags to allow multiple types
534539
var schema = new OpenApiSchema
535540
{
536-
Type = JsonSchemaType.String | JsonSchemaType.Null
541+
Type = JsonSchemaType.String | JsonSchemaType.Null
537542
}
538543

539544
// bitwise NOT(~) - inverts bits; filters out null flag
@@ -545,7 +550,7 @@ var schema = new OpenApiSchema
545550
// bitwise AND(&) - intersects flags to check for a specific type
546551
var schema = new OpenApiSchema
547552
{
548-
Type = (JsonSchemaType.String & JsonSchemaType.Null) == JsonSchemaType.Null
553+
Type = (JsonSchemaType.String & JsonSchemaType.Null) == JsonSchemaType.Null
549554
}
550555

551556
```
@@ -588,6 +593,7 @@ This resolver class has been removed in favor of a more streamlined resolution m
588593
### Visitor and Validator now pass an interface model
589594

590595
**Example:**
596+
591597
```csharp
592598
//v1.6.x
593599
public override void Visit(OpenApiParameter parameter){}
@@ -605,6 +611,7 @@ All the `IEffective` and `GetEffective` infrastructure in the models have been r
605611
Copy constructors for referenceable components have been made internal, a new `CreateShallowCopy()` method has been exposed on these models to facilitate cloning.
606612

607613
**Example:**
614+
608615
```csharp
609616
var schema = new OpenApiSchema();
610617
var schemaCopy = schema.CreateShallowCopy();
@@ -619,6 +626,7 @@ The redundant _style property on the Parameter model has been removed to simplif
619626
Discriminator mappings have been updated from using a `Dictionary<string, string>` to a `Dictionary<string, OpenApiSchemaReference>`. This change improves the handling of discriminator mappings by referencing OpenAPI schema components more explicitly, which enhances schema resolution.
620627

621628
**Example:**
629+
622630
```csharp
623631
// v1.6.x
624632
Discriminator = new()
@@ -660,5 +668,5 @@ OpenApiSchemaReference schemaRef = new OpenApiSchemaReference("MySchema")
660668

661669
## Feedback
662670

663-
If you have any feedback please file a GitHub issue [here](https://github.com/microsoft/OpenAPI.NET/issues)
671+
If you have any feedback please file [a new GitHub issue](https://github.com/microsoft/OpenAPI.NET/issues)
664672
The team is looking forward to hear your experience trying the new version and we hope you have fun busting out your OpenAPI 3.1 descriptions.

0 commit comments

Comments
 (0)