Skip to content

Commit 1502f72

Browse files
authored
Merge pull request #2441 from microsoft/docs/upgrade-guide-updates
docs: minor updates to the upgrade guide
2 parents 555639d + 3cab6f9 commit 1502f72

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

docs/upgrade-guide-2.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.topic: conceptual
88

99
# Introduction
1010

11-
We are excited to announce the preview of a 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

1414
## The biggest update ever
@@ -86,11 +86,11 @@ var mySchema = new OpenApiSchema();
8686
mySchema.AnyOf.Add(otherSchema);
8787

8888
// one solution
89-
mySchema.AnyOf ??= [];
89+
mySchema.AnyOf ??= new List<IOpenApiSchema>();
9090
mySchema.AnyOf.Add(otherSchema);
9191

9292
// alternative
93-
mySchema.AnyOf = [otherSchema];
93+
mySchema.AnyOf = new List<IOpenApiSchema> { otherSchema };
9494
```
9595

9696
## Reduced Dependencies
@@ -251,7 +251,7 @@ parameter.Extensions.Add("x-foo", new JsonNodeExtension(openApiObject));
251251
252252
### Enable Null Reference Type Support
253253

254-
Version 2.0 preview 13 introduces support for null reference types, which improves type safety and reduces the likelihood of null reference exceptions.
254+
Version 2.0 introduces support for null reference types, which improves type safety and reduces the likelihood of null reference exceptions.
255255

256256
**Example:**
257257

@@ -266,19 +266,6 @@ var document = new OpenApiDocument
266266
var componentA = document.Components["A"];
267267
```
268268

269-
### Collections are implementations
270-
271-
Any collection used by the model now documents using the implementation type instead of the interface. This facilitates the usage of new language features such as collections initialization.
272-
273-
```csharp
274-
var schema = new OpenApiSchema();
275-
276-
// 1.X: does not compile due to the lack of implementation type
277-
// 2.X: compiles successfully
278-
schema.AnyOf = [];
279-
// now a List<OpenApiSchema> instead of IList<OpenApiSchema>
280-
```
281-
282269
### Ephemeral object properties are now in Metadata
283270

284271
In version 1.X applications could add ephemeral properties to some of the models from the libraries. These properties would be carried along in an "Annotations" property, but not serialized. This is especially helpful when building integrations that build document in multiple phases and need additional context to complete the work. The property is now named metadata to avoid any confusion with other terms. The parent interface has also been renamed from `IOpenApiAnnotatable` to `IMetadataContainer`.
@@ -432,7 +419,7 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible
432419
/// <summary>
433420
/// An object to hold reusable <see cref="OpenApiPathItem"/> Object.
434421
/// </summary>
435-
public IDictionary<string, OpenApiPathItem>? PathItems { get; set; } = new Dictionary<string, OpenApiPathItem>();
422+
public IDictionary<string, OpenApiPathItem>? PathItems { get; set; }
436423
}
437424
```
438425

@@ -441,7 +428,7 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible
441428
Through the use of proxy objects in order to represent references, it is now possible to set the Summary and Description property on an object that is a reference. This was previously not possible.
442429

443430
```csharp
444-
var parameter = new OpenApiParameterReference("id", hostdocument)
431+
var parameter = new OpenApiParameterReference("id", hostDocument)
445432
{
446433
Description = "Customer Id"
447434
};
@@ -511,7 +498,7 @@ The `SerializeAs()` method simplifies serialization scenarios, making it easier
511498

512499
```csharp
513500
OpenApiDocument document = new OpenApiDocument();
514-
string json = document.SerializeAs(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json);
501+
string json = await document.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, OpenApiConstants.Json);
515502

516503
```
517504

@@ -526,7 +513,7 @@ string json = document.SerializeAs(OpenApiSpecVersion.OpenApi3_0, OpenApiConstan
526513
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json);
527514

528515
// After (2.0)
529-
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
516+
var outputString = await openApiDocument.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
530517
```
531518

532519
### OpenApiSchema's Type property is now a flaggable enum

0 commit comments

Comments
 (0)