diff --git a/src/Microsoft.OpenApi/Any/OpenApiAny.cs b/src/Microsoft.OpenApi/Any/OpenApiAny.cs
index bee1239fb..54bddf326 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiAny.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiAny.cs
@@ -35,7 +35,7 @@ public OpenApiAny(JsonNode jsonNode)
///
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
{
- writer.WriteAny(new OpenApiAny(Node));
+ writer.WriteAny(Node);
}
}
}
diff --git a/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs b/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs
index 9f89ddc11..d6e9cb9df 100644
--- a/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs
+++ b/src/Microsoft.OpenApi/Helpers/JsonNodeCloneHelper.cs
@@ -15,16 +15,16 @@ internal static class JsonNodeCloneHelper
ReferenceHandler = ReferenceHandler.IgnoreCycles
};
- internal static OpenApiAny Clone(OpenApiAny value)
+ internal static JsonNode Clone(JsonNode value)
{
- var jsonString = Serialize(value?.Node);
+ var jsonString = Serialize(value);
if (string.IsNullOrEmpty(jsonString))
{
return null;
}
var result = JsonSerializer.Deserialize(jsonString, options);
- return new OpenApiAny(result);
+ return result;
}
private static string Serialize(object obj)
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs
index b2ffa1fe4..a5bae9fa9 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiDeprecationExtension.cs
@@ -77,9 +77,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// The source object.
/// The .
/// When the source element is not an object
- public static OpenApiDeprecationExtension Parse(OpenApiAny source)
+ public static OpenApiDeprecationExtension Parse(JsonNode source)
{
- if (source.Node is not JsonObject rawObject) return null;
+ if (source is not JsonObject rawObject) return null;
var extension = new OpenApiDeprecationExtension();
if (rawObject.TryGetPropertyValue(nameof(RemovalDate).ToFirstCharacterLowerCase(), out var removalDate) && removalDate is JsonNode removalDateValue)
extension.RemovalDate = removalDateValue.GetValue();
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumFlagsExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumFlagsExtension.cs
index 26bb0b29c..9cbae6350 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumFlagsExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumFlagsExtension.cs
@@ -1,4 +1,4 @@
-// ------------------------------------------------------------
+// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
@@ -44,9 +44,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// The source element to parse.
/// The .
/// When the source element is not an object
- public static OpenApiEnumFlagsExtension Parse(OpenApiAny source)
+ public static OpenApiEnumFlagsExtension Parse(JsonNode source)
{
- if (source.Node is not JsonObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
+ if (source is not JsonObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
var extension = new OpenApiEnumFlagsExtension();
if (rawObject.TryGetPropertyValue(nameof(IsFlags).ToFirstCharacterLowerCase(), out var flagsValue) && flagsValue is JsonNode isFlags)
{
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs
index f657d6459..1235e68b0 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiEnumValuesDescriptionExtension.cs
@@ -63,9 +63,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// The source element to parse.
/// The .
/// When the source element is not an object
- public static OpenApiEnumValuesDescriptionExtension Parse(OpenApiAny source)
+ public static OpenApiEnumValuesDescriptionExtension Parse(JsonNode source)
{
- if (source.Node is not JsonObject rawObject) return null;
+ if (source is not JsonObject rawObject) return null;
var extension = new OpenApiEnumValuesDescriptionExtension();
if (rawObject.TryGetPropertyValue("values", out var values) && values is JsonArray valuesArray)
{
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs
index b4d086edc..f64eebf3f 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPagingExtension.cs
@@ -72,9 +72,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// The source element to parse.
/// The .
/// When the source element is not an object
- public static OpenApiPagingExtension Parse(OpenApiAny source)
+ public static OpenApiPagingExtension Parse(JsonNode source)
{
- if (source.Node is not JsonObject rawObject) return null;
+ if (source is not JsonObject rawObject) return null;
var extension = new OpenApiPagingExtension();
if (rawObject.TryGetPropertyValue(nameof(NextLinkName).ToFirstCharacterLowerCase(), out var nextLinkName) && nextLinkName is JsonNode nextLinkNameStr)
{
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs
index dfa48ba85..ad47db39b 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtension.cs
@@ -38,9 +38,9 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
///
/// The source object.
/// The .
- public static OpenApiPrimaryErrorMessageExtension Parse(OpenApiAny source)
+ public static OpenApiPrimaryErrorMessageExtension Parse(JsonNode source)
{
- if (source.Node is not JsonNode rawObject) return null;
+ if (source is not JsonNode rawObject) return null;
return new()
{
IsPrimaryErrorMessage = rawObject.GetValue()
diff --git a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs
index 0839ba945..2d3a8c117 100644
--- a/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs
+++ b/src/Microsoft.OpenApi/MicrosoftExtensions/OpenApiReservedParameterExtension.cs
@@ -40,9 +40,9 @@ public bool? IsReserved
/// The source object.
/// The .
///
- public static OpenApiReservedParameterExtension Parse(OpenApiAny source)
+ public static OpenApiReservedParameterExtension Parse(JsonNode source)
{
- if (source.Node is not JsonNode rawBoolean) return null;
+ if (source is not JsonNode rawBoolean) return null;
return new()
{
IsReserved = rawBoolean.GetValue()
diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
index b0e76ca90..785477c9d 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Helpers;
using Microsoft.OpenApi.Interfaces;
@@ -31,7 +32,7 @@ public class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible
/// exclusive. To represent examples of media types that cannot naturally represented
/// in JSON or YAML, use a string value to contain the example, escaping where necessary.
///
- public virtual OpenApiAny Value { get; set; }
+ public virtual JsonNode Value { get; set; }
///
/// A URL that points to the literal example.
diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
index 799d4314a..315382a4d 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Helpers;
@@ -77,7 +78,7 @@ public virtual OpenApiSchema Schema
///
/// Example of the media type.
///
- public virtual OpenApiAny Example { get; set; }
+ public virtual JsonNode Example { get; set; }
///
/// Examples of the media type.
diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
index 8c0ecd4ec..806632bda 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Helpers;
using Microsoft.OpenApi.Interfaces;
@@ -30,7 +31,7 @@ public virtual OpenApiSchema Schema
/// Example of the media type.
/// The example object SHOULD be in the correct format as specified by the media type.
///
- public OpenApiAny Example { get; set; }
+ public JsonNode Example { get; set; }
///
/// Examples of the media type.
diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
index 69f6201a2..1b1514733 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Helpers;
@@ -130,7 +131,7 @@ public virtual OpenApiSchema Schema
/// To represent examples of media types that cannot naturally be represented in JSON or YAML,
/// a string value can contain the example with escaping where necessary.
///
- public virtual OpenApiAny Example { get; set; }
+ public virtual JsonNode Example { get; set; }
///
/// A map containing the representations for the parameter.
diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
index d2cf23506..90b3f9126 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
@@ -6,6 +6,7 @@
using System.Linq;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
+using Microsoft.OpenApi.Helpers;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
@@ -148,7 +149,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiReferenceable, IOpenApi
/// Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level.
/// For example, if type is string, then default can be "foo" but cannot be 1.
///
- public virtual OpenApiAny Default { get; set; }
+ public virtual JsonNode Default { get; set; }
///
/// Relevant only for Schema "properties" definitions. Declares the property as "read only".
@@ -269,7 +270,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiReferenceable, IOpenApi
/// To represent examples that cannot be naturally represented in JSON or YAML,
/// a string value can be used to contain the example with escaping where necessary.
///
- public virtual OpenApiAny Example { get; set; }
+ public virtual JsonNode Example { get; set; }
///
/// A free-form property to include examples of an instance for this schema.
@@ -359,7 +360,7 @@ public OpenApiSchema(OpenApiSchema schema)
MinLength = schema?.MinLength ?? MinLength;
Pattern = schema?.Pattern ?? Pattern;
MultipleOf = schema?.MultipleOf ?? MultipleOf;
- Default = schema?.Default != null ? new(schema?.Default.Node) : null;
+ Default = schema?.Default != null ? JsonNodeCloneHelper.Clone(schema?.Default) : null;
ReadOnly = schema?.ReadOnly ?? ReadOnly;
WriteOnly = schema?.WriteOnly ?? WriteOnly;
AllOf = schema?.AllOf != null ? new List(schema.AllOf) : null;
@@ -378,7 +379,7 @@ public OpenApiSchema(OpenApiSchema schema)
AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
- Example = schema?.Example != null ? new(schema?.Example.Node) : null;
+ Example = schema?.Example != null ? JsonNodeCloneHelper.Clone(schema?.Example) : null;
Examples = schema?.Examples != null ? new List(schema.Examples) : null;
Enum = schema?.Enum != null ? new List(schema.Enum) : null;
Nullable = schema?.Nullable ?? Nullable;
@@ -492,7 +493,7 @@ public void SerializeInternalWithoutReference(IOpenApiWriter writer, OpenApiSpec
writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => w.WriteValue(s));
// enum
- writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (nodeWriter, s) => nodeWriter.WriteAny(new OpenApiAny(s)));
+ writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (nodeWriter, s) => nodeWriter.WriteAny(s));
// type
if (Type?.GetType() == typeof(string))
@@ -605,7 +606,7 @@ internal void WriteV31Properties(IOpenApiWriter writer)
writer.WriteProperty(OpenApiConstants.V31ExclusiveMaximum, V31ExclusiveMaximum);
writer.WriteProperty(OpenApiConstants.V31ExclusiveMinimum, V31ExclusiveMinimum);
writer.WriteProperty(OpenApiConstants.UnevaluatedProperties, UnevaluatedProperties, false);
- writer.WriteOptionalCollection(OpenApiConstants.Examples, Examples, (nodeWriter, s) => nodeWriter.WriteAny(new OpenApiAny(s)));
+ writer.WriteOptionalCollection(OpenApiConstants.Examples, Examples, (nodeWriter, s) => nodeWriter.WriteAny(s));
writer.WriteOptionalMap(OpenApiConstants.PatternProperties, PatternProperties, (w, s) => s.SerializeAsV31(w));
}
@@ -701,7 +702,7 @@ internal void WriteAsItemsProperties(IOpenApiWriter writer)
writer.WriteProperty(OpenApiConstants.MinItems, MinItems);
// enum
- writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteAny(new OpenApiAny(s)));
+ writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteAny(s));
// multipleOf
writer.WriteProperty(OpenApiConstants.MultipleOf, MultipleOf);
@@ -780,7 +781,7 @@ internal void WriteAsSchemaProperties(
writer.WriteOptionalCollection(OpenApiConstants.Required, Required, (w, s) => w.WriteValue(s));
// enum
- writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteAny(new OpenApiAny(s)));
+ writer.WriteOptionalCollection(OpenApiConstants.Enum, Enum, (w, s) => w.WriteAny(s));
// items
writer.WriteOptionalObject(OpenApiConstants.Items, Items, (w, s) => s.SerializeAsV2(w));
diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs
index eeee360a9..feea24cea 100644
--- a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs
+++ b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
@@ -91,7 +92,7 @@ public override string Summary
public override string ExternalValue { get => Target.ExternalValue; set => Target.ExternalValue = value; }
///
- public override OpenApiAny Value { get => Target.Value; set => Target.Value = value; }
+ public override JsonNode Value { get => Target.Value; set => Target.Value = value; }
///
public override void SerializeAsV3(IOpenApiWriter writer)
diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs
index 64111c477..49f566966 100644
--- a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs
+++ b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
@@ -97,7 +98,7 @@ public override string Description
public override bool AllowReserved { get => Target.AllowReserved; set => Target.AllowReserved = value; }
///
- public override OpenApiAny Example { get => Target.Example; set => Target.Example = value; }
+ public override JsonNode Example { get => Target.Example; set => Target.Example = value; }
///
public override IDictionary Examples { get => Target.Examples; set => Target.Examples = value; }
diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs
index 488e054a4..f677ea0a1 100644
--- a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs
+++ b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
@@ -99,7 +100,7 @@ public override string Description
public override IDictionary Examples { get => Target.Examples; set => Target.Examples = value; }
///
- public override OpenApiAny Example { get => Target.Example; set => Target.Example = value; }
+ public override JsonNode Example { get => Target.Example; set => Target.Example = value; }
///
public override ParameterLocation? In { get => Target.In; set => Target.In = value; }
diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs
index 665120d2c..b4b2b639e 100644
--- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs
+++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs
@@ -122,7 +122,7 @@ public override string Description
///
public override decimal? MultipleOf { get => Target.MultipleOf; set => Target.MultipleOf = value; }
///
- public override OpenApiAny Default { get => Target.Default; set => Target.Default = value; }
+ public override JsonNode Default { get => Target.Default; set => Target.Default = value; }
///
public override bool ReadOnly { get => Target.ReadOnly; set => Target.ReadOnly = value; }
///
@@ -160,7 +160,7 @@ public override string Description
///
public override OpenApiDiscriminator Discriminator { get => Target.Discriminator; set => Target.Discriminator = value; }
///
- public override OpenApiAny Example { get => Target.Example; set => Target.Example = value; }
+ public override JsonNode Example { get => Target.Example; set => Target.Example = value; }
///
public override IList Examples { get => Target.Examples; set => Target.Examples = value; }
///
diff --git a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
index 705a14738..dca24c3e5 100644
--- a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
+++ b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
@@ -15,7 +15,7 @@ namespace Microsoft.OpenApi.Models
///
public class RuntimeExpressionAnyWrapper : IOpenApiElement
{
- private OpenApiAny _any;
+ private JsonNode _any;
private RuntimeExpression _expression;
///
@@ -35,7 +35,7 @@ public RuntimeExpressionAnyWrapper(RuntimeExpressionAnyWrapper runtimeExpression
///
/// Gets/Sets the
///
- public OpenApiAny Any
+ public JsonNode Any
{
get
{
diff --git a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs
index f821bb784..fa0040ff8 100644
--- a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs
+++ b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.MicrosoftExtensions;
@@ -49,7 +50,7 @@ public class OpenApiReaderSettings
///
/// Dictionary of parsers for converting extensions into strongly typed classes
///
- public Dictionary> ExtensionParsers { get; set; } = new();
+ public Dictionary> ExtensionParsers { get; set; } = new();
///
/// Rules to use for validating OpenAPI specification. If none are provided a default set of rules are applied.
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs
index 933040da6..ad8394b58 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMapParameter.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using System;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
@@ -13,8 +14,8 @@ internal class AnyFieldMapParameter
/// Constructor.
///
public AnyFieldMapParameter(
- Func propertyGetter,
- Action propertySetter,
+ Func propertyGetter,
+ Action propertySetter,
Func SchemaGetter = null)
{
this.PropertyGetter = propertyGetter;
@@ -25,12 +26,12 @@ public AnyFieldMapParameter(
///
/// Function to retrieve the value of the property.
///
- public Func PropertyGetter { get; }
+ public Func PropertyGetter { get; }
///
/// Function to set the value of the property.
///
- public Action PropertySetter { get; }
+ public Action PropertySetter { get; }
///
/// Function to get the schema to apply to the property.
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs
index b0c38247c..a4dc41b7f 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
@@ -15,8 +16,8 @@ internal class AnyMapFieldMapParameter
///
public AnyMapFieldMapParameter(
Func> propertyMapGetter,
- Func propertyGetter,
- Action propertySetter,
+ Func propertyGetter,
+ Action propertySetter,
Func schemaGetter)
{
this.PropertyMapGetter = propertyMapGetter;
@@ -33,12 +34,12 @@ public AnyMapFieldMapParameter(
///
/// Function to retrieve the value of the property from an inner element.
///
- public Func PropertyGetter { get; }
+ public Func PropertyGetter { get; }
///
/// Function to set the value of the property.
///
- public Action PropertySetter { get; }
+ public Action PropertySetter { get; }
///
/// Function to get the schema to apply to the property.
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs
index 306a2f559..6654344cd 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ListNode.cs
@@ -37,7 +37,7 @@ public override List CreateList(Func map, Ope
public override List CreateListOfAny()
{
- var list = _nodeList.Select(n => Create(Context, n).CreateAny().Node)
+ var list = _nodeList.Select(n => Create(Context, n).CreateAny())
.Where(i => i != null)
.ToList();
@@ -68,9 +68,9 @@ IEnumerator IEnumerable.GetEnumerator()
/// Create a
///
/// The created Any object.
- public override OpenApiAny CreateAny()
+ public override JsonNode CreateAny()
{
- return new OpenApiAny(_nodeList);
+ return _nodeList;
}
}
}
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs
index c251bce3c..919f1d85c 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs
@@ -171,9 +171,9 @@ public string GetScalarValue(ValueNode key)
/// Create an
///
/// The created Json object.
- public override OpenApiAny CreateAny()
+ public override JsonNode CreateAny()
{
- return new OpenApiAny(_node);
+ return _node;
}
}
}
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs
index 250581fbd..44d626f35 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs
@@ -67,7 +67,7 @@ public virtual Dictionary CreateSimpleMap(Func map)
throw new OpenApiReaderException("Cannot create simple map from this type of node.", Context);
}
- public virtual OpenApiAny CreateAny()
+ public virtual JsonNode CreateAny()
{
throw new OpenApiReaderException("Cannot create an Any object this type of node.", Context);
}
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs
index 9b59771d5..5f8031e87 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs
@@ -83,7 +83,7 @@ public void ParseField(
}
}
- public override OpenApiAny CreateAny()
+ public override JsonNode CreateAny()
{
throw new NotImplementedException();
}
diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs
index 1d74ff874..ec9fefde5 100644
--- a/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs
+++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ValueNode.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
@@ -32,9 +32,9 @@ public override string GetScalarValue()
/// Create a
///
/// The created Any object.
- public override OpenApiAny CreateAny()
+ public override JsonNode CreateAny()
{
- return new OpenApiAny(_node);
+ return _node;
}
}
}
diff --git a/src/Microsoft.OpenApi/Reader/ParsingContext.cs b/src/Microsoft.OpenApi/Reader/ParsingContext.cs
index 58b7151ed..f17e2aacb 100644
--- a/src/Microsoft.OpenApi/Reader/ParsingContext.cs
+++ b/src/Microsoft.OpenApi/Reader/ParsingContext.cs
@@ -29,7 +29,7 @@ public class ParsingContext
///
/// Extension parsers
///
- public Dictionary> ExtensionParsers { get; set; } =
+ public Dictionary> ExtensionParsers { get; set; } =
new();
internal RootNode RootNode { get; set; }
diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs
index 500f10353..5667b8f98 100644
--- a/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs
index 2823974de..60167f891 100644
--- a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs
index 06c6b4c1f..0bafab857 100644
--- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs
@@ -72,7 +72,7 @@ private static void ProcessAnyFields(
}
}
- public static OpenApiAny LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
+ public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
{
return node.CreateAny();
}
@@ -85,7 +85,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node)
}
else
{
- return node.CreateAny();
+ return new OpenApiAny(node.CreateAny());
}
}
diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs
index c382019f4..6fa8406bf 100644
--- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3Deserializer.cs
@@ -165,7 +165,7 @@ private static RuntimeExpressionAnyWrapper LoadRuntimeExpressionAnyWrapper(Parse
public static OpenApiAny LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
{
- return node.CreateAny();
+ return new OpenApiAny(node.CreateAny());
}
private static IOpenApiExtension LoadExtension(string name, ParseNode node)
@@ -177,7 +177,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node)
}
else
{
- return node.CreateAny();
+ return new OpenApiAny(node.CreateAny());
}
}
diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs
index 7ffc907fc..c2ef954a5 100644
--- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs
+++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Extensions;
diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs
index 33eb3e11e..a56590bf1 100644
--- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs
+++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs
@@ -128,7 +128,7 @@ private static RuntimeExpressionAnyWrapper LoadRuntimeExpressionAnyWrapper(Parse
};
}
- public static OpenApiAny LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
+ public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument = null)
{
return node.CreateAny();
}
@@ -137,7 +137,7 @@ private static IOpenApiExtension LoadExtension(string name, ParseNode node)
{
return node.Context.ExtensionParsers.TryGetValue(name, out var parser)
? parser(node.CreateAny(), OpenApiSpecVersion.OpenApi3_1)
- : node.CreateAny();
+ : new OpenApiAny(node.CreateAny());
}
private static string LoadString(ParseNode node)
diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs
index c422007a7..9cf54f65a 100644
--- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs
+++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
@@ -931,7 +932,7 @@ internal void Walk(IDictionary examples)
///
/// Visits and child objects
///
- internal void Walk(OpenApiAny example)
+ internal void Walk(JsonNode example)
{
if (example == null)
{
diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs
index cf983158e..4bc5aa94a 100644
--- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs
+++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs
@@ -25,7 +25,7 @@ public static class OpenApiHeaderRules
if (header.Example != null)
{
RuleHelpers.ValidateDataTypeMismatch(context,
- nameof(HeaderMismatchedDataType), header.Example.Node, header.Schema);
+ nameof(HeaderMismatchedDataType), header.Example, header.Schema);
}
context.Exit();
@@ -42,7 +42,7 @@ public static class OpenApiHeaderRules
context.Enter(key);
context.Enter("value");
RuleHelpers.ValidateDataTypeMismatch(context,
- nameof(HeaderMismatchedDataType), header.Examples[key]?.Value.Node, header.Schema);
+ nameof(HeaderMismatchedDataType), header.Examples[key]?.Value, header.Schema);
context.Exit();
context.Exit();
}
diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs
index 3b56bffd7..7ac09cbbf 100644
--- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs
+++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs
@@ -32,7 +32,7 @@ public static class OpenApiMediaTypeRules
if (mediaType.Example != null)
{
- RuleHelpers.ValidateDataTypeMismatch(context, nameof(MediaTypeMismatchedDataType), mediaType.Example.Node, mediaType.Schema);
+ RuleHelpers.ValidateDataTypeMismatch(context, nameof(MediaTypeMismatchedDataType), mediaType.Example, mediaType.Schema);
}
context.Exit();
@@ -48,7 +48,7 @@ public static class OpenApiMediaTypeRules
{
context.Enter(key);
context.Enter("value");
- RuleHelpers.ValidateDataTypeMismatch(context, nameof(MediaTypeMismatchedDataType), mediaType.Examples[key]?.Value.Node, mediaType.Schema);
+ RuleHelpers.ValidateDataTypeMismatch(context, nameof(MediaTypeMismatchedDataType), mediaType.Examples[key]?.Value, mediaType.Schema);
context.Exit();
context.Exit();
}
diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs
index 512c518ce..c6ad7835d 100644
--- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs
+++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs
@@ -70,7 +70,7 @@ public static class OpenApiParameterRules
if (parameter.Example != null)
{
- RuleHelpers.ValidateDataTypeMismatch(context, nameof(ParameterMismatchedDataType), parameter.Example.Node, parameter.Schema);
+ RuleHelpers.ValidateDataTypeMismatch(context, nameof(ParameterMismatchedDataType), parameter.Example, parameter.Schema);
}
context.Exit();
@@ -87,7 +87,7 @@ public static class OpenApiParameterRules
context.Enter(key);
context.Enter("value");
RuleHelpers.ValidateDataTypeMismatch(context,
- nameof(ParameterMismatchedDataType), parameter.Examples[key]?.Value.Node, parameter.Schema);
+ nameof(ParameterMismatchedDataType), parameter.Examples[key]?.Value, parameter.Schema);
context.Exit();
context.Exit();
}
diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs
index 5f75be881..e768e8d42 100644
--- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs
+++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs
@@ -25,7 +25,7 @@ public static class OpenApiSchemaRules
if (schema.Default != null)
{
- RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Default.Node, schema);
+ RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Default, schema);
}
context.Exit();
@@ -35,7 +35,7 @@ public static class OpenApiSchemaRules
if (schema.Example != null)
{
- RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Example.Node, schema);
+ RuleHelpers.ValidateDataTypeMismatch(context, nameof(SchemaMismatchedDataType), schema.Example, schema);
}
context.Exit();
diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
index 1d5dc720d..b0ef0a174 100644
--- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
+++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs
@@ -46,18 +46,17 @@ public static void WriteExtensions(this IOpenApiWriter writer, IDictionary value.
///
/// The Open API writer.
- /// The Any value
- public static void WriteAny(this IOpenApiWriter writer, OpenApiAny any)
+ /// The JsonNode value
+ public static void WriteAny(this IOpenApiWriter writer, JsonNode node)
{
Utils.CheckArgumentNull(writer);;
- if (any.Node == null)
+ if (node == null)
{
writer.WriteNull();
return;
}
- var node = any.Node;
var element = JsonDocument.Parse(node.ToJsonString()).RootElement;
switch (element.ValueKind)
{
@@ -90,7 +89,7 @@ private static void WriteArray(this IOpenApiWriter writer, JsonArray array)
foreach (var item in array)
{
- writer.WriteAny(new OpenApiAny(item));
+ writer.WriteAny(item);
}
writer.WriteEndArray();
@@ -103,7 +102,7 @@ private static void WriteObject(this IOpenApiWriter writer, JsonObject entity)
foreach (var item in entity)
{
writer.WritePropertyName(item.Key);
- writer.WriteAny(new OpenApiAny(item.Value));
+ writer.WriteAny(item.Value);
}
writer.WriteEndObject();
diff --git a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs
index 25af4cdae..9d7727aae 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/TestCustomExtension.cs
@@ -30,7 +30,7 @@ public void ParseCustomExtension()
var settings = new OpenApiReaderSettings
{
ExtensionParsers = { { "x-foo", (a,v) => {
- var fooNode = (JsonObject)a.Node;
+ var fooNode = (JsonObject)a;
return new FooExtension() {
Bar = (fooNode["bar"].ToString()),
Baz = (fooNode["baz"].ToString())
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
index a78bd1180..6a2411237 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
@@ -38,12 +38,12 @@ public void ParseHeaderWithDefaultShouldSucceed()
{
Type = "number",
Format = "float",
- Default = new OpenApiAny(5)
+ Default = new OpenApiAny(5).Node
}
},
options => options
.IgnoringCyclicReferences()
- .Excluding(x => x.Schema.Default.Node.Parent));
+ .Excluding(x => x.Schema.Default.Parent));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
index ad1ca897f..595631e29 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
@@ -321,12 +321,12 @@ public void ParseOperationWithResponseExamplesShouldSucceed()
Format = "float"
}
},
- Example = new OpenApiAny(new JsonArray()
+ Example = new JsonArray()
{
5.0,
6.0,
7.0
- })
+ }
},
["application/xml"] = new OpenApiMediaType()
{
@@ -344,12 +344,12 @@ public void ParseOperationWithResponseExamplesShouldSucceed()
}}
}
}, options => options.IgnoringCyclicReferences()
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[0].Parent)
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[0].Root)
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[1].Parent)
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[1].Root)
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[2].Parent)
- .Excluding(o => o.Responses["200"].Content["application/json"].Example.Node[2].Root));
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[0].Parent)
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[0].Root)
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[1].Parent)
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[1].Root)
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[2].Parent)
+ .Excluding(o => o.Responses["200"].Content["application/json"].Example[2].Root));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
index 9324c5132..e9eeaa054 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
@@ -231,9 +231,9 @@ public void ParseParameterWithDefaultShouldSucceed()
{
Type = "number",
Format = "float",
- Default = new OpenApiAny(5)
+ Default = new OpenApiAny(5).Node
}
- }, options => options.IgnoringCyclicReferences().Excluding(x => x.Schema.Default.Node.Parent));
+ }, options => options.IgnoringCyclicReferences().Excluding(x => x.Schema.Default.Parent));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
index a9b646040..4c66a67f8 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
@@ -37,8 +37,8 @@ public void ParseSchemaWithDefaultShouldSucceed()
{
Type = "number",
Format = "float",
- Default = new OpenApiAny(5)
- }, options => options.IgnoringCyclicReferences().Excluding(x => x.Default.Node.Parent));
+ Default = 5
+ }, options => options.IgnoringCyclicReferences().Excluding(x => x.Default.Parent));
}
[Fact]
@@ -60,8 +60,8 @@ public void ParseSchemaWithExampleShouldSucceed()
{
Type = "number",
Format = "float",
- Example = new OpenApiAny(5)
- }, options => options.IgnoringCyclicReferences().Excluding(x => x.Example.Node.Parent));
+ Example = 5
+ }, options => options.IgnoringCyclicReferences().Excluding(x => x.Example.Parent));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
index bd72ff78a..fa58fa5bc 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
@@ -1141,14 +1141,14 @@ public void HeaderParameterShouldAllowExample()
AllowReserved = true,
Style = ParameterStyle.Simple,
Explode = true,
- Example = new OpenApiAny("99391c7e-ad88-49ec-a2ad-99ddcb1f7721"),
+ Example = "99391c7e-ad88-49ec-a2ad-99ddcb1f7721",
Schema = new()
{
Type = "string",
Format = "uuid"
},
}, options => options.IgnoringCyclicReferences()
- .Excluding(e => e.Example.Node.Parent)
+ .Excluding(e => e.Example.Parent)
.Excluding(x => x.Reference));
var examplesHeader = result.OpenApiDocument.Components?.Headers?["examples-header"];
@@ -1167,12 +1167,12 @@ public void HeaderParameterShouldAllowExample()
{
{ "uuid1", new OpenApiExample()
{
- Value = new OpenApiAny("99391c7e-ad88-49ec-a2ad-99ddcb1f7721")
+ Value = "99391c7e-ad88-49ec-a2ad-99ddcb1f7721"
}
},
{ "uuid2", new OpenApiExample()
{
- Value = new OpenApiAny("99391c7e-ad88-49ec-a2ad-99ddcb1f7721")
+ Value = "99391c7e-ad88-49ec-a2ad-99ddcb1f7721"
}
}
},
@@ -1182,8 +1182,8 @@ public void HeaderParameterShouldAllowExample()
Format = "uuid"
},
}, options => options.IgnoringCyclicReferences()
- .Excluding(e => e.Examples["uuid1"].Value.Node.Parent)
- .Excluding(e => e.Examples["uuid2"].Value.Node.Parent));
+ .Excluding(e => e.Examples["uuid1"].Value.Parent)
+ .Excluding(e => e.Examples["uuid2"].Value.Parent));
}
[Fact]
@@ -1270,7 +1270,7 @@ public void ParseDocWithRefsUsingProxyReferencesSucceeds()
{
Type = "integer",
Format = "int32",
- Default = new OpenApiAny(10)
+ Default = 10
},
Reference = new OpenApiReference
{
@@ -1298,7 +1298,7 @@ public void ParseDocWithRefsUsingProxyReferencesSucceeds()
{
Type = "integer",
Format = "int32",
- Default = new OpenApiAny(10)
+ Default = 10
},
}
}
@@ -1339,7 +1339,8 @@ public void ParseDocWithRefsUsingProxyReferencesSucceeds()
// Assert
actualParam.Should().BeEquivalentTo(expectedParam, options => options
.Excluding(x => x.Reference.HostDocument)
- .Excluding(x => x.Schema.Default.Node.Parent)
+ .Excluding(x => x.Schema.Default.Parent)
+ .Excluding(x => x.Schema.Default.Options)
.IgnoringCyclicReferences());
outputDoc.Should().BeEquivalentTo(expectedSerializedDoc.MakeLineBreaksEnvironmentNeutral());
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
index f8b0d1f1f..84f028f6b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.IO;
@@ -27,7 +27,7 @@ public void ParseAdvancedExampleShouldSucceed()
var example = OpenApiModelFactory.Load(Path.Combine(SampleFolderPath, "advancedExample.yaml"), OpenApiSpecVersion.OpenApi3_0, out var diagnostic);
var expected = new OpenApiExample
{
- Value = new OpenApiAny(new JsonObject
+ Value = new JsonObject
{
["versions"] = new JsonArray
{
@@ -59,23 +59,23 @@ public void ParseAdvancedExampleShouldSucceed()
}
}
}
- })
+ }
};
- var actualRoot = example.Value.Node["versions"][0]["status"].Root;
- var expectedRoot = expected.Value.Node["versions"][0]["status"].Root;
+ var actualRoot = example.Value["versions"][0]["status"].Root;
+ var expectedRoot = expected.Value["versions"][0]["status"].Root;
diagnostic.Errors.Should().BeEmpty();
example.Should().BeEquivalentTo(expected, options => options.IgnoringCyclicReferences()
- .Excluding(e => e.Value.Node["versions"][0]["status"].Root)
- .Excluding(e => e.Value.Node["versions"][0]["id"].Root)
- .Excluding(e => e.Value.Node["versions"][0]["links"][0]["href"].Root)
- .Excluding(e => e.Value.Node["versions"][0]["links"][0]["rel"].Root)
- .Excluding(e => e.Value.Node["versions"][1]["status"].Root)
- .Excluding(e => e.Value.Node["versions"][1]["id"].Root)
- .Excluding(e => e.Value.Node["versions"][1]["links"][0]["href"].Root)
- .Excluding(e => e.Value.Node["versions"][1]["links"][0]["rel"].Root));
+ .Excluding(e => e.Value["versions"][0]["status"].Root)
+ .Excluding(e => e.Value["versions"][0]["id"].Root)
+ .Excluding(e => e.Value["versions"][0]["links"][0]["href"].Root)
+ .Excluding(e => e.Value["versions"][0]["links"][0]["rel"].Root)
+ .Excluding(e => e.Value["versions"][1]["status"].Root)
+ .Excluding(e => e.Value["versions"][1]["id"].Root)
+ .Excluding(e => e.Value["versions"][1]["links"][0]["href"].Root)
+ .Excluding(e => e.Value["versions"][1]["links"][0]["rel"].Root));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
index 90c797723..f7102b338 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
@@ -30,14 +30,14 @@ public void ParseMediaTypeWithExampleShouldSucceed()
mediaType.Should().BeEquivalentTo(
new OpenApiMediaType
{
- Example = new OpenApiAny(5),
+ Example = 5,
Schema = new()
{
Type = "number",
Format = "float"
}
}, options => options.IgnoringCyclicReferences()
- .Excluding(m => m.Example.Node.Parent)
+ .Excluding(m => m.Example.Parent)
);
}
@@ -55,11 +55,11 @@ public void ParseMediaTypeWithExamplesShouldSucceed()
{
["example1"] = new()
{
- Value = new OpenApiAny(5)
+ Value = 5
},
["example2"] = new()
{
- Value = new OpenApiAny(7.5)
+ Value = 7.5
}
},
Schema = new()
@@ -68,8 +68,8 @@ public void ParseMediaTypeWithExamplesShouldSucceed()
Format = "float"
}
}, options => options.IgnoringCyclicReferences()
- .Excluding(m => m.Examples["example1"].Value.Node.Parent)
- .Excluding(m => m.Examples["example2"].Value.Node.Parent));
+ .Excluding(m => m.Examples["example1"].Value.Parent)
+ .Excluding(m => m.Examples["example2"].Value.Parent));
}
}
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
index 1a6cb9aa9..2ff60b388 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
@@ -254,13 +254,13 @@ public void ParseParameterWithExampleShouldSucceed()
Name = "username",
Description = "username to fetch",
Required = true,
- Example = new OpenApiAny((float)5.0),
+ Example = (float)5.0,
Schema = new()
{
Type = "number",
Format = "float"
}
- }, options => options.IgnoringCyclicReferences().Excluding(p => p.Example.Node.Parent));
+ }, options => options.IgnoringCyclicReferences().Excluding(p => p.Example.Parent));
}
[Fact]
@@ -281,11 +281,11 @@ public void ParseParameterWithExamplesShouldSucceed()
{
["example1"] = new()
{
- Value = new OpenApiAny(5.0)
+ Value = 5.0
},
["example2"] = new()
{
- Value = new OpenApiAny((float)7.5)
+ Value = (float) 7.5
}
},
Schema = new()
@@ -294,8 +294,8 @@ public void ParseParameterWithExamplesShouldSucceed()
Format = "float"
}
}, options => options.IgnoringCyclicReferences()
- .Excluding(p => p.Examples["example1"].Value.Node.Parent)
- .Excluding(p => p.Examples["example2"].Value.Node.Parent));
+ .Excluding(p => p.Examples["example1"].Value.Parent)
+ .Excluding(p => p.Examples["example2"].Value.Parent));
}
[Fact]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
index 52e879aca..06a7f80f9 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
@@ -216,11 +216,11 @@ public void ParseBasicSchemaWithExampleShouldSucceed()
{
"name"
},
- Example = new OpenApiAny(new JsonObject
+ Example = new JsonObject
{
["name"] = new OpenApiAny("Puma").Node,
["id"] = new OpenApiAny(1).Node
- })
+ }
}, options => options
.IgnoringCyclicReferences()
.Excluding((IMemberInfo memberInfo) =>
@@ -378,7 +378,7 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed()
Type = "integer",
Format = "int32",
Description = "the size of the pack the dog is from",
- Default = new OpenApiAny(0),
+ Default = 0,
Minimum = 0
}
}
diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs
index 99a27d358..6849e5e9c 100644
--- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs
+++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiDeprecationExtensionTests.cs
@@ -80,7 +80,7 @@ public void Parses()
{ "version", new OpenApiAny("v1.0").Node},
{ "description", new OpenApiAny("removing").Node}
};
- var value = OpenApiDeprecationExtension.Parse(new OpenApiAny(oaiValue));
+ var value = OpenApiDeprecationExtension.Parse(oaiValue);
Assert.NotNull(value);
Assert.Equal("v1.0", value.Version);
Assert.Equal("removing", value.Description);
diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs
index 3451f8c52..3d084908c 100644
--- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPagingExtensionsTests.cs
@@ -83,7 +83,7 @@ public void ParsesPagingInfo()
};
// Act
- var extension = OpenApiPagingExtension.Parse(new OpenApiAny(obj));
+ var extension = OpenApiPagingExtension.Parse(obj);
// Assert
Assert.Equal("@odata.nextLink", extension.NextLinkName);
diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs
index 10bd9d400..f7256f8e6 100644
--- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs
+++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiPrimaryErrorMessageExtensionTests.cs
@@ -47,7 +47,7 @@ public void WritesValue()
public void ParsesValue()
{
// Arrange
- var value = new OpenApiAny(true);
+ var value = true;
// Act
var extension = MicrosoftExtensions.OpenApiPrimaryErrorMessageExtension.Parse(value);
diff --git a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiReservedParameterExtensionTests.cs b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiReservedParameterExtensionTests.cs
index 6bd14a9fb..4972f3230 100644
--- a/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiReservedParameterExtensionTests.cs
+++ b/test/Microsoft.OpenApi.Tests/MicrosoftExtensions/OpenApiReservedParameterExtensionTests.cs
@@ -13,7 +13,7 @@ public class OpenApiReservedParameterExtensionTests
[Fact]
public void Parses()
{
- var oaiValue = new OpenApiAny(true);
+ var oaiValue = true;
var value = OpenApiReservedParameterExtension.Parse(oaiValue);
Assert.NotNull(value);
Assert.True(value.IsReserved);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
index bec6f6b23..ef9786272 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
@@ -22,7 +22,7 @@ public class OpenApiExampleTests
{
public static OpenApiExample AdvancedExample = new()
{
- Value = new OpenApiAny(new JsonObject
+ Value = new JsonObject
{
["versions"] = new JsonArray
{
@@ -55,13 +55,13 @@ public class OpenApiExampleTests
}
}
}
- })
+ }
};
public static OpenApiExampleReference OpenApiExampleReference = new(ReferencedExample, "example1");
public static OpenApiExample ReferencedExample = new()
{
- Value = new OpenApiAny(new JsonObject
+ Value = new JsonObject
{
["versions"] = new JsonArray
{
@@ -94,7 +94,7 @@ public class OpenApiExampleTests
}
},
["aDate"] = JsonSerializer.Serialize(DateTime.Parse("12/12/2022 00:00:00").ToString("yyyy-MM-dd"))
- })
+ }
};
[Theory]
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs
index 4468ed201..d4e7f95f4 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs
@@ -30,10 +30,10 @@ public class OpenApiLinkTests
},
RequestBody = new()
{
- Any = new OpenApiAny(new JsonObject
+ Any = new JsonObject
{
["property1"] = true
- })
+ }
},
Description = "description1",
Server = new()
@@ -60,10 +60,10 @@ public class OpenApiLinkTests
},
RequestBody = new()
{
- Any = new OpenApiAny(new JsonObject
+ Any = new JsonObject
{
["property1"] = true
- })
+ }
},
Description = "description1",
Server = new()
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs
index ea9612c4f..e00799567 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs
@@ -18,8 +18,8 @@ public class OpenApiMediaTypeTests
public static OpenApiMediaType BasicMediaType = new();
public static OpenApiMediaType AdvanceMediaType = new()
- {
- Example = new OpenApiAny(42),
+ {
+ Example = 42,
Encoding = new Dictionary
{
{"testEncoding", OpenApiEncodingTests.AdvanceEncoding}
@@ -28,7 +28,7 @@ public class OpenApiMediaTypeTests
public static OpenApiMediaType MediaTypeWithObjectExample = new()
{
- Example = new OpenApiAny(new JsonObject
+ Example = new JsonObject
{
["versions"] = new JsonArray
{
@@ -60,7 +60,7 @@ public class OpenApiMediaTypeTests
}
}
}
- }),
+ },
Encoding = new Dictionary
{
{"testEncoding", OpenApiEncodingTests.AdvanceEncoding}
@@ -69,7 +69,7 @@ public class OpenApiMediaTypeTests
public static OpenApiMediaType MediaTypeWithXmlExample = new()
{
- Example = new OpenApiAny("123"),
+ Example = "123",
Encoding = new Dictionary
{
{"testEncoding", OpenApiEncodingTests.AdvanceEncoding}
@@ -81,7 +81,7 @@ public class OpenApiMediaTypeTests
Examples = {
["object1"] = new()
{
- Value = new OpenApiAny(new JsonObject
+ Value = new JsonObject
{
["versions"] = new JsonArray
{
@@ -113,7 +113,7 @@ public class OpenApiMediaTypeTests
}
}
}
- })
+ }
}
},
Encoding = new Dictionary
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs
index 14a29a907..631490a38 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs
@@ -35,11 +35,11 @@ public class OpenApiResponseTests
Type = "array",
Items = new OpenApiSchemaReference("customType", null)
},
- Example = new OpenApiAny("Blabla"),
+ Example = "Blabla",
Extensions = new Dictionary
{
["myextension"] = new OpenApiAny("myextensionvalue"),
- },
+ },
}
},
Headers =
@@ -74,7 +74,7 @@ public class OpenApiResponseTests
Type = "array",
Items = new OpenApiSchemaReference("customType", null)
},
- Example = new OpenApiAny("Blabla"),
+ Example = "Blabla",
Extensions = new Dictionary
{
["myextension"] = new OpenApiAny("myextensionvalue"),
diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs
index a10fba5ff..4ea8cdef9 100644
--- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiExampleReferenceTests.cs
@@ -136,7 +136,7 @@ public void ExampleReferenceResolutionWorks()
{
// Assert
Assert.NotNull(_localExampleReference.Value);
- Assert.Equal("[{\"id\":1,\"name\":\"John Doe\"}]", _localExampleReference.Value.Node.ToJsonString());
+ Assert.Equal("[{\"id\":1,\"name\":\"John Doe\"}]", _localExampleReference.Value.ToJsonString());
Assert.Equal("Example of a local user", _localExampleReference.Summary);
Assert.Equal("This is an example of a local user", _localExampleReference.Description);
diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
index f15f19bff..0e8f3e22e 100755
--- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
+++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
@@ -275,7 +275,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public string Version { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiDeprecationExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiDeprecationExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
public class OpenApiEnumFlagsExtension : Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
@@ -283,7 +283,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public bool IsFlags { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumFlagsExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumFlagsExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
public class OpenApiEnumValuesDescriptionExtension : Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
@@ -292,7 +292,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public System.Collections.Generic.List ValuesDescriptions { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumValuesDescriptionExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiEnumValuesDescriptionExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
public class OpenApiPagingExtension : Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
@@ -302,7 +302,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public string OperationName { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiPagingExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiPagingExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
public class OpenApiPrimaryErrorMessageExtension : Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
@@ -310,7 +310,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public bool IsPrimaryErrorMessage { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiPrimaryErrorMessageExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiPrimaryErrorMessageExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
public class OpenApiReservedParameterExtension : Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
@@ -318,7 +318,7 @@ namespace Microsoft.OpenApi.MicrosoftExtensions
public bool? IsReserved { get; set; }
public static string Name { get; }
public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
- public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiReservedParameterExtension Parse(Microsoft.OpenApi.Any.OpenApiAny source) { }
+ public static Microsoft.OpenApi.MicrosoftExtensions.OpenApiReservedParameterExtension Parse(System.Text.Json.Nodes.JsonNode source) { }
}
}
namespace Microsoft.OpenApi.Models
@@ -597,7 +597,7 @@ namespace Microsoft.OpenApi.Models
public virtual Microsoft.OpenApi.Models.OpenApiReference Reference { get; set; }
public virtual string Summary { get; set; }
public virtual bool UnresolvedReference { get; set; }
- public virtual Microsoft.OpenApi.Any.OpenApiAny Value { get; set; }
+ public virtual System.Text.Json.Nodes.JsonNode Value { get; set; }
public void Serialize(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion version) { }
public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
@@ -637,7 +637,7 @@ namespace Microsoft.OpenApi.Models
public virtual System.Collections.Generic.IDictionary Content { get; set; }
public virtual bool Deprecated { get; set; }
public virtual string Description { get; set; }
- public virtual Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public virtual System.Text.Json.Nodes.JsonNode Example { get; set; }
public virtual System.Collections.Generic.IDictionary Examples { get; set; }
public virtual bool Explode { get; set; }
public virtual System.Collections.Generic.IDictionary Extensions { get; set; }
@@ -705,7 +705,7 @@ namespace Microsoft.OpenApi.Models
public OpenApiMediaType() { }
public OpenApiMediaType(Microsoft.OpenApi.Models.OpenApiMediaType mediaType) { }
public System.Collections.Generic.IDictionary Encoding { get; set; }
- public Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public System.Text.Json.Nodes.JsonNode Example { get; set; }
public System.Collections.Generic.IDictionary Examples { get; set; }
public System.Collections.Generic.IDictionary Extensions { get; set; }
public virtual Microsoft.OpenApi.Models.OpenApiSchema Schema { get; set; }
@@ -771,7 +771,7 @@ namespace Microsoft.OpenApi.Models
public virtual System.Collections.Generic.IDictionary Content { get; set; }
public virtual bool Deprecated { get; set; }
public virtual string Description { get; set; }
- public virtual Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public virtual System.Text.Json.Nodes.JsonNode Example { get; set; }
public virtual System.Collections.Generic.IDictionary Examples { get; set; }
public virtual bool Explode { get; set; }
public virtual System.Collections.Generic.IDictionary Extensions { get; set; }
@@ -881,7 +881,7 @@ namespace Microsoft.OpenApi.Models
public virtual System.Collections.Generic.IList AllOf { get; set; }
public virtual System.Collections.Generic.IList AnyOf { get; set; }
public virtual string Comment { get; set; }
- public virtual Microsoft.OpenApi.Any.OpenApiAny Default { get; set; }
+ public virtual System.Text.Json.Nodes.JsonNode Default { get; set; }
public virtual System.Collections.Generic.IDictionary Definitions { get; set; }
public virtual bool Deprecated { get; set; }
public virtual string Description { get; set; }
@@ -889,7 +889,7 @@ namespace Microsoft.OpenApi.Models
public virtual string DynamicAnchor { get; set; }
public virtual string DynamicRef { get; set; }
public virtual System.Collections.Generic.IList Enum { get; set; }
- public virtual Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public virtual System.Text.Json.Nodes.JsonNode Example { get; set; }
public virtual System.Collections.Generic.IList Examples { get; set; }
public virtual bool? ExclusiveMaximum { get; set; }
public virtual bool? ExclusiveMinimum { get; set; }
@@ -1098,7 +1098,7 @@ namespace Microsoft.OpenApi.Models
{
public RuntimeExpressionAnyWrapper() { }
public RuntimeExpressionAnyWrapper(Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper) { }
- public Microsoft.OpenApi.Any.OpenApiAny Any { get; set; }
+ public System.Text.Json.Nodes.JsonNode Any { get; set; }
public Microsoft.OpenApi.Expressions.RuntimeExpression Expression { get; set; }
public void WriteValue(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
}
@@ -1131,7 +1131,7 @@ namespace Microsoft.OpenApi.Models.References
public override System.Collections.Generic.IDictionary Extensions { get; set; }
public override string ExternalValue { get; set; }
public override string Summary { get; set; }
- public override Microsoft.OpenApi.Any.OpenApiAny Value { get; set; }
+ public override System.Text.Json.Nodes.JsonNode Value { get; set; }
public override void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
public override void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { }
}
@@ -1143,7 +1143,7 @@ namespace Microsoft.OpenApi.Models.References
public override System.Collections.Generic.IDictionary Content { get; set; }
public override bool Deprecated { get; set; }
public override string Description { get; set; }
- public override Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public override System.Text.Json.Nodes.JsonNode Example { get; set; }
public override System.Collections.Generic.IDictionary Examples { get; set; }
public override bool Explode { get; set; }
public override System.Collections.Generic.IDictionary Extensions { get; set; }
@@ -1175,7 +1175,7 @@ namespace Microsoft.OpenApi.Models.References
public override System.Collections.Generic.IDictionary Content { get; set; }
public override bool Deprecated { get; set; }
public override string Description { get; set; }
- public override Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public override System.Text.Json.Nodes.JsonNode Example { get; set; }
public override System.Collections.Generic.IDictionary Examples { get; set; }
public override bool Explode { get; set; }
public override System.Collections.Generic.IDictionary Extensions { get; set; }
@@ -1229,7 +1229,7 @@ namespace Microsoft.OpenApi.Models.References
public override System.Collections.Generic.IList AllOf { get; set; }
public override System.Collections.Generic.IList AnyOf { get; set; }
public override string Comment { get; set; }
- public override Microsoft.OpenApi.Any.OpenApiAny Default { get; set; }
+ public override System.Text.Json.Nodes.JsonNode Default { get; set; }
public override System.Collections.Generic.IDictionary Definitions { get; set; }
public override bool Deprecated { get; set; }
public override string Description { get; set; }
@@ -1237,7 +1237,7 @@ namespace Microsoft.OpenApi.Models.References
public override string DynamicAnchor { get; set; }
public override string DynamicRef { get; set; }
public override System.Collections.Generic.IList Enum { get; set; }
- public override Microsoft.OpenApi.Any.OpenApiAny Example { get; set; }
+ public override System.Text.Json.Nodes.JsonNode Example { get; set; }
public override System.Collections.Generic.IList Examples { get; set; }
public override bool? ExclusiveMaximum { get; set; }
public override bool? ExclusiveMinimum { get; set; }
@@ -1359,7 +1359,7 @@ namespace Microsoft.OpenApi.Reader
public System.Uri BaseUrl { get; set; }
public Microsoft.OpenApi.Interfaces.IStreamLoader CustomExternalLoader { get; set; }
public System.Collections.Generic.List DefaultContentType { get; set; }
- public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; }
+ public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; }
public bool LeaveStreamOpen { get; set; }
public bool LoadExternalRefs { get; set; }
public Microsoft.OpenApi.Reader.ReferenceResolutionSetting ReferenceResolution { get; set; }
@@ -1378,7 +1378,7 @@ namespace Microsoft.OpenApi.Reader
public System.Uri BaseUrl { get; set; }
public System.Collections.Generic.List DefaultContentType { get; set; }
public Microsoft.OpenApi.Reader.OpenApiDiagnostic Diagnostic { get; }
- public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; }
+ public System.Collections.Generic.Dictionary> ExtensionParsers { get; set; }
public void EndObject() { }
public T GetFromTempStorage(string key, object scope = null) { }
public string GetLocation() { }
@@ -1818,7 +1818,7 @@ namespace Microsoft.OpenApi.Writers
}
public static class OpenApiWriterAnyExtensions
{
- public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.Any.OpenApiAny any) { }
+ public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Text.Json.Nodes.JsonNode node) { }
public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.IDictionary extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { }
}
public abstract class OpenApiWriterBase : Microsoft.OpenApi.Writers.IOpenApiWriter
diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs
index a189a3575..bbc9dfe35 100644
--- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs
@@ -23,7 +23,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
var header = new OpenApiHeader
{
Required = true,
- Example = new OpenApiAny(55),
+ Example = 55,
Schema = new OpenApiSchema
{
Type = "string"
@@ -72,29 +72,28 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
{
["example0"] = new()
{
- Value = new OpenApiAny("1"),
+ Value = "1",
},
["example1"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 2,
["y"] = "20",
["z"] = "200"
- })
+ }
},
["example2"] = new()
{
- Value =new OpenApiAny(
- new JsonArray(){3})
+ Value = new JsonArray(){3}
},
["example3"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 4,
["y"] = 40
- })
+ }
},
}
};
diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs
index d735e87d2..9f42cb21b 100644
--- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs
@@ -22,7 +22,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
IEnumerable warnings;
var mediaType = new OpenApiMediaType
{
- Example = new OpenApiAny(55),
+ Example = 55,
Schema = new()
{
Type = "string",
@@ -70,29 +70,28 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
{
["example0"] = new()
{
- Value = new OpenApiAny("1"),
+ Value = "1",
},
["example1"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 2,
["y"] = "20",
["z"] = "200"
- })
+ }
},
["example2"] = new()
{
- Value =new OpenApiAny(
- new JsonArray(){3})
+ Value = new JsonArray(){3}
},
["example3"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 4,
["y"] = 40
- })
+ }
},
}
};
diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs
index 197d0dbb7..beac66d74 100644
--- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs
@@ -71,7 +71,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema()
Name = "parameter1",
In = ParameterLocation.Path,
Required = true,
- Example = new OpenApiAny(55),
+ Example = 55,
Schema = new()
{
Type = "string",
@@ -122,28 +122,28 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema()
{
["example0"] = new()
{
- Value = new OpenApiAny("1"),
+ Value = "1",
},
["example1"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 2,
["y"] = "20",
["z"] = "200"
- })
+ }
},
["example2"] = new()
{
- Value = new OpenApiAny(new JsonArray(){3})
+ Value = new JsonArray(){3}
},
["example3"] = new()
{
- Value = new OpenApiAny(new JsonObject()
+ Value = new JsonObject()
{
["x"] = 4,
["y"] = 40
- })
+ }
},
}
};
diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs
index 3144955b3..5885377ed 100644
--- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs
@@ -26,7 +26,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema()
IEnumerable warnings;
var schema = new OpenApiSchema
{
- Default = new OpenApiAny(55),
+ Default = 55,
Type = "string",
};
@@ -57,8 +57,8 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem
IEnumerable warnings;
var schema = new OpenApiSchema
{
- Example = new OpenApiAny(55),
- Default = new OpenApiAny("1234"),
+ Example = 55,
+ Default = "1234",
Type = "string",
};
@@ -180,7 +180,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema()
Type = "string"
}
},
- Default = new OpenApiAny(new JsonObject()
+ Default = new JsonObject()
{
["property1"] = new JsonArray()
{
@@ -200,7 +200,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema()
},
["property3"] = "123",
["property4"] = DateTime.UtcNow
- })
+ }
};
// Act
diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs
index 6e1a883c4..96e8027a0 100644
--- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
@@ -263,7 +263,7 @@ private static string WriteAsJson(JsonNode any, bool produceTerseOutput = false)
new StreamWriter(stream),
new() { Terse = produceTerseOutput });
- writer.WriteAny(new OpenApiAny(any));
+ writer.WriteAny(any);
writer.Flush();
stream.Position = 0;