diff --git a/tracer/build/_build/UpdateVendors/UpdateVendors.cs b/tracer/build/_build/UpdateVendors/UpdateVendors.cs
index 82f5909b1fb7..e382ab9f0ba2 100644
--- a/tracer/build/_build/UpdateVendors/UpdateVendors.cs
+++ b/tracer/build/_build/UpdateVendors/UpdateVendors.cs
@@ -71,10 +71,14 @@ private static async Task UpdateVendor(VendoredDependency dependency, AbsolutePa
File.Delete(projFile);
Console.WriteLine($"Renamed {libraryName} project file.");
- // Delete the assembly properties
- var assemblyPropertiesFolder = Path.Combine(sourceLocation, @"Properties");
- SafeDeleteDirectory(assemblyPropertiesFolder);
- Console.WriteLine($"Deleted {libraryName} assembly properties file.");
+ // Delete the assembly info file
+ var assemblyInfo = Path.Combine(sourceLocation, @"Properties", "AssemblyInfo.cs");
+ if (File.Exists(assemblyInfo))
+ {
+ File.Delete(assemblyInfo);
+ }
+
+ Console.WriteLine($"Deleted {libraryName} assembly info file.");
Console.WriteLine($"Running transforms on files for {libraryName}.");
@@ -111,7 +115,9 @@ private static bool ShouldDropFile(VendoredDependency dependency, string basePat
foreach (var relativeFileToDrop in dependency.RelativePathsToExclude)
{
var absolutePath = Path.Combine(basePath, relativeFileToDrop).Replace('/', '\\');
- if (normalizedFilePath.Equals(absolutePath, StringComparison.OrdinalIgnoreCase))
+ if (normalizedFilePath.Equals(absolutePath, StringComparison.OrdinalIgnoreCase)
+ || (absolutePath.EndsWith('\\') &&
+ normalizedFilePath.StartsWith(absolutePath, StringComparison.OrdinalIgnoreCase)))
{
return true;
}
diff --git a/tracer/build/_build/UpdateVendors/VendoredDependency.cs b/tracer/build/_build/UpdateVendors/VendoredDependency.cs
index 7f911712c89e..15a082e3c2d1 100644
--- a/tracer/build/_build/UpdateVendors/VendoredDependency.cs
+++ b/tracer/build/_build/UpdateVendors/VendoredDependency.cs
@@ -15,12 +15,34 @@ public class VendoredDependency
{
private const string AutoGeneratedMessage = @"//------------------------------------------------------------------------------
//
-// This file was automatically generated by the UpdateVendors tool.
+// This file was automatically generated by the UpdateVendoredCode tool.
//------------------------------------------------------------------------------
";
static VendoredDependency()
{
+ Add(
+ libraryName: "Microsoft.OpenApi",
+ "1.6.23",
+ "https://github.com/microsoft/OpenAPI.NET/archive/1.6.23.zip",
+ new[] { "OpenAPI.NET-1.6.23", "src", "Microsoft.OpenApi" },
+ filePath => RewriteCsFileWithStandardTransform(filePath, "Microsoft.OpenApi"),
+ new[]
+ {
+ "Extensions/OpenApiElementExtensions.cs",
+ "Extensions/OpenApiSerializableExtensions.cs",
+ "Extensions/OpenApiTypeMapper.cs",
+ "MicrosoftExtensions/", // whole folder
+ "Services/CopyReferences.cs",
+ "Services/OpenApiFilterService.cs",
+ "Services/OpenApiUrlTreeNode.cs",
+ "Services/OperationSearch.cs",
+ "Services/SearchResult.cs",
+ "Validations/", // whole folder
+ "Writers/FormattingStreamWriter.cs",
+ "Writers/OpenApiYamlWriter.cs"
+ });
+
Add(
libraryName: "Serilog",
version: "2.10.0",
diff --git a/tracer/dependabot/Datadog.Dependabot.Vendors.csproj b/tracer/dependabot/Datadog.Dependabot.Vendors.csproj
index cefa00f782b0..57a26e75a5b2 100644
--- a/tracer/dependabot/Datadog.Dependabot.Vendors.csproj
+++ b/tracer/dependabot/Datadog.Dependabot.Vendors.csproj
@@ -1,11 +1,14 @@
- netcoreapp3.1
+ net8.0
Datadog.Dependabot.Honeypot
+
+
+
@@ -30,18 +33,24 @@
-
+
-
+
-
+
+
+
+
+
+
+
diff --git a/tracer/src/Datadog.Trace.Trimming/build/Datadog.Trace.Trimming.xml b/tracer/src/Datadog.Trace.Trimming/build/Datadog.Trace.Trimming.xml
index 6567951c659f..52dbf326a37d 100644
--- a/tracer/src/Datadog.Trace.Trimming/build/Datadog.Trace.Trimming.xml
+++ b/tracer/src/Datadog.Trace.Trimming/build/Datadog.Trace.Trimming.xml
@@ -223,6 +223,7 @@
+
@@ -246,6 +247,7 @@
+
@@ -494,6 +496,7 @@
+
@@ -538,6 +541,8 @@
+
+
@@ -546,6 +551,8 @@
+
+
@@ -554,6 +561,7 @@
+
@@ -719,6 +727,7 @@
+
@@ -970,7 +979,10 @@
+
+
+
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/AnyType.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/AnyType.cs
new file mode 100644
index 000000000000..49c9b99b7bf3
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/AnyType.cs
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Type of an
+ ///
+ internal enum AnyType
+ {
+ ///
+ /// Primitive.
+ ///
+ Primitive,
+
+ ///
+ /// Null.
+ ///
+ Null,
+
+ ///
+ /// Array.
+ ///
+ Array,
+
+ ///
+ /// Object.
+ ///
+ Object
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiAny.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiAny.cs
new file mode 100644
index 000000000000..8a68a3f5d875
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiAny.cs
@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Base interface for all the types that represent Open API Any.
+ ///
+ internal interface IOpenApiAny : IOpenApiElement, IOpenApiExtension
+ {
+ ///
+ /// Type of an .
+ ///
+ AnyType AnyType { get; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs
new file mode 100644
index 000000000000..cdeeab83dc04
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/IOpenApiPrimitive.cs
@@ -0,0 +1,82 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Primitive type.
+ ///
+ internal enum PrimitiveType
+ {
+ ///
+ /// 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.
+ ///
+ internal interface IOpenApiPrimitive : IOpenApiAny
+ {
+ ///
+ /// Primitive type.
+ ///
+ PrimitiveType PrimitiveType { get; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
new file mode 100644
index 000000000000..dc37f55728b8
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
@@ -0,0 +1,66 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Contains logic for cloning objects through copy constructors.
+ ///
+ internal class OpenApiAnyCloneHelper
+ {
+ ///
+ /// Clones an instance of object from the copy constructor
+ ///
+ /// The object instance.
+ /// A clone copy or the object itself.
+ [Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
+ [RequiresUnreferencedCode("CloneFromCopyConstructor is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of CloneFromCopyConstructor instead.")]
+ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
+ {
+ if (obj != null)
+ {
+ var t = obj.GetType();
+ foreach (var ci in t.GetConstructors())
+ {
+ var pi = ci.GetParameters();
+ if (pi.Length == 1 && pi[0].ParameterType == t)
+ {
+ return (IOpenApiAny)ci.Invoke(new object[] { obj });
+ }
+ }
+ }
+
+ return obj;
+ }
+
+ ///
+ /// Clones an instance of object from the copy constructor
+ ///
+ /// The object instance.
+ /// A clone copy or the object itself.
+ public static T CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny
+ {
+ if (obj != null)
+ {
+ foreach (var ci in typeof(T).GetConstructors())
+ {
+ var pi = ci.GetParameters();
+ if (pi.Length == 1 && pi[0].ParameterType == typeof(T))
+ {
+ return (T)ci.Invoke([obj]);
+ }
+ }
+ }
+
+ return obj;
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiArray.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiArray.cs
new file mode 100644
index 000000000000..8048a8de0373
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiArray.cs
@@ -0,0 +1,58 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+using System.Collections.Generic;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API array.
+ ///
+ internal class OpenApiArray : List, IOpenApiAny
+ {
+ ///
+ /// The type of
+ ///
+ public AnyType AnyType { get; } = AnyType.Array;
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiArray() { }
+
+ ///
+ /// Initializes a copy of object
+ ///
+ public OpenApiArray(OpenApiArray array)
+ {
+ AnyType = array.AnyType;
+ foreach (var item in array)
+ {
+ Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor(item));
+ }
+ }
+
+ ///
+ /// Write out contents of OpenApiArray to passed writer
+ ///
+ /// Instance of JSON or YAML writer.
+ /// Version of the OpenAPI specification that that will be output.
+ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteStartArray();
+
+ foreach (var item in this)
+ {
+ writer.WriteAny(item);
+ }
+
+ writer.WriteEndArray();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBinary.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBinary.cs
new file mode 100644
index 000000000000..9ce03de6c8c7
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBinary.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API binary.
+ ///
+ internal class OpenApiBinary : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ ///
+ public OpenApiBinary(byte[] value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Binary;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBoolean.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBoolean.cs
new file mode 100644
index 000000000000..a4ba9f7712e5
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiBoolean.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API boolean.
+ ///
+ internal class OpenApiBoolean : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ ///
+ public OpenApiBoolean(bool value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Boolean;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiByte.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiByte.cs
new file mode 100644
index 000000000000..293baf17cb81
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiByte.cs
@@ -0,0 +1,37 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Byte
+ ///
+ internal class OpenApiByte : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiByte(byte value)
+ : this(new[] { value })
+ {
+ }
+
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiByte(byte[] value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Byte;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDate.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDate.cs
new file mode 100644
index 000000000000..2a6f05c93d42
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDate.cs
@@ -0,0 +1,31 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Date
+ ///
+ internal class OpenApiDate : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiDate(DateTime value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Date;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDateTime.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDateTime.cs
new file mode 100644
index 000000000000..e620601f5277
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDateTime.cs
@@ -0,0 +1,31 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Datetime
+ ///
+ internal class OpenApiDateTime : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiDateTime(DateTimeOffset value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.DateTime;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDouble.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDouble.cs
new file mode 100644
index 000000000000..1ceddc5dc009
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiDouble.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Double
+ ///
+ internal class OpenApiDouble : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiDouble(double value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Double;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiFloat.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiFloat.cs
new file mode 100644
index 000000000000..6d5a380f258b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiFloat.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Float
+ ///
+ internal class OpenApiFloat : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiFloat(float value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Float;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiInteger.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiInteger.cs
new file mode 100644
index 000000000000..f65e20a754d6
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiInteger.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API Integer
+ ///
+ internal class OpenApiInteger : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiInteger(int value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Integer;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiLong.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiLong.cs
new file mode 100644
index 000000000000..deee698575a4
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiLong.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API long.
+ ///
+ internal class OpenApiLong : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiLong(long value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// Primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Long;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiNull.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiNull.cs
new file mode 100644
index 000000000000..03c2c58cbf70
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiNull.cs
@@ -0,0 +1,46 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API null.
+ ///
+ internal class OpenApiNull : IOpenApiAny
+ {
+ ///
+ /// The type of
+ ///
+ public AnyType AnyType { get; } = AnyType.Null;
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiNull() { }
+
+ ///
+ /// Initializes a copy of object
+ ///
+ public OpenApiNull(OpenApiNull openApiNull)
+ {
+ AnyType = openApiNull.AnyType;
+ }
+
+ ///
+ /// Write out null representation
+ ///
+ ///
+ /// Version of the OpenAPI specification that that will be output.
+ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteAny(this);
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiObject.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiObject.cs
new file mode 100644
index 000000000000..a9184c19f9f2
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiObject.cs
@@ -0,0 +1,59 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API object.
+ ///
+ internal class OpenApiObject : Dictionary, IOpenApiAny
+ {
+ ///
+ /// Type of .
+ ///
+ public AnyType AnyType { get; } = AnyType.Object;
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiObject() { }
+
+ ///
+ /// Initializes a copy of object
+ ///
+ public OpenApiObject(OpenApiObject obj)
+ {
+ AnyType = obj.AnyType;
+ foreach (var key in obj.Keys)
+ {
+ this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor(obj[key]);
+ }
+ }
+
+ ///
+ /// Serialize OpenApiObject to writer
+ ///
+ ///
+ /// Version of the OpenAPI specification that that will be output.
+ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteStartObject();
+
+ foreach (var item in this)
+ {
+ writer.WritePropertyName(item.Key);
+ writer.WriteAny(item.Value);
+ }
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPassword.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPassword.cs
new file mode 100644
index 000000000000..aa8d9e0e912d
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPassword.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API password.
+ ///
+ internal class OpenApiPassword : OpenApiPrimitive
+ {
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiPassword(string value)
+ : base(value)
+ {
+ }
+
+ ///
+ /// The primitive type this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.Password;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPrimitive.cs
new file mode 100644
index 000000000000..16028451c061
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiPrimitive.cs
@@ -0,0 +1,160 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Globalization;
+using System.Text;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API primitive class.
+ ///
+ ///
+ internal abstract class OpenApiPrimitive : IOpenApiPrimitive
+ {
+ ///
+ /// Initializes the class with the given value.
+ ///
+ ///
+ public OpenApiPrimitive(T value)
+ {
+ Value = value;
+ }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ ///
+ public OpenApiPrimitive(OpenApiPrimitive openApiPrimitive)
+ {
+ Value = openApiPrimitive.Value;
+ }
+
+ ///
+ /// The kind of .
+ ///
+ public AnyType AnyType => AnyType.Primitive;
+
+ ///
+ /// The primitive class this object represents.
+ ///
+ public abstract PrimitiveType PrimitiveType { get; }
+
+ ///
+ /// Value of this
+ ///
+ public T Value { get; }
+
+ ///
+ /// Write out content of primitive element
+ ///
+ ///
+ ///
+ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ switch (this.PrimitiveType)
+ {
+ case PrimitiveType.Integer:
+ var intValue = (OpenApiInteger)(IOpenApiPrimitive)this;
+ writer.WriteValue(intValue.Value);
+ break;
+
+ case PrimitiveType.Long:
+ var longValue = (OpenApiLong)(IOpenApiPrimitive)this;
+ writer.WriteValue(longValue.Value);
+ break;
+
+ case PrimitiveType.Float:
+ var floatValue = (OpenApiFloat)(IOpenApiPrimitive)this;
+ writer.WriteValue(floatValue.Value);
+ break;
+
+ case PrimitiveType.Double:
+ var doubleValue = (OpenApiDouble)(IOpenApiPrimitive)this;
+ var actualValue = doubleValue.Value;
+ if (actualValue.Equals(double.NaN)
+ || actualValue.Equals(double.NegativeInfinity)
+ || actualValue.Equals(double.PositiveInfinity))
+ {
+ // Write out NaN, -Infinity, Infinity as strings
+ writer.WriteValue(actualValue.ToString(CultureInfo.InvariantCulture));
+ break;
+ }
+ else
+ {
+ writer.WriteValue(actualValue);
+ }
+ break;
+
+ case PrimitiveType.String:
+ var stringValue = (OpenApiString)(IOpenApiPrimitive)this;
+ if (stringValue.IsRawString())
+ writer.WriteRaw(stringValue.Value);
+ else
+ writer.WriteValue(stringValue.Value);
+ break;
+
+ case PrimitiveType.Byte:
+ var byteValue = (OpenApiByte)(IOpenApiPrimitive)this;
+ if (byteValue.Value == null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ writer.WriteValue(Convert.ToBase64String(byteValue.Value));
+ }
+
+ break;
+
+ case PrimitiveType.Binary:
+ var binaryValue = (OpenApiBinary)(IOpenApiPrimitive)this;
+ if (binaryValue.Value == null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ writer.WriteValue(Encoding.UTF8.GetString(binaryValue.Value));
+ }
+
+ break;
+
+ case PrimitiveType.Boolean:
+ var boolValue = (OpenApiBoolean)(IOpenApiPrimitive)this;
+ writer.WriteValue(boolValue.Value);
+ break;
+
+ case PrimitiveType.Date:
+ var dateValue = (OpenApiDate)(IOpenApiPrimitive)this;
+ writer.WriteValue(dateValue.Value.ToString("o").Substring(0, 10));
+ break;
+
+ case PrimitiveType.DateTime:
+ var dateTimeValue = (OpenApiDateTime)(IOpenApiPrimitive)this;
+ writer.WriteValue(dateTimeValue.Value);
+ break;
+
+ case PrimitiveType.Password:
+ var passwordValue = (OpenApiPassword)(IOpenApiPrimitive)this;
+ writer.WriteValue(passwordValue.Value);
+ break;
+
+ default:
+ throw new OpenApiWriterException(
+ string.Format(
+ SRResource.PrimitiveTypeNotSupported,
+ this.PrimitiveType));
+ }
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiString.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiString.cs
new file mode 100644
index 000000000000..20c7000f2186
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Any/OpenApiString.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Any
+{
+ ///
+ /// Open API string type.
+ ///
+ internal class OpenApiString : OpenApiPrimitive
+ {
+ private bool isExplicit;
+ private bool isRawString;
+
+ ///
+ /// Initializes the class.
+ ///
+ ///
+ public OpenApiString(string value)
+ : this(value, false)
+ {
+ }
+
+ ///
+ /// Initializes the class.
+ ///
+ ///
+ /// Used to indicate if a string is quoted.
+ public OpenApiString(string value, bool isExplicit)
+ : base(value)
+ {
+ this.isExplicit = isExplicit;
+ }
+
+ ///
+ /// Initializes the class.
+ ///
+ ///
+ /// Used to indicate if a string is quoted.
+ /// Used to indicate to the writer that the value should be written without encoding.
+ public OpenApiString(string value, bool isExplicit, bool isRawString)
+ : base(value)
+ {
+ this.isExplicit = isExplicit;
+ this.isRawString = isRawString;
+ }
+
+ ///
+ /// The primitive class this object represents.
+ ///
+ public override PrimitiveType PrimitiveType => PrimitiveType.String;
+
+ ///
+ /// True if string was specified explicitly by the means of double quotes, single quotes, or literal or folded style.
+ ///
+ public bool IsExplicit()
+ {
+ return this.isExplicit;
+ }
+
+ ///
+ /// True if the writer should process the value as supplied without encoding.
+ ///
+ public bool IsRawString()
+ {
+ return this.isRawString;
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/DisplayAttribute.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/DisplayAttribute.cs
new file mode 100644
index 000000000000..195dd7d35df2
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/DisplayAttribute.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Attributes
+{
+ ///
+ /// Represents the Open Api Data type metadata attribute.
+ ///
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
+ internal class DisplayAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The display name.
+ public DisplayAttribute(string name)
+ {
+ Name = Utils.CheckArgumentNullOrEmpty(name);
+ }
+
+ ///
+ /// The display Name.
+ ///
+ public string Name { get; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs
new file mode 100644
index 000000000000..8a17bab8c31b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs
@@ -0,0 +1,430 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+#nullable enable
+
+// This collection of attribute definitions are helpers for accessing trim-related attributes in
+// projects targeting .NET 6 or lower. Since the trimmer queries for these attributes by name, having
+// these attributes source included is sufficient for the trimmer to recognize them. For more information
+// on this approach, see https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/#approach-2-define-the-attributes-internally.
+namespace System.Diagnostics.CodeAnalysis
+{
+#if !NET7_0_OR_GREATER
+ ///
+ /// Indicates that the specified method requires the ability to generate new code at runtime,
+ /// for example through .
+ ///
+ ///
+ /// This allows tools to understand which methods are unsafe to call when compiling ahead of time.
+ ///
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
+ internal sealed class RequiresDynamicCodeAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified message.
+ ///
+ ///
+ /// A message that contains information about the usage of dynamic code.
+ ///
+ public RequiresDynamicCodeAttribute(string message)
+ {
+ Message = message;
+ }
+
+ ///
+ /// Gets a message that contains information about the usage of dynamic code.
+ ///
+ public string Message { get; }
+
+ ///
+ /// Gets or sets an optional URL that contains more information about the method,
+ /// why it requires dynamic code, and what options a consumer has to deal with it.
+ ///
+ public string? Url { get; set; }
+ }
+#endif
+
+#if !NET5_0_OR_GREATER
+ ///
+ /// Indicates that the specified method requires dynamic access to code that is not referenced
+ /// statically, for example through .
+ ///
+ ///
+ /// This allows tools to understand which methods are unsafe to call when removing unreferenced
+ /// code from an application.
+ ///
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
+ internal sealed class RequiresUnreferencedCodeAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified message.
+ ///
+ ///
+ /// A message that contains information about the usage of unreferenced code.
+ ///
+ public RequiresUnreferencedCodeAttribute(string message)
+ {
+ Message = message;
+ }
+
+ ///
+ /// Gets a message that contains information about the usage of unreferenced code.
+ ///
+ public string Message { get; }
+
+ ///
+ /// Gets or sets an optional URL that contains more information about the method,
+ /// why it requires unreferenced code, and what options a consumer has to deal with it.
+ ///
+ public string? Url { get; set; }
+ }
+
+ ///
+ /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a
+ /// single code artifact.
+ ///
+ ///
+ /// is different than
+ /// in that it doesn't have a
+ /// . So it is always preserved in the compiled assembly.
+ ///
+ [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
+ internal sealed class UnconditionalSuppressMessageAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the
+ /// class, specifying the category of the tool and the identifier for an analysis rule.
+ ///
+ /// The category for the attribute.
+ /// The identifier of the analysis rule the attribute applies to.
+ public UnconditionalSuppressMessageAttribute(string category, string checkId)
+ {
+ Category = category;
+ CheckId = checkId;
+ }
+
+ ///
+ /// Gets the category identifying the classification of the attribute.
+ ///
+ ///
+ /// The property describes the tool or tool analysis category
+ /// for which a message suppression attribute applies.
+ ///
+ public string Category { get; }
+
+ ///
+ /// Gets the identifier of the analysis tool rule to be suppressed.
+ ///
+ ///
+ /// Concatenated together, the and
+ /// properties form a unique check identifier.
+ ///
+ public string CheckId { get; }
+
+ ///
+ /// Gets or sets the scope of the code that is relevant for the attribute.
+ ///
+ ///
+ /// The Scope property is an optional argument that specifies the metadata scope for which
+ /// the attribute is relevant.
+ ///
+ public string? Scope { get; set; }
+
+ ///
+ /// Gets or sets a fully qualified path that represents the target of the attribute.
+ ///
+ ///
+ /// The property is an optional argument identifying the analysis target
+ /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void".
+ /// Because it is fully qualified, it can be long, particularly for targets such as parameters.
+ /// The analysis tool user interface should be capable of automatically formatting the parameter.
+ ///
+ public string? Target { get; set; }
+
+ ///
+ /// Gets or sets an optional argument expanding on exclusion criteria.
+ ///
+ ///
+ /// The property is an optional argument that specifies additional
+ /// exclusion where the literal metadata target is not sufficiently precise. For example,
+ /// the cannot be applied within a method,
+ /// and it may be desirable to suppress a violation against a statement in the method that will
+ /// give a rule violation, but not against all statements in the method.
+ ///
+ public string? MessageId { get; set; }
+
+ ///
+ /// Gets or sets the justification for suppressing the code analysis message.
+ ///
+ public string? Justification { get; set; }
+ }
+
+ ///
+ /// States a dependency that one member has on another.
+ ///
+ ///
+ /// This can be used to inform tooling of a dependency that is otherwise not evident purely from
+ /// metadata and IL, for example a member relied on via reflection.
+ ///
+ [AttributeUsage(
+ AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method,
+ AllowMultiple = true, Inherited = false)]
+ internal sealed class DynamicDependencyAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified signature of a member on the same type as the consumer.
+ ///
+ /// The signature of the member depended on.
+ public DynamicDependencyAttribute(string memberSignature)
+ {
+ MemberSignature = memberSignature;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified signature of a member on a .
+ ///
+ /// The signature of the member depended on.
+ /// The containing .
+ public DynamicDependencyAttribute(string memberSignature, Type type)
+ {
+ MemberSignature = memberSignature;
+ Type = type;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified signature of a member on a type in an assembly.
+ ///
+ /// The signature of the member depended on.
+ /// The full name of the type containing the specified member.
+ /// The assembly name of the type containing the specified member.
+ public DynamicDependencyAttribute(string memberSignature, string typeName, string assemblyName)
+ {
+ MemberSignature = memberSignature;
+ TypeName = typeName;
+ AssemblyName = assemblyName;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified types of members on a .
+ ///
+ /// The types of members depended on.
+ /// The containing the specified members.
+ public DynamicDependencyAttribute(DynamicallyAccessedMemberTypes memberTypes, Type type)
+ {
+ MemberTypes = memberTypes;
+ Type = type;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified types of members on a type in an assembly.
+ ///
+ /// The types of members depended on.
+ /// The full name of the type containing the specified members.
+ /// The assembly name of the type containing the specified members.
+ public DynamicDependencyAttribute(DynamicallyAccessedMemberTypes memberTypes, string typeName, string assemblyName)
+ {
+ MemberTypes = memberTypes;
+ TypeName = typeName;
+ AssemblyName = assemblyName;
+ }
+
+ ///
+ /// Gets the signature of the member depended on.
+ ///
+ ///
+ /// Either must be a valid string or
+ /// must not equal , but not both.
+ ///
+ public string? MemberSignature { get; }
+
+ ///
+ /// Gets the which specifies the type
+ /// of members depended on.
+ ///
+ ///
+ /// Either must be a valid string or
+ /// must not equal , but not both.
+ ///
+ public DynamicallyAccessedMemberTypes MemberTypes { get; }
+
+ ///
+ /// Gets the containing the specified member.
+ ///
+ ///
+ /// If neither nor are specified,
+ /// the type of the consumer is assumed.
+ ///
+ public Type? Type { get; }
+
+ ///
+ /// Gets the full name of the type containing the specified member.
+ ///
+ ///
+ /// If neither nor are specified,
+ /// the type of the consumer is assumed.
+ ///
+ public string? TypeName { get; }
+
+ ///
+ /// Gets the assembly name of the specified type.
+ ///
+ ///
+ /// is only valid when is specified.
+ ///
+ public string? AssemblyName { get; }
+
+ ///
+ /// Gets or sets the condition in which the dependency is applicable, e.g. "DEBUG".
+ ///
+ public string? Condition { get; set; }
+ }
+
+ ///
+ /// Indicates that certain members on a specified are accessed dynamically,
+ /// for example through .
+ ///
+ ///
+ /// This allows tools to understand which members are being accessed during the execution
+ /// of a program.
+ ///
+ /// This attribute is valid on members whose type is or .
+ ///
+ /// When this attribute is applied to a location of type , the assumption is
+ /// that the string represents a fully qualified type name.
+ ///
+ /// When this attribute is applied to a class, interface, or struct, the members specified
+ /// can be accessed dynamically on instances returned from calling
+ /// on instances of that class, interface, or struct.
+ ///
+ /// If the attribute is applied to a method it's treated as a special case and it implies
+ /// the attribute should be applied to the "this" parameter of the method. As such the attribute
+ /// should only be used on instance methods of types assignable to System.Type (or string, but no methods
+ /// will use it there).
+ ///
+ [AttributeUsage(
+ AttributeTargets.Field | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter |
+ AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method |
+ AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct,
+ Inherited = false)]
+ internal sealed class DynamicallyAccessedMembersAttribute : Attribute
+ {
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified member types.
+ ///
+ /// The types of members dynamically accessed.
+ public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
+ {
+ MemberTypes = memberTypes;
+ }
+
+ ///
+ /// Gets the which specifies the type
+ /// of members dynamically accessed.
+ ///
+ public DynamicallyAccessedMemberTypes MemberTypes { get; }
+ }
+
+ ///
+ /// Specifies the types of members that are dynamically accessed.
+ ///
+ /// This enumeration has a attribute that allows a
+ /// bitwise combination of its member values.
+ ///
+ [Flags]
+ internal enum DynamicallyAccessedMemberTypes
+ {
+ ///
+ /// Specifies no members.
+ ///
+ None = 0,
+
+ ///
+ /// Specifies the default, parameterless public constructor.
+ ///
+ PublicParameterlessConstructor = 0x0001,
+
+ ///
+ /// Specifies all public constructors.
+ ///
+ PublicConstructors = 0x0002 | PublicParameterlessConstructor,
+
+ ///
+ /// Specifies all non-public constructors.
+ ///
+ NonPublicConstructors = 0x0004,
+
+ ///
+ /// Specifies all public methods.
+ ///
+ PublicMethods = 0x0008,
+
+ ///
+ /// Specifies all non-public methods.
+ ///
+ NonPublicMethods = 0x0010,
+
+ ///
+ /// Specifies all public fields.
+ ///
+ PublicFields = 0x0020,
+
+ ///
+ /// Specifies all non-public fields.
+ ///
+ NonPublicFields = 0x0040,
+
+ ///
+ /// Specifies all public nested types.
+ ///
+ PublicNestedTypes = 0x0080,
+
+ ///
+ /// Specifies all non-public nested types.
+ ///
+ NonPublicNestedTypes = 0x0100,
+
+ ///
+ /// Specifies all public properties.
+ ///
+ PublicProperties = 0x0200,
+
+ ///
+ /// Specifies all non-public properties.
+ ///
+ NonPublicProperties = 0x0400,
+
+ ///
+ /// Specifies all public events.
+ ///
+ PublicEvents = 0x0800,
+
+ ///
+ /// Specifies all non-public events.
+ ///
+ NonPublicEvents = 0x1000,
+
+ ///
+ /// Specifies all interfaces implemented by the type.
+ ///
+ Interfaces = 0x2000,
+
+ ///
+ /// Specifies all members.
+ ///
+ All = ~None
+ }
+#endif
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/CallerArgumentExpressionAttribute.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/CallerArgumentExpressionAttribute.cs
new file mode 100644
index 000000000000..62ac70a05434
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/CallerArgumentExpressionAttribute.cs
@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+#if !NETCOREAPP3_1_OR_GREATER
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+
+namespace System.Runtime.CompilerServices;
+
+[ExcludeFromCodeCoverage]
+[DebuggerNonUserCode]
+[AttributeUsage(AttributeTargets.Parameter)]
+sealed class CallerArgumentExpressionAttribute :
+ Attribute
+{
+ public CallerArgumentExpressionAttribute(string parameterName) =>
+ ParameterName = parameterName;
+
+ public string ParameterName { get; }
+}
+#endif
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiException.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiException.cs
new file mode 100644
index 000000000000..eb8d8d15cc72
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiException.cs
@@ -0,0 +1,56 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions
+{
+ ///
+ /// Exception type representing exceptions in the Open API library.
+ ///
+ internal class OpenApiException : Exception
+ {
+ ///
+ /// Creates a new instance of the class with default values.
+ ///
+ public OpenApiException()
+ : this(SRResource.OpenApiExceptionGenericError)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class with an error message.
+ ///
+ /// The plain text error message for this exception.
+ public OpenApiException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class with an error message and an inner exception.
+ ///
+ /// The plain text error message for this exception.
+ /// The inner exception that is the cause of this exception to be thrown.
+ public OpenApiException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+ ///
+ /// The reference pointer. This is a fragment identifier used to point to where the error occurred in the document.
+ /// If the document has been parsed as JSON/YAML then the identifier will be a
+ /// JSON Pointer as per https://tools.ietf.org/html/rfc6901
+ /// If the document fails to parse as JSON/YAML then the fragment will be based on
+ /// a text/plain pointer as defined in https://tools.ietf.org/html/rfc5147
+ /// Currently only line= is provided because using char= causes tests to break due to CR/LF and LF differences
+ ///
+ public string Pointer { get; set; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs
new file mode 100644
index 000000000000..240f5438d788
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Exceptions/OpenApiWriterException.cs
@@ -0,0 +1,46 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions
+{
+ ///
+ /// Exception type representing exceptions in the OpenAPI writer.
+ ///
+ internal class OpenApiWriterException : OpenApiException
+ {
+ ///
+ /// Creates a new instance of the class with default values.
+ ///
+ public OpenApiWriterException()
+ : this(SRResource.OpenApiWriterExceptionGenericError)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class with an error message.
+ ///
+ /// The plain text error message for this exception.
+ public OpenApiWriterException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class with an error message and an inner exception.
+ ///
+ /// The plain text error message for this exception.
+ /// The inner exception that is the cause of this exception to be thrown.
+ public OpenApiWriterException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/BodyExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/BodyExpression.cs
new file mode 100644
index 000000000000..c37e69880b65
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/BodyExpression.cs
@@ -0,0 +1,65 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Body expression.
+ ///
+ internal sealed class BodyExpression : SourceExpression
+ {
+ ///
+ /// body string
+ ///
+ public const string Body = "body";
+
+ ///
+ /// Prefix for a pointer
+ ///
+ public const string PointerPrefix = "#";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public BodyExpression()
+ : base(null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901).
+ public BodyExpression(JsonPointer pointer)
+ : base(pointer?.ToString())
+ {
+ Utils.CheckArgumentNull(pointer);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression
+ {
+ get
+ {
+ if (string.IsNullOrWhiteSpace(Value))
+ {
+ return Body;
+ }
+
+ return Body + PointerPrefix + Value;
+ }
+ }
+
+ ///
+ /// Gets the fragment string.
+ ///
+ public string Fragment { get => Value; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/CompositeExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/CompositeExpression.cs
new file mode 100644
index 000000000000..9dfd60bf2e33
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/CompositeExpression.cs
@@ -0,0 +1,51 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// String literal with embedded expressions
+ ///
+ internal class CompositeExpression : RuntimeExpression
+ {
+ private readonly string template;
+ private Regex expressionPattern = new(@"{(?\$[^}]*)");
+
+ ///
+ /// Expressions embedded into string literal
+ ///
+ public List ContainedExpressions = new();
+
+ ///
+ /// Create a composite expression from a string literal with an embedded expression
+ ///
+ ///
+ public CompositeExpression(string expression)
+ {
+ template = expression;
+
+ // Extract subexpressions and convert to RuntimeExpressions
+ var matches = expressionPattern.Matches(expression);
+
+ foreach (var item in matches.Cast())
+ {
+ var value = item.Groups["exp"].Captures.Cast().First().Value;
+ ContainedExpressions.Add(Build(value));
+ }
+ }
+
+ ///
+ /// Return original string literal with embedded expression
+ ///
+ public override string Expression => template;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/HeaderExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/HeaderExpression.cs
new file mode 100644
index 000000000000..f17380d8ebe6
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/HeaderExpression.cs
@@ -0,0 +1,41 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Header expression, The token identifier in header is case-insensitive.
+ ///
+ internal class HeaderExpression : SourceExpression
+ {
+ ///
+ /// header. string
+ ///
+ public const string Header = "header.";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The token string, it's case-insensitive.
+ public HeaderExpression(string token)
+ : base(token)
+ {
+ Utils.CheckArgumentNullOrEmpty(token);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression { get => Header + Value; }
+
+ ///
+ /// Gets the token string.
+ ///
+ public string Token { get => Value; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/MethodExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/MethodExpression.cs
new file mode 100644
index 000000000000..265feaf26d50
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/MethodExpression.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Method expression.
+ ///
+ internal sealed class MethodExpression : RuntimeExpression
+ {
+ ///
+ /// $method. string
+ ///
+ public const string Method = "$method";
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression => Method;
+
+ ///
+ /// Private constructor.
+ ///
+ public MethodExpression()
+ {
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/PathExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/PathExpression.cs
new file mode 100644
index 000000000000..37210c817079
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/PathExpression.cs
@@ -0,0 +1,41 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Path expression, the name in path is case-sensitive.
+ ///
+ internal sealed class PathExpression : SourceExpression
+ {
+ ///
+ /// path. string
+ ///
+ public const string Path = "path.";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name string, it's case-insensitive.
+ public PathExpression(string name)
+ : base(name)
+ {
+ Utils.CheckArgumentNullOrEmpty(name);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression { get => Path + Value; }
+
+ ///
+ /// Gets the name string.
+ ///
+ public string Name { get => Value; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/QueryExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/QueryExpression.cs
new file mode 100644
index 000000000000..dc6d773b98bf
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/QueryExpression.cs
@@ -0,0 +1,41 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Query expression, the name in query is case-sensitive.
+ ///
+ internal sealed class QueryExpression : SourceExpression
+ {
+ ///
+ /// query. string
+ ///
+ public const string Query = "query.";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name string, it's case-insensitive.
+ public QueryExpression(string name)
+ : base(name)
+ {
+ Utils.CheckArgumentNullOrEmpty(name);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression { get => Query + Value; }
+
+ ///
+ /// Gets the name string.
+ ///
+ public string Name { get => Value; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RequestExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RequestExpression.cs
new file mode 100644
index 000000000000..fa5359eff9db
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RequestExpression.cs
@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// $request. expression.
+ ///
+ internal sealed class RequestExpression : RuntimeExpression
+ {
+ ///
+ /// $request. string
+ ///
+ public const string Request = "$request.";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The source of the request.
+ public RequestExpression(SourceExpression source)
+ {
+ Source = Utils.CheckArgumentNull(source);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression => Request + Source.Expression;
+
+ ///
+ /// The expression.
+ ///
+ public SourceExpression Source { get; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/ResponseExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/ResponseExpression.cs
new file mode 100644
index 000000000000..533b78b76094
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/ResponseExpression.cs
@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// $response. expression.
+ ///
+ internal sealed class ResponseExpression : RuntimeExpression
+ {
+ ///
+ /// $response. string
+ ///
+ public const string Response = "$response.";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The source of the response.
+ public ResponseExpression(SourceExpression source)
+ {
+ Source = Utils.CheckArgumentNull(source);
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression => Response + Source.Expression;
+
+ ///
+ /// The expression.
+ ///
+ public SourceExpression Source { get; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RuntimeExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RuntimeExpression.cs
new file mode 100644
index 000000000000..f0e60a3e4f34
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/RuntimeExpression.cs
@@ -0,0 +1,111 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Base class for the Open API runtime expression.
+ ///
+ internal abstract class RuntimeExpression : IEquatable
+ {
+ ///
+ /// The dollar sign prefix for a runtime expression.
+ ///
+ public const string Prefix = "$";
+
+ ///
+ /// The expression string.
+ ///
+ public abstract string Expression { get; }
+
+ ///
+ /// Build the runtime expression from input string.
+ ///
+ /// The runtime expression.
+ /// The built runtime expression object.
+ public static RuntimeExpression Build(string expression)
+ {
+ Utils.CheckArgumentNullOrEmpty(expression);
+
+ if (!expression.StartsWith(Prefix))
+ {
+ return new CompositeExpression(expression);
+ }
+
+ // $url
+ if (expression == UrlExpression.Url)
+ {
+ return new UrlExpression();
+ }
+
+ // $method
+ if (expression == MethodExpression.Method)
+ {
+ return new MethodExpression();
+ }
+
+ // $statusCode
+ if (expression == StatusCodeExpression.StatusCode)
+ {
+ return new StatusCodeExpression();
+ }
+
+ // $request.
+ if (expression.StartsWith(RequestExpression.Request))
+ {
+ var subString = expression.Substring(RequestExpression.Request.Length);
+ var source = SourceExpression.Build(subString);
+ return new RequestExpression(source);
+ }
+
+ // $response.
+ if (expression.StartsWith(ResponseExpression.Response))
+ {
+ var subString = expression.Substring(ResponseExpression.Response.Length);
+ var source = SourceExpression.Build(subString);
+ return new ResponseExpression(source);
+ }
+
+ throw new OpenApiException(string.Format(SRResource.RuntimeExpressionHasInvalidFormat, expression));
+ }
+
+ ///
+ /// GetHashCode implementation for IEquatable.
+ ///
+ public override int GetHashCode()
+ {
+ return Expression.GetHashCode();
+ }
+
+ ///
+ /// Equals implementation for IEquatable.
+ ///
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as RuntimeExpression);
+ }
+
+ ///
+ /// Equals implementation for object of the same type.
+ ///
+ public bool Equals(RuntimeExpression obj)
+ {
+ return obj != null && obj.Expression == Expression;
+ }
+
+ ///
+ public override string ToString()
+ {
+ return Expression;
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/SourceExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/SourceExpression.cs
new file mode 100644
index 000000000000..00a9caa08d4b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/SourceExpression.cs
@@ -0,0 +1,80 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Source expression.
+ ///
+ internal abstract class SourceExpression : RuntimeExpression
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The value string.
+ protected SourceExpression(string value)
+ {
+ Value = value;
+ }
+
+ ///
+ /// Gets the expression string.
+ ///
+ protected string Value { get; }
+
+ ///
+ /// Build the source expression from input string.
+ ///
+ /// The source expression.
+ /// The built source expression.
+ public new static SourceExpression Build(string expression)
+ {
+ if (!string.IsNullOrWhiteSpace(expression))
+ {
+ var expressions = expression.Split('.');
+ if (expressions.Length == 2)
+ {
+ if (expression.StartsWith(HeaderExpression.Header))
+ {
+ // header.
+ return new HeaderExpression(expressions[1]);
+ }
+
+ if (expression.StartsWith(QueryExpression.Query))
+ {
+ // query.
+ return new QueryExpression(expressions[1]);
+ }
+
+ if (expression.StartsWith(PathExpression.Path))
+ {
+ // path.
+ return new PathExpression(expressions[1]);
+ }
+ }
+
+ // body
+ if (expression.StartsWith(BodyExpression.Body))
+ {
+ var subString = expression.Substring(BodyExpression.Body.Length);
+ if (string.IsNullOrEmpty(subString))
+ {
+ return new BodyExpression();
+ }
+
+ return new BodyExpression(new(subString));
+ }
+ }
+
+ throw new OpenApiException(string.Format(SRResource.SourceExpressionHasInvalidFormat, expression));
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs
new file mode 100644
index 000000000000..1ad412ec36f7
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/StatusCodeExpression.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// StatusCode expression.
+ ///
+ internal sealed class StatusCodeExpression : RuntimeExpression
+ {
+ ///
+ /// $statusCode string.
+ ///
+ public const string StatusCode = "$statusCode";
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression => StatusCode;
+
+ ///
+ /// Private constructor.
+ ///
+ public StatusCodeExpression()
+ {
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/UrlExpression.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/UrlExpression.cs
new file mode 100644
index 000000000000..dcb9c66b1a7b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Expressions/UrlExpression.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions
+{
+ ///
+ /// Url expression.
+ ///
+ internal sealed class UrlExpression : RuntimeExpression
+ {
+ ///
+ /// $url string.
+ ///
+ public const string Url = "$url";
+
+ ///
+ /// Gets the expression string.
+ ///
+ public override string Expression => Url;
+
+ ///
+ /// Private constructor.
+ ///
+ public UrlExpression()
+ {
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/EnumExtensions.cs
new file mode 100644
index 000000000000..2f786986ab6a
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/EnumExtensions.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Concurrent;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Reflection;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Attributes;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions
+{
+ ///
+ /// Enumeration type extension methods.
+ ///
+ internal static class EnumExtensions
+ {
+ // Cache to store display names of enum values
+ private static readonly ConcurrentDictionary DisplayNameCache = new();
+
+ ///
+ /// Gets an attribute on an enum field value.
+ ///
+ /// The type of the attribute to retrieve.
+ /// The enum value.
+ ///
+ /// The attribute of the specified type or null.
+ ///
+ [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Fields are never trimmed for enum types.")]
+ public static T GetAttributeOfType(this Enum enumValue) where T : Attribute
+ {
+ var type = enumValue.GetType();
+ // Use GetField to get the field info for the enum value
+ var memInfo = type.GetField(enumValue.ToString(), BindingFlags.Public | BindingFlags.Static);
+
+ if (memInfo == null)
+ return null;
+
+ // Retrieve the custom attributes of type T
+ var attributes = memInfo.GetCustomAttributes(false);
+ return attributes.FirstOrDefault();
+ }
+
+ ///
+ /// Gets the enum display name.
+ ///
+ /// The enum value.
+ ///
+ /// Use if it exists.
+ /// Otherwise, use the standard string representation.
+ ///
+ public static string GetDisplayName(this Enum enumValue)
+ {
+ // Retrieve the display name from the cache if it exists
+ return DisplayNameCache.GetOrAdd(enumValue, e =>
+ {
+ // Get the DisplayAttribute
+ var attribute = e.GetAttributeOfType();
+
+ // Return the DisplayAttribute name if it exists, otherwise return the enum's string representation
+ return attribute == null ? e.ToString() : attribute.Name;
+ });
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs
new file mode 100644
index 000000000000..6224669355ed
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi
+{
+ internal static class OpenAPIWriterExtensions
+ {
+ ///
+ /// Temporary extension method until we add Settings property to IOpenApiWriter in next major version
+ ///
+ ///
+ ///
+ internal static OpenApiWriterSettings GetSettings(this IOpenApiWriter openApiWriter)
+ {
+ if (openApiWriter is OpenApiWriterBase @base)
+ {
+ return @base.Settings;
+ }
+ return new();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs
new file mode 100644
index 000000000000..6d0500d0cb14
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs
@@ -0,0 +1,42 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Models;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions
+{
+ ///
+ /// Extension methods to verify validity and add an extension to Extensions property.
+ ///
+ internal static class OpenApiExtensibleExtensions
+ {
+ ///
+ /// Add extension into the Extensions
+ ///
+ /// .
+ /// The extensible Open API element.
+ /// The extension name.
+ /// The extension value.
+ public static void AddExtension(this T element, string name, IOpenApiExtension any)
+ where T : IOpenApiExtensible
+ {
+ Utils.CheckArgumentNull(element);
+ Utils.CheckArgumentNullOrEmpty(name);
+
+ if (!name.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix))
+ {
+ throw new OpenApiException(string.Format(SRResource.ExtensionFieldNameMustBeginWithXDash, name));
+ }
+
+ element.Extensions[name] = Utils.CheckArgumentNull(any);
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs
new file mode 100644
index 000000000000..514b0b595bb5
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs
@@ -0,0 +1,110 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Models;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions
+{
+ ///
+ /// Extension methods for resolving references on elements.
+ ///
+ internal static class OpenApiReferencableExtensions
+ {
+ ///
+ /// Resolves a JSON Pointer with respect to an element, returning the referenced element.
+ ///
+ /// The referencable Open API element on which to apply the JSON pointer
+ /// a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901).
+ /// The element pointed to by the JSON pointer.
+ public static IOpenApiReferenceable ResolveReference(this IOpenApiReferenceable element, JsonPointer pointer)
+ {
+ if (!pointer.Tokens.Any())
+ {
+ return element;
+ }
+ var propertyName = pointer.Tokens.FirstOrDefault();
+ var mapKey = pointer.Tokens.ElementAtOrDefault(1);
+ try
+ {
+ if (element is OpenApiHeader header)
+ {
+ return ResolveReferenceOnHeaderElement(header, propertyName, mapKey, pointer);
+ }
+ if (element is OpenApiParameter parameter)
+ {
+ return ResolveReferenceOnParameterElement(parameter, propertyName, mapKey, pointer);
+ }
+ if (element is OpenApiResponse response)
+ {
+ return ResolveReferenceOnResponseElement(response, propertyName, mapKey, pointer);
+ }
+ }
+ catch (KeyNotFoundException)
+ {
+ throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer));
+ }
+ throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer));
+ }
+
+ private static IOpenApiReferenceable ResolveReferenceOnHeaderElement(
+ OpenApiHeader headerElement,
+ string propertyName,
+ string mapKey,
+ JsonPointer pointer)
+ {
+ switch (propertyName)
+ {
+ case OpenApiConstants.Schema:
+ return headerElement.Schema;
+ case OpenApiConstants.Examples when mapKey != null:
+ return headerElement.Examples[mapKey];
+ default:
+ throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer));
+ }
+ }
+
+ private static IOpenApiReferenceable ResolveReferenceOnParameterElement(
+ OpenApiParameter parameterElement,
+ string propertyName,
+ string mapKey,
+ JsonPointer pointer)
+ {
+ switch (propertyName)
+ {
+ case OpenApiConstants.Schema:
+ return parameterElement.Schema;
+ case OpenApiConstants.Examples when mapKey != null:
+ return parameterElement.Examples[mapKey];
+ default:
+ throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer));
+ }
+ }
+
+ private static IOpenApiReferenceable ResolveReferenceOnResponseElement(
+ OpenApiResponse responseElement,
+ string propertyName,
+ string mapKey,
+ JsonPointer pointer)
+ {
+ switch (propertyName)
+ {
+ case OpenApiConstants.Headers when mapKey != null:
+ return responseElement.Headers[mapKey];
+ case OpenApiConstants.Links when mapKey != null:
+ return responseElement.Links[mapKey];
+ default:
+ throw new OpenApiException(string.Format(SRResource.InvalidReferenceId, pointer));
+ }
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs
new file mode 100644
index 000000000000..d62536d1c7c3
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs
@@ -0,0 +1,62 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Models;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Properties;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+
+///
+/// Extension methods for serialization.
+///
+internal static class OpenApiServerExtensions
+{
+ ///
+ /// Replaces URL variables in a server's URL
+ ///
+ /// The OpenAPI server object
+ /// The server variable values that will be used to replace the default values.
+ /// A URL with the provided variables substituted.
+ ///
+ /// Thrown when:
+ /// 1. A substitution has no valid value in both the supplied dictionary and the default
+ /// 2. A substitution's value is not available in the enum provided
+ ///
+ public static string ReplaceServerUrlVariables(this OpenApiServer server, IDictionary values = null)
+ {
+ var parsedUrl = server.Url;
+ foreach (var variable in server.Variables)
+ {
+ // Try to get the value from the provided values
+ if (values is not { } v || !v.TryGetValue(variable.Key, out var value) || string.IsNullOrEmpty(value))
+ {
+ // Fall back to the default value
+ value = variable.Value.Default;
+ }
+
+ // Validate value
+ if (string.IsNullOrEmpty(value))
+ {
+ // According to the spec, the variable's default value is required.
+ // This code path should be hit when a value isn't provided & a default value isn't available
+ throw new ArgumentException(
+ string.Format(SRResource.ParseServerUrlDefaultValueNotAvailable, variable.Key), nameof(server));
+ }
+
+ // If an enum is provided, the array should not be empty & the value should exist in the enum
+ if (variable.Value.Enum is {} e && (e.Count == 0 || !e.Contains(value)))
+ {
+ throw new ArgumentException(
+ string.Format(SRResource.ParseServerUrlValueNotValid, value, variable.Key), nameof(values));
+ }
+
+ parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", value);
+ }
+
+ return parsedUrl;
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/StringExtensions.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/StringExtensions.cs
new file mode 100644
index 000000000000..31baf9bc2b67
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Extensions/StringExtensions.cs
@@ -0,0 +1,47 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Attributes;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions
+{
+ ///
+ /// String extension methods.
+ ///
+ internal static class StringExtensions
+ {
+ ///
+ /// Gets the enum value based on the given enum type and display name.
+ ///
+ /// The display name.
+ public static T GetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName)
+ {
+ var type = typeof(T);
+ if (!type.IsEnum)
+ {
+ return default;
+ }
+
+ foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
+ {
+ var displayAttribute = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute));
+ if (displayAttribute != null && displayAttribute.Name == displayName)
+ {
+ return (T)field.GetValue(null);
+ }
+ }
+
+ return default;
+ }
+ internal static string ToFirstCharacterLowerCase(this string input)
+ => string.IsNullOrEmpty(input) ? string.Empty : char.ToLowerInvariant(input[0]) + input.Substring(1);
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IEffective.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IEffective.cs
new file mode 100644
index 000000000000..18f9db6a919b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IEffective.cs
@@ -0,0 +1,28 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Models;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// OpenApiElements that implement IEffective indicate that their description is not self-contained.
+ /// External elements affect the effective description.
+ ///
+ /// Currently this will only be used for accessing external references.
+ /// In the next major version, this will be the approach accessing all referenced elements.
+ /// This will enable us to support merging properties that are peers of the $ref
+ /// Type of OpenApi Element that is being referenced.
+ internal interface IEffective where T : class,IOpenApiElement
+ {
+ ///
+ /// Returns a calculated and cloned version of the element.
+ ///
+ T GetEffective(OpenApiDocument document);
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs
new file mode 100644
index 000000000000..4b4bf23cd5cf
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs
@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Represents an Open API element that can be annotated with
+ /// non-serializable properties in a property bag.
+ ///
+ internal interface IOpenApiAnnotatable
+ {
+ ///
+ /// A collection of properties associated with the current OpenAPI element.
+ ///
+ IDictionary Annotations { get; set; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs
new file mode 100644
index 000000000000..c1d7c75a5a76
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiElement.cs
@@ -0,0 +1,17 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Represents an Open API element.
+ ///
+ internal interface IOpenApiElement
+ {
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs
new file mode 100644
index 000000000000..b518aa751223
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs
@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Represents an Extensible Open API element.
+ ///
+ internal interface IOpenApiExtensible : IOpenApiElement
+ {
+ ///
+ /// Specification extensions.
+ ///
+ IDictionary Extensions { get; set; }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs
new file mode 100644
index 000000000000..217a75d2cd08
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiExtension.cs
@@ -0,0 +1,25 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Interface required for implementing any custom extension
+ ///
+ internal interface IOpenApiExtension
+ {
+ ///
+ /// Write out contents of custom extension
+ ///
+ ///
+ /// Version of the OpenAPI specification that that will be output.
+ void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion);
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs
new file mode 100644
index 000000000000..2e14765c8769
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs
@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Models;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Represents an Open API element is referenceable.
+ ///
+ internal interface IOpenApiReferenceable : IOpenApiSerializable
+ {
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference object.
+ ///
+ OpenApiReference Reference { get; set; }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ void SerializeAsV3WithoutReference(IOpenApiWriter writer);
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ void SerializeAsV2WithoutReference(IOpenApiWriter writer);
+
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs
new file mode 100644
index 000000000000..e124bcbfae43
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Interfaces/IOpenApiSerializable.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces
+{
+ ///
+ /// Represents an Open API element that comes with serialization functionality.
+ ///
+ internal interface IOpenApiSerializable : IOpenApiElement
+ {
+ ///
+ /// Serialize Open API element to v3.0.
+ ///
+ /// The writer.
+ void SerializeAsV3(IOpenApiWriter writer);
+
+ ///
+ /// Serialize Open API element to v2.0.
+ ///
+ /// The writer.
+ void SerializeAsV2(IOpenApiWriter writer);
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/JsonPointer.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/JsonPointer.cs
new file mode 100644
index 000000000000..83647c18ff19
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/JsonPointer.cs
@@ -0,0 +1,76 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Linq;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi
+{
+ ///
+ /// JSON pointer.
+ ///
+ internal class JsonPointer
+ {
+ ///
+ /// Initializes the class.
+ ///
+ /// Pointer as string.
+ public JsonPointer(string pointer)
+ {
+ Tokens = string.IsNullOrEmpty(pointer) || pointer == "/"
+ ? new string[0]
+ : pointer.Split('/').Skip(1).Select(Decode).ToArray();
+ }
+
+ ///
+ /// Initializes the class.
+ ///
+ /// Pointer as tokenized string.
+ private JsonPointer(string[] tokens)
+ {
+ Tokens = tokens;
+ }
+
+ ///
+ /// Tokens.
+ ///
+ public string[] Tokens { get; }
+
+ ///
+ /// Gets the parent pointer.
+ ///
+ public JsonPointer ParentPointer
+ {
+ get
+ {
+ if (Tokens.Length == 0)
+ {
+ return null;
+ }
+
+ return new(Tokens.Take(Tokens.Length - 1).ToArray());
+ }
+ }
+
+ ///
+ /// Decode the string.
+ ///
+ private string Decode(string token)
+ {
+ return Uri.UnescapeDataString(token).Replace("~1", "/").Replace("~0", "~");
+ }
+
+ ///
+ /// Gets the string representation of this JSON pointer.
+ ///
+ public override string ToString()
+ {
+ return "/" + string.Join("/", Tokens);
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Microsoft.OpenApi.csproj.txt b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Microsoft.OpenApi.csproj.txt
new file mode 100644
index 000000000000..9eacf3c170f6
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Microsoft.OpenApi.csproj.txt
@@ -0,0 +1,45 @@
+
+
+ netstandard2.0
+ Latest
+ true
+ 1.6.23
+ .NET models with JSON and YAML writers for OpenAPI specification
+ true
+
+ true
+ NU5048
+ README.md
+
+
+
+ bin\$(Configuration)\$(TargetFramework)\Microsoft.OpenApi.xml
+ ..\Microsoft.OpenApi.snk
+
+
+
+
+ True
+ True
+ SRResource.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ SRResource.Designer.cs
+
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiCallback.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiCallback.cs
new file mode 100644
index 000000000000..7fe319028a6f
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiCallback.cs
@@ -0,0 +1,154 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Expressions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Callback Object: A map of possible out-of band callbacks related to the parent operation.
+ ///
+ internal class OpenApiCallback : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// A Path Item Object used to define a callback request and expected responses.
+ ///
+ public Dictionary PathItems { get; set; }
+ = new();
+
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference pointer.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiCallback() { }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiCallback(OpenApiCallback callback)
+ {
+ PathItems = callback?.PathItems != null ? new(callback?.PathItems) : null;
+ UnresolvedReference = callback?.UnresolvedReference ?? UnresolvedReference;
+ Reference = callback?.Reference != null ? new(callback?.Reference) : null;
+ Extensions = callback?.Extensions != null ? new Dictionary(callback.Extensions) : null;
+ }
+
+ ///
+ /// Add a into the .
+ ///
+ /// The runtime expression.
+ /// The path item.
+ public void AddPathItem(RuntimeExpression expression, OpenApiPathItem pathItem)
+ {
+ Utils.CheckArgumentNull(expression);
+ Utils.CheckArgumentNull(pathItem);
+
+ if (PathItems == null)
+ {
+ PathItems = new();
+ }
+
+ PathItems.Add(expression, pathItem);
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiCallback object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiCallback
+ public OpenApiCallback GetEffective(OpenApiDocument doc)
+ {
+ if (this.Reference != null)
+ {
+ return doc.ResolveReferenceTo(this.Reference);
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // path items
+ foreach (var item in PathItems)
+ {
+ writer.WriteRequiredObject(item.Key.Expression, item.Value, (w, p) => p.SerializeAsV3(w));
+ }
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Callback object does not exist in V2.
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ // Callback object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiComponents.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiComponents.cs
new file mode 100644
index 000000000000..ff74fa27beee
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiComponents.cs
@@ -0,0 +1,295 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Components Object.
+ ///
+ internal class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Schemas { get; set; } = new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Responses { get; set; } = new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Parameters { get; set; } =
+ new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Examples { get; set; } = new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary RequestBodies { get; set; } =
+ new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Headers { get; set; } = new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary SecuritySchemes { get; set; } =
+ new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Links { get; set; } = new Dictionary();
+
+ ///
+ /// An object to hold reusable Objects.
+ ///
+ public IDictionary Callbacks { get; set; } = new Dictionary();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiComponents() { }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiComponents(OpenApiComponents components)
+ {
+ Schemas = components?.Schemas != null ? new Dictionary(components.Schemas) : null;
+ Responses = components?.Responses != null ? new Dictionary(components.Responses) : null;
+ Parameters = components?.Parameters != null ? new Dictionary(components.Parameters) : null;
+ Examples = components?.Examples != null ? new Dictionary(components.Examples) : null;
+ RequestBodies = components?.RequestBodies != null ? new Dictionary(components.RequestBodies) : null;
+ Headers = components?.Headers != null ? new Dictionary(components.Headers) : null;
+ SecuritySchemes = components?.SecuritySchemes != null ? new Dictionary(components.SecuritySchemes) : null;
+ Links = components?.Links != null ? new Dictionary(components.Links) : null;
+ Callbacks = components?.Callbacks != null ? new Dictionary(components.Callbacks) : null;
+ Extensions = components?.Extensions != null ? new Dictionary(components.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ // If references have been inlined we don't need the to render the components section
+ // however if they have cycles, then we will need a component rendered
+ if (writer.GetSettings().InlineLocalReferences)
+ {
+ var loops = writer.GetSettings().LoopDetector.Loops;
+ writer.WriteStartObject();
+ if (loops.TryGetValue(typeof(OpenApiSchema), out var schemas))
+ {
+ var openApiSchemas = schemas.Cast().Distinct().ToList()
+ .ToDictionary(k => k.Reference.Id);
+
+ writer.WriteOptionalMap(
+ OpenApiConstants.Schemas,
+ Schemas,
+ (w, _, component) => component.SerializeAsV3WithoutReference(w));
+ }
+ writer.WriteEndObject();
+ return;
+ }
+
+ writer.WriteStartObject();
+
+ // Serialize each referenceable object as full object without reference if the reference in the object points to itself.
+ // If the reference exists but points to other objects, the object is serialized to just that reference.
+
+ // schemas
+ writer.WriteOptionalMap(
+ OpenApiConstants.Schemas,
+ Schemas,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Schema} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // responses
+ writer.WriteOptionalMap(
+ OpenApiConstants.Responses,
+ Responses,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Response} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // parameters
+ writer.WriteOptionalMap(
+ OpenApiConstants.Parameters,
+ Parameters,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Parameter} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // examples
+ writer.WriteOptionalMap(
+ OpenApiConstants.Examples,
+ Examples,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Example} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // requestBodies
+ writer.WriteOptionalMap(
+ OpenApiConstants.RequestBodies,
+ RequestBodies,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.RequestBody} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // headers
+ writer.WriteOptionalMap(
+ OpenApiConstants.Headers,
+ Headers,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Header} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // securitySchemes
+ writer.WriteOptionalMap(
+ OpenApiConstants.SecuritySchemes,
+ SecuritySchemes,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.SecurityScheme} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // links
+ writer.WriteOptionalMap(
+ OpenApiConstants.Links,
+ Links,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Link} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // callbacks
+ writer.WriteOptionalMap(
+ OpenApiConstants.Callbacks,
+ Callbacks,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Callback} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV3WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV3(w);
+ }
+ });
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Components object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiConstants.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiConstants.cs
new file mode 100644
index 000000000000..d12c84d3d273
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiConstants.cs
@@ -0,0 +1,652 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Constants used in the Open API document.
+ ///
+ internal static class OpenApiConstants
+ {
+ ///
+ /// Field: OpenApi
+ ///
+ public const string OpenApi = "openapi";
+
+ ///
+ /// Field: Info
+ ///
+ public const string Info = "info";
+
+ ///
+ /// Field: Title
+ ///
+ public const string Title = "title";
+
+ ///
+ /// Field: Type
+ ///
+ public const string Type = "type";
+
+ ///
+ /// Field: Format
+ ///
+ public const string Format = "format";
+
+ ///
+ /// Field: Version
+ ///
+ public const string Version = "version";
+
+ ///
+ /// Field: Contact
+ ///
+ public const string Contact = "contact";
+
+ ///
+ /// Field: License
+ ///
+ public const string License = "license";
+
+ ///
+ /// Field: TermsOfService
+ ///
+ public const string TermsOfService = "termsOfService";
+
+ ///
+ /// Field: Servers
+ ///
+ public const string Servers = "servers";
+
+ ///
+ /// Field: Server
+ ///
+ public const string Server = "server";
+
+ ///
+ /// Field: Paths
+ ///
+ public const string Paths = "paths";
+
+ ///
+ /// Field: Components
+ ///
+ public const string Components = "components";
+
+ ///
+ /// Field: Security
+ ///
+ public const string Security = "security";
+
+ ///
+ /// Field: Tags
+ ///
+ public const string Tags = "tags";
+
+ ///
+ /// Field: ExternalDocs
+ ///
+ public const string ExternalDocs = "externalDocs";
+
+ ///
+ /// Field: OperationRef
+ ///
+ public const string OperationRef = "operationRef";
+
+ ///
+ /// Field: OperationId
+ ///
+ public const string OperationId = "operationId";
+
+ ///
+ /// Field: Parameters
+ ///
+ public const string Parameters = "parameters";
+
+ ///
+ /// Field: RequestBody
+ ///
+ public const string RequestBody = "requestBody";
+
+ ///
+ /// Field: ExtensionFieldNamePrefix
+ ///
+ public const string ExtensionFieldNamePrefix = "x-";
+
+ ///
+ /// Field: Name
+ ///
+ public const string Name = "name";
+
+ ///
+ /// Field: Namespace
+ ///
+ public const string Namespace = "namespace";
+
+ ///
+ /// Field: Prefix
+ ///
+ public const string Prefix = "prefix";
+
+ ///
+ /// Field: Attribute
+ ///
+ public const string Attribute = "attribute";
+
+ ///
+ /// Field: Wrapped
+ ///
+ public const string Wrapped = "wrapped";
+
+ ///
+ /// Field: In
+ ///
+ public const string In = "in";
+
+ ///
+ /// Field: Summary
+ ///
+ public const string Summary = "summary";
+
+ ///
+ /// Field: Variables
+ ///
+ public const string Variables = "variables";
+
+ ///
+ /// Field: Description
+ ///
+ public const string Description = "description";
+
+ ///
+ /// Field: Required
+ ///
+ public const string Required = "required";
+
+ ///
+ /// Field: Deprecated
+ ///
+ public const string Deprecated = "deprecated";
+
+ ///
+ /// Field: Style
+ ///
+ public const string Style = "style";
+
+ ///
+ /// Field: Explode
+ ///
+ public const string Explode = "explode";
+
+ ///
+ /// Field: AllowReserved
+ ///
+ public const string AllowReserved = "allowReserved";
+
+ ///
+ /// Field: Schema
+ ///
+ public const string Schema = "schema";
+
+ ///
+ /// Field: Schemas
+ ///
+ public const string Schemas = "schemas";
+
+ ///
+ /// Field: Responses
+ ///
+ public const string Responses = "responses";
+
+ ///
+ /// Field: Example
+ ///
+ public const string Example = "example";
+
+ ///
+ /// Field: Examples
+ ///
+ public const string Examples = "examples";
+
+ ///
+ /// Field: Encoding
+ ///
+ public const string Encoding = "encoding";
+
+ ///
+ /// Field: RequestBodies
+ ///
+ public const string RequestBodies = "requestBodies";
+
+ ///
+ /// Field: AllowEmptyValue
+ ///
+ public const string AllowEmptyValue = "allowEmptyValue";
+
+ ///
+ /// Field: Value
+ ///
+ public const string Value = "value";
+
+ ///
+ /// Field: ExternalValue
+ ///
+ public const string ExternalValue = "externalValue";
+
+ ///
+ /// Field: DollarRef
+ ///
+ public const string DollarRef = "$ref";
+
+ ///
+ /// Field: Headers
+ ///
+ public const string Headers = "headers";
+
+ ///
+ /// Field: SecuritySchemes
+ ///
+ public const string SecuritySchemes = "securitySchemes";
+
+ ///
+ /// Field: Content
+ ///
+ public const string Content = "content";
+
+ ///
+ /// Field: Links
+ ///
+ public const string Links = "links";
+
+ ///
+ /// Field: Callbacks
+ ///
+ public const string Callbacks = "callbacks";
+
+ ///
+ /// Field: Url
+ ///
+ public const string Url = "url";
+
+ ///
+ /// Field: Email
+ ///
+ public const string Email = "email";
+
+ ///
+ /// Field: Default
+ ///
+ public const string Default = "default";
+
+ ///
+ /// Field: Enum
+ ///
+ public const string Enum = "enum";
+
+ ///
+ /// Field: MultipleOf
+ ///
+ public const string MultipleOf = "multipleOf";
+
+ ///
+ /// Field: Maximum
+ ///
+ public const string Maximum = "maximum";
+
+ ///
+ /// Field: ExclusiveMaximum
+ ///
+ public const string ExclusiveMaximum = "exclusiveMaximum";
+
+ ///
+ /// Field: Minimum
+ ///
+ public const string Minimum = "minimum";
+
+ ///
+ /// Field: ExclusiveMinimum
+ ///
+ public const string ExclusiveMinimum = "exclusiveMinimum";
+
+ ///
+ /// Field: MaxLength
+ ///
+ public const string MaxLength = "maxLength";
+
+ ///
+ /// Field: MinLength
+ ///
+ public const string MinLength = "minLength";
+
+ ///
+ /// Field: Pattern
+ ///
+ public const string Pattern = "pattern";
+
+ ///
+ /// Field: MaxItems
+ ///
+ public const string MaxItems = "maxItems";
+
+ ///
+ /// Field: MinItems
+ ///
+ public const string MinItems = "minItems";
+
+ ///
+ /// Field: UniqueItems
+ ///
+ public const string UniqueItems = "uniqueItems";
+
+ ///
+ /// Field: MaxProperties
+ ///
+ public const string MaxProperties = "maxProperties";
+
+ ///
+ /// Field: MinProperties
+ ///
+ public const string MinProperties = "minProperties";
+
+ ///
+ /// Field: AllOf
+ ///
+ public const string AllOf = "allOf";
+
+ ///
+ /// Field: OneOf
+ ///
+ public const string OneOf = "oneOf";
+
+ ///
+ /// Field: AnyOf
+ ///
+ public const string AnyOf = "anyOf";
+
+ ///
+ /// Field: Not
+ ///
+ public const string Not = "not";
+
+ ///
+ /// Field: Items
+ ///
+ public const string Items = "items";
+
+ ///
+ /// Field: Properties
+ ///
+ public const string Properties = "properties";
+
+ ///
+ /// Field: AdditionalProperties
+ ///
+ public const string AdditionalProperties = "additionalProperties";
+
+ ///
+ /// Field: Nullable
+ ///
+ public const string Nullable = "nullable";
+
+ ///
+ /// Field: Discriminator
+ ///
+ public const string Discriminator = "discriminator";
+
+ ///
+ /// Field: ReadOnly
+ ///
+ public const string ReadOnly = "readOnly";
+
+ ///
+ /// Field: WriteOnly
+ ///
+ public const string WriteOnly = "writeOnly";
+
+ ///
+ /// Field: Xml
+ ///
+ public const string Xml = "xml";
+
+ ///
+ /// Field: Flow
+ ///
+ public const string Flow = "flow";
+
+ ///
+ /// Field: Application
+ ///
+ public const string Application = "application";
+
+ ///
+ /// Field: AccessCode
+ ///
+ public const string AccessCode = "accessCode";
+
+ ///
+ /// Field: Implicit
+ ///
+ public const string Implicit = "implicit";
+
+ ///
+ /// Field: Password
+ ///
+ public const string Password = "password";
+
+ ///
+ /// Field: ClientCredentials
+ ///
+ public const string ClientCredentials = "clientCredentials";
+
+ ///
+ /// Field: AuthorizationCode
+ ///
+ public const string AuthorizationCode = "authorizationCode";
+
+ ///
+ /// Field: AuthorizationUrl
+ ///
+ public const string AuthorizationUrl = "authorizationUrl";
+
+ ///
+ /// Field: TokenUrl
+ ///
+ public const string TokenUrl = "tokenUrl";
+
+ ///
+ /// Field: RefreshUrl
+ ///
+ public const string RefreshUrl = "refreshUrl";
+
+ ///
+ /// Field: Scopes
+ ///
+ public const string Scopes = "scopes";
+
+ ///
+ /// Field: ContentType
+ ///
+ public const string ContentType = "contentType";
+
+ ///
+ /// Field: Get
+ ///
+ public const string Get = "get";
+
+ ///
+ /// Field: Put
+ ///
+ public const string Put = "put";
+
+ ///
+ /// Field: Post
+ ///
+ public const string Post = "post";
+
+ ///
+ /// Field: Delete
+ ///
+ public const string Delete = "delete";
+
+ ///
+ /// Field: Options
+ ///
+ public const string Options = "options";
+
+ ///
+ /// Field: Head
+ ///
+ public const string Head = "head";
+
+ ///
+ /// Field: Patch
+ ///
+ public const string Patch = "patch";
+
+ ///
+ /// Field: Trace
+ ///
+ public const string Trace = "trace";
+
+ ///
+ /// Field: PropertyName
+ ///
+ public const string PropertyName = "propertyName";
+
+ ///
+ /// Field: Mapping
+ ///
+ public const string Mapping = "mapping";
+
+ ///
+ /// Field: Scheme
+ ///
+ public const string Scheme = "scheme";
+
+ ///
+ /// Field: BearerFormat
+ ///
+ public const string BearerFormat = "bearerFormat";
+
+ ///
+ /// Field: Flows
+ ///
+ public const string Flows = "flows";
+
+ ///
+ /// Field: OpenIdConnectUrl
+ ///
+ public const string OpenIdConnectUrl = "openIdConnectUrl";
+
+ ///
+ /// Field: DefaultName
+ ///
+ public const string DefaultName = "Default Name";
+
+ ///
+ /// Field: DefaultDefault
+ ///
+ public const string DefaultDefault = "Default Default";
+
+ ///
+ /// Field: DefaultTitle
+ ///
+ public const string DefaultTitle = "Default Title";
+
+ ///
+ /// Field: DefaultDescription
+ ///
+ public const string DefaultDescription = "Default Description";
+
+ ///
+ /// Field: BodyName extensions
+ ///
+ public const string BodyName = "x-bodyName";
+
+ ///
+ /// Field: Examples Extension
+ ///
+ public const string ExamplesExtension = "x-examples";
+
+ ///
+ /// Field: version3_0_0
+ ///
+ public static readonly Version version3_0_0 = new(3, 0, 0);
+
+ ///
+ /// Field: defaultUrl
+ ///
+ public static readonly Uri defaultUrl = new("http://localhost/");
+
+ #region V2.0
+
+ ///
+ /// Field: Host
+ ///
+ public const string Host = "host";
+
+ ///
+ /// Field: Swagger
+ ///
+ public const string Swagger = "swagger";
+
+ ///
+ /// Field: version2_0
+ ///
+ public static readonly Version version2_0 = new(2, 0);
+
+ ///
+ /// Field: BasePath
+ ///
+ public const string BasePath = "basePath";
+
+ ///
+ /// Field: Schemes
+ ///
+ public const string Schemes = "schemes";
+
+ ///
+ /// Field: SecurityDefinitions
+ ///
+ public const string SecurityDefinitions = "securityDefinitions";
+
+ ///
+ /// Field: Definitions
+ ///
+ public const string Definitions = "definitions";
+
+ ///
+ /// Field: Basic
+ ///
+ public const string Basic = "basic";
+
+ ///
+ /// Field: Bearer
+ ///
+ public const string Bearer = "bearer";
+
+ ///
+ /// Field: JWT
+ ///
+ public const string Jwt = "JWT";
+
+ ///
+ /// Field: Consumes
+ ///
+ public const string Consumes = "consumes";
+
+ ///
+ /// Field: Produces
+ ///
+ public const string Produces = "produces";
+
+ #endregion
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiContact.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiContact.cs
new file mode 100644
index 000000000000..911e8a87c86a
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiContact.cs
@@ -0,0 +1,93 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Contact Object.
+ ///
+ internal class OpenApiContact : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// The identifying name of the contact person/organization.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// The URL pointing to the contact information. MUST be in the format of a URL.
+ ///
+ public Uri Url { get; set; }
+
+ ///
+ /// The email address of the contact person/organization.
+ /// MUST be in the format of an email address.
+ ///
+ public string Email { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiContact() { }
+
+ ///
+ /// Initializes a copy of an instance
+ ///
+ public OpenApiContact(OpenApiContact contact)
+ {
+ Name = contact?.Name ?? Name;
+ Url = contact?.Url != null ? new Uri(contact.Url.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ Email = contact?.Email ?? Email;
+ Extensions = contact?.Extensions != null ? new Dictionary(contact.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0);
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0);
+ }
+
+ private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteStartObject();
+
+ // name
+ writer.WriteProperty(OpenApiConstants.Name, Name);
+
+ // url
+ writer.WriteProperty(OpenApiConstants.Url, Url?.OriginalString);
+
+ // email
+ writer.WriteProperty(OpenApiConstants.Email, Email);
+
+ // extensions
+ writer.WriteExtensions(Extensions, specVersion);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs
new file mode 100644
index 000000000000..f02d91457007
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Discriminator object.
+ ///
+ internal class OpenApiDiscriminator : IOpenApiSerializable
+ {
+ ///
+ /// REQUIRED. The name of the property in the payload that will hold the discriminator value.
+ ///
+ public string PropertyName { get; set; }
+
+ ///
+ /// An object to hold mappings between payload values and schema names or references.
+ ///
+ public IDictionary Mapping { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiDiscriminator() { }
+
+ ///
+ /// Initializes a copy of an instance
+ ///
+ public OpenApiDiscriminator(OpenApiDiscriminator discriminator)
+ {
+ PropertyName = discriminator?.PropertyName ?? PropertyName;
+ Mapping = discriminator?.Mapping != null ? new Dictionary(discriminator.Mapping) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // propertyName
+ writer.WriteProperty(OpenApiConstants.PropertyName, PropertyName);
+
+ // mapping
+ writer.WriteOptionalMap(OpenApiConstants.Mapping, Mapping, (w, s) => w.WriteValue(s));
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Discriminator object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDocument.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDocument.cs
new file mode 100644
index 000000000000..a14d65ed3057
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiDocument.cs
@@ -0,0 +1,564 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Services;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Describes an OpenAPI object (OpenAPI document). See: https://swagger.io/specification
+ ///
+ internal class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable
+ {
+ ///
+ /// Related workspace containing OpenApiDocuments that are referenced in this document
+ ///
+ public OpenApiWorkspace Workspace { get; set; }
+
+ ///
+ /// REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
+ ///
+ public OpenApiInfo Info { get; set; }
+
+ ///
+ /// An array of Server Objects, which provide connectivity information to a target server.
+ ///
+ public IList Servers { get; set; } = new List();
+
+ ///
+ /// REQUIRED. The available paths and operations for the API.
+ ///
+ public OpenApiPaths Paths { get; set; }
+
+ ///
+ /// An element to hold various schemas for the specification.
+ ///
+ public OpenApiComponents Components { get; set; }
+
+ ///
+ /// A declaration of which security mechanisms can be used across the API.
+ ///
+ public IList SecurityRequirements { get; set; } = new List();
+
+ ///
+ /// A list of tags used by the specification with additional metadata.
+ ///
+ public IList Tags { get; set; } = new List();
+
+ ///
+ /// Additional external documentation.
+ ///
+ public OpenApiExternalDocs ExternalDocs { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// The unique hash code of the generated OpenAPI document
+ ///
+ public string HashCode => GenerateHashValue(this);
+
+ ///
+ public IDictionary Annotations { get; set; }
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiDocument() {}
+
+ ///
+ /// Initializes a copy of an an object
+ ///
+ public OpenApiDocument(OpenApiDocument document)
+ {
+ Workspace = document?.Workspace != null ? new(document?.Workspace) : null;
+ Info = document?.Info != null ? new(document?.Info) : null;
+ Servers = document?.Servers != null ? new List(document.Servers) : null;
+ Paths = document?.Paths != null ? new(document?.Paths) : null;
+ Components = document?.Components != null ? new(document?.Components) : null;
+ SecurityRequirements = document?.SecurityRequirements != null ? new List(document.SecurityRequirements) : null;
+ Tags = document?.Tags != null ? new List(document.Tags) : null;
+ ExternalDocs = document?.ExternalDocs != null ? new(document?.ExternalDocs) : null;
+ Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null;
+ Annotations = document?.Annotations != null ? new Dictionary(document.Annotations) : null;
+ }
+
+ ///
+ /// Serialize to the latest patch of OpenAPI object V3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // openapi
+ writer.WriteProperty(OpenApiConstants.OpenApi, "3.0.4");
+
+ // info
+ writer.WriteRequiredObject(OpenApiConstants.Info, Info, (w, i) => i.SerializeAsV3(w));
+
+ // servers
+ writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, (w, s) => s.SerializeAsV3(w));
+
+ // paths
+ writer.WriteRequiredObject(OpenApiConstants.Paths, Paths, (w, p) => p.SerializeAsV3(w));
+
+ // components
+ writer.WriteOptionalObject(OpenApiConstants.Components, Components, (w, c) => c.SerializeAsV3(w));
+
+ // security
+ writer.WriteOptionalCollection(
+ OpenApiConstants.Security,
+ SecurityRequirements,
+ (w, s) => s.SerializeAsV3(w));
+
+ // tags
+ writer.WriteOptionalCollection(OpenApiConstants.Tags, Tags, (w, t) => t.SerializeAsV3WithoutReference(w));
+
+ // external docs
+ writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, e) => e.SerializeAsV3(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to OpenAPI object V2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // swagger
+ writer.WriteProperty(OpenApiConstants.Swagger, "2.0");
+
+ // info
+ writer.WriteRequiredObject(OpenApiConstants.Info, Info, (w, i) => i.SerializeAsV2(w));
+
+ // host, basePath, schemes, consumes, produces
+ WriteHostInfoV2(writer, Servers);
+
+ // paths
+ writer.WriteRequiredObject(OpenApiConstants.Paths, Paths, (w, p) => p.SerializeAsV2(w));
+
+ // If references have been inlined we don't need to render the components section
+ // however if they have cycles, then we will need a component rendered
+ if (writer.GetSettings().InlineLocalReferences)
+ {
+ var loops = writer.GetSettings().LoopDetector.Loops;
+
+ if (loops.TryGetValue(typeof(OpenApiSchema), out var schemas))
+ {
+ var openApiSchemas = schemas.Cast().Distinct().ToList()
+ .ToDictionary(k => k.Reference.Id);
+
+ foreach (var schema in openApiSchemas.Values.ToList())
+ {
+ FindSchemaReferences.ResolveSchemas(Components, openApiSchemas);
+ }
+
+ writer.WriteOptionalMap(
+ OpenApiConstants.Definitions,
+ openApiSchemas,
+ (w, _, component) => component.SerializeAsV2WithoutReference(w));
+ }
+ }
+ else
+ {
+ // Serialize each referenceable object as full object without reference if the reference in the object points to itself.
+ // If the reference exists but points to other objects, the object is serialized to just that reference.
+ // definitions
+ writer.WriteOptionalMap(
+ OpenApiConstants.Definitions,
+ Components?.Schemas,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Schema} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV2WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV2(w);
+ }
+ });
+ }
+ // parameters
+ var parameters = Components?.Parameters != null
+ ? new(Components.Parameters)
+ : new Dictionary();
+
+ if (Components?.RequestBodies != null)
+ {
+ foreach (var requestBody in Components.RequestBodies.Where(b => !parameters.ContainsKey(b.Key)))
+ {
+ parameters.Add(requestBody.Key, requestBody.Value.ConvertToBodyParameter());
+ }
+ }
+ writer.WriteOptionalMap(
+ OpenApiConstants.Parameters,
+ parameters,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Parameter} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV2WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV2(w);
+ }
+ });
+
+ // responses
+ writer.WriteOptionalMap(
+ OpenApiConstants.Responses,
+ Components?.Responses,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.Response} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV2WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV2(w);
+ }
+ });
+
+ // securityDefinitions
+ writer.WriteOptionalMap(
+ OpenApiConstants.SecurityDefinitions,
+ Components?.SecuritySchemes,
+ (w, key, component) =>
+ {
+ if (component.Reference is {Type: ReferenceType.SecurityScheme} &&
+ component.Reference.Id == key)
+ {
+ component.SerializeAsV2WithoutReference(w);
+ }
+ else
+ {
+ component.SerializeAsV2(w);
+ }
+ });
+
+ // security
+ writer.WriteOptionalCollection(
+ OpenApiConstants.Security,
+ SecurityRequirements,
+ (w, s) => s.SerializeAsV2(w));
+
+ // tags
+ writer.WriteOptionalCollection(OpenApiConstants.Tags, Tags, (w, t) => t.SerializeAsV2WithoutReference(w));
+
+ // externalDocs
+ writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, e) => e.SerializeAsV2(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+
+ private static string ParseServerUrl(OpenApiServer server)
+ {
+ return server.ReplaceServerUrlVariables(new Dictionary(0));
+ }
+
+ private static void WriteHostInfoV2(IOpenApiWriter writer, IList servers)
+ {
+ if (servers == null || !servers.Any())
+ {
+ return;
+ }
+
+ // Arbitrarily choose the first server given that V2 only allows
+ // one host, port, and base path.
+ var serverUrl = ParseServerUrl(servers.First());
+
+ // Divide the URL in the Url property into host and basePath required in OpenAPI V2
+ // The Url property cannot contain path templating to be valid for V2 serialization.
+ var firstServerUrl = new Uri(serverUrl, UriKind.RelativeOrAbsolute);
+
+ // host
+ if (firstServerUrl.IsAbsoluteUri)
+ {
+ writer.WriteProperty(
+ OpenApiConstants.Host,
+ firstServerUrl.GetComponents(UriComponents.Host | UriComponents.Port, UriFormat.SafeUnescaped));
+
+ // basePath
+ if (firstServerUrl.AbsolutePath != "/")
+ {
+ writer.WriteProperty(OpenApiConstants.BasePath, firstServerUrl.AbsolutePath);
+ }
+ } else
+ {
+ var relativeUrl = firstServerUrl.OriginalString;
+ if (relativeUrl.StartsWith("//"))
+ {
+ var pathPosition = relativeUrl.IndexOf('/', 3);
+ writer.WriteProperty(OpenApiConstants.Host, relativeUrl.Substring(0, pathPosition));
+ relativeUrl = relativeUrl.Substring(pathPosition);
+ }
+ if (!String.IsNullOrEmpty(relativeUrl) && relativeUrl != "/")
+ {
+ writer.WriteProperty(OpenApiConstants.BasePath, relativeUrl);
+ }
+ }
+
+ // Consider all schemes of the URLs in the server list that have the same
+ // host, port, and base path as the first server.
+ var schemes = servers.Select(
+ s =>
+ {
+ Uri.TryCreate(ParseServerUrl(s), UriKind.RelativeOrAbsolute, out var url);
+ return url;
+ })
+ .Where(
+ u => Uri.Compare(
+ u,
+ firstServerUrl,
+ UriComponents.Host | UriComponents.Port | UriComponents.Path,
+ UriFormat.SafeUnescaped,
+ StringComparison.OrdinalIgnoreCase) ==
+ 0 && u.IsAbsoluteUri)
+ .Select(u => u.Scheme)
+ .Distinct()
+ .ToList();
+
+ // schemes
+ writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => w.WriteValue(s));
+ }
+
+ ///
+ /// Walk the OpenApiDocument and resolve unresolved references
+ ///
+ ///
+ /// This method will be replaced by a LoadExternalReferences in the next major update to this library.
+ /// Resolving references at load time is going to go away.
+ ///
+ public IEnumerable ResolveReferences()
+ {
+ var resolver = new OpenApiReferenceResolver(this, false);
+ var walker = new OpenApiWalker(resolver);
+ walker.Walk(this);
+ return resolver.Errors;
+ }
+
+ ///
+ /// Load the referenced object from a object
+ ///
+ internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IOpenApiReferenceable
+ {
+ if (reference.IsExternal)
+ {
+ return ResolveReference(reference, true) as T;
+ }
+ else
+ {
+ return ResolveReference(reference, false) as T;
+ }
+ }
+
+ ///
+ /// Load the referenced object from a object
+ ///
+ public IOpenApiReferenceable ResolveReference(OpenApiReference reference)
+ {
+ return ResolveReference(reference, false);
+ }
+
+ ///
+ /// Takes in an OpenApi document instance and generates its hash value
+ ///
+ /// The OpenAPI description to hash.
+ /// The hash value.
+ public static string GenerateHashValue(OpenApiDocument doc)
+ {
+ using HashAlgorithm sha = SHA512.Create();
+ using var cryptoStream = new CryptoStream(Stream.Null, sha, CryptoStreamMode.Write);
+ using var streamWriter = new StreamWriter(cryptoStream);
+
+ var openApiJsonWriter = new OpenApiJsonWriter(streamWriter, new() { Terse = true });
+ doc.SerializeAsV3(openApiJsonWriter);
+ openApiJsonWriter.Flush();
+
+ cryptoStream.FlushFinalBlock();
+ var hash = sha.Hash;
+
+ return ConvertByteArrayToString(hash);
+ }
+
+ private static string ConvertByteArrayToString(byte[] hash)
+ {
+ // Build the final string by converting each byte
+ // into hex and appending it to a StringBuilder
+ var sb = new StringBuilder();
+ for (var i = 0; i < hash.Length; i++)
+ {
+ sb.Append(hash[i].ToString("X2"));
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// Load the referenced object from a object
+ ///
+ internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal)
+ {
+ if (reference == null)
+ {
+ return null;
+ }
+
+ // Todo: Verify if we need to check to see if this external reference is actually targeted at this document.
+ if (useExternal)
+ {
+ if (this.Workspace == null)
+ {
+ throw new ArgumentException(Properties.SRResource.WorkspaceRequredForExternalReferenceResolution);
+ }
+ return this.Workspace.ResolveReference(reference);
+ }
+
+ if (!reference.Type.HasValue)
+ {
+ throw new ArgumentException(Properties.SRResource.LocalReferenceRequiresType);
+ }
+
+ // Special case for Tag
+ if (reference.Type == ReferenceType.Tag)
+ {
+ foreach (var tag in this.Tags)
+ {
+ if (tag.Name == reference.Id)
+ {
+ tag.Reference = reference;
+ return tag;
+ }
+ }
+
+ return null;
+ }
+
+ if (this.Components == null)
+ {
+ throw new OpenApiException(string.Format(Properties.SRResource.InvalidReferenceId, reference.Id));
+ }
+
+ try
+ {
+ switch (reference.Type)
+ {
+ case ReferenceType.Schema:
+ return this.Components.Schemas[reference.Id];
+
+ case ReferenceType.Response:
+ return this.Components.Responses[reference.Id];
+
+ case ReferenceType.Parameter:
+ return this.Components.Parameters[reference.Id];
+
+ case ReferenceType.Example:
+ return this.Components.Examples[reference.Id];
+
+ case ReferenceType.RequestBody:
+ return this.Components.RequestBodies[reference.Id];
+
+ case ReferenceType.Header:
+ return this.Components.Headers[reference.Id];
+
+ case ReferenceType.SecurityScheme:
+ return this.Components.SecuritySchemes[reference.Id];
+
+ case ReferenceType.Link:
+ return this.Components.Links[reference.Id];
+
+ case ReferenceType.Callback:
+ return this.Components.Callbacks[reference.Id];
+
+ case ReferenceType.Path:
+ return this.Paths[reference.Id];
+
+ default:
+ throw new OpenApiException(Properties.SRResource.InvalidReferenceType);
+ }
+ }
+ catch (KeyNotFoundException)
+ {
+ throw new OpenApiException(string.Format(Properties.SRResource.InvalidReferenceId, reference.Id));
+ }
+ }
+ }
+
+ internal class FindSchemaReferences : OpenApiVisitorBase
+ {
+ private Dictionary Schemas;
+
+ public static void ResolveSchemas(OpenApiComponents components, Dictionary schemas )
+ {
+ var visitor = new FindSchemaReferences();
+ visitor.Schemas = schemas;
+ var walker = new OpenApiWalker(visitor);
+ walker.Walk(components);
+ }
+
+ public override void Visit(IOpenApiReferenceable referenceable)
+ {
+ switch (referenceable)
+ {
+ case OpenApiSchema schema:
+ if (!Schemas.ContainsKey(schema.Reference.Id))
+ {
+ Schemas.Add(schema.Reference.Id, schema);
+ }
+ break;
+
+ default:
+ break;
+ }
+ base.Visit(referenceable);
+ }
+
+ public override void Visit(OpenApiSchema schema)
+ {
+ // This is needed to handle schemas used in Responses in components
+ if (schema.Reference != null)
+ {
+ if (!Schemas.ContainsKey(schema.Reference.Id))
+ {
+ Schemas.Add(schema.Reference.Id, schema);
+ }
+ }
+ base.Visit(schema);
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiEncoding.cs
new file mode 100644
index 000000000000..5609e1f14a8e
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiEncoding.cs
@@ -0,0 +1,116 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// ExternalDocs object.
+ ///
+ internal class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// The Content-Type for encoding a specific property.
+ /// The value can be a specific media type (e.g. application/json),
+ /// a wildcard media type (e.g. image/*), or a comma-separated list of the two types.
+ ///
+ public string ContentType { get; set; }
+
+ ///
+ /// A map allowing additional information to be provided as headers.
+ ///
+ public IDictionary Headers { get; set; } = new Dictionary();
+
+ ///
+ /// Describes how a specific property value will be serialized depending on its type.
+ ///
+ public ParameterStyle? Style { get; set; }
+
+ ///
+ /// When this is true, property values of type array or object generate separate parameters
+ /// for each value of the array, or key-value-pair of the map. For other types of properties
+ /// this property has no effect. When style is form, the default value is true.
+ /// For all other styles, the default value is false.
+ /// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
+ ///
+ public bool? Explode { get; set; }
+
+ ///
+ /// Determines whether the parameter value SHOULD allow reserved characters,
+ /// as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding.
+ /// The default value is false. This property SHALL be ignored
+ /// if the request body media type is not application/x-www-form-urlencoded.
+ ///
+ public bool? AllowReserved { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiEncoding() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiEncoding(OpenApiEncoding encoding)
+ {
+ ContentType = encoding?.ContentType ?? ContentType;
+ Headers = encoding?.Headers != null ? new Dictionary(encoding.Headers) : null;
+ Style = encoding?.Style ?? Style;
+ Explode = encoding?.Explode ?? Explode;
+ AllowReserved = encoding?.AllowReserved ?? AllowReserved;
+ Extensions = encoding?.Extensions != null ? new Dictionary(encoding.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // contentType
+ writer.WriteProperty(OpenApiConstants.ContentType, ContentType);
+
+ // headers
+ writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV3(w));
+
+ // style
+ writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
+
+ // explode
+ writer.WriteProperty(OpenApiConstants.Explode, Explode, false);
+
+ // allowReserved
+ writer.WriteProperty(OpenApiConstants.AllowReserved, AllowReserved, false);
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // nothing here
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiError.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiError.cs
new file mode 100644
index 000000000000..781d1be21556
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiError.cs
@@ -0,0 +1,61 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Exceptions;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Error related to the Open API Document.
+ ///
+ internal class OpenApiError
+ {
+ ///
+ /// Initializes the class using the message and pointer from the given exception.
+ ///
+ public OpenApiError(OpenApiException exception) : this(exception.Pointer, exception.Message)
+ {
+ }
+
+ ///
+ /// Initializes the class.
+ ///
+ public OpenApiError(string pointer, string message)
+ {
+ Pointer = pointer;
+ Message = message;
+ }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiError(OpenApiError error)
+ {
+ Pointer = error.Pointer;
+ Message = error.Message;
+ }
+
+ ///
+ /// Message explaining the error.
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// Pointer to the location of the error.
+ ///
+ public string Pointer { get; set; }
+
+ ///
+ /// Gets the string representation of .
+ ///
+ public override string ToString()
+ {
+ return Message + (!string.IsNullOrEmpty(Pointer) ? " [" + Pointer + "]" : "");
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExample.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExample.cs
new file mode 100644
index 000000000000..55a158619607
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExample.cs
@@ -0,0 +1,177 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Example Object.
+ ///
+ internal class OpenApiExample : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// Short description for the example.
+ ///
+ public string Summary { get; set; }
+
+ ///
+ /// Long description for the example.
+ /// CommonMark syntax MAY be used for rich text representation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Embedded literal example. The value field and externalValue field are mutually
+ /// 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 IOpenApiAny Value { get; set; }
+
+ ///
+ /// A URL that points to the literal example.
+ /// This provides the capability to reference examples that cannot easily be
+ /// included in JSON or YAML documents.
+ /// The value field and externalValue field are mutually exclusive.
+ ///
+ public string ExternalValue { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Reference object.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// Indicates object is a placeholder reference to an actual object and does not contain valid data.
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiExample() {}
+
+ ///
+ /// Initializes a copy of object
+ ///
+ public OpenApiExample(OpenApiExample example)
+ {
+ Summary = example?.Summary ?? Summary;
+ Description = example?.Description ?? Description;
+ Value = OpenApiAnyCloneHelper.CloneFromCopyConstructor(example?.Value);
+ ExternalValue = example?.ExternalValue ?? ExternalValue;
+ Extensions = example?.Extensions != null ? new Dictionary(example.Extensions) : null;
+ Reference = example?.Reference != null ? new(example?.Reference) : null;
+ UnresolvedReference = example?.UnresolvedReference ?? UnresolvedReference;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiExample object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiExample
+ public OpenApiExample GetEffective(OpenApiDocument doc)
+ {
+ if (this.Reference != null)
+ {
+ return doc.ResolveReferenceTo(this.Reference);
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ Serialize(writer, OpenApiSpecVersion.OpenApi3_0);
+ }
+
+ ///
+ /// Writes out existing examples in a mediatype object
+ ///
+ ///
+ ///
+ public void Serialize(IOpenApiWriter writer, OpenApiSpecVersion version)
+ {
+ writer.WriteStartObject();
+
+ // summary
+ writer.WriteProperty(OpenApiConstants.Summary, Summary);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // value
+ writer.WriteOptionalObject(OpenApiConstants.Value, Value, (w, v) => w.WriteAny(v));
+
+ // externalValue
+ writer.WriteProperty(OpenApiConstants.ExternalValue, ExternalValue);
+
+ // extensions
+ writer.WriteExtensions(Extensions, version);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Example object of this form does not exist in V2.
+ // V2 Example object requires knowledge of media type and exists only
+ // in Response object, so it will be serialized as a part of the Response object.
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ // Example object of this form does not exist in V2.
+ // V2 Example object requires knowledge of media type and exists only
+ // in Response object, so it will be serialized as a part of the Response object.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs
new file mode 100644
index 000000000000..0f6bacfc865a
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs
@@ -0,0 +1,84 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Generic dictionary type for Open API dictionary element.
+ ///
+ /// The Open API element,
+ internal abstract class OpenApiExtensibleDictionary : Dictionary,
+ IOpenApiSerializable,
+ IOpenApiExtensible
+ where T : IOpenApiSerializable
+ {
+ ///
+ /// Parameterless constructor
+ ///
+ protected OpenApiExtensibleDictionary() { }
+
+ ///
+ /// Initializes a copy of class.
+ ///
+ /// The generic dictionary.
+ /// The dictionary of .
+ protected OpenApiExtensibleDictionary(
+ Dictionary dictionary = null,
+ IDictionary extensions = null) : base (dictionary)
+ {
+ Extensions = extensions != null ? new Dictionary(extensions) : null;
+ }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ foreach (var item in this)
+ {
+ writer.WriteRequiredObject(item.Key, item.Value, (w, p) => p.SerializeAsV3(w));
+ }
+
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ foreach (var item in this)
+ {
+ writer.WriteRequiredObject(item.Key, item.Value, (w, p) => p.SerializeAsV2(w));
+ }
+
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
new file mode 100644
index 000000000000..bc33ec634c8b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs
@@ -0,0 +1,83 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// ExternalDocs object.
+ ///
+ internal class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// A short description of the target documentation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// REQUIRED. The URL for the target documentation. Value MUST be in the format of a URL.
+ ///
+ public Uri Url { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiExternalDocs() { }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiExternalDocs(OpenApiExternalDocs externalDocs)
+ {
+ Description = externalDocs?.Description ?? Description;
+ Url = externalDocs?.Url != null ? new Uri(externalDocs.Url.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ Extensions = externalDocs?.Extensions != null ? new Dictionary(externalDocs.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0);
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0);
+ }
+
+ private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // url
+ writer.WriteProperty(OpenApiConstants.Url, Url?.OriginalString);
+
+ // extensions
+ writer.WriteExtensions(Extensions, specVersion);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiHeader.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiHeader.cs
new file mode 100644
index 000000000000..d878a0b63a07
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiHeader.cs
@@ -0,0 +1,271 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Header Object.
+ /// The Header Object follows the structure of the Parameter Object.
+ ///
+ internal class OpenApiHeader : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference pointer.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// A brief description of the header.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Determines whether this header is mandatory.
+ ///
+ public bool Required { get; set; }
+
+ ///
+ /// Specifies that a header is deprecated and SHOULD be transitioned out of usage.
+ ///
+ public bool Deprecated { get; set; }
+
+ ///
+ /// Sets the ability to pass empty-valued headers.
+ ///
+ public bool AllowEmptyValue { get; set; }
+
+ ///
+ /// Describes how the header value will be serialized depending on the type of the header value.
+ ///
+ public ParameterStyle? Style { get; set; }
+
+ ///
+ /// When this is true, header values of type array or object generate separate parameters
+ /// for each value of the array or key-value pair of the map.
+ ///
+ public bool Explode { get; set; }
+
+ ///
+ /// Determines whether the header value SHOULD allow reserved characters, as defined by RFC3986.
+ ///
+ public bool AllowReserved { get; set; }
+
+ ///
+ /// The schema defining the type used for the header.
+ ///
+ public OpenApiSchema Schema { get; set; }
+
+ ///
+ /// Example of the media type.
+ ///
+ public IOpenApiAny Example { get; set; }
+
+ ///
+ /// Examples of the media type.
+ ///
+ public IDictionary Examples { get; set; } = new Dictionary();
+
+ ///
+ /// A map containing the representations for the header.
+ ///
+ public IDictionary Content { get; set; } = new Dictionary();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiHeader() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiHeader(OpenApiHeader header)
+ {
+ UnresolvedReference = header?.UnresolvedReference ?? UnresolvedReference;
+ Reference = header?.Reference != null ? new(header?.Reference) : null;
+ Description = header?.Description ?? Description;
+ Required = header?.Required ?? Required;
+ Deprecated = header?.Deprecated ?? Deprecated;
+ AllowEmptyValue = header?.AllowEmptyValue ?? AllowEmptyValue;
+ Style = header?.Style ?? Style;
+ Explode = header?.Explode ?? Explode;
+ AllowReserved = header?.AllowReserved ?? AllowReserved;
+ Schema = header?.Schema != null ? new(header?.Schema) : null;
+ Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(header?.Example);
+ Examples = header?.Examples != null ? new Dictionary(header.Examples) : null;
+ Content = header?.Content != null ? new Dictionary(header.Content) : null;
+ Extensions = header?.Extensions != null ? new Dictionary(header.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiHeader object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiHeader
+ public OpenApiHeader GetEffective(OpenApiDocument doc)
+ {
+ if (this.Reference != null)
+ {
+ return doc.ResolveReferenceTo(this.Reference);
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // required
+ writer.WriteProperty(OpenApiConstants.Required, Required, false);
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ // allowEmptyValue
+ writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
+
+ // style
+ writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
+
+ // explode
+ writer.WriteProperty(OpenApiConstants.Explode, Explode, false);
+
+ // allowReserved
+ writer.WriteProperty(OpenApiConstants.AllowReserved, AllowReserved, false);
+
+ // schema
+ writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV3(w));
+
+ // example
+ writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, s) => w.WriteAny(s));
+
+ // examples
+ writer.WriteOptionalMap(OpenApiConstants.Examples, Examples, (w, e) => e.SerializeAsV3(w));
+
+ // content
+ writer.WriteOptionalMap(OpenApiConstants.Content, Content, (w, c) => c.SerializeAsV3(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV2(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV2WithoutReference(writer);
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // required
+ writer.WriteProperty(OpenApiConstants.Required, Required, false);
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ // allowEmptyValue
+ writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
+
+ // style
+ writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
+
+ // explode
+ writer.WriteProperty(OpenApiConstants.Explode, Explode, false);
+
+ // allowReserved
+ writer.WriteProperty(OpenApiConstants.AllowReserved, AllowReserved, false);
+
+ // schema
+ Schema?.WriteAsItemsProperties(writer);
+
+ // example
+ writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, s) => w.WriteAny(s));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiInfo.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiInfo.cs
new file mode 100644
index 000000000000..d0c740794e25
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiInfo.cs
@@ -0,0 +1,141 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Open API Info Object, it provides the metadata about the Open API.
+ ///
+ internal class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// REQUIRED. The title of the application.
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// A short description of the application.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// REQUIRED. The version of the OpenAPI document.
+ ///
+ public string Version { get; set; }
+
+ ///
+ /// A URL to the Terms of Service for the API. MUST be in the format of a URL.
+ ///
+ public Uri TermsOfService { get; set; }
+
+ ///
+ /// The contact information for the exposed API.
+ ///
+ public OpenApiContact Contact { get; set; }
+
+ ///
+ /// The license information for the exposed API.
+ ///
+ public OpenApiLicense License { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiInfo() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiInfo(OpenApiInfo info)
+ {
+ Title = info?.Title ?? Title;
+ Description = info?.Description ?? Description;
+ Version = info?.Version ?? Version;
+ TermsOfService = info?.TermsOfService ?? TermsOfService;
+ Contact = info?.Contact != null ? new(info?.Contact) : null;
+ License = info?.License != null ? new(info?.License) : null;
+ Extensions = info?.Extensions != null ? new Dictionary(info.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // title
+ writer.WriteProperty(OpenApiConstants.Title, Title);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // termsOfService
+ writer.WriteProperty(OpenApiConstants.TermsOfService, TermsOfService?.OriginalString);
+
+ // contact object
+ writer.WriteOptionalObject(OpenApiConstants.Contact, Contact, (w, c) => c.SerializeAsV3(w));
+
+ // license object
+ writer.WriteOptionalObject(OpenApiConstants.License, License, (w, l) => l.SerializeAsV3(w));
+
+ // version
+ writer.WriteProperty(OpenApiConstants.Version, Version);
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // title
+ writer.WriteProperty(OpenApiConstants.Title, Title);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // termsOfService
+ writer.WriteProperty(OpenApiConstants.TermsOfService, TermsOfService?.OriginalString);
+
+ // contact object
+ writer.WriteOptionalObject(OpenApiConstants.Contact, Contact, (w, c) => c.SerializeAsV2(w));
+
+ // license object
+ writer.WriteOptionalObject(OpenApiConstants.License, License, (w, l) => l.SerializeAsV2(w));
+
+ // version
+ writer.WriteProperty(OpenApiConstants.Version, Version);
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLicense.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLicense.cs
new file mode 100644
index 000000000000..8d71d2a617fb
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLicense.cs
@@ -0,0 +1,83 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// License Object.
+ ///
+ internal class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// REQUIRED. The license name used for the API.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// The URL pointing to the contact information. MUST be in the format of a URL.
+ ///
+ public Uri Url { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiLicense() { }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiLicense(OpenApiLicense license)
+ {
+ Name = license?.Name ?? Name;
+ Url = license?.Url != null ? new Uri(license.Url.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ Extensions = license?.Extensions != null ? new Dictionary(license.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi3_0);
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ WriteInternal(writer, OpenApiSpecVersion.OpenApi2_0);
+ }
+
+ private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
+ {
+ writer.WriteStartObject();
+
+ // name
+ writer.WriteProperty(OpenApiConstants.Name, Name);
+
+ // url
+ writer.WriteProperty(OpenApiConstants.Url, Url?.OriginalString);
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, specVersion);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLink.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLink.cs
new file mode 100644
index 000000000000..ac2e9f349996
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiLink.cs
@@ -0,0 +1,177 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Link Object.
+ ///
+ internal class OpenApiLink : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// A relative or absolute reference to an OAS operation.
+ /// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object.
+ ///
+ public string OperationRef { get; set; }
+
+ ///
+ /// The name of an existing, resolvable OAS operation, as defined with a unique operationId.
+ /// This field is mutually exclusive of the operationRef field.
+ ///
+ public string OperationId { get; set; }
+
+ ///
+ /// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef.
+ ///
+ public Dictionary Parameters { get; set; } =
+ new();
+
+ ///
+ /// A literal value or {expression} to use as a request body when calling the target operation.
+ ///
+ public RuntimeExpressionAnyWrapper RequestBody { get; set; }
+
+ ///
+ /// A description of the link.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// A server object to be used by the target operation.
+ ///
+ public OpenApiServer Server { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference pointer.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiLink() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiLink(OpenApiLink link)
+ {
+ OperationRef = link?.OperationRef ?? OperationRef;
+ OperationId = link?.OperationId ?? OperationId;
+ Parameters = link?.Parameters != null ? new(link?.Parameters) : null;
+ RequestBody = link?.RequestBody != null ? new(link?.RequestBody) : null;
+ Description = link?.Description ?? Description;
+ Server = link?.Server != null ? new(link?.Server) : null;
+ Extensions = link?.Extensions != null ? new Dictionary(link.Extensions) : null;
+ UnresolvedReference = link?.UnresolvedReference ?? UnresolvedReference;
+ Reference = link?.Reference != null ? new(link?.Reference) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiLink object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiLink
+ public OpenApiLink GetEffective(OpenApiDocument doc)
+ {
+ if (this.Reference != null)
+ {
+ return doc.ResolveReferenceTo(this.Reference);
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // operationRef
+ writer.WriteProperty(OpenApiConstants.OperationRef, OperationRef);
+
+ // operationId
+ writer.WriteProperty(OpenApiConstants.OperationId, OperationId);
+
+ // parameters
+ writer.WriteOptionalMap(OpenApiConstants.Parameters, Parameters, (w, p) => p.WriteValue(w));
+
+ // requestBody
+ writer.WriteOptionalObject(OpenApiConstants.RequestBody, RequestBody, (w, r) => r.WriteValue(w));
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // server
+ writer.WriteOptionalObject(OpenApiConstants.Server, Server, (w, s) => s.SerializeAsV3(w));
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Link object does not exist in V2.
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ // Link object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiMediaType.cs
new file mode 100644
index 000000000000..f8b97ff1504b
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiMediaType.cs
@@ -0,0 +1,135 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Media Type Object.
+ ///
+ internal class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// The schema defining the type used for the request body.
+ ///
+ public OpenApiSchema Schema { get; set; }
+
+ ///
+ /// Example of the media type.
+ /// The example object SHOULD be in the correct format as specified by the media type.
+ ///
+ public IOpenApiAny Example { get; set; }
+
+ ///
+ /// Examples of the media type.
+ /// Each example object SHOULD match the media type and specified schema if present.
+ ///
+ public IDictionary Examples { get; set; } = new Dictionary();
+
+ ///
+ /// A map between a property name and its encoding information.
+ /// The key, being the property name, MUST exist in the schema as a property.
+ /// The encoding object SHALL only apply to requestBody objects
+ /// when the media type is multipart or application/x-www-form-urlencoded.
+ ///
+ public IDictionary Encoding { get; set; } = new Dictionary();
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiMediaType() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiMediaType(OpenApiMediaType mediaType)
+ {
+ Schema = mediaType?.Schema != null ? new(mediaType?.Schema) : null;
+ Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(mediaType?.Example);
+ Examples = mediaType?.Examples != null ? new Dictionary(mediaType.Examples) : null;
+ Encoding = mediaType?.Encoding != null ? new Dictionary(mediaType.Encoding) : null;
+ Extensions = mediaType?.Extensions != null ? new Dictionary(mediaType.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // schema
+ writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV3(w));
+
+ // example
+ writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e));
+
+ // examples
+ if (Examples != null && Examples.Any())
+ {
+ SerializeExamples(writer, Examples);
+ }
+
+ // encoding
+ writer.WriteOptionalMap(OpenApiConstants.Encoding, Encoding, (w, e) => e.SerializeAsV3(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // Media type does not exist in V2.
+ }
+
+ private static void SerializeExamples(IOpenApiWriter writer, IDictionary examples)
+ {
+ /* Special case for writing out empty arrays as valid response examples
+ * Check if there is any example with an empty array as its value and set the flag `hasEmptyArray` to true
+ * */
+ var hasEmptyArray = examples.Values.Any( static example =>
+ example.Value is OpenApiArray arr && arr.Count == 0
+ );
+
+ if (hasEmptyArray)
+ {
+ writer.WritePropertyName(OpenApiConstants.Examples);
+ writer.WriteStartObject();
+ foreach (var kvp in examples.Where(static kvp => kvp.Value.Value is OpenApiArray arr && arr.Count == 0))
+ {
+ writer.WritePropertyName(kvp.Key);
+ writer.WriteStartObject();
+ writer.WriteRequiredObject(OpenApiConstants.Value, kvp.Value.Value, (w, v) => w.WriteAny(v));
+ writer.WriteEndObject();
+ }
+ writer.WriteEndObject();
+ }
+ else
+ {
+ writer.WriteOptionalMap(OpenApiConstants.Examples, examples, (w, e) => e.SerializeAsV3(w));
+ }
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs
new file mode 100644
index 000000000000..7b68d1f05e06
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs
@@ -0,0 +1,100 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// OAuth Flow Object.
+ ///
+ internal class OpenApiOAuthFlow : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// REQUIRED. The authorization URL to be used for this flow.
+ /// Applies to implicit and authorizationCode OAuthFlow.
+ ///
+ public Uri AuthorizationUrl { get; set; }
+
+ ///
+ /// REQUIRED. The token URL to be used for this flow.
+ /// Applies to password, clientCredentials, and authorizationCode OAuthFlow.
+ ///
+ public Uri TokenUrl { get; set; }
+
+ ///
+ /// The URL to be used for obtaining refresh tokens.
+ ///
+ public Uri RefreshUrl { get; set; }
+
+ ///
+ /// REQUIRED. A map between the scope name and a short description for it.
+ ///
+ public IDictionary Scopes { get; set; } = new Dictionary();
+
+ ///
+ /// Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiOAuthFlow() { }
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiOAuthFlow(OpenApiOAuthFlow oAuthFlow)
+ {
+ AuthorizationUrl = oAuthFlow?.AuthorizationUrl != null ? new Uri(oAuthFlow.AuthorizationUrl.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ TokenUrl = oAuthFlow?.TokenUrl != null ? new Uri(oAuthFlow.TokenUrl.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ RefreshUrl = oAuthFlow?.RefreshUrl != null ? new Uri(oAuthFlow.RefreshUrl.OriginalString, UriKind.RelativeOrAbsolute) : null;
+ Scopes = oAuthFlow?.Scopes != null ? new Dictionary(oAuthFlow.Scopes) : null;
+ Extensions = oAuthFlow?.Extensions != null ? new Dictionary(oAuthFlow.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // authorizationUrl
+ writer.WriteProperty(OpenApiConstants.AuthorizationUrl, AuthorizationUrl?.ToString());
+
+ // tokenUrl
+ writer.WriteProperty(OpenApiConstants.TokenUrl, TokenUrl?.ToString());
+
+ // refreshUrl
+ writer.WriteProperty(OpenApiConstants.RefreshUrl, RefreshUrl?.ToString());
+
+ // scopes
+ writer.WriteRequiredMap(OpenApiConstants.Scopes, Scopes, (w, s) => w.WriteValue(s));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // OAuthFlow object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs
new file mode 100644
index 000000000000..ef73ad56dd59
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs
@@ -0,0 +1,104 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// OAuth Flows Object.
+ ///
+ internal class OpenApiOAuthFlows : IOpenApiSerializable, IOpenApiExtensible
+ {
+ ///
+ /// Configuration for the OAuth Implicit flow
+ ///
+ public OpenApiOAuthFlow Implicit { get; set; }
+
+ ///
+ /// Configuration for the OAuth Resource Owner Password flow.
+ ///
+ public OpenApiOAuthFlow Password { get; set; }
+
+ ///
+ /// Configuration for the OAuth Client Credentials flow.
+ ///
+ public OpenApiOAuthFlow ClientCredentials { get; set; }
+
+ ///
+ /// Configuration for the OAuth Authorization Code flow.
+ ///
+ public OpenApiOAuthFlow AuthorizationCode { get; set; }
+
+ ///
+ /// Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiOAuthFlows() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ ///
+ public OpenApiOAuthFlows(OpenApiOAuthFlows oAuthFlows)
+ {
+ Implicit = oAuthFlows?.Implicit != null ? new(oAuthFlows?.Implicit) : null;
+ Password = oAuthFlows?.Password != null ? new(oAuthFlows?.Password) : null;
+ ClientCredentials = oAuthFlows?.ClientCredentials != null ? new(oAuthFlows?.ClientCredentials) : null;
+ AuthorizationCode = oAuthFlows?.AuthorizationCode != null ? new(oAuthFlows?.AuthorizationCode) : null;
+ Extensions = oAuthFlows?.Extensions != null ? new Dictionary(oAuthFlows.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // implicit
+ writer.WriteOptionalObject(OpenApiConstants.Implicit, Implicit, (w, o) => o.SerializeAsV3(w));
+
+ // password
+ writer.WriteOptionalObject(OpenApiConstants.Password, Password, (w, o) => o.SerializeAsV3(w));
+
+ // clientCredentials
+ writer.WriteOptionalObject(
+ OpenApiConstants.ClientCredentials,
+ ClientCredentials,
+ (w, o) => o.SerializeAsV3(w));
+
+ // authorizationCode
+ writer.WriteOptionalObject(
+ OpenApiConstants.AuthorizationCode,
+ AuthorizationCode,
+ (w, o) => o.SerializeAsV3(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // OAuthFlows object does not exist in V2.
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOperation.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOperation.cs
new file mode 100644
index 000000000000..c0d96c21a197
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiOperation.cs
@@ -0,0 +1,343 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Operation Object.
+ ///
+ internal class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable
+ {
+ ///
+ /// Default value for .
+ ///
+ public const bool DeprecatedDefault = false;
+
+ ///
+ /// A list of tags for API documentation control.
+ /// Tags can be used for logical grouping of operations by resources or any other qualifier.
+ ///
+ public IList Tags { get; set; } = new List();
+
+ ///
+ /// A short summary of what the operation does.
+ ///
+ public string Summary { get; set; }
+
+ ///
+ /// A verbose explanation of the operation behavior.
+ /// CommonMark syntax MAY be used for rich text representation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Additional external documentation for this operation.
+ ///
+ public OpenApiExternalDocs ExternalDocs { get; set; }
+
+ ///
+ /// Unique string used to identify the operation. The id MUST be unique among all operations described in the API.
+ /// Tools and libraries MAY use the operationId to uniquely identify an operation, therefore,
+ /// it is RECOMMENDED to follow common programming naming conventions.
+ ///
+ public string OperationId { get; set; }
+
+ ///
+ /// A list of parameters that are applicable for this operation.
+ /// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it.
+ /// The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location.
+ /// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.
+ ///
+ public IList Parameters { get; set; } = new List();
+
+ ///
+ /// The request body applicable for this operation.
+ /// The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231
+ /// has explicitly defined semantics for request bodies.
+ /// In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers.
+ ///
+ public OpenApiRequestBody RequestBody { get; set; }
+
+ ///
+ /// REQUIRED. The list of possible responses as they are returned from executing this operation.
+ ///
+ public OpenApiResponses Responses { get; set; } = new();
+
+ ///
+ /// A map of possible out-of band callbacks related to the parent operation.
+ /// The key is a unique identifier for the Callback Object.
+ /// Each value in the map is a Callback Object that describes a request
+ /// that may be initiated by the API provider and the expected responses.
+ /// The key value used to identify the callback object is an expression, evaluated at runtime,
+ /// that identifies a URL to use for the callback operation.
+ ///
+ public IDictionary Callbacks { get; set; } = new Dictionary();
+
+ ///
+ /// Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation.
+ ///
+ public bool Deprecated { get; set; } = DeprecatedDefault;
+
+ ///
+ /// A declaration of which security mechanisms can be used for this operation.
+ /// The list of values includes alternative security requirement objects that can be used.
+ /// Only one of the security requirement objects need to be satisfied to authorize a request.
+ /// This definition overrides any declared top-level security.
+ /// To remove a top-level security declaration, an empty array can be used.
+ ///
+ public IList Security { get; set; } = new List();
+
+ ///
+ /// An alternative server array to service this operation.
+ /// If an alternative server object is specified at the Path Item Object or Root level,
+ /// it will be overridden by this value.
+ ///
+ public IList Servers { get; set; } = new List();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ public IDictionary Annotations { get; set; }
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiOperation() {}
+
+ ///
+ /// Initializes a copy of an object
+ ///
+ public OpenApiOperation(OpenApiOperation operation)
+ {
+ Tags = operation?.Tags != null ? new List(operation?.Tags) : null;
+ Summary = operation?.Summary ?? Summary;
+ Description = operation?.Description ?? Description;
+ ExternalDocs = operation?.ExternalDocs != null ? new(operation?.ExternalDocs) : null;
+ OperationId = operation?.OperationId ?? OperationId;
+ Parameters = operation?.Parameters != null ? new List(operation.Parameters) : null;
+ RequestBody = operation?.RequestBody != null ? new(operation?.RequestBody) : null;
+ Responses = operation?.Responses != null ? new(operation?.Responses) : null;
+ Callbacks = operation?.Callbacks != null ? new Dictionary(operation.Callbacks) : null;
+ Deprecated = operation?.Deprecated ?? Deprecated;
+ Security = operation?.Security != null ? new List(operation.Security) : null;
+ Servers = operation?.Servers != null ? new List(operation.Servers) : null;
+ Extensions = operation?.Extensions != null ? new Dictionary(operation.Extensions) : null;
+ Annotations = operation?.Annotations != null ? new Dictionary(operation.Annotations) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // tags
+ writer.WriteOptionalCollection(
+ OpenApiConstants.Tags,
+ Tags,
+ (w, t) => t.SerializeAsV3(w));
+
+ // summary
+ writer.WriteProperty(OpenApiConstants.Summary, Summary);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // externalDocs
+ writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, e) => e.SerializeAsV3(w));
+
+ // operationId
+ writer.WriteProperty(OpenApiConstants.OperationId, OperationId);
+
+ // parameters
+ writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV3(w));
+
+ // requestBody
+ writer.WriteOptionalObject(OpenApiConstants.RequestBody, RequestBody, (w, r) => r.SerializeAsV3(w));
+
+ // responses
+ writer.WriteRequiredObject(OpenApiConstants.Responses, Responses, (w, r) => r.SerializeAsV3(w));
+
+ // callbacks
+ writer.WriteOptionalMap(OpenApiConstants.Callbacks, Callbacks, (w, c) => c.SerializeAsV3(w));
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ // security
+ writer.WriteOptionalCollection(OpenApiConstants.Security, Security, (w, s) => s.SerializeAsV3(w));
+
+ // servers
+ writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, (w, s) => s.SerializeAsV3(w));
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ writer.WriteStartObject();
+
+ // tags
+ writer.WriteOptionalCollection(
+ OpenApiConstants.Tags,
+ Tags,
+ (w, t) => t.SerializeAsV2(w));
+
+ // summary
+ writer.WriteProperty(OpenApiConstants.Summary, Summary);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // externalDocs
+ writer.WriteOptionalObject(OpenApiConstants.ExternalDocs, ExternalDocs, (w, e) => e.SerializeAsV2(w));
+
+ // operationId
+ writer.WriteProperty(OpenApiConstants.OperationId, OperationId);
+
+ List parameters;
+ if (Parameters == null)
+ {
+ parameters = new();
+ }
+ else
+ {
+ parameters = new(Parameters);
+ }
+
+ if (RequestBody != null)
+ {
+ // consumes
+ var consumes = RequestBody.Content.Keys.Distinct().ToList();
+ if (consumes.Any())
+ {
+ // This is form data. We need to split the request body into multiple parameters.
+ if (consumes.Contains("application/x-www-form-urlencoded") ||
+ consumes.Contains("multipart/form-data"))
+ {
+ parameters.AddRange(RequestBody.ConvertToFormDataParameters());
+ }
+ else
+ {
+ parameters.Add(RequestBody.ConvertToBodyParameter());
+ }
+ }
+ else if (RequestBody.Reference != null)
+ {
+ parameters.Add(
+ new()
+ {
+ UnresolvedReference = true,
+ Reference = RequestBody.Reference
+ });
+
+ if (RequestBody.Reference.HostDocument != null)
+ {
+ var effectiveRequestBody = RequestBody.GetEffective(RequestBody.Reference.HostDocument);
+ if (effectiveRequestBody != null)
+ consumes = effectiveRequestBody.Content.Keys.Distinct().ToList();
+ }
+ }
+
+ if (consumes.Any())
+ {
+ writer.WritePropertyName(OpenApiConstants.Consumes);
+ writer.WriteStartArray();
+ foreach (var mediaType in consumes)
+ {
+ writer.WriteValue(mediaType);
+ }
+ writer.WriteEndArray();
+ }
+ }
+
+ if (Responses != null)
+ {
+ var produces = Responses
+ .Where(static r => r.Value.Content != null)
+ .SelectMany(static r => r.Value.Content?.Keys)
+ .Concat(
+ Responses
+ .Where(static r => r.Value.Reference is {HostDocument: not null})
+ .SelectMany(static r => r.Value.GetEffective(r.Value.Reference.HostDocument)?.Content?.Keys))
+ .Distinct()
+ .ToList();
+
+ if (produces.Any())
+ {
+ // produces
+ writer.WritePropertyName(OpenApiConstants.Produces);
+ writer.WriteStartArray();
+ foreach (var mediaType in produces)
+ {
+ writer.WriteValue(mediaType);
+ }
+
+ writer.WriteEndArray();
+ }
+ }
+
+ // parameters
+ // Use the parameters created locally to include request body if exists.
+ writer.WriteOptionalCollection(OpenApiConstants.Parameters, parameters, (w, p) => p.SerializeAsV2(w));
+
+ // responses
+ writer.WriteRequiredObject(OpenApiConstants.Responses, Responses, (w, r) => r.SerializeAsV2(w));
+
+ // schemes
+ // All schemes in the Servers are extracted, regardless of whether the host matches
+ // the host defined in the outermost Swagger object. This is due to the
+ // inaccessibility of information for that host in the context of an inner object like this Operation.
+ if (Servers != null)
+ {
+ var schemes = Servers.Select(
+ s =>
+ {
+ Uri.TryCreate(s.Url, UriKind.RelativeOrAbsolute, out var url);
+ return url?.Scheme;
+ })
+ .Where(s => s != null)
+ .Distinct()
+ .ToList();
+
+ writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) => w.WriteValue(s));
+ }
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ // security
+ writer.WriteOptionalCollection(OpenApiConstants.Security, Security, (w, s) => s.SerializeAsV2(w));
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiParameter.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiParameter.cs
new file mode 100644
index 000000000000..d6f5033b6122
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiParameter.cs
@@ -0,0 +1,444 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Parameter Object.
+ ///
+ internal class OpenApiParameter : IOpenApiReferenceable, IEffective, IOpenApiExtensible
+ {
+ private bool? _explode;
+ ///
+ /// The style of the parameter.
+ ///
+ public ParameterStyle? _style;
+
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference object.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// REQUIRED. The name of the parameter. Parameter names are case sensitive.
+ /// If in is "path", the name field MUST correspond to the associated path segment from the path field in the Paths Object.
+ /// If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
+ /// For all other cases, the name corresponds to the parameter name used by the in property.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// REQUIRED. The location of the parameter.
+ /// Possible values are "query", "header", "path" or "cookie".
+ ///
+ public ParameterLocation? In { get; set; }
+
+ ///
+ /// A brief description of the parameter. This could contain examples of use.
+ /// CommonMark syntax MAY be used for rich text representation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Determines whether this parameter is mandatory.
+ /// If the parameter location is "path", this property is REQUIRED and its value MUST be true.
+ /// Otherwise, the property MAY be included and its default value is false.
+ ///
+ public bool Required { get; set; }
+
+ ///
+ /// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
+ ///
+ public bool Deprecated { get; set; }
+
+ ///
+ /// Sets the ability to pass empty-valued parameters.
+ /// This is valid only for query parameters and allows sending a parameter with an empty value.
+ /// Default value is false.
+ /// If style is used, and if behavior is n/a (cannot be serialized),
+ /// the value of allowEmptyValue SHALL be ignored.
+ ///
+ public bool AllowEmptyValue { get; set; }
+
+ ///
+ /// Describes how the parameter value will be serialized depending on the type of the parameter value.
+ /// Default values (based on value of in): for query - form; for path - simple; for header - simple;
+ /// for cookie - form.
+ ///
+ public ParameterStyle? Style
+ {
+ get => _style ?? SetDefaultStyleValue();
+ set => _style = value;
+ }
+
+ ///
+ /// When this is true, parameter values of type array or object generate separate parameters
+ /// for each value of the array or key-value pair of the map.
+ /// For other types of parameters this property has no effect.
+ /// When style is form, the default value is true.
+ /// For all other styles, the default value is false.
+ ///
+ public bool Explode
+ {
+ get => _explode ?? Style == ParameterStyle.Form;
+ set => _explode = value;
+ }
+
+ ///
+ /// Determines whether the parameter value SHOULD allow reserved characters,
+ /// as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding.
+ /// This property only applies to parameters with an in value of query.
+ /// The default value is false.
+ ///
+ public bool AllowReserved { get; set; }
+
+ ///
+ /// The schema defining the type used for the parameter.
+ ///
+ public OpenApiSchema Schema { get; set; }
+
+ ///
+ /// Examples of the media type. Each example SHOULD contain a value
+ /// in the correct format as specified in the parameter encoding.
+ /// The examples object is mutually exclusive of the example object.
+ /// Furthermore, if referencing a schema which contains an example,
+ /// the examples value SHALL override the example provided by the schema.
+ ///
+ public IDictionary Examples { get; set; } = new Dictionary();
+
+ ///
+ /// Example of the media type. The example SHOULD match the specified schema and encoding properties
+ /// if present. The example object is mutually exclusive of the examples object.
+ /// Furthermore, if referencing a schema which contains an example,
+ /// the example value SHALL override the example provided by the 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 IOpenApiAny Example { get; set; }
+
+ ///
+ /// A map containing the representations for the parameter.
+ /// The key is the media type and the value describes it.
+ /// The map MUST only contain one entry.
+ /// For more complex scenarios, the content property can define the media type and schema of the parameter.
+ /// A parameter MUST contain either a schema property, or a content property, but not both.
+ /// When example or examples are provided in conjunction with the schema object,
+ /// the example MUST follow the prescribed serialization strategy for the parameter.
+ ///
+ public IDictionary Content { get; set; } = new Dictionary();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// A parameterless constructor
+ ///
+ public OpenApiParameter() {}
+
+ ///
+ /// Initializes a clone instance of object
+ ///
+ public OpenApiParameter(OpenApiParameter parameter)
+ {
+ UnresolvedReference = parameter?.UnresolvedReference ?? UnresolvedReference;
+ Reference = parameter?.Reference != null ? new(parameter?.Reference) : null;
+ Name = parameter?.Name ?? Name;
+ In = parameter?.In ?? In;
+ Description = parameter?.Description ?? Description;
+ Required = parameter?.Required ?? Required;
+ Style = parameter?.Style ?? Style;
+ Explode = parameter?.Explode ?? Explode;
+ AllowReserved = parameter?.AllowReserved ?? AllowReserved;
+ Schema = parameter?.Schema != null ? new(parameter?.Schema) : null;
+ Examples = parameter?.Examples != null ? new Dictionary(parameter.Examples) : null;
+ Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(parameter?.Example);
+ Content = parameter?.Content != null ? new Dictionary(parameter.Content) : null;
+ Extensions = parameter?.Extensions != null ? new Dictionary(parameter.Extensions) : null;
+ AllowEmptyValue = parameter?.AllowEmptyValue ?? AllowEmptyValue;
+ Deprecated = parameter?.Deprecated ?? Deprecated;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = this.GetEffective(Reference.HostDocument);
+ }
+ }
+
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiParameter object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiParameter
+ public OpenApiParameter GetEffective(OpenApiDocument doc)
+ {
+ return Reference != null ? doc.ResolveReferenceTo(Reference) : this;
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // name
+ writer.WriteProperty(OpenApiConstants.Name, Name);
+
+ // in
+ writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName());
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // required
+ writer.WriteProperty(OpenApiConstants.Required, Required, false);
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ // allowEmptyValue
+ writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
+
+ // style
+ if (_style.HasValue)
+ {
+ writer.WriteProperty(OpenApiConstants.Style, _style.Value.GetDisplayName());
+ }
+
+ // explode
+ writer.WriteProperty(OpenApiConstants.Explode, _explode, _style is ParameterStyle.Form);
+
+ // allowReserved
+ writer.WriteProperty(OpenApiConstants.AllowReserved, AllowReserved, false);
+
+ // schema
+ writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV3(w));
+
+ // example
+ writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, s) => w.WriteAny(s));
+
+ // examples
+ writer.WriteOptionalMap(OpenApiConstants.Examples, Examples, (w, e) => e.SerializeAsV3(w));
+
+ // content
+ writer.WriteOptionalMap(OpenApiConstants.Content, Content, (w, c) => c.SerializeAsV3(w));
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV2(writer);
+ return;
+ }
+ else
+ {
+ target = this.GetEffective(Reference.HostDocument);
+ }
+ }
+
+ target.SerializeAsV2WithoutReference(writer);
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // in
+ if (this is OpenApiFormDataParameter)
+ {
+ writer.WriteProperty(OpenApiConstants.In, "formData");
+ }
+ else if (this is OpenApiBodyParameter)
+ {
+ writer.WriteProperty(OpenApiConstants.In, "body");
+ }
+ else
+ {
+ writer.WriteProperty(OpenApiConstants.In, In?.GetDisplayName());
+ }
+
+ // name
+ writer.WriteProperty(OpenApiConstants.Name, Name);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // required
+ writer.WriteProperty(OpenApiConstants.Required, Required, false);
+
+ // deprecated
+ writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false);
+
+ var extensionsClone = new Dictionary(Extensions);
+
+ // schema
+ if (this is OpenApiBodyParameter)
+ {
+ writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV2(w));
+ }
+ // In V2 parameter's type can't be a reference to a custom object schema or can't be of type object
+ // So in that case map the type as string.
+ else
+ if (Schema?.UnresolvedReference == true || "object".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase))
+ {
+ writer.WriteProperty(OpenApiConstants.Type, "string");
+ }
+ else
+ {
+ // type
+ // format
+ // items
+ // collectionFormat
+ // default
+ // maximum
+ // exclusiveMaximum
+ // minimum
+ // exclusiveMinimum
+ // maxLength
+ // minLength
+ // pattern
+ // maxItems
+ // minItems
+ // uniqueItems
+ // enum
+ // multipleOf
+ if (Schema != null)
+ {
+ Schema.WriteAsItemsProperties(writer);
+
+ if (Schema.Extensions != null)
+ {
+ foreach (var key in Schema.Extensions.Keys)
+ {
+ // The extension will already have been serialized as part of the call to WriteAsItemsProperties above,
+ // so remove it from the cloned collection so we don't write it again.
+ extensionsClone.Remove(key);
+ }
+ }
+ }
+
+ // allowEmptyValue
+ writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
+
+ if (this.In == ParameterLocation.Query && "array".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase))
+ {
+ if (this.Style == ParameterStyle.Form && this.Explode == true)
+ {
+ writer.WriteProperty("collectionFormat", "multi");
+ }
+ else if (this.Style == ParameterStyle.PipeDelimited)
+ {
+ writer.WriteProperty("collectionFormat", "pipes");
+ }
+ else if (this.Style == ParameterStyle.SpaceDelimited)
+ {
+ writer.WriteProperty("collectionFormat", "ssv");
+ }
+ }
+ }
+
+ //examples
+ if (Examples != null && Examples.Any())
+ {
+ writer.WritePropertyName(OpenApiConstants.ExamplesExtension);
+ writer.WriteStartObject();
+
+ foreach (var example in Examples)
+ {
+ writer.WritePropertyName(example.Key);
+ example.Value.Serialize(writer, OpenApiSpecVersion.OpenApi2_0);
+ }
+ writer.WriteEndObject();
+ }
+
+ // extensions
+ writer.WriteExtensions(extensionsClone, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+
+ private ParameterStyle? SetDefaultStyleValue()
+ {
+ Style = In switch
+ {
+ ParameterLocation.Query => ParameterStyle.Form,
+ ParameterLocation.Header => ParameterStyle.Simple,
+ ParameterLocation.Path => ParameterStyle.Simple,
+ ParameterLocation.Cookie => ParameterStyle.Form,
+ _ => (ParameterStyle?)ParameterStyle.Simple,
+ };
+
+ return Style;
+ }
+ }
+
+ ///
+ /// Body parameter class to propagate information needed for
+ ///
+ internal class OpenApiBodyParameter : OpenApiParameter
+ {
+ }
+
+ ///
+ /// Form parameter class to propagate information needed for
+ ///
+ internal class OpenApiFormDataParameter : OpenApiParameter
+ {
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPathItem.cs
new file mode 100644
index 000000000000..71dd4c8d0efe
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPathItem.cs
@@ -0,0 +1,230 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Path Item Object: to describe the operations available on a single path.
+ ///
+ internal class OpenApiPathItem : IOpenApiExtensible, IOpenApiReferenceable, IEffective
+ {
+ ///
+ /// An optional, string summary, intended to apply to all operations in this path.
+ ///
+ public string Summary { get; set; }
+
+ ///
+ /// An optional, string description, intended to apply to all operations in this path.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Gets the definition of operations on this path.
+ ///
+ public IDictionary Operations { get; set; }
+ = new Dictionary();
+
+ ///
+ /// An alternative server array to service all operations in this path.
+ ///
+ public IList Servers { get; set; } = new List();
+
+ ///
+ /// A list of parameters that are applicable for all the operations described under this path.
+ /// These parameters can be overridden at the operation level, but cannot be removed there.
+ ///
+ public IList Parameters { get; set; } = new List();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference object.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// Add one operation into this path item.
+ ///
+ /// The operation type kind.
+ /// The operation item.
+ public void AddOperation(OperationType operationType, OpenApiOperation operation)
+ {
+ Operations[operationType] = operation;
+ }
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiPathItem() {}
+
+ ///
+ /// Initializes a clone of an object
+ ///
+ public OpenApiPathItem(OpenApiPathItem pathItem)
+ {
+ Summary = pathItem?.Summary ?? Summary;
+ Description = pathItem?.Description ?? Description;
+ Operations = pathItem?.Operations != null ? new Dictionary(pathItem.Operations) : null;
+ Servers = pathItem?.Servers != null ? new List(pathItem.Servers) : null;
+ Parameters = pathItem?.Parameters != null ? new List(pathItem.Parameters) : null;
+ Extensions = pathItem?.Extensions != null ? new Dictionary(pathItem.Extensions) : null;
+ UnresolvedReference = pathItem?.UnresolvedReference ?? UnresolvedReference;
+ Reference = pathItem?.Reference != null ? new(pathItem?.Reference) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiPathItem object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiPathItem
+ public OpenApiPathItem GetEffective(OpenApiDocument doc)
+ {
+ if (this.Reference != null)
+ {
+ return doc.ResolveReferenceTo(this.Reference);
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV2(writer);
+ return;
+ }
+ else
+ {
+ target = this.GetEffective(Reference.HostDocument);
+ }
+ }
+
+ target.SerializeAsV2WithoutReference(writer);
+ }
+
+ ///
+ /// Serialize inline PathItem in OpenAPI V2
+ ///
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // operations except "trace"
+ foreach (var operation in Operations)
+ {
+ if (operation.Key != OperationType.Trace)
+ {
+ writer.WriteOptionalObject(
+ operation.Key.GetDisplayName(),
+ operation.Value,
+ (w, o) => o.SerializeAsV2(w));
+ }
+ }
+
+ // parameters
+ writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV2(w));
+
+ // write "summary" as extensions
+ writer.WriteProperty(OpenApiConstants.ExtensionFieldNamePrefix + OpenApiConstants.Summary, Summary);
+
+ // write "description" as extensions
+ writer.WriteProperty(
+ OpenApiConstants.ExtensionFieldNamePrefix + OpenApiConstants.Description,
+ Description);
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize inline PathItem in OpenAPI V3
+ ///
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // summary
+ writer.WriteProperty(OpenApiConstants.Summary, Summary);
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // operations
+ foreach (var operation in Operations)
+ {
+ writer.WriteOptionalObject(
+ operation.Key.GetDisplayName(),
+ operation.Value,
+ (w, o) => o.SerializeAsV3(w));
+ }
+
+ // servers
+ writer.WriteOptionalCollection(OpenApiConstants.Servers, Servers, (w, s) => s.SerializeAsV3(w));
+
+ // parameters
+ writer.WriteOptionalCollection(OpenApiConstants.Parameters, Parameters, (w, p) => p.SerializeAsV3(w));
+
+ // specification extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPaths.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPaths.cs
new file mode 100644
index 000000000000..20dd6adf832e
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiPaths.cs
@@ -0,0 +1,27 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Paths object.
+ ///
+ internal class OpenApiPaths : OpenApiExtensibleDictionary
+ {
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiPaths() {}
+
+ ///
+ /// Initializes a copy of object
+ ///
+ /// The .
+ public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) { }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiReference.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiReference.cs
new file mode 100644
index 000000000000..d4431b3995e0
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiReference.cs
@@ -0,0 +1,236 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Extensions;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// A simple object to allow referencing other components in the specification, internally and externally.
+ ///
+ internal class OpenApiReference : IOpenApiSerializable
+ {
+ ///
+ /// External resource in the reference.
+ /// It maybe:
+ /// 1. a absolute/relative file path, for example: ../commons/pet.json
+ /// 2. a Url, for example: http://localhost/pet.json
+ ///
+ public string ExternalResource { get; set; }
+
+ ///
+ /// The element type referenced.
+ ///
+ /// This must be present if is not present.
+ public ReferenceType? Type { get; set; }
+
+ ///
+ /// The identifier of the reusable component of one particular ReferenceType.
+ /// If ExternalResource is present, this is the path to the component after the '#/'.
+ /// For example, if the reference is 'example.json#/path/to/component', the Id is 'path/to/component'.
+ /// If ExternalResource is not present, this is the name of the component without the reference type name.
+ /// For example, if the reference is '#/components/schemas/componentName', the Id is 'componentName'.
+ ///
+ public string Id { get; set; }
+
+ ///
+ /// Gets a flag indicating whether this reference is an external reference.
+ ///
+ public bool IsExternal => ExternalResource != null;
+
+ ///
+ /// Gets a flag indicating whether this reference is a local reference.
+ ///
+ public bool IsLocal => ExternalResource == null;
+
+ ///
+ /// Gets a flag indicating whether a file is a valid OpenAPI document or a fragment
+ ///
+ public bool IsFragrament = false;
+
+ ///
+ /// The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference.
+ ///
+ public OpenApiDocument HostDocument { get; set; }
+
+ ///
+ /// Gets the full reference string for v3.0.
+ ///
+ public string ReferenceV3
+ {
+ get
+ {
+ if (IsExternal)
+ {
+ return GetExternalReferenceV3();
+ }
+
+ if (!Type.HasValue)
+ {
+ throw new ArgumentNullException(nameof(Type));
+ }
+
+ if (Type == ReferenceType.Tag)
+ {
+ return Id;
+ }
+
+ if (Type == ReferenceType.SecurityScheme)
+ {
+ return Id;
+ }
+
+ return "#/components/" + Type.Value.GetDisplayName() + "/" + Id;
+ }
+ }
+
+ ///
+ /// Gets the full reference string for V2.0
+ ///
+ public string ReferenceV2
+ {
+ get
+ {
+ if (IsExternal)
+ {
+ return GetExternalReferenceV2();
+ }
+
+ if (!Type.HasValue)
+ {
+ throw new ArgumentNullException(nameof(Type));
+ }
+
+ if (Type == ReferenceType.Tag)
+ {
+ return Id;
+ }
+
+ if (Type == ReferenceType.SecurityScheme)
+ {
+ return Id;
+ }
+
+ return "#/" + GetReferenceTypeNameAsV2(Type.Value) + "/" + Id;
+ }
+ }
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiReference() {}
+
+ ///
+ /// Initializes a copy instance of the object
+ ///
+ public OpenApiReference(OpenApiReference reference)
+ {
+ ExternalResource = reference?.ExternalResource;
+ Type = reference?.Type;
+ Id = reference?.Id;
+ HostDocument = new(reference?.HostDocument);
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ if (Type == ReferenceType.Tag)
+ {
+ // Write the string value only
+ writer.WriteValue(ReferenceV3);
+ return;
+ }
+
+ writer.WriteStartObject();
+
+ // $ref
+ writer.WriteProperty(OpenApiConstants.DollarRef, ReferenceV3);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ if (Type == ReferenceType.Tag)
+ {
+ // Write the string value only
+ writer.WriteValue(ReferenceV2);
+ return;
+ }
+
+ if (Type == ReferenceType.SecurityScheme)
+ {
+ // Write the string as property name
+ writer.WritePropertyName(ReferenceV2);
+ return;
+ }
+
+ writer.WriteStartObject();
+
+ // $ref
+ writer.WriteProperty(OpenApiConstants.DollarRef, ReferenceV2);
+
+ writer.WriteEndObject();
+ }
+
+ private string GetExternalReferenceV3()
+ {
+ if (Id != null)
+ {
+ if (IsFragrament)
+ {
+ return ExternalResource + "#" + Id;
+ }
+
+ if (Type.HasValue)
+ {
+ return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id;
+ }
+ }
+
+ return ExternalResource;
+ }
+
+ private string GetExternalReferenceV2()
+ {
+ if (Id != null)
+ {
+ return ExternalResource + "#/" + GetReferenceTypeNameAsV2((ReferenceType)Type) + "/" + Id;
+ }
+
+ return ExternalResource;
+ }
+
+ private string GetReferenceTypeNameAsV2(ReferenceType type)
+ {
+ return type switch
+ {
+ ReferenceType.Schema => OpenApiConstants.Definitions,
+ ReferenceType.Parameter or ReferenceType.RequestBody => OpenApiConstants.Parameters,
+ ReferenceType.Response => OpenApiConstants.Responses,
+ ReferenceType.Header => OpenApiConstants.Headers,
+ ReferenceType.Tag => OpenApiConstants.Tags,
+ ReferenceType.SecurityScheme => OpenApiConstants.SecurityDefinitions,
+ _ => null,// If the reference type is not supported in V2, simply return null
+ // to indicate that the reference is not pointing to any object.
+ };
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiRequestBody.cs
new file mode 100644
index 000000000000..d841f83d9fef
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiRequestBody.cs
@@ -0,0 +1,192 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Request Body Object
+ ///
+ internal class OpenApiRequestBody : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference object.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// A brief description of the request body. This could contain examples of use.
+ /// CommonMark syntax MAY be used for rich text representation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Determines if the request body is required in the request. Defaults to false.
+ ///
+ public bool Required { get; set; }
+
+ ///
+ /// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it.
+ /// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
+ ///
+ public IDictionary Content { get; set; } = new Dictionary();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Parameter-less constructor
+ ///
+ public OpenApiRequestBody() { }
+
+ ///
+ /// Initializes a copy instance of an object
+ ///
+ public OpenApiRequestBody(OpenApiRequestBody requestBody)
+ {
+ UnresolvedReference = requestBody?.UnresolvedReference ?? UnresolvedReference;
+ Reference = requestBody?.Reference != null ? new(requestBody?.Reference) : null;
+ Description = requestBody?.Description ?? Description;
+ Required = requestBody?.Required ?? Required;
+ Content = requestBody?.Content != null ? new Dictionary(requestBody.Content) : null;
+ Extensions = requestBody?.Extensions != null ? new Dictionary(requestBody.Extensions) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiRequestBody object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiRequestBody
+ public OpenApiRequestBody GetEffective(OpenApiDocument doc)
+ {
+ return Reference != null ? doc.ResolveReferenceTo(Reference) : this;
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteProperty(OpenApiConstants.Description, Description);
+
+ // content
+ writer.WriteRequiredMap(OpenApiConstants.Content, Content, (w, c) => c.SerializeAsV3(w));
+
+ // required
+ writer.WriteProperty(OpenApiConstants.Required, Required, false);
+
+ // extensions
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ // RequestBody object does not exist in V2.
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ // RequestBody object does not exist in V2.
+ }
+
+ internal OpenApiBodyParameter ConvertToBodyParameter()
+ {
+ var bodyParameter = new OpenApiBodyParameter
+ {
+ Description = Description,
+ // V2 spec actually allows the body to have custom name.
+ // To allow round-tripping we use an extension to hold the name
+ Name = "body",
+ Schema = Content.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(),
+ Examples = Content.Values.FirstOrDefault()?.Examples,
+ Required = Required,
+ Extensions = Extensions.ToDictionary(static k => k.Key, static v => v.Value) // Clone extensions so we can remove the x-bodyName extensions from the output V2 model.
+ };
+ if (bodyParameter.Extensions.ContainsKey(OpenApiConstants.BodyName))
+ {
+ bodyParameter.Name = (Extensions[OpenApiConstants.BodyName] as OpenApiString)?.Value ?? "body";
+ bodyParameter.Extensions.Remove(OpenApiConstants.BodyName);
+ }
+ return bodyParameter;
+ }
+
+ internal IEnumerable ConvertToFormDataParameters()
+ {
+ if (Content == null || !Content.Any())
+ yield break;
+
+ foreach (var property in Content.First().Value.Schema.Properties)
+ {
+ var paramSchema = property.Value;
+ if ("string".Equals(paramSchema.Type, StringComparison.OrdinalIgnoreCase)
+ && ("binary".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase)
+ || "base64".Equals(paramSchema.Format, StringComparison.OrdinalIgnoreCase)))
+ {
+ paramSchema.Type = "file";
+ paramSchema.Format = null;
+ }
+ yield return new()
+ {
+ Description = property.Value.Description,
+ Name = property.Key,
+ Schema = property.Value,
+ Examples = Content.Values.FirstOrDefault()?.Examples,
+ Required = Content.First().Value.Schema.Required?.Contains(property.Key) ?? false
+ };
+ }
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponse.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponse.cs
new file mode 100644
index 000000000000..cbbfef21d312
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponse.cs
@@ -0,0 +1,238 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Response object.
+ ///
+ internal class OpenApiResponse : IOpenApiReferenceable, IOpenApiExtensible, IEffective
+ {
+ ///
+ /// REQUIRED. A short description of the response.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Maps a header name to its definition.
+ ///
+ public IDictionary Headers { get; set; } = new Dictionary();
+
+ ///
+ /// A map containing descriptions of potential response payloads.
+ /// The key is a media type or media type range and the value describes it.
+ ///
+ public IDictionary Content { get; set; } = new Dictionary();
+
+ ///
+ /// A map of operations links that can be followed from the response.
+ /// The key of the map is a short name for the link,
+ /// following the naming constraints of the names for Component Objects.
+ ///
+ public IDictionary Links { get; set; } = new Dictionary();
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///
+ /// Indicates if object is populated with data or is just a reference to the data
+ ///
+ public bool UnresolvedReference { get; set; }
+
+ ///
+ /// Reference pointer.
+ ///
+ public OpenApiReference Reference { get; set; }
+
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiResponse() {}
+
+ ///
+ /// Initializes a copy of object
+ ///
+ public OpenApiResponse(OpenApiResponse response)
+ {
+ Description = response?.Description ?? Description;
+ Headers = response?.Headers != null ? new Dictionary(response.Headers) : null;
+ Content = response?.Content != null ? new Dictionary(response.Content) : null;
+ Links = response?.Links != null ? new Dictionary(response.Links) : null;
+ Extensions = response?.Extensions != null ? new Dictionary(response.Extensions) : null;
+ UnresolvedReference = response?.UnresolvedReference ?? UnresolvedReference;
+ Reference = response?.Reference != null ? new(response?.Reference) : null;
+ }
+
+ ///
+ /// Serialize to Open Api v3.0.
+ ///
+ public void SerializeAsV3(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV3(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV3WithoutReference(writer);
+ }
+
+ ///
+ /// Returns an effective OpenApiRequestBody object based on the presence of a $ref
+ ///
+ /// The host OpenApiDocument that contains the reference.
+ /// OpenApiResponse
+ public OpenApiResponse GetEffective(OpenApiDocument doc)
+ {
+ return Reference != null ? doc.ResolveReferenceTo(Reference) : this;
+ }
+
+ ///
+ /// Serialize to OpenAPI V3 document without using reference.
+ ///
+ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteRequiredProperty(OpenApiConstants.Description, Description);
+
+ // headers
+ writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV3(w));
+
+ // content
+ writer.WriteOptionalMap(OpenApiConstants.Content, Content, (w, c) => c.SerializeAsV3(w));
+
+ // links
+ writer.WriteOptionalMap(OpenApiConstants.Links, Links, (w, l) => l.SerializeAsV3(w));
+
+ // extension
+ writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi3_0);
+
+ writer.WriteEndObject();
+ }
+
+ ///
+ /// Serialize to Open Api v2.0.
+ ///
+ public void SerializeAsV2(IOpenApiWriter writer)
+ {
+ Utils.CheckArgumentNull(writer);
+
+ var target = this;
+
+ if (Reference != null)
+ {
+ if (!writer.GetSettings().ShouldInlineReference(Reference))
+ {
+ Reference.SerializeAsV2(writer);
+ return;
+ }
+ else
+ {
+ target = GetEffective(Reference.HostDocument);
+ }
+ }
+ target.SerializeAsV2WithoutReference(writer);
+ }
+
+ ///
+ /// Serialize to OpenAPI V2 document without using reference.
+ ///
+ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
+ {
+ writer.WriteStartObject();
+
+ // description
+ writer.WriteRequiredProperty(OpenApiConstants.Description, Description);
+
+ var extensionsClone = new Dictionary(Extensions);
+
+ if (Content != null)
+ {
+ var mediatype = Content.FirstOrDefault();
+ if (mediatype.Value != null)
+ {
+ // schema
+ writer.WriteOptionalObject(
+ OpenApiConstants.Schema,
+ mediatype.Value.Schema,
+ (w, s) => s.SerializeAsV2(w));
+
+ // examples
+ if (Content.Values.Any(m => m.Example != null))
+ {
+ writer.WritePropertyName(OpenApiConstants.Examples);
+ writer.WriteStartObject();
+
+ foreach (var mediaTypePair in Content)
+ {
+ if (mediaTypePair.Value.Example != null)
+ {
+ writer.WritePropertyName(mediaTypePair.Key);
+ writer.WriteAny(mediaTypePair.Value.Example);
+ }
+ }
+
+ writer.WriteEndObject();
+ }
+
+ if (Content.Values.Any(m => m.Examples != null && m.Examples.Any()))
+ {
+ writer.WritePropertyName(OpenApiConstants.ExamplesExtension);
+ writer.WriteStartObject();
+
+ foreach (var example in Content
+ .Where(mediaTypePair => mediaTypePair.Value.Examples != null && mediaTypePair.Value.Examples.Any())
+ .SelectMany(mediaTypePair => mediaTypePair.Value.Examples))
+ {
+ writer.WritePropertyName(example.Key);
+ example.Value.Serialize(writer, OpenApiSpecVersion.OpenApi2_0);
+ }
+
+ writer.WriteEndObject();
+ }
+
+ writer.WriteExtensions(mediatype.Value.Extensions, OpenApiSpecVersion.OpenApi2_0);
+
+ foreach (var key in mediatype.Value.Extensions.Keys)
+ {
+ // The extension will already have been serialized as part of the call above,
+ // so remove it from the cloned collection so we don't write it again.
+ extensionsClone.Remove(key);
+ }
+ }
+ }
+
+ // headers
+ writer.WriteOptionalMap(OpenApiConstants.Headers, Headers, (w, h) => h.SerializeAsV2(w));
+
+ // extension
+ writer.WriteExtensions(extensionsClone, OpenApiSpecVersion.OpenApi2_0);
+
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponses.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponses.cs
new file mode 100644
index 000000000000..950ad57fed4f
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiResponses.cs
@@ -0,0 +1,27 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Responses object.
+ ///
+ internal class OpenApiResponses : OpenApiExtensibleDictionary
+ {
+ ///
+ /// Parameterless constructor
+ ///
+ public OpenApiResponses() { }
+
+ ///
+ /// Initializes a copy of object
+ ///
+ /// The
+ public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses) {}
+ }
+}
diff --git a/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiSchema.cs b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiSchema.cs
new file mode 100644
index 000000000000..cb43738d08be
--- /dev/null
+++ b/tracer/src/Datadog.Trace/Vendors/Microsoft.OpenApi/Models/OpenApiSchema.cs
@@ -0,0 +1,777 @@
+//------------------------------------------------------------------------------
+//
+// This file was automatically generated by the UpdateVendoredCode tool.
+//------------------------------------------------------------------------------
+#pragma warning disable CS0618, CS0649, CS1574, CS1580, CS1581, CS1584, CS1591, CS1573, CS8018, SYSLIB0011, SYSLIB0023, SYSLIB0032
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.Linq;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Any;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Interfaces;
+using Datadog.Trace.Vendors.Microsoft.OpenApi.Writers;
+
+namespace Datadog.Trace.Vendors.Microsoft.OpenApi.Models
+{
+ ///
+ /// Schema Object.
+ ///
+ internal class OpenApiSchema : IOpenApiReferenceable, IEffective, IOpenApiExtensible, IOpenApiAnnotatable
+ {
+ ///
+ /// Follow JSON Schema definition. Short text providing information about the data.
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Value MUST be a string. Multiple types via an array are not supported.
+ ///
+ public string Type { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// While relying on JSON Schema's defined formats,
+ /// the OAS offers a few additional predefined formats.
+ ///
+ public string Format { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// CommonMark syntax MAY be used for rich text representation.
+ ///
+ public string Description { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public decimal? Maximum { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public bool? ExclusiveMaximum { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public decimal? Minimum { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public bool? ExclusiveMinimum { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MaxLength { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MinLength { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect
+ ///
+ public string Pattern { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public decimal? MultipleOf { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided.
+ /// 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 IOpenApiAny Default { get; set; }
+
+ ///
+ /// Relevant only for Schema "properties" definitions. Declares the property as "read only".
+ /// This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request.
+ /// If the property is marked as readOnly being true and is in the required list,
+ /// the required will take effect on the response only.
+ /// A property MUST NOT be marked as both readOnly and writeOnly being true.
+ /// Default value is false.
+ ///
+ public bool ReadOnly { get; set; }
+
+ ///
+ /// Relevant only for Schema "properties" definitions. Declares the property as "write only".
+ /// Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response.
+ /// If the property is marked as writeOnly being true and is in the required list,
+ /// the required will take effect on the request only.
+ /// A property MUST NOT be marked as both readOnly and writeOnly being true.
+ /// Default value is false.
+ ///
+ public bool WriteOnly { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
+ ///
+ public IList AllOf { get; set; } = new List();
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
+ ///
+ public IList OneOf { get; set; } = new List();
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
+ ///
+ public IList AnyOf { get; set; } = new List();
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
+ ///
+ public OpenApiSchema Not { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public ISet Required { get; set; } = new HashSet();
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object
+ /// and not a standard JSON Schema. items MUST be present if the type is array.
+ ///
+ public OpenApiSchema Items { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MaxItems { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MinItems { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public bool? UniqueItems { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced).
+ ///
+ public IDictionary Properties { get; set; } = new Dictionary();
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MaxProperties { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public int? MinProperties { get; set; }
+
+ ///
+ /// Indicates if the schema can contain properties other than those defined by the properties map.
+ ///
+ public bool AdditionalPropertiesAllowed { get; set; } = true;
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ /// Value can be boolean or object. Inline or referenced schema
+ /// MUST be of a Schema Object and not a standard JSON Schema.
+ ///
+ public OpenApiSchema AdditionalProperties { get; set; }
+
+ ///
+ /// Adds support for polymorphism. The discriminator is an object name that is used to differentiate
+ /// between other schemas which may satisfy the payload description.
+ ///
+ public OpenApiDiscriminator Discriminator { get; set; }
+
+ ///
+ /// A free-form property to include an example of an instance for this schema.
+ /// 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 IOpenApiAny Example { get; set; }
+
+ ///
+ /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
+ ///
+ public IList Enum { get; set; } = new List();
+
+ ///
+ /// Allows sending a null value for the defined schema. Default value is false.
+ ///
+ public bool Nullable { get; set; }
+
+ ///
+ /// Additional external documentation for this schema.
+ ///
+ public OpenApiExternalDocs ExternalDocs { get; set; }
+
+ ///
+ /// Specifies that a schema is deprecated and SHOULD be transitioned out of usage.
+ /// Default value is false.
+ ///
+ public bool Deprecated { get; set; }
+
+ ///
+ /// This MAY be used only on properties schemas. It has no effect on root schemas.
+ /// Adds additional metadata to describe the XML representation of this property.
+ ///
+ public OpenApiXml Xml { get; set; }
+
+ ///
+ /// This object MAY be extended with Specification Extensions.
+ ///
+ public IDictionary Extensions { get; set; } = new Dictionary();
+
+ ///