diff --git a/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV2Deserializer.cs b/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV2Deserializer.cs
index f852cae9c..379f77ebb 100644
--- a/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV2Deserializer.cs
+++ b/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV2Deserializer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.OpenApi.Readers.YamlReaders.ParseNodes;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi.Readers.YamlReaders
{
diff --git a/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV3Deserializer.cs b/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV3Deserializer.cs
index d1793575c..10b46b744 100644
--- a/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV3Deserializer.cs
+++ b/src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiV3Deserializer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.OpenApi.Readers.YamlReaders.ParseNodes;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi.Readers.YamlReaders
{
diff --git a/src/Microsoft.OpenApi/Any/IOpenApiAny.cs b/src/Microsoft.OpenApi/Any/IOpenApiAny.cs
index 1e99f7773..f8ff6518d 100644
--- a/src/Microsoft.OpenApi/Any/IOpenApiAny.cs
+++ b/src/Microsoft.OpenApi/Any/IOpenApiAny.cs
@@ -1,26 +1,44 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
+ ///
+ /// Any type kind.
+ ///
public enum AnyTypeKind
{
- None,
-
+ ///
+ /// Primitive.
+ ///
Primitive,
+ ///
+ /// Null.
+ ///
Null,
+ ///
+ /// Array.
+ ///
Array,
+ ///
+ /// Object.
+ ///
Object
}
+ ///
+ /// Base interface for the Open Api Any.
+ ///
public interface IOpenApiAny
{
+ ///
+ /// Any type kind.
+ ///
AnyTypeKind AnyKind { get; }
}
}
diff --git a/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs
new file mode 100644
index 000000000..f711ba58e
--- /dev/null
+++ b/src/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
+
+namespace Microsoft.OpenApi.Any
+{
+ ///
+ /// Primitive type kind.
+ ///
+ public enum PrimitiveTypeKind
+ {
+ ///
+ /// Integer
+ ///
+ Integer,
+
+ ///
+ /// Long
+ ///
+ Long,
+
+ ///
+ /// Float
+ ///
+ Float,
+
+ ///
+ /// Double
+ ///
+ Double,
+
+ ///
+ /// String
+ ///
+ String,
+
+ ///
+ /// Byte
+ ///
+ Byte,
+
+ ///
+ /// Binary
+ ///
+ Binary,
+
+ ///
+ /// Boolean
+ ///
+ Boolean,
+
+ ///
+ /// Date
+ ///
+ Date,
+
+ ///
+ /// DateTime
+ ///
+ DateTime,
+
+ ///
+ /// Password
+ ///
+ Password
+ }
+
+ ///
+ /// Base interface for the Primitive type.
+ ///
+ public interface IOpenApiPrimitive : IOpenApiAny
+ {
+ ///
+ /// Primitive type kind.
+ ///
+ PrimitiveTypeKind PrimitiveKind { get; }
+ }
+}
diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs
index 6e7760e93..30904a82e 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs
@@ -1,12 +1,11 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
using System.Collections.Generic;
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiArray : List, IOpenApiAny
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiBinary.cs b/src/Microsoft.OpenApi/Any/OpenApiBinary.cs
index 0abec2348..39fe79cba 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiBinary.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiBinary.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiBinary : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs b/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs
index 60331a222..9ce5c8b21 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiBoolean.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiBoolean : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiByte.cs b/src/Microsoft.OpenApi/Any/OpenApiByte.cs
index 14e51965c..b3bc33f21 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiByte.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiByte.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiByte : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiDate.cs b/src/Microsoft.OpenApi/Any/OpenApiDate.cs
index 01a21d2a7..2c4df1d7f 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiDate.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiDate.cs
@@ -1,12 +1,11 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
using System;
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiDate : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs b/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs
index f11d44be5..eddd40c46 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiDateTime.cs
@@ -1,12 +1,11 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
using System;
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiDateTime : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiDouble.cs b/src/Microsoft.OpenApi/Any/OpenApiDouble.cs
index cb5323330..2a0fc66db 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiDouble.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiDouble.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiDouble : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiFloat.cs b/src/Microsoft.OpenApi/Any/OpenApiFloat.cs
index 65102542e..3a8b17ee8 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiFloat.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiFloat.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiFloat : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiInteger.cs b/src/Microsoft.OpenApi/Any/OpenApiInteger.cs
index 285f741be..337b32570 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiInteger.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiInteger.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiInteger : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiLong.cs b/src/Microsoft.OpenApi/Any/OpenApiLong.cs
index 9fc6aac59..0ce9797e1 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiLong.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiLong.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiLong : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiNull.cs b/src/Microsoft.OpenApi/Any/OpenApiNull.cs
index 410f8ab9b..33128f049 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiNull.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiNull.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiNull : IOpenApiAny
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiObject.cs b/src/Microsoft.OpenApi/Any/OpenApiObject.cs
index a673dc60e..26dc94993 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs
@@ -1,12 +1,11 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
using System.Collections.Generic;
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiObject : Dictionary, IOpenApiAny
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiPassword.cs b/src/Microsoft.OpenApi/Any/OpenApiPassword.cs
index e2c315dd6..fdbe06896 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiPassword.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiPassword.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiPassword : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs
index c85a6c1ad..72951ea62 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs
@@ -1,27 +1,11 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
- public enum PrimitiveTypeKind
- {
- Integer,
- Long,
- Float,
- Double,
- String,
- Byte,
- Binary,
- Boolean,
- Date,
- DateTime,
- Password
- }
-
- public abstract class OpenApiPrimitive : IOpenApiAny
+ public abstract class OpenApiPrimitive : IOpenApiPrimitive
{
public AnyTypeKind AnyKind { get; } = AnyTypeKind.Primitive;
diff --git a/src/Microsoft.OpenApi/Any/OpenApiString.cs b/src/Microsoft.OpenApi/Any/OpenApiString.cs
index 8f3c0fc34..c1f4fe464 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiString.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiString.cs
@@ -1,10 +1,9 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace Microsoft.OpenApi
+namespace Microsoft.OpenApi.Any
{
public class OpenApiString : OpenApiPrimitive
{
diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs
index 4b078bee0..989852f14 100644
--- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs
+++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs
@@ -4,6 +4,7 @@
//
//---------------------------------------------------------------------
+using Microsoft.OpenApi.Any;
using System.Collections.Generic;
namespace Microsoft.OpenApi
diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs
index 1a837a7cc..91ebff730 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs
index f03a45ac3..18f547c85 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs
index 2e92320a0..dceba76dc 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
index 606801d9b..a178aaa4c 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs
@@ -4,6 +4,7 @@
//
//---------------------------------------------------------------------
+using Microsoft.OpenApi.Any;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
index 7f2c0b092..6d0a9aedd 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
index 7095f8602..fb66f1835 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
index 8423d3db0..2d7089c73 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs
index 1936b8b54..8ff4f937b 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs
index be280f2f3..4beb59a19 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs
index acef64ef2..44a73ba42 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
index fcf6aa7c3..25777e294 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs
index 854addcc6..5ec22dd7f 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs
index 501a82fc6..5a13574dd 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
index 11b01de2b..27daaa566 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
index 1aa9fb35b..132930108 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
index 0d8803790..cfc2291f2 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
index 61886d2be..4e3d39965 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs
@@ -6,6 +6,7 @@
using System.Collections;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs
index b7ed7dafa..86303441d 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs
index 707717391..1da76feeb 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
index 4f1eb9d1d..324594407 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs
index 2d99a391a..a61eef269 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs
index df2bf585a..68f9d5354 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs
index d26f5e23d..f35a37870 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs
index d671ae1e9..89980abfb 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs
@@ -5,6 +5,7 @@
//---------------------------------------------------------------------
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs
index a593b60c4..620522db1 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
namespace Microsoft.OpenApi
{
diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
new file mode 100644
index 000000000..873e2dde6
--- /dev/null
+++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
@@ -0,0 +1,196 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System.Collections.Generic;
+using Microsoft.OpenApi.Any;
+
+namespace Microsoft.OpenApi.Writers
+{
+ ///
+ /// Extensions methods for writing the
+ ///
+ public static class OpenApiWriterAnyExtensions
+ {
+ ///
+ /// Write the specification extensions
+ ///
+ /// The Open API writer.
+ /// The specification extensions.
+ public static void WriteExtensions(this IOpenApiWriter writer, IDictionary extensions)
+ {
+ if (writer == null)
+ {
+ throw Error.ArgumentNull(nameof(writer));
+ }
+
+ if (extensions != null)
+ {
+ foreach (var item in extensions)
+ {
+ writer.WritePropertyName(item.Key);
+ writer.WriteAny(item.Value);
+ }
+ }
+ }
+
+ ///
+ /// Write the value.
+ ///
+ /// The Open API Any type.
+ /// The Open API writer.
+ /// The Any value
+ public static void WriteAny(this IOpenApiWriter writer, T any) where T : IOpenApiAny
+ {
+ if (writer == null)
+ {
+ throw Error.ArgumentNull(nameof(writer));
+ }
+
+ if (any == null)
+ {
+ writer.WriteNull();
+ }
+
+ switch (any.AnyKind)
+ {
+ case AnyTypeKind.Array: // Array
+ writer.WriteArray(any as OpenApiArray);
+ break;
+
+ case AnyTypeKind.Object: // Object
+ writer.WriteObject(any as OpenApiObject);
+ break;
+
+ case AnyTypeKind.Primitive: // Primitive
+ writer.WritePrimitive(any as IOpenApiPrimitive);
+ break;
+
+ case AnyTypeKind.Null: // null
+ writer.WriteNull();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private static void WriteArray(this IOpenApiWriter writer, OpenApiArray array)
+ {
+ if (writer == null)
+ {
+ throw Error.ArgumentNull(nameof(writer));
+ }
+
+ if (array == null)
+ {
+ throw Error.ArgumentNull(nameof(array));
+ }
+
+ writer.WriteStartArray();
+
+ foreach (var item in array)
+ {
+ writer.WriteAny(item);
+ }
+
+ writer.WriteEndArray();
+ }
+
+ private static void WriteObject(this IOpenApiWriter writer, OpenApiObject entity)
+ {
+ if (writer == null)
+ {
+ throw Error.ArgumentNull(nameof(writer));
+ }
+
+ if (entity == null)
+ {
+ throw Error.ArgumentNull(nameof(entity));
+ }
+
+ writer.WriteStartObject();
+
+ foreach (var item in entity)
+ {
+ writer.WritePropertyName(item.Key);
+ writer.WriteAny(item.Value);
+ }
+
+ writer.WriteEndObject();
+ }
+
+ private static void WritePrimitive(this IOpenApiWriter writer, IOpenApiPrimitive primitive)
+ {
+ if (writer == null)
+ {
+ throw Error.ArgumentNull(nameof(writer));
+ }
+
+ if (primitive == null)
+ {
+ throw Error.ArgumentNull(nameof(primitive));
+ }
+
+ switch (primitive.PrimitiveKind)
+ {
+ case PrimitiveTypeKind.Integer:
+ OpenApiInteger intValue = (OpenApiInteger)primitive;
+ writer.WriteValue(intValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Long:
+ OpenApiLong longValue = (OpenApiLong)primitive;
+ writer.WriteValue(longValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Float:
+ OpenApiFloat floatValue = (OpenApiFloat)primitive;
+ writer.WriteValue(floatValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Double:
+ OpenApiDouble doubleValue = (OpenApiDouble)primitive;
+ writer.WriteValue(doubleValue.Value);
+ break;
+
+ case PrimitiveTypeKind.String:
+ OpenApiString stringValue = (OpenApiString)primitive;
+ writer.WriteValue(stringValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Byte:
+ OpenApiByte byteValue = (OpenApiByte)primitive;
+ writer.WriteValue(byteValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Binary:
+ OpenApiBinary binaryValue = (OpenApiBinary)primitive;
+ writer.WriteValue(binaryValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Boolean:
+ OpenApiBoolean boolValue = (OpenApiBoolean)primitive;
+ writer.WriteValue(boolValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Date:
+ OpenApiDate dateValue = (OpenApiDate)primitive;
+ writer.WriteValue(dateValue.Value);
+ break;
+
+ case PrimitiveTypeKind.DateTime:
+ OpenApiDateTime dateTimeValue = (OpenApiDateTime)primitive;
+ writer.WriteValue(dateTimeValue.Value);
+ break;
+
+ case PrimitiveTypeKind.Password:
+ OpenApiPassword passwordValue = (OpenApiPassword)primitive;
+ writer.WriteValue(passwordValue.Value);
+ break;
+
+ default:
+ throw new OpenApiException("Not supported primitive type.");
+ }
+ }
+ }
+}
diff --git a/test/Microsoft.OpenApi.Tests/ExampleTests.cs b/test/Microsoft.OpenApi.Tests/ExampleTests.cs
index 8f4d8dc85..6ffc11f80 100644
--- a/test/Microsoft.OpenApi.Tests/ExampleTests.cs
+++ b/test/Microsoft.OpenApi.Tests/ExampleTests.cs
@@ -1,15 +1,15 @@
-using Microsoft.OpenApi;
-using Microsoft.OpenApi.Readers;
-using Microsoft.OpenApi.Writers;
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
+
using SharpYaml.Serialization;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using Microsoft.OpenApi.Readers.YamlReaders;
+using Microsoft.OpenApi.Writers;
using Xunit;
-namespace OpenApi.Tests
+namespace Microsoft.OpenApi.Tests
{
public class ExampleTests
{
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 606813e27..ce2c5fbd8 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -47,6 +47,7 @@
+
diff --git a/test/Microsoft.OpenApi.Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/OpenApiDocumentTests.cs
index d8fc2afbe..254076f3c 100644
--- a/test/Microsoft.OpenApi.Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Tests/OpenApiDocumentTests.cs
@@ -1,20 +1,15 @@
-using Microsoft.OpenApi;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
-namespace OpenApi.Tests
+namespace Microsoft.OpenApi.Tests
{
public class OpenApiDocumentTests
{
-
public void CreateEmptyDocument()
{
var doc = new OpenApiDocument();
-
-
}
}
}
diff --git a/test/Microsoft.OpenApi.Tests/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/OpenApiExternalDocsTests.cs
index 8688c5f6b..ec5ea454a 100644
--- a/test/Microsoft.OpenApi.Tests/OpenApiExternalDocsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/OpenApiExternalDocsTests.cs
@@ -1,8 +1,7 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
using System;
diff --git a/test/Microsoft.OpenApi.Tests/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/OpenApiTagTests.cs
index 7a3e2facf..1c5faa3b4 100644
--- a/test/Microsoft.OpenApi.Tests/OpenApiTagTests.cs
+++ b/test/Microsoft.OpenApi.Tests/OpenApiTagTests.cs
@@ -1,8 +1,7 @@
-//---------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
-//
-//---------------------------------------------------------------------
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
namespace Microsoft.OpenApi.Tests
{
diff --git a/test/Microsoft.OpenApi.Tests/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/OpenApiWriterAnyExtensionsTests.cs
new file mode 100644
index 000000000..362398366
--- /dev/null
+++ b/test/Microsoft.OpenApi.Tests/OpenApiWriterAnyExtensionsTests.cs
@@ -0,0 +1,140 @@
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
+
+using System.IO;
+using Microsoft.OpenApi.Any;
+using Microsoft.OpenApi.Writers;
+using Xunit;
+
+namespace Microsoft.OpenApi.Tests
+{
+ public class OpenApiWriterAnyExtensionsTests
+ {
+ [Fact]
+ public void WriteOpenApiNullAsJsonWorks()
+ {
+ // Arrange
+ OpenApiNull nullValue = new OpenApiNull();
+
+ // Act
+ string json = WriteAsJson(nullValue);
+
+ // Assert
+ Assert.Equal("null", json);
+ }
+
+ [Fact]
+ public void WriteOpenApiIntergerAsJsonWorks()
+ {
+ // Arrange
+ OpenApiInteger intValue = new OpenApiInteger(42);
+
+ // Act
+ string json = WriteAsJson(intValue);
+
+ // Assert
+ Assert.Equal("42", json);
+ }
+
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public void WriteOpenApiBooleanAsJsonWorks(bool input)
+ {
+ // Arrange
+ OpenApiBoolean boolValue = new OpenApiBoolean(input);
+
+ // Act
+ string json = WriteAsJson(boolValue);
+
+ // Assert
+ Assert.Equal(input.ToString().ToLower(), json);
+ }
+
+ private static OpenApiObject openApiObject = new OpenApiObject
+ {
+ { "stringProp", new OpenApiString("stringValue1") },
+ { "objProp", new OpenApiObject() },
+ {
+ "arrayProp",
+ new OpenApiArray
+ {
+ new OpenApiBoolean(false)
+ }
+ }
+ };
+
+ [Fact]
+ public void WriteOpenApiObjectAsJsonWorks()
+ {
+ // Arrange
+ string expect = @"
+{
+ ""stringProp"": ""stringValue1"",
+ ""objProp"": { },
+ ""arrayProp"": [
+ false
+ ]
+}";
+
+ // Act
+ string json = WriteAsJson(openApiObject);
+
+ // Assert
+ Assert.Equal(expect, json);
+ }
+
+ [Fact]
+ public void WriteOpenApiArrayAsJsonWorks()
+ {
+ // Arrange
+ string expect = @"
+[
+ false,
+ {
+ ""stringProp"": ""stringValue1"",
+ ""objProp"": { },
+ ""arrayProp"": [
+ false
+ ]
+ },
+ ""stringValue2""
+]";
+
+ OpenApiArray array = new OpenApiArray
+ {
+ new OpenApiBoolean(false),
+ openApiObject,
+ new OpenApiString("stringValue2")
+ };
+
+ // Act
+ string json = WriteAsJson(array);
+
+ // Assert
+ Assert.Equal(expect, json);
+ }
+
+ private static string WriteAsJson(IOpenApiAny any)
+ {
+ MemoryStream stream = new MemoryStream();
+ IOpenApiWriter writer = new OpenApiJsonWriter(new StreamWriter(stream));
+ writer.WriteAny(any);
+ writer.Flush();
+ stream.Position = 0;
+ string value = new StreamReader(stream).ReadToEnd();
+
+ if (any.AnyKind == AnyTypeKind.Primitive || any.AnyKind == AnyTypeKind.Null)
+ {
+ return value;
+ }
+ else
+ {
+ // add "\r\n" at the head because the expect string has a newline at starting.
+ return "\r\n" + value.Replace("\n", "\r\n");
+ }
+ }
+ }
+}
diff --git a/test/Microsoft.OpenApi.Tests/ValidationTests.cs b/test/Microsoft.OpenApi.Tests/ValidationTests.cs
index 716a5680f..c0f398673 100644
--- a/test/Microsoft.OpenApi.Tests/ValidationTests.cs
+++ b/test/Microsoft.OpenApi.Tests/ValidationTests.cs
@@ -1,13 +1,12 @@
-using Microsoft.OpenApi;
+// ------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
+// ------------------------------------------------------------
+
using Microsoft.OpenApi.Sevices;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Xunit;
-namespace OpenApi.Tests
+namespace Microsoft.OpenApi.Tests
{
public class ValidationTests
{