diff --git a/.editorconfig b/.editorconfig
index e8f790dff..5b8c4b64e 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -121,14 +121,3 @@ csharp_preserve_single_line_blocks = true
[*.vb]
# Modifier preferences
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
-
-
-# Verify settings
-[*.{received,verified}.{txt,xml,json}]
-charset = "utf-8-bom"
-end_of_line = lf
-indent_size = unset
-indent_style = unset
-insert_final_newline = false
-tab_width = unset
-trim_trailing_whitespace = false
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
index dea329be9..bdb0cabc8 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -15,6 +15,3 @@
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
-
-# VerifyTests
-*.verified.txt text eol=lf working-tree-encoding=UTF-8
diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml
index 3d9334e96..72d96dd1d 100644
--- a/.github/workflows/auto-merge-dependabot.yml
+++ b/.github/workflows/auto-merge-dependabot.yml
@@ -19,7 +19,7 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
- uses: dependabot/fetch-metadata@v2.2.0
+ uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index be1bd2a64..27eb18d23 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -17,7 +17,7 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to GitHub package feed
- uses: docker/login-action@v3.3.0
+ uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
@@ -30,13 +30,13 @@ jobs:
id: getversion
- name: Push to GitHub Packages - Nightly
if: ${{ github.ref == 'refs/heads/vnext' }}
- uses: docker/build-push-action@v6.5.0
+ uses: docker/build-push-action@v6.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
- name: Push to GitHub Packages - Release
if: ${{ github.ref == 'refs/heads/master' }}
- uses: docker/build-push-action@v6.5.0
+ uses: docker/build-push-action@v6.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln
index 67f3f0e17..bb3c028e7 100644
--- a/Microsoft.OpenApi.sln
+++ b/Microsoft.OpenApi.sln
@@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{D8F799DD-04AC-4A13-B344-45A5B944450A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Trimming.Tests", "test\Microsoft.OpenApi.Trimming.Tests\Microsoft.OpenApi.Trimming.Tests.csproj", "{1D2E0C6E-B103-4CB6-912E-D56FA1501296}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -70,10 +68,6 @@ Global
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.Build.0 = Release|Any CPU
- {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -87,7 +81,6 @@ Global
{AD79B61D-88CF-497C-9ED5-41AE3867C5AC} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1}
{D8F799DD-04AC-4A13-B344-45A5B944450A} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
- {1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565}
diff --git a/README.md b/README.md
index c804787c1..021e570f5 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,12 @@ In order to test the validity of an OpenApi document, we avail the following too
5. Copy and paste your OpenAPI descriptions in the **Input Content** window or paste the path to the descriptions file in the **Input File** textbox and click on `Convert` to render the results.
+# Build Status
+
+|**master**|
+|--|
+|[](https://ci.appveyor.com/project/MicrosoftOpenAPINETAdmin/openapi-net-54e7i/branch/master)|
+
# Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
index d41487182..3bbbe339d 100644
--- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
+++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
@@ -3,7 +3,7 @@
netstandard2.0
latest
true
- 1.6.16
+ 1.6.15
OpenAPI.NET Readers for JSON and YAML documents
true
diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
index c6c8add2f..c9431de98 100644
--- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
+++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
@@ -3,7 +3,6 @@
using System;
using System.IO;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OpenApi.Interfaces;
@@ -42,7 +41,7 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null)
/// Instance of newly created OpenApiDocument.
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
{
- using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
+ using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
}
@@ -55,7 +54,6 @@ public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
public async Task ReadAsync(Stream input, CancellationToken cancellationToken = default)
{
MemoryStream bufferedStream;
- int bufferSize = 4096;
if (input is MemoryStream stream)
{
bufferedStream = stream;
@@ -65,12 +63,11 @@ public async Task ReadAsync(Stream input, CancellationToken cancella
// Buffer stream so that OpenApiTextReaderReader can process it synchronously
// YamlDocument doesn't support async reading.
bufferedStream = new();
- bufferSize = 81920;
- await input.CopyToAsync(bufferedStream, bufferSize, cancellationToken);
+ await input.CopyToAsync(bufferedStream, 81920, cancellationToken);
bufferedStream.Position = 0;
}
- using var reader = new StreamReader(bufferedStream, Encoding.UTF8, true, bufferSize, _settings.LeaveStreamOpen);
+ using var reader = new StreamReader(bufferedStream, default, true, -1, _settings.LeaveStreamOpen);
return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken);
}
@@ -83,7 +80,7 @@ public async Task ReadAsync(Stream input, CancellationToken cancella
/// Instance of newly created OpenApiDocument
public T ReadFragment(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable
{
- using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
+ using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic);
}
}
diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
index 813d8d497..76c67aeeb 100644
--- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
+++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
index eaa1dac31..b0e553f71 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
@@ -1,8 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
-using System;
-using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
namespace Microsoft.OpenApi.Any
{
@@ -16,8 +15,6 @@ public class OpenApiAnyCloneHelper
///
/// 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)
@@ -35,27 +32,5 @@ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny 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/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs
index 5a9af0fff..99bbb7d63 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs
@@ -27,10 +27,6 @@ public OpenApiArray() { }
public OpenApiArray(OpenApiArray array)
{
AnyType = array.AnyType;
- foreach (var item in array)
- {
- Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor(item));
- }
}
///
diff --git a/src/Microsoft.OpenApi/Any/OpenApiObject.cs b/src/Microsoft.OpenApi/Any/OpenApiObject.cs
index 95783cc23..f224824c3 100644
--- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs
+++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs
@@ -27,10 +27,6 @@ public OpenApiObject() { }
public OpenApiObject(OpenApiObject obj)
{
AnyType = obj.AnyType;
- foreach (var key in obj.Keys)
- {
- this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor(obj[key]);
- }
}
///
diff --git a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs
deleted file mode 100644
index 538ed521e..000000000
--- a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs
+++ /dev/null
@@ -1,425 +0,0 @@
-// 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/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs
index 1eadaa5f4..4e2e795d3 100644
--- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs
+++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Microsoft.OpenApi.Attributes;
@@ -22,11 +21,10 @@ public static class EnumExtensions
///
/// 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();
- var memInfo = type.GetField(enumValue.ToString(), BindingFlags.Public | BindingFlags.Static);
+ var memInfo = type.GetMember(enumValue.ToString()).First();
var attributes = memInfo.GetCustomAttributes(false);
return attributes.FirstOrDefault();
}
diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs
index 541523df5..51ce37365 100644
--- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs
+++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Microsoft.OpenApi.Attributes;
@@ -17,7 +16,7 @@ public 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)
+ public static T GetEnumFromDisplayName(this string displayName)
{
var type = typeof(T);
if (!type.IsEnum)
@@ -25,12 +24,14 @@ public static class StringExtensions
return default;
}
- foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
+ foreach (var value in Enum.GetValues(type))
{
+ var field = type.GetField(value.ToString());
+
var displayAttribute = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute));
if (displayAttribute != null && displayAttribute.Name == displayName)
{
- return (T)field.GetValue(null);
+ return (T)value;
}
}
diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
index 00d47b331..ff795f27a 100644
--- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
+++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
@@ -3,7 +3,7 @@
netstandard2.0
Latest
true
- 1.6.16
+ 1.6.15
.NET models with JSON and YAML writers for OpenAPI specification
true
diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
index c78353127..1b9d31022 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs
@@ -66,7 +66,7 @@ public OpenApiExample(OpenApiExample example)
{
Summary = example?.Summary ?? Summary;
Description = example?.Description ?? Description;
- Value = OpenApiAnyCloneHelper.CloneFromCopyConstructor(example?.Value);
+ 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;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
index 4093775a2..0e5fa4e8d 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs
@@ -106,7 +106,7 @@ public OpenApiHeader(OpenApiHeader header)
Explode = header?.Explode ?? Explode;
AllowReserved = header?.AllowReserved ?? AllowReserved;
Schema = header?.Schema != null ? new(header?.Schema) : null;
- Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(header?.Example);
+ 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;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
index 4751c4b28..444f41ba5 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs
@@ -54,7 +54,7 @@ public OpenApiMediaType() {}
public OpenApiMediaType(OpenApiMediaType mediaType)
{
Schema = mediaType?.Schema != null ? new(mediaType?.Schema) : null;
- Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(mediaType?.Example);
+ 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;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
index 1cfbd2c6c..fc1eaf8cc 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs
@@ -166,7 +166,7 @@ public OpenApiParameter(OpenApiParameter parameter)
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);
+ 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;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs
index 86b165d65..e366bf10d 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs
@@ -83,7 +83,7 @@ public string ReferenceV3
return Id;
}
- return "#/components/" + Type.Value.GetDisplayName() + "/" + Id;
+ return "#/components/" + Type.GetDisplayName() + "/" + Id;
}
}
@@ -200,11 +200,8 @@ private string GetExternalReferenceV3()
{
return ExternalResource + "#" + Id;
}
-
- if (Type.HasValue)
- {
- return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id;
- }
+
+ return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id;
}
return ExternalResource;
diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
index 40adf9a31..fd38927b6 100644
--- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
+++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs
@@ -263,7 +263,7 @@ public OpenApiSchema(OpenApiSchema schema)
MinLength = schema?.MinLength ?? MinLength;
Pattern = schema?.Pattern ?? Pattern;
MultipleOf = schema?.MultipleOf ?? MultipleOf;
- Default = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Default);
+ Default = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Default);
ReadOnly = schema?.ReadOnly ?? ReadOnly;
WriteOnly = schema?.WriteOnly ?? WriteOnly;
AllOf = schema?.AllOf != null ? new List(schema.AllOf) : null;
@@ -281,7 +281,7 @@ public OpenApiSchema(OpenApiSchema schema)
AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
- Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Example);
+ Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Example);
Enum = schema?.Enum != null ? new List(schema.Enum) : null;
Nullable = schema?.Nullable ?? Nullable;
ExternalDocs = schema?.ExternalDocs != null ? new(schema?.ExternalDocs) : null;
diff --git a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
index 796c72c3e..1ef1aaaa1 100644
--- a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
+++ b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs
@@ -26,7 +26,7 @@ public RuntimeExpressionAnyWrapper() {}
///
public RuntimeExpressionAnyWrapper(RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper)
{
- Any = OpenApiAnyCloneHelper.CloneFromCopyConstructor(runtimeExpressionAnyWrapper?.Any);
+ Any = OpenApiAnyCloneHelper.CloneFromCopyConstructor(runtimeExpressionAnyWrapper?.Any);
Expression = runtimeExpressionAnyWrapper?.Expression;
}
diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
index 92051949b..fa1b9911e 100644
--- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
+++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
@@ -61,10 +61,6 @@ public static class OpenApiFilterService
public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate)
{
// Fetch and copy title, graphVersion and server info from OpenApiDoc
- var components = source.Components is null
- ? null
- : new OpenApiComponents() { SecuritySchemes = source.Components.SecuritySchemes };
-
var subset = new OpenApiDocument
{
Info = new()
@@ -78,7 +74,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun
Extensions = source.Info.Extensions
},
- Components = components,
+ Components = new() { SecuritySchemes = source.Components.SecuritySchemes },
SecurityRequirements = source.SecurityRequirements,
Servers = source.Servers
};
diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs
index 448683fd9..3dd916755 100644
--- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs
+++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs
@@ -186,15 +186,16 @@ private static ValidationRuleSet BuildDefaultRuleSet()
{
var ruleSet = new ValidationRuleSet();
var validationRuleType = typeof(ValidationRule);
-
- var ruleTypeProperties = GetValidationRuleTypes();
- foreach (var property in ruleTypeProperties)
+ var rules = typeof(ValidationRuleSet).Assembly.GetTypes()
+ .Where(t => t.IsClass
+ && t != typeof(object)
+ && t.GetCustomAttributes(typeof(OpenApiRuleAttribute), false).Any())
+ .SelectMany(t2 => t2.GetProperties(BindingFlags.Static | BindingFlags.Public)
+ .Where(p => validationRuleType.IsAssignableFrom(p.PropertyType)));
+
+ foreach (var property in rules)
{
- if (!validationRuleType.IsAssignableFrom(property.PropertyType))
- {
- continue;
- }
var propertyValue = property.GetValue(null); // static property
if (propertyValue is ValidationRule rule)
{
@@ -204,28 +205,5 @@ private static ValidationRuleSet BuildDefaultRuleSet()
return ruleSet;
}
-
- internal static PropertyInfo[] GetValidationRuleTypes()
- {
- return [
- ..typeof(OpenApiComponentsRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiContactRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiDocumentRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiExtensibleRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiExternalDocsRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiInfoRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiLicenseRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiMediaTypeRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiOAuthFlowRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiServerRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiResponseRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiResponsesRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiSchemaRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiHeaderRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiTagRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiPathsRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ..typeof(OpenApiParameterRules).GetProperties(BindingFlags.Static | BindingFlags.Public),
- ];
- }
}
}
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
index cef3a9174..cb5405b31 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
@@ -14,8 +14,8 @@
-
-
+
+
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
index e092a1c43..7314da8ab 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
@@ -65,46 +65,6 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen
Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count);
}
- [Fact]
- public void CreateFilteredDocumentOnMinimalOpenApi()
- {
- // Arrange
-
- // We create a minimal OpenApiDocument with a single path and operation.
- var openApiDoc = new OpenApiDocument
- {
- Info = new()
- {
- Title = "Test",
- Version = "1.0.0"
- },
- Paths = new()
- {
- ["/test"] = new OpenApiPathItem()
- {
- Operations = new Dictionary
- {
- [OperationType.Get] = new OpenApiOperation()
- }
- }
- }
- };
-
- // Act
- var requestUrls = new Dictionary>()
- {
- { "/test", ["GET"] }
- };
- var filterPredicate = OpenApiFilterService.CreatePredicate(null, null, requestUrls, openApiDoc);
- var filteredDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, filterPredicate);
-
- // Assert
- Assert.NotNull(filteredDocument);
- Assert.NotNull(filteredDocument.Paths);
- Assert.Single(filteredDocument.Paths);
- }
-
-
[Theory]
[InlineData("UtilityFiles/appsettingstest.json")]
[InlineData(null)]
diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
index 8ffaa2cf1..c724a2e68 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
index 7bb0fe922..856d5ada7 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
@@ -1,9 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
-using System;
using System.IO;
-using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
@@ -46,20 +44,5 @@ public async Task StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue()
stream.Seek(0, SeekOrigin.Begin); // does not throw an object disposed exception
Assert.True(stream.CanRead);
}
-
- [Fact]
- public async Task StreamShouldReadWhenInitialized()
- {
- var httpClient = new HttpClient
- {
- BaseAddress = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/")
- };
-
- var stream = await httpClient.GetStreamAsync("master/examples/v3.0/petstore.yaml");
-
- // Read V3 as YAML
- var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic);
- Assert.NotNull(openApiDocument);
- }
}
}
diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
index 8954143d6..f3e5f025d 100644
--- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
+++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs
index f9bb8beff..274258601 100644
--- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs
@@ -1,5 +1,4 @@
-using System;
-using Microsoft.OpenApi.Attributes;
+using Microsoft.OpenApi.Attributes;
using Microsoft.OpenApi.Extensions;
using Xunit;
@@ -15,19 +14,6 @@ public enum ApiLevel
Corporate = 3
}
- [Flags]
- public enum UserType
- {
- [DisplayAttribute("admin")]
- Admin = 1,
- [DisplayAttribute("editor")]
- Editor = 2,
- [DisplayAttribute("publisher")]
- Publisher = 3,
- [DisplayAttribute("all")]
- All = Admin | Editor | Publisher
- }
-
public class DisplayAttributeTests
{
[Theory]
@@ -38,23 +24,5 @@ public void GetDisplayNameExtensionShouldUseDisplayAttribute(ApiLevel apiLevel,
{
Assert.Equal(expected, apiLevel.GetDisplayName());
}
-
- [Theory]
- [InlineData(ApiLevel.Private,"private")]
- [InlineData(ApiLevel.Public, "public")]
- [InlineData(ApiLevel.Corporate, "corporate")]
- public void GetEnumFromDisplayNameShouldReturnEnumValue(ApiLevel expected, string displayName)
- {
- Assert.Equal(expected, displayName.GetEnumFromDisplayName());
- }
-
- [Theory]
- [InlineData(UserType.Admin,"admin")]
- [InlineData(UserType.Publisher, "publisher")]
- [InlineData(UserType.Editor, "editor")]
- public void GetEnumFromDisplayNameShouldReturnEnumValueForFlagsEnum(UserType expected, string displayName)
- {
- Assert.Equal(expected, displayName.GetEnumFromDisplayName());
- }
}
}
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 28f48e4e3..351a72df4 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -15,9 +15,9 @@
-
-
-
+
+
+
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs
index 0acd55925..5d8320c62 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs
@@ -1,9 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
+using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Any;
@@ -483,45 +485,6 @@ public void OpenApiSchemaCopyConstructorSucceeds()
Assert.True(actualSchema.Nullable);
}
- public static TheoryData SchemaExamples()
- {
- return new()
- {
- new OpenApiArray() { new OpenApiString("example") },
- new OpenApiBinary([0, 1, 2]),
- new OpenApiBoolean(true),
- new OpenApiByte(42),
- new OpenApiDate(new(2024, 07, 19, 12, 34, 56)),
- new OpenApiDateTime(new(2024, 07, 19, 12, 34, 56, new(01, 00, 00))),
- new OpenApiDouble(42.37),
- new OpenApiFloat(42.37f),
- new OpenApiInteger(42),
- new OpenApiLong(42),
- new OpenApiNull(),
- new OpenApiObject() { ["prop"] = new OpenApiString("example") },
- new OpenApiPassword("secret"),
- new OpenApiString("example"),
- };
- }
-
- [Theory]
- [MemberData(nameof(SchemaExamples))]
- public void CloningSchemaExamplesWorks(IOpenApiAny example)
- {
- // Arrange
- var schema = new OpenApiSchema
- {
- Example = example
- };
-
- // Act && Assert
- var schemaCopy = new OpenApiSchema(schema);
- Assert.NotNull(schemaCopy.Example);
-
- // Act && Assert
- Assert.Equivalent(schema.Example, schemaCopy.Example);
- }
-
[Fact]
public void CloningSchemaExtensionsWorks()
{
diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
index 82c5f6a88..37f40bb11 100755
--- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
+++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
@@ -22,10 +22,7 @@ namespace Microsoft.OpenApi.Any
public class OpenApiAnyCloneHelper
{
public OpenApiAnyCloneHelper() { }
- [System.Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { }
- public static T CloneFromCopyConstructor(T obj)
- where T : Microsoft.OpenApi.Any.IOpenApiAny { }
}
public class OpenApiArray : System.Collections.Generic.List, Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension
{
diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs
index 3c302be13..708d6ee64 100644
--- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs
@@ -1,9 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
-using System.Linq;
-using System.Reflection;
-using Microsoft.OpenApi.Validations.Rules;
using Xunit;
namespace Microsoft.OpenApi.Validations.Tests
@@ -40,25 +37,5 @@ public void DefaultRuleSetPropertyReturnsTheCorrectRules()
// Update the number if you add new default rule(s).
Assert.Equal(23, rules.Count);
}
-
- [Fact]
- public void GetValidationRuleTypesReturnsAllSupportedTypes()
- {
- var declaredRuleTypeProperties = typeof(ValidationRuleSet).Assembly.GetTypes()
- .Where(t => t.IsClass
- && t != typeof(object)
- && t.GetCustomAttributes(typeof(OpenApiRuleAttribute), false).Any())
- .SelectMany(t2 => t2.GetProperties(BindingFlags.Static | BindingFlags.Public))
- .ToList();
-
- var resolvedRuleTypeProperties = ValidationRuleSet.GetValidationRuleTypes();
-
- foreach (var ruleTypeProperty in resolvedRuleTypeProperties)
- {
- Assert.True(declaredRuleTypeProperties.Remove(ruleTypeProperty));
- }
-
- Assert.Empty(declaredRuleTypeProperties);
- }
}
}
diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj
deleted file mode 100644
index 3e6daf74c..000000000
--- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- Exe
- net8.0
- enable
- enable
- true
- false
- true
- false
-
-
-
-
-
-
-
-
-
diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Program.cs b/test/Microsoft.OpenApi.Trimming.Tests/Program.cs
deleted file mode 100644
index 1bc52a60a..000000000
--- a/test/Microsoft.OpenApi.Trimming.Tests/Program.cs
+++ /dev/null
@@ -1 +0,0 @@
-Console.WriteLine("Hello, World!");