Skip to content

Commit 13c32b0

Browse files
authored
Standardize Serialize entry points, add IOpenApiSerializable, and remove IDictionary implementation (#94)
- Remove OpenApiElement abstract class. Use IOpenApiElement interface throughout to indicate this is an OpenAPI-related object. - Using IOpenApiElement allows us to inherit the dictionary-like objects (Paths, Responses, and SecurityRequirement) directly from the Dictionary<T1, T2> class without having to use IDictionary and re-implment all the dictionary functionalities. Because of this, OpenApiDictionary is no longer needed. - The objects in the spec (which are serializable with WriteAsV2 and WriteAsV3) are marked as IOpenApiSerializable. This allows us to still indicate IOpenApiAny as IOpenApiElement but we will not have to implement WriteAsV2 and WriteAsV3 for IOpenApiAny. - Standardize the entry point for serializing an Open API serializable element: WriteAsVX is changed to SerializeAsVX. The cutoff point between Write and Serialize is decided on what is being transformed and by whom: If the whole object is translated into a stream or string, we use Serialize terminology. If the writer (TextWriter) is just adding letters, then that's a Write action. - Serialize methods (to string) in the Test projects are moved to Core. Rename extensions and move to Extensions folder.
1 parent 4ddad20 commit 13c32b0

File tree

102 files changed

+532
-979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+532
-979
lines changed

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Company>Microsoft</Company>
77
<Product>Microsoft.OpenApi.Readers</Product>
88
<PackageId>Microsoft.OpenApi.Readers</PackageId>
9-
<Version>1.0.0-beta002</Version>
9+
<Version>1.0.0-beta003</Version>
1010
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1111
<AssemblyName>Microsoft.OpenApi.Readers</AssemblyName>
1212
<RootNamespace>Microsoft.OpenApi.Readers</RootNamespace>

src/Microsoft.OpenApi.Readers/V2/OpenApiContactDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using Microsoft.OpenApi.Any;
8+
using Microsoft.OpenApi.Extensions;
89
using Microsoft.OpenApi.Models;
910
using Microsoft.OpenApi.Readers.ParseNodes;
1011

src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Collections.Generic;
7+
using Microsoft.OpenApi.Extensions;
78
using Microsoft.OpenApi.Models;
89
using Microsoft.OpenApi.Readers.ParseNodes;
910

src/Microsoft.OpenApi.Readers/V2/OpenApiExampleDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6-
using Microsoft.OpenApi.Any;
6+
using Microsoft.OpenApi.Extensions;
77
using Microsoft.OpenApi.Models;
88
using Microsoft.OpenApi.Readers.ParseNodes;
99

src/Microsoft.OpenApi.Readers/V2/OpenApiInfoDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using Microsoft.OpenApi.Any;
9+
using Microsoft.OpenApi.Extensions;
910
using Microsoft.OpenApi.Models;
1011
using Microsoft.OpenApi.Readers.ParseNodes;
1112

src/Microsoft.OpenApi.Readers/V2/OpenApiLicenseDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using Microsoft.OpenApi.Any;
8+
using Microsoft.OpenApi.Extensions;
89
using Microsoft.OpenApi.Models;
910
using Microsoft.OpenApi.Readers.ParseNodes;
1011

src/Microsoft.OpenApi.Readers/V2/OpenApiOAuthFlowDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using Microsoft.OpenApi.Any;
8+
using Microsoft.OpenApi.Extensions;
89
using Microsoft.OpenApi.Models;
910
using Microsoft.OpenApi.Readers.ParseNodes;
1011

src/Microsoft.OpenApi.Readers/V2/OpenApiOAuthFlowsDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using Microsoft.OpenApi.Any;
7+
using Microsoft.OpenApi.Extensions;
78
using Microsoft.OpenApi.Models;
89
using Microsoft.OpenApi.Readers.ParseNodes;
910

src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Collections.Generic;
77
using System.Linq;
8+
using Microsoft.OpenApi.Extensions;
89
using Microsoft.OpenApi.Models;
910
using Microsoft.OpenApi.Readers.ParseNodes;
1011

src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using Microsoft.OpenApi.Extensions;
67
using Microsoft.OpenApi.Models;
78
using Microsoft.OpenApi.Readers.ParseNodes;
89

0 commit comments

Comments
 (0)