From ad775b248d29ed2b1e702c15932751a03c54d6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Wed, 6 Mar 2024 10:50:35 +0100 Subject: [PATCH 001/121] Add stub test to support trailing slashes --- .../Services/OpenApiUrlTreeNodeTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 511c6c5bd..76e1c5f31 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -466,5 +466,23 @@ public async Task VerifyDiagramFromSampleOpenAPI() await Verifier.Verify(diagram); } + + [Fact] + public void SupportsTrailingSlashesInPath() + { + var openApiDocument = new OpenApiDocument + { + Paths = new() + { + ["/cars/{car-id}/build/"] = new() + } + }; + + var label1 = "trailing-slash"; + var rootNode = OpenApiUrlTreeNode.Create(openApiDocument, label1); + var buildNode = rootNode.Children["cars"].Children["{car-id}"].Children["build"]; + + // Should buildNode have a path of "build/" or should it have a child with an empty string key? + } } } From 35398a180542bfa9d36964ce4fa2003cd6e1a443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Wed, 6 Mar 2024 15:35:38 +0100 Subject: [PATCH 002/121] Attempt at supporting trailing slashes --- .../Services/OpenApiUrlTreeNode.cs | 7 +++++ .../Services/OpenApiUrlTreeNodeTests.cs | 28 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 53a79c8a4..38b571112 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -150,6 +150,13 @@ public OpenApiUrlTreeNode Attach(string path, } var segments = path.Split('/'); + if (path.EndsWith("/")) + { + // Remove the last element, which is empty, and append the trailing slash to the new last element + // This is to support URLs with trailing slashes + Array.Resize(ref segments, segments.Length - 1); + segments[segments.Length - 1] += "/"; + } return Attach(segments: segments, pathItem: pathItem, diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 76e1c5f31..5303d7390 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -467,22 +467,36 @@ public async Task VerifyDiagramFromSampleOpenAPI() await Verifier.Verify(diagram); } - [Fact] - public void SupportsTrailingSlashesInPath() + public static TheoryData SupportsTrailingSlashesInPathData => new TheoryData + { + // Path, children up to second to leaf, last expected leaf node name, expected leaf node path + { "/cars/{car-id}/build/", ["cars", "{car-id}"], "build/", @"\cars\{car-id}\build/" }, + { "/cars/", [], "cars/", @"\cars/" }, + }; + + [Theory] + [MemberData(nameof(SupportsTrailingSlashesInPathData))] + public void SupportsTrailingSlashesInPath(string path, string[] childrenBeforeLastNode, string expectedLeafNodeName, string expectedLeafNodePath) { var openApiDocument = new OpenApiDocument { Paths = new() { - ["/cars/{car-id}/build/"] = new() + [path] = new() } }; - var label1 = "trailing-slash"; - var rootNode = OpenApiUrlTreeNode.Create(openApiDocument, label1); - var buildNode = rootNode.Children["cars"].Children["{car-id}"].Children["build"]; + var label = "trailing-slash"; + var rootNode = OpenApiUrlTreeNode.Create(openApiDocument, label); + + var secondToLeafNode = rootNode; + foreach (var childName in childrenBeforeLastNode) + { + secondToLeafNode = secondToLeafNode.Children[childName]; + } - // Should buildNode have a path of "build/" or should it have a child with an empty string key? + Assert.True(secondToLeafNode.Children.TryGetValue(expectedLeafNodeName, out var lastNode)); + Assert.Equal(expectedLeafNodePath, lastNode.Path); } } } From 996407c3680a77c7419eeb9822756b8fcf025aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Thu, 7 Mar 2024 08:18:12 +0100 Subject: [PATCH 003/121] Ensure leaf nodes have no children --- .../Services/OpenApiUrlTreeNodeTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 5303d7390..4760cf37a 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -495,8 +495,9 @@ public void SupportsTrailingSlashesInPath(string path, string[] childrenBeforeLa secondToLeafNode = secondToLeafNode.Children[childName]; } - Assert.True(secondToLeafNode.Children.TryGetValue(expectedLeafNodeName, out var lastNode)); - Assert.Equal(expectedLeafNodePath, lastNode.Path); + Assert.True(secondToLeafNode.Children.TryGetValue(expectedLeafNodeName, out var leafNode)); + Assert.Equal(expectedLeafNodePath, leafNode.Path); + Assert.Empty(leafNode.Children); } } } From 7fa2f2c89846f958535b5335d2d47bd49d44ca29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Mon, 11 Mar 2024 08:15:04 +0100 Subject: [PATCH 004/121] Add `StringComparison.OrdinalIgnoreCase` --- src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 38b571112..425250fc9 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -150,7 +150,7 @@ public OpenApiUrlTreeNode Attach(string path, } var segments = path.Split('/'); - if (path.EndsWith("/")) + if (path.EndsWith("/", StringComparison.OrdinalIgnoreCase)) { // Remove the last element, which is empty, and append the trailing slash to the new last element // This is to support URLs with trailing slashes From d8eda7aca828415f253aa6f0ac3780f303719f51 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 3 Jul 2024 18:05:02 -0700 Subject: [PATCH 005/121] Make library trim-compatible --- .../Any/OpenApiAnyCloneHelper.cs | 11 +- .../Attributes/TrimmingAttributes.cs | 145 ++++++++++++++++++ .../Extensions/EnumExtensions.cs | 103 +++++++++++++ .../Models/OpenApiReference.cs | 4 +- 4 files changed, 255 insertions(+), 8 deletions(-) create mode 100644 src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index b0e553f71..c2f76b08c 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Reflection; +using System.Diagnostics.CodeAnalysis; namespace Microsoft.OpenApi.Any { @@ -15,17 +15,16 @@ public class OpenApiAnyCloneHelper /// /// The object instance. /// A clone copy or the object itself. - public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) + public static IOpenApiAny CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny { if (obj != null) { - var t = obj.GetType(); - foreach (var ci in t.GetConstructors()) + foreach (var ci in typeof(T).GetConstructors()) { var pi = ci.GetParameters(); - if (pi.Length == 1 && pi[0].ParameterType == t) + if (pi.Length == 1 && pi[0].ParameterType == typeof(T)) { - return (IOpenApiAny)ci.Invoke(new object[] { obj }); + return (IOpenApiAny)ci.Invoke([obj]); } } } diff --git a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs new file mode 100644 index 000000000..8c84377fd --- /dev/null +++ b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#nullable enable + +namespace System.Diagnostics.CodeAnalysis +{ +#if !NET7_0_OR_GREATER + /// + /// 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 4e2e795d3..bc77d2133 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using Microsoft.OpenApi.Attributes; +using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Extensions { @@ -42,5 +43,107 @@ public static string GetDisplayName(this Enum enumValue) var attribute = enumValue.GetAttributeOfType(); return attribute == null ? enumValue.ToString() : attribute.Name; } + + /// + /// Gets the enum display name for without the use of reflection. + /// + /// The type of the enum value. + /// The enum value. + /// The display string to use. + public static string GetDisplayName(this T enumValue) where T : Enum + { + return enumValue switch + { + ParameterStyle parameterStyle => parameterStyle.GetDisplayName(), + ParameterLocation parameterLocation => parameterLocation.GetDisplayName(), + ReferenceType referenceType => referenceType.GetDisplayName(), + OperationType operationType => operationType.GetDisplayName(), + SecuritySchemeType securitySchemeType => securitySchemeType.GetDisplayName(), + _ => enumValue.ToString() + }; + } + + /// + /// Gets the enum display for name without the use of reflection. + /// + /// The enum value. + /// The display string to use. + internal static string GetDisplayName(this ParameterStyle parameterStyle) => parameterStyle switch + { + ParameterStyle.Matrix => "matrix", + ParameterStyle.Label => "label", + ParameterStyle.Form => "form", + ParameterStyle.Simple => "simple", + ParameterStyle.SpaceDelimited => "spaceDelimited", + ParameterStyle.PipeDelimited => "pipeDelimited", + ParameterStyle.DeepObject => "deepObject", + _ => parameterStyle.ToString() + }; + + /// + /// Gets the enum display for name without the use of reflection. + /// + /// The enum value. + /// The display string to use. + internal static string GetDisplayName(this ParameterLocation parameterLocation) => parameterLocation switch + { + ParameterLocation.Query => "query", + ParameterLocation.Header => "header", + ParameterLocation.Path => "path", + ParameterLocation.Cookie => "cookie", + _ => parameterLocation.ToString() + }; + + /// + /// Gets the enum display for name without the use of reflection. + /// + /// The enum value. + /// The display string to use. + internal static string GetDisplayName(this ReferenceType referenceType) => referenceType switch + { + ReferenceType.Schema => "schemas", + ReferenceType.Response => "responses", + ReferenceType.Parameter => "parameters", + ReferenceType.Example => "examples", + ReferenceType.RequestBody => "requestBodies", + ReferenceType.Header => "headers", + ReferenceType.SecurityScheme => "securitySchemes", + ReferenceType.Link => "links", + ReferenceType.Callback => "callbacks", + ReferenceType.Tag => "tags", + _ => referenceType.ToString() + }; + + /// + /// Gets the enum display for name without the use of reflection. + /// + /// The enum value. + /// The display string to use. + internal static string GetDisplayName(this OperationType operationType) => operationType switch + { + OperationType.Get => "get", + OperationType.Put => "put", + OperationType.Post => "post", + OperationType.Delete => "delete", + OperationType.Options => "options", + OperationType.Head => "head", + OperationType.Patch => "patch", + OperationType.Trace => "trace", + _ => operationType.ToString() + }; + + /// + /// Gets the enum display for name without the use of reflection. + /// + /// The enum value. + /// The display string to use. + internal static string GetDisplayName(this SecuritySchemeType securitySchemeType) => securitySchemeType switch + { + SecuritySchemeType.ApiKey => "apiKey", + SecuritySchemeType.Http => "http", + SecuritySchemeType.OAuth2 => "oauth2", + SecuritySchemeType.OpenIdConnect => "openIdConnect", + _ => securitySchemeType.ToString() + }; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index e366bf10d..339b9c632 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.GetDisplayName() + "/" + Id; + return "#/components/" + Type.Value.GetDisplayName() + "/" + Id; } } @@ -201,7 +201,7 @@ private string GetExternalReferenceV3() return ExternalResource + "#" + Id; } - return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; + return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id; } return ExternalResource; From 08718e15e72f4236e37f160e57f1767c8428b8f9 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 3 Jul 2024 21:57:46 -0700 Subject: [PATCH 006/121] Avoid using generic overload for all enum types --- .../Extensions/EnumExtensions.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index bc77d2133..81fc65a1b 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -44,25 +44,6 @@ public static string GetDisplayName(this Enum enumValue) return attribute == null ? enumValue.ToString() : attribute.Name; } - /// - /// Gets the enum display name for without the use of reflection. - /// - /// The type of the enum value. - /// The enum value. - /// The display string to use. - public static string GetDisplayName(this T enumValue) where T : Enum - { - return enumValue switch - { - ParameterStyle parameterStyle => parameterStyle.GetDisplayName(), - ParameterLocation parameterLocation => parameterLocation.GetDisplayName(), - ReferenceType referenceType => referenceType.GetDisplayName(), - OperationType operationType => operationType.GetDisplayName(), - SecuritySchemeType securitySchemeType => securitySchemeType.GetDisplayName(), - _ => enumValue.ToString() - }; - } - /// /// Gets the enum display for name without the use of reflection. /// From 11466d76fe4687f7924a94584410d4b55e9afb9a Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 3 Jul 2024 23:26:50 -0700 Subject: [PATCH 007/121] Update PublicApi.Approved.txt --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 37f40bb11..f9c5e2b89 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -22,7 +22,8 @@ namespace Microsoft.OpenApi.Any public class OpenApiAnyCloneHelper { public OpenApiAnyCloneHelper() { } - public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { } + public static Microsoft.OpenApi.Any.IOpenApiAny 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 { From 015448fba520612be2408dc4a41b80a86f0d1b0b Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Fri, 5 Jul 2024 20:09:19 +1000 Subject: [PATCH 008/121] make verified files as lf and utf8 --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index bdb0cabc8..dea329be9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,6 @@ *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain + +# VerifyTests +*.verified.txt text eol=lf working-tree-encoding=UTF-8 From a0b6f9d0be3ca9c70279e0f9e7f952ba7b5bb7c9 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 5 Jul 2024 19:12:55 -0700 Subject: [PATCH 009/121] Avoid binary compat break in CloneFromCopyConstructor --- .../Any/OpenApiAnyCloneHelper.cs | 23 +++++++++++++++++++ .../PublicApi/PublicApi.approved.txt | 1 + 2 files changed, 24 insertions(+) diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index c2f76b08c..57c0826af 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -10,6 +10,29 @@ namespace Microsoft.OpenApi.Any /// public class OpenApiAnyCloneHelper { + /// + /// Clones an instance of object from the copy constructor + /// + /// The object instance. + /// A clone copy or the object itself. + 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 /// diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index f9c5e2b89..759d441cc 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -22,6 +22,7 @@ namespace Microsoft.OpenApi.Any public class OpenApiAnyCloneHelper { public OpenApiAnyCloneHelper() { } + public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { } public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(T obj) where T : Microsoft.OpenApi.Any.IOpenApiAny { } } From 5b006b2a6507fd8216604eaa352ac7d1328fcabe Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Mon, 8 Jul 2024 17:22:27 -0700 Subject: [PATCH 010/121] Add obsoletion attributes and fix CloneFromCopyConstructor --- src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs | 2 ++ src/Microsoft.OpenApi/Extensions/EnumExtensions.cs | 13 +++++++------ src/Microsoft.OpenApi/Models/OpenApiExample.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiParameter.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 4 ++-- .../Models/RuntimeExpressionAnyWrapper.cs | 2 +- .../Attributes/DisplayAttributeTests.cs | 4 +++- .../PublicApi/PublicApi.approved.txt | 3 +++ 10 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index 57c0826af..49699d930 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Diagnostics.CodeAnalysis; namespace Microsoft.OpenApi.Any @@ -15,6 +16,7 @@ public class OpenApiAnyCloneHelper /// /// The object instance. /// A clone copy or the object itself. + [Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")] public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) { if (obj != null) diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 81fc65a1b..0e1a12e43 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -38,6 +38,7 @@ public static T GetAttributeOfType(this Enum enumValue) where T : Attribute /// Use if exists. /// Otherwise, use the standard string representation. /// + [Obsolete("Use native AoT-friendly type-specific overloads GetDisplayName methods instead.")] public static string GetDisplayName(this Enum enumValue) { var attribute = enumValue.GetAttributeOfType(); @@ -58,7 +59,7 @@ public static string GetDisplayName(this Enum enumValue) ParameterStyle.SpaceDelimited => "spaceDelimited", ParameterStyle.PipeDelimited => "pipeDelimited", ParameterStyle.DeepObject => "deepObject", - _ => parameterStyle.ToString() + _ => throw new InvalidOperationException($"Unknown parameter style: {parameterStyle}") }; /// @@ -66,13 +67,13 @@ public static string GetDisplayName(this Enum enumValue) /// /// The enum value. /// The display string to use. - internal static string GetDisplayName(this ParameterLocation parameterLocation) => parameterLocation switch + public static string GetDisplayName(this ParameterLocation parameterLocation) => parameterLocation switch { ParameterLocation.Query => "query", ParameterLocation.Header => "header", ParameterLocation.Path => "path", ParameterLocation.Cookie => "cookie", - _ => parameterLocation.ToString() + _ => throw new InvalidOperationException($"Unknown parameter location: {parameterLocation}") }; /// @@ -92,7 +93,7 @@ public static string GetDisplayName(this Enum enumValue) ReferenceType.Link => "links", ReferenceType.Callback => "callbacks", ReferenceType.Tag => "tags", - _ => referenceType.ToString() + _ => throw new InvalidOperationException($"Unknown reference type: {referenceType}") }; /// @@ -110,7 +111,7 @@ public static string GetDisplayName(this Enum enumValue) OperationType.Head => "head", OperationType.Patch => "patch", OperationType.Trace => "trace", - _ => operationType.ToString() + _ => throw new InvalidOperationException($"Unknown operation type: {operationType}") }; /// @@ -124,7 +125,7 @@ public static string GetDisplayName(this Enum enumValue) SecuritySchemeType.Http => "http", SecuritySchemeType.OAuth2 => "oauth2", SecuritySchemeType.OpenIdConnect => "openIdConnect", - _ => securitySchemeType.ToString() + _ => throw new InvalidOperationException($"Unknown security scheme type: {securitySchemeType}") }; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 1b9d31022..c78353127 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 0e5fa4e8d..4093775a2 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 444f41ba5..4751c4b28 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 fc1eaf8cc..1cfbd2c6c 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/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index fd38927b6..40adf9a31 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 1ef1aaaa1..796c72c3e 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/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index 274258601..7c3222d78 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -22,7 +22,9 @@ public class DisplayAttributeTests [InlineData(ApiLevel.Corporate, "corporate")] public void GetDisplayNameExtensionShouldUseDisplayAttribute(ApiLevel apiLevel, string expected) { - Assert.Equal(expected, apiLevel.GetDisplayName()); +#pragma warning disable CS0618 // Type or member is obsolete, testing obsolete behavior + Assert.Equal(expected, apiLevel.GetDisplayName()); +#pragma warning restore CS0618 // Type or member is obsolete, testing obsolete behavior } } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 759d441cc..48db67ac0 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -22,6 +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 Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(T obj) where T : Microsoft.OpenApi.Any.IOpenApiAny { } @@ -250,6 +251,8 @@ namespace Microsoft.OpenApi.Extensions { public static T GetAttributeOfType(this System.Enum enumValue) where T : System.Attribute { } + public static string GetDisplayName(this Microsoft.OpenApi.Models.ParameterLocation parameterLocation) { } + [System.Obsolete("Use native AoT-friendly type-specific overloads GetDisplayName methods instead.")] public static string GetDisplayName(this System.Enum enumValue) { } } public static class OpenApiElementExtensions From 8ea0964d6f3e1ab6ea70cb1b7e925b227513288a Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Tue, 9 Jul 2024 13:52:00 -0700 Subject: [PATCH 011/121] Add ReferenceType.Path and tests for display names --- .../Extensions/EnumExtensions.cs | 1 + .../Attributes/DisplayAttributeTests.cs | 149 +++++++++++++++++- 2 files changed, 149 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 0e1a12e43..1df069f35 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -93,6 +93,7 @@ public static string GetDisplayName(this Enum enumValue) ReferenceType.Link => "links", ReferenceType.Callback => "callbacks", ReferenceType.Tag => "tags", + ReferenceType.Path => "path", _ => throw new InvalidOperationException($"Unknown reference type: {referenceType}") }; diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index 7c3222d78..80d138bee 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -1,5 +1,10 @@ -using Microsoft.OpenApi.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata; +using Microsoft.OpenApi.Attributes; using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Models; using Xunit; namespace Microsoft.OpenApi.Tests.Attributes @@ -26,5 +31,147 @@ public void GetDisplayNameExtensionShouldUseDisplayAttribute(ApiLevel apiLevel, Assert.Equal(expected, apiLevel.GetDisplayName()); #pragma warning restore CS0618 // Type or member is obsolete, testing obsolete behavior } + + [Fact] + public void GetDisplayNameWorksForAllParameterStyle() + { + var enumValues = new List(Enum.GetValues()); + + Assert.Equal("matrix", ParameterStyle.Matrix.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.Matrix)); + + Assert.Equal("label", ParameterStyle.Label.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.Label)); + + Assert.Equal("form", ParameterStyle.Form.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.Form)); + + Assert.Equal("simple", ParameterStyle.Simple.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.Simple)); + + Assert.Equal("spaceDelimited", ParameterStyle.SpaceDelimited.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.SpaceDelimited)); + + Assert.Equal("pipeDelimited", ParameterStyle.PipeDelimited.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.PipeDelimited)); + + Assert.Equal("deepObject", ParameterStyle.DeepObject.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterStyle.DeepObject)); + + Assert.Empty(enumValues); + } + + [Fact] + public void GetDisplayNameWorksForAllParameterLocation() + { + var enumValues = new List(Enum.GetValues()); + + Assert.Equal("query", ParameterLocation.Query.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterLocation.Query)); + + Assert.Equal("header", ParameterLocation.Header.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterLocation.Header)); + + Assert.Equal("path", ParameterLocation.Path.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterLocation.Path)); + + Assert.Equal("cookie", ParameterLocation.Cookie.GetDisplayName()); + Assert.True(enumValues.Remove(ParameterLocation.Cookie)); + + Assert.Empty(enumValues); + } + + [Fact] + public void GetDisplayNameWorksForAllReferenceType() + { + var enumValues = new List(Enum.GetValues()); + + Assert.Equal("schemas", ReferenceType.Schema.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Schema)); + + Assert.Equal("responses", ReferenceType.Response.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Response)); + + Assert.Equal("parameters", ReferenceType.Parameter.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Parameter)); + + Assert.Equal("examples", ReferenceType.Example.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Example)); + + Assert.Equal("requestBodies", ReferenceType.RequestBody.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.RequestBody)); + + Assert.Equal("headers", ReferenceType.Header.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Header)); + + Assert.Equal("securitySchemes", ReferenceType.SecurityScheme.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.SecurityScheme)); + + Assert.Equal("links", ReferenceType.Link.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Link)); + + Assert.Equal("callbacks", ReferenceType.Callback.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Callback)); + + Assert.Equal("tags", ReferenceType.Tag.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Tag)); + + Assert.Equal("path", ReferenceType.Path.GetDisplayName()); + Assert.True(enumValues.Remove(ReferenceType.Path)); + + Assert.Empty(enumValues); + } + + [Fact] + public void GetDisplayNameWorksForAllOperationTypes() + { + var enumValues = new List(Enum.GetValues()); + + Assert.Equal("get", OperationType.Get.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Get)); + + Assert.Equal("put", OperationType.Put.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Put)); + + Assert.Equal("post", OperationType.Post.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Post)); + + Assert.Equal("delete", OperationType.Delete.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Delete)); + + Assert.Equal("options", OperationType.Options.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Options)); + + Assert.Equal("head", OperationType.Head.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Head)); + + Assert.Equal("patch", OperationType.Patch.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Patch)); + + Assert.Equal("trace", OperationType.Trace.GetDisplayName()); + Assert.True(enumValues.Remove(OperationType.Trace)); + + Assert.Empty(enumValues); + } + + [Fact] + public void GetDisplayNameWorksForAllSecuritySchemeTypes() + { + var enumValues = new List(Enum.GetValues()); + + Assert.Equal("apiKey", SecuritySchemeType.ApiKey.GetDisplayName()); + Assert.True(enumValues.Remove(SecuritySchemeType.ApiKey)); + + Assert.Equal("http", SecuritySchemeType.Http.GetDisplayName()); + Assert.True(enumValues.Remove(SecuritySchemeType.Http)); + + Assert.Equal("oauth2", SecuritySchemeType.OAuth2.GetDisplayName()); + Assert.True(enumValues.Remove(SecuritySchemeType.OAuth2)); + + Assert.Equal("openIdConnect", SecuritySchemeType.OpenIdConnect.GetDisplayName()); + Assert.True(enumValues.Remove(SecuritySchemeType.OpenIdConnect)); + + Assert.Empty(enumValues); + } } } From 212840898f980b7b4214fcd6a329012693fde1a7 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Mon, 15 Jul 2024 09:36:17 -0700 Subject: [PATCH 012/121] Guard ReferenceType consumption for ExternalResource --- src/Microsoft.OpenApi/Models/OpenApiReference.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 339b9c632..86b165d65 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -200,8 +200,11 @@ private string GetExternalReferenceV3() { return ExternalResource + "#" + Id; } - - return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id; + + if (Type.HasValue) + { + return ExternalResource + "#/components/" + Type.Value.GetDisplayName() + "/"+ Id; + } } return ExternalResource; From 07076a7a34735801721aacf14a0b7b374b495c94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:22:35 +0000 Subject: [PATCH 013/121] Bump docker/build-push-action from 6.3.0 to 6.4.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.3.0...v6.4.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 790809712..4cd14b17b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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.3.0 + uses: docker/build-push-action@v6.4.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.3.0 + uses: docker/build-push-action@v6.4.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From bced7d5f93d323883c910bc9b788b19855dbcec5 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Tue, 16 Jul 2024 22:22:46 -0700 Subject: [PATCH 014/121] Add trimming test project and fix warnings --- .../Any/OpenApiAnyCloneHelper.cs | 1 + .../Attributes/TrimmingAttributes.cs | 280 ++++++++++++++++++ .../Extensions/EnumExtensions.cs | 3 + .../Extensions/StringExtensions.cs | 3 +- .../Validations/ValidationRuleSet.cs | 39 ++- .../Validations/ValidationRuleSetTests.cs | 23 ++ .../Microsoft.OpenApi.Trimming.Tests.csproj | 17 ++ .../Program.cs | 2 + 8 files changed, 358 insertions(+), 10 deletions(-) create mode 100644 test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj create mode 100644 test/Microsoft.OpenApi.Trimming.Tests/Program.cs diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index 49699d930..ed224b7ef 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -17,6 +17,7 @@ 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) diff --git a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs index 8c84377fd..538ed521e 100644 --- a/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs +++ b/src/Microsoft.OpenApi/Attributes/TrimmingAttributes.cs @@ -3,9 +3,289 @@ #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 . diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 1df069f35..362135d57 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using Microsoft.OpenApi.Attributes; @@ -22,6 +23,7 @@ public static class EnumExtensions /// /// The attribute of the specified type or null. /// + [RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")] public static T GetAttributeOfType(this Enum enumValue) where T : Attribute { var type = enumValue.GetType(); @@ -39,6 +41,7 @@ public static T GetAttributeOfType(this Enum enumValue) where T : Attribute /// Otherwise, use the standard string representation. /// [Obsolete("Use native AoT-friendly type-specific overloads GetDisplayName methods instead.")] + [RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")] public static string GetDisplayName(this Enum enumValue) { var attribute = enumValue.GetAttributeOfType(); diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs index 51ce37365..01f54baea 100644 --- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Microsoft.OpenApi.Attributes; @@ -16,7 +17,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(this string displayName) + public static T GetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName) { var type = typeof(T); if (!type.IsEnum) diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index 3dd916755..104ec35de 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -185,17 +185,15 @@ IEnumerator IEnumerable.GetEnumerator() private static ValidationRuleSet BuildDefaultRuleSet() { var ruleSet = new ValidationRuleSet(); - var validationRuleType = typeof(ValidationRule); + + var ruleTypeProperties = GetValidationRuleTypes(); - 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) + foreach (var property in ruleTypeProperties) { + if (!typeof(ValidationRule).IsAssignableFrom(property.PropertyType)) + { + continue; + } var propertyValue = property.GetValue(null); // static property if (propertyValue is ValidationRule rule) { @@ -205,5 +203,28 @@ 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.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index 708d6ee64..3c302be13 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -1,6 +1,9 @@ // 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 @@ -37,5 +40,25 @@ 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 new file mode 100644 index 000000000..e28b1ed96 --- /dev/null +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -0,0 +1,17 @@ + + + Exe + net8.0 + enable + enable + true + true + false + + + + + + + + diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Program.cs b/test/Microsoft.OpenApi.Trimming.Tests/Program.cs new file mode 100644 index 000000000..3751555cb --- /dev/null +++ b/test/Microsoft.OpenApi.Trimming.Tests/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); From be1046d8362e5a7f12d19445881190b8a639a8f1 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 17 Jul 2024 11:58:08 -0400 Subject: [PATCH 015/121] Apply suggestions from code review Co-authored-by: Eric Erhardt --- src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs | 2 +- .../Microsoft.OpenApi.Trimming.Tests.csproj | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index ed224b7ef..65eb2b6f6 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -41,7 +41,7 @@ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) /// /// The object instance. /// A clone copy or the object itself. - public static IOpenApiAny CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny + public static T CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny { if (obj != null) { diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index e28b1ed96..b4e3f4a36 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -4,7 +4,8 @@ net8.0 enable enable - true + true + false true false From 4cc030d19c063ce83a128b39513eddbb0a9661fe Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 17 Jul 2024 12:01:02 -0400 Subject: [PATCH 016/121] ci: adds trimming project to solution --- Microsoft.OpenApi.sln | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index bb3c028e7..67f3f0e17 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -30,6 +30,8 @@ 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 @@ -68,6 +70,10 @@ 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 @@ -81,6 +87,7 @@ 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} From 74275b80e8c132ac0c90476f8e1235735cc87769 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 17 Jul 2024 12:02:36 -0400 Subject: [PATCH 017/121] ci: adds readers project to trimming test project --- .../Microsoft.OpenApi.Trimming.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index b4e3f4a36..4bc040154 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -15,4 +15,8 @@ + + + + From 7f7c54ad8128baa1988f26793fbad99bad910bd6 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 17 Jul 2024 12:05:34 -0400 Subject: [PATCH 018/121] ci: adds missing trimming root assembly directive --- .../Microsoft.OpenApi.Trimming.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index 4bc040154..319531402 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -17,6 +17,7 @@ + From 06b54c377330c5a17a45bf4ec5f50bbdac6bab9e Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 17 Jul 2024 10:23:30 -0700 Subject: [PATCH 019/121] Fix build, address feedback, and remove Readers from trim tests --- src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs | 2 +- src/Microsoft.OpenApi/Extensions/EnumExtensions.cs | 1 + src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs | 3 ++- .../Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 3 ++- .../Microsoft.OpenApi.Trimming.Tests.csproj | 5 ----- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index 65eb2b6f6..eaa1dac31 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -50,7 +50,7 @@ public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) var pi = ci.GetParameters(); if (pi.Length == 1 && pi[0].ParameterType == typeof(T)) { - return (IOpenApiAny)ci.Invoke([obj]); + return (T)ci.Invoke([obj]); } } } diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 362135d57..280cdf719 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -23,6 +23,7 @@ public static class EnumExtensions /// /// The attribute of the specified type or null. /// + [Obsolete("GetAttributeOfType is deprecated and will be removed in a future release.")] [RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")] public static T GetAttributeOfType(this Enum enumValue) where T : Attribute { diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index 104ec35de..448683fd9 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -185,12 +185,13 @@ IEnumerator IEnumerable.GetEnumerator() private static ValidationRuleSet BuildDefaultRuleSet() { var ruleSet = new ValidationRuleSet(); + var validationRuleType = typeof(ValidationRule); var ruleTypeProperties = GetValidationRuleTypes(); foreach (var property in ruleTypeProperties) { - if (!typeof(ValidationRule).IsAssignableFrom(property.PropertyType)) + if (!validationRuleType.IsAssignableFrom(property.PropertyType)) { continue; } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 48db67ac0..785ecbd52 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -24,7 +24,7 @@ namespace Microsoft.OpenApi.Any 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 Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(T 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 @@ -249,6 +249,7 @@ namespace Microsoft.OpenApi.Extensions { public static class EnumExtensions { + [System.Obsolete("GetAttributeOfType is deprecated and will be removed in a future release.")] public static T GetAttributeOfType(this System.Enum enumValue) where T : System.Attribute { } public static string GetDisplayName(this Microsoft.OpenApi.Models.ParameterLocation parameterLocation) { } diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index 319531402..b4e3f4a36 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -15,9 +15,4 @@ - - - - - From 887d88b98912daf10e6ce6125dfb08b4793734a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:00:39 +0000 Subject: [PATCH 020/121] Bump Verify.Xunit from 25.3.1 to 25.3.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 25.3.1 to 25.3.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/25.3.1...25.3.2) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 488cd39de..8e10f711a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 598f2b6962695fd05a15cf1b49dde622cd309479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Canales=20Mart=C3=ADn?= Date: Thu, 18 Jul 2024 17:32:50 +0200 Subject: [PATCH 021/121] Create test for bug --- .../Services/OpenApiServiceTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 7314da8ab..e092a1c43 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -65,6 +65,46 @@ 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)] From 691d99d99b9db22fe0e8e96a5c639601cb70a718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Canales=20Mart=C3=ADn?= Date: Thu, 18 Jul 2024 17:36:17 +0200 Subject: [PATCH 022/121] Add null check to OpenApiDocument.Components Without a null check this method will fail if the optional components field is missing. --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index fa1b9911e..92051949b 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -61,6 +61,10 @@ 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() @@ -74,7 +78,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun Extensions = source.Info.Extensions }, - Components = new() { SecuritySchemes = source.Components.SecuritySchemes }, + Components = components, SecurityRequirements = source.SecurityRequirements, Servers = source.Servers }; From c117bc56f17317853763b065aac943a1eedee9f7 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 18 Jul 2024 11:59:18 -0700 Subject: [PATCH 023/121] Rely on enum fields never being trimmed --- .../Extensions/EnumExtensions.cs | 92 +---------- .../Extensions/StringExtensions.cs | 7 +- .../Attributes/DisplayAttributeTests.cs | 153 +----------------- .../PublicApi/PublicApi.approved.txt | 3 - 4 files changed, 7 insertions(+), 248 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 280cdf719..1eadaa5f4 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using Microsoft.OpenApi.Attributes; -using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Extensions { @@ -23,12 +22,11 @@ public static class EnumExtensions /// /// The attribute of the specified type or null. /// - [Obsolete("GetAttributeOfType is deprecated and will be removed in a future release.")] - [RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")] + [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.GetMember(enumValue.ToString()).First(); + var memInfo = type.GetField(enumValue.ToString(), BindingFlags.Public | BindingFlags.Static); var attributes = memInfo.GetCustomAttributes(false); return attributes.FirstOrDefault(); } @@ -41,96 +39,10 @@ public static T GetAttributeOfType(this Enum enumValue) where T : Attribute /// Use if exists. /// Otherwise, use the standard string representation. /// - [Obsolete("Use native AoT-friendly type-specific overloads GetDisplayName methods instead.")] - [RequiresUnreferencedCode("GetAttributeOfType is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of GetDisplayName instead.")] public static string GetDisplayName(this Enum enumValue) { var attribute = enumValue.GetAttributeOfType(); return attribute == null ? enumValue.ToString() : attribute.Name; } - - /// - /// Gets the enum display for name without the use of reflection. - /// - /// The enum value. - /// The display string to use. - internal static string GetDisplayName(this ParameterStyle parameterStyle) => parameterStyle switch - { - ParameterStyle.Matrix => "matrix", - ParameterStyle.Label => "label", - ParameterStyle.Form => "form", - ParameterStyle.Simple => "simple", - ParameterStyle.SpaceDelimited => "spaceDelimited", - ParameterStyle.PipeDelimited => "pipeDelimited", - ParameterStyle.DeepObject => "deepObject", - _ => throw new InvalidOperationException($"Unknown parameter style: {parameterStyle}") - }; - - /// - /// Gets the enum display for name without the use of reflection. - /// - /// The enum value. - /// The display string to use. - public static string GetDisplayName(this ParameterLocation parameterLocation) => parameterLocation switch - { - ParameterLocation.Query => "query", - ParameterLocation.Header => "header", - ParameterLocation.Path => "path", - ParameterLocation.Cookie => "cookie", - _ => throw new InvalidOperationException($"Unknown parameter location: {parameterLocation}") - }; - - /// - /// Gets the enum display for name without the use of reflection. - /// - /// The enum value. - /// The display string to use. - internal static string GetDisplayName(this ReferenceType referenceType) => referenceType switch - { - ReferenceType.Schema => "schemas", - ReferenceType.Response => "responses", - ReferenceType.Parameter => "parameters", - ReferenceType.Example => "examples", - ReferenceType.RequestBody => "requestBodies", - ReferenceType.Header => "headers", - ReferenceType.SecurityScheme => "securitySchemes", - ReferenceType.Link => "links", - ReferenceType.Callback => "callbacks", - ReferenceType.Tag => "tags", - ReferenceType.Path => "path", - _ => throw new InvalidOperationException($"Unknown reference type: {referenceType}") - }; - - /// - /// Gets the enum display for name without the use of reflection. - /// - /// The enum value. - /// The display string to use. - internal static string GetDisplayName(this OperationType operationType) => operationType switch - { - OperationType.Get => "get", - OperationType.Put => "put", - OperationType.Post => "post", - OperationType.Delete => "delete", - OperationType.Options => "options", - OperationType.Head => "head", - OperationType.Patch => "patch", - OperationType.Trace => "trace", - _ => throw new InvalidOperationException($"Unknown operation type: {operationType}") - }; - - /// - /// Gets the enum display for name without the use of reflection. - /// - /// The enum value. - /// The display string to use. - internal static string GetDisplayName(this SecuritySchemeType securitySchemeType) => securitySchemeType switch - { - SecuritySchemeType.ApiKey => "apiKey", - SecuritySchemeType.Http => "http", - SecuritySchemeType.OAuth2 => "oauth2", - SecuritySchemeType.OpenIdConnect => "openIdConnect", - _ => throw new InvalidOperationException($"Unknown security scheme type: {securitySchemeType}") - }; } } diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs index 01f54baea..3fa3f6b52 100644 --- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs @@ -17,6 +17,7 @@ public static class StringExtensions /// Gets the enum value based on the given enum type and display name. /// /// The display name. + [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Fields are never trimmed for enum types.")] public static T GetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName) { var type = typeof(T); @@ -25,14 +26,12 @@ public static class StringExtensions return default; } - foreach (var value in Enum.GetValues(type)) + foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static)) { - var field = type.GetField(value.ToString()); - var displayAttribute = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute)); if (displayAttribute != null && displayAttribute.Name == displayName) { - return (T)value; + return (T)field.GetValue(null); } } diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index 80d138bee..274258601 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata; -using Microsoft.OpenApi.Attributes; +using Microsoft.OpenApi.Attributes; using Microsoft.OpenApi.Extensions; -using Microsoft.OpenApi.Models; using Xunit; namespace Microsoft.OpenApi.Tests.Attributes @@ -27,151 +22,7 @@ public class DisplayAttributeTests [InlineData(ApiLevel.Corporate, "corporate")] public void GetDisplayNameExtensionShouldUseDisplayAttribute(ApiLevel apiLevel, string expected) { -#pragma warning disable CS0618 // Type or member is obsolete, testing obsolete behavior - Assert.Equal(expected, apiLevel.GetDisplayName()); -#pragma warning restore CS0618 // Type or member is obsolete, testing obsolete behavior - } - - [Fact] - public void GetDisplayNameWorksForAllParameterStyle() - { - var enumValues = new List(Enum.GetValues()); - - Assert.Equal("matrix", ParameterStyle.Matrix.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.Matrix)); - - Assert.Equal("label", ParameterStyle.Label.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.Label)); - - Assert.Equal("form", ParameterStyle.Form.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.Form)); - - Assert.Equal("simple", ParameterStyle.Simple.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.Simple)); - - Assert.Equal("spaceDelimited", ParameterStyle.SpaceDelimited.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.SpaceDelimited)); - - Assert.Equal("pipeDelimited", ParameterStyle.PipeDelimited.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.PipeDelimited)); - - Assert.Equal("deepObject", ParameterStyle.DeepObject.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterStyle.DeepObject)); - - Assert.Empty(enumValues); - } - - [Fact] - public void GetDisplayNameWorksForAllParameterLocation() - { - var enumValues = new List(Enum.GetValues()); - - Assert.Equal("query", ParameterLocation.Query.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterLocation.Query)); - - Assert.Equal("header", ParameterLocation.Header.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterLocation.Header)); - - Assert.Equal("path", ParameterLocation.Path.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterLocation.Path)); - - Assert.Equal("cookie", ParameterLocation.Cookie.GetDisplayName()); - Assert.True(enumValues.Remove(ParameterLocation.Cookie)); - - Assert.Empty(enumValues); - } - - [Fact] - public void GetDisplayNameWorksForAllReferenceType() - { - var enumValues = new List(Enum.GetValues()); - - Assert.Equal("schemas", ReferenceType.Schema.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Schema)); - - Assert.Equal("responses", ReferenceType.Response.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Response)); - - Assert.Equal("parameters", ReferenceType.Parameter.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Parameter)); - - Assert.Equal("examples", ReferenceType.Example.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Example)); - - Assert.Equal("requestBodies", ReferenceType.RequestBody.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.RequestBody)); - - Assert.Equal("headers", ReferenceType.Header.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Header)); - - Assert.Equal("securitySchemes", ReferenceType.SecurityScheme.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.SecurityScheme)); - - Assert.Equal("links", ReferenceType.Link.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Link)); - - Assert.Equal("callbacks", ReferenceType.Callback.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Callback)); - - Assert.Equal("tags", ReferenceType.Tag.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Tag)); - - Assert.Equal("path", ReferenceType.Path.GetDisplayName()); - Assert.True(enumValues.Remove(ReferenceType.Path)); - - Assert.Empty(enumValues); - } - - [Fact] - public void GetDisplayNameWorksForAllOperationTypes() - { - var enumValues = new List(Enum.GetValues()); - - Assert.Equal("get", OperationType.Get.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Get)); - - Assert.Equal("put", OperationType.Put.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Put)); - - Assert.Equal("post", OperationType.Post.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Post)); - - Assert.Equal("delete", OperationType.Delete.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Delete)); - - Assert.Equal("options", OperationType.Options.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Options)); - - Assert.Equal("head", OperationType.Head.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Head)); - - Assert.Equal("patch", OperationType.Patch.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Patch)); - - Assert.Equal("trace", OperationType.Trace.GetDisplayName()); - Assert.True(enumValues.Remove(OperationType.Trace)); - - Assert.Empty(enumValues); - } - - [Fact] - public void GetDisplayNameWorksForAllSecuritySchemeTypes() - { - var enumValues = new List(Enum.GetValues()); - - Assert.Equal("apiKey", SecuritySchemeType.ApiKey.GetDisplayName()); - Assert.True(enumValues.Remove(SecuritySchemeType.ApiKey)); - - Assert.Equal("http", SecuritySchemeType.Http.GetDisplayName()); - Assert.True(enumValues.Remove(SecuritySchemeType.Http)); - - Assert.Equal("oauth2", SecuritySchemeType.OAuth2.GetDisplayName()); - Assert.True(enumValues.Remove(SecuritySchemeType.OAuth2)); - - Assert.Equal("openIdConnect", SecuritySchemeType.OpenIdConnect.GetDisplayName()); - Assert.True(enumValues.Remove(SecuritySchemeType.OpenIdConnect)); - - Assert.Empty(enumValues); + Assert.Equal(expected, apiLevel.GetDisplayName()); } } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 785ecbd52..82c5f6a88 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -249,11 +249,8 @@ namespace Microsoft.OpenApi.Extensions { public static class EnumExtensions { - [System.Obsolete("GetAttributeOfType is deprecated and will be removed in a future release.")] public static T GetAttributeOfType(this System.Enum enumValue) where T : System.Attribute { } - public static string GetDisplayName(this Microsoft.OpenApi.Models.ParameterLocation parameterLocation) { } - [System.Obsolete("Use native AoT-friendly type-specific overloads GetDisplayName methods instead.")] public static string GetDisplayName(this System.Enum enumValue) { } } public static class OpenApiElementExtensions From d0829ab32be5d488b8e2404f87912e74a9cc7c65 Mon Sep 17 00:00:00 2001 From: martincostello Date: Fri, 19 Jul 2024 13:56:36 +0100 Subject: [PATCH 024/121] Fix copy constructor for arrays and objects - Fix `OpenApiArray` and `OpenApiObject` not copying their items when they are copied to a new instance. - Add tests for all built-in `IOpenApiAny` types with schema examples. --- .../Any/OpenApiAnyCloneHelper.cs | 2 - src/Microsoft.OpenApi/Any/OpenApiArray.cs | 4 ++ src/Microsoft.OpenApi/Any/OpenApiObject.cs | 4 ++ .../Models/OpenApiSchemaTests.cs | 41 ++++++++++++++++++- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs index b0e553f71..f880b7d64 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -using System.Reflection; - namespace Microsoft.OpenApi.Any { /// diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs index 99bbb7d63..461e2284a 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs @@ -27,6 +27,10 @@ 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 f224824c3..60cfc75c3 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs @@ -27,6 +27,10 @@ public OpenApiObject() { } public OpenApiObject(OpenApiObject obj) { AnyType = obj.AnyType; + foreach (var key in obj.Keys) + { + this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor(obj[key]); + } } /// diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 5d8320c62..0acd55925 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -1,11 +1,9 @@ // 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; @@ -485,6 +483,45 @@ 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() { From 35811cc51ef23845e30710de0269fdec13f51c47 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 19 Jul 2024 10:18:59 -0700 Subject: [PATCH 025/121] Address feedback --- .../Extensions/StringExtensions.cs | 1 - .../Attributes/DisplayAttributeTests.cs | 32 ++++++++++++++++++- .../Program.cs | 3 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs index 3fa3f6b52..541523df5 100644 --- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs @@ -17,7 +17,6 @@ public static class StringExtensions /// Gets the enum value based on the given enum type and display name. /// /// The display name. - [UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Fields are never trimmed for enum types.")] public static T GetEnumFromDisplayName<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(this string displayName) { var type = typeof(T); diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index 274258601..0035ffd02 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -1,4 +1,5 @@ -using Microsoft.OpenApi.Attributes; +using System; +using Microsoft.OpenApi.Attributes; using Microsoft.OpenApi.Extensions; using Xunit; @@ -14,6 +15,17 @@ public enum ApiLevel Corporate = 3 } + [Flags] + public enum UserType + { + [DisplayAttribute("admin")] + Admin = 1, + [DisplayAttribute("editor")] + Editor = 2, + [DisplayAttribute("publisher")] + Publisher = 3 + } + public class DisplayAttributeTests { [Theory] @@ -24,5 +36,23 @@ 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.Trimming.Tests/Program.cs b/test/Microsoft.OpenApi.Trimming.Tests/Program.cs index 3751555cb..1bc52a60a 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Program.cs +++ b/test/Microsoft.OpenApi.Trimming.Tests/Program.cs @@ -1,2 +1 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +Console.WriteLine("Hello, World!"); From 8267c4042728f47e0d6096e09e0df1c029d5aa01 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 19 Jul 2024 10:20:18 -0700 Subject: [PATCH 026/121] Add back doc comment on M.O.Readers --- .../Microsoft.OpenApi.Trimming.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj index b4e3f4a36..3e6daf74c 100644 --- a/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj +++ b/test/Microsoft.OpenApi.Trimming.Tests/Microsoft.OpenApi.Trimming.Tests.csproj @@ -13,6 +13,7 @@ + From bd7dcc8115bd7213940370f45ab10906baddb03a Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 20 Jul 2024 10:34:18 +1000 Subject: [PATCH 027/121] add verify settings to editorconfig --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.editorconfig b/.editorconfig index 5b8c4b64e..e8f790dff 100644 --- a/.editorconfig +++ b/.editorconfig @@ -121,3 +121,14 @@ 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 From 134dd0cc3427866104b860828fc38a629c1bc34e Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Mon, 22 Jul 2024 09:50:53 +0100 Subject: [PATCH 028/121] Remove redundant section Remove link to obsolete AppVeyor build. --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 021e570f5..c804787c1 100644 --- a/README.md +++ b/README.md @@ -113,12 +113,6 @@ 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**| -|--| -|[![Build status](https://ci.appveyor.com/api/projects/status/9l6hly3vjeu0tmtx/branch/master?svg=true)](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 From 620076775a00c495a0ae06d0bd3dc99b1225a97a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 22 Jul 2024 11:58:55 +0300 Subject: [PATCH 029/121] Update test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs Co-authored-by: Eric Erhardt --- .../Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index 0035ffd02..b37865565 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -24,6 +24,8 @@ public enum UserType Editor = 2, [DisplayAttribute("publisher")] Publisher = 3 + [DisplayAttribute("all")] + All = Admin | Editor | Publisher } public class DisplayAttributeTests From 47ad39db0a318b7e1751d2bab6fe71c764a0601e Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 22 Jul 2024 12:20:25 +0300 Subject: [PATCH 030/121] Fix syntax error --- .../Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs index b37865565..f9bb8beff 100644 --- a/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs @@ -23,7 +23,7 @@ public enum UserType [DisplayAttribute("editor")] Editor = 2, [DisplayAttribute("publisher")] - Publisher = 3 + Publisher = 3, [DisplayAttribute("all")] All = Admin | Editor | Publisher } From 321e20d7b8c1897cb1fc5453c0cfd55a5ed9f31f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 22 Jul 2024 12:48:45 +0300 Subject: [PATCH 031/121] Use native AOT-friendly generic overload --- src/Microsoft.OpenApi/Any/OpenApiArray.cs | 2 +- src/Microsoft.OpenApi/Any/OpenApiObject.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs index 461e2284a..5a9af0fff 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs @@ -29,7 +29,7 @@ public OpenApiArray(OpenApiArray array) AnyType = array.AnyType; foreach (var item in array) { - Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor(item)); + Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor(item)); } } diff --git a/src/Microsoft.OpenApi/Any/OpenApiObject.cs b/src/Microsoft.OpenApi/Any/OpenApiObject.cs index 60cfc75c3..95783cc23 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs @@ -29,7 +29,7 @@ public OpenApiObject(OpenApiObject obj) AnyType = obj.AnyType; foreach (var key in obj.Keys) { - this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor(obj[key]); + this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor(obj[key]); } } From f3dbb1a3315f90986be04ef9c256739f3fa6c309 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:13:56 +0000 Subject: [PATCH 032/121] Bump docker/build-push-action from 6.4.0 to 6.5.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.4.0 to 6.5.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.4.0...v6.5.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4cd14b17b..dd1dc37a9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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.4.0 + uses: docker/build-push-action@v6.5.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.4.0 + uses: docker/build-push-action@v6.5.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From c93619755bee327d272af9b5d41107f7057164ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:13:57 +0000 Subject: [PATCH 033/121] Bump docker/login-action from 3.2.0 to 3.3.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v3.2.0...v3.3.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4cd14b17b..4159ea789 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.2.0 + uses: docker/login-action@v3.3.0 with: username: ${{ secrets.ACR_USERNAME }} password: ${{ secrets.ACR_PASSWORD }} From bc9bed964878ea97f8e58b086aa17d5bba138499 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:27:42 +0000 Subject: [PATCH 034/121] Bump Verify.Xunit from 25.3.2 to 26.0.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 25.3.2 to 26.0.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/25.3.2...26.0.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 8e10f711a..483e1c3c7 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 4a015992724cc175e870688fb76aa663c212eee2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jul 2024 20:52:17 +0300 Subject: [PATCH 035/121] Initialize stream reader with default encoding and buffer size values to eliminate exceptions --- src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index c9431de98..c6c8add2f 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; @@ -41,7 +42,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, default, true, -1, _settings.LeaveStreamOpen); + using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen); return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); } @@ -54,6 +55,7 @@ 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; @@ -63,11 +65,12 @@ 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(); - await input.CopyToAsync(bufferedStream, 81920, cancellationToken); + bufferSize = 81920; + await input.CopyToAsync(bufferedStream, bufferSize, cancellationToken); bufferedStream.Position = 0; } - using var reader = new StreamReader(bufferedStream, default, true, -1, _settings.LeaveStreamOpen); + using var reader = new StreamReader(bufferedStream, Encoding.UTF8, true, bufferSize, _settings.LeaveStreamOpen); return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); } @@ -80,7 +83,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, default, true, -1, _settings.LeaveStreamOpen); + using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen); return new OpenApiTextReaderReader(_settings).ReadFragment(reader, version, out diagnostic); } } From 29acad79de4f530891024081ec73d49b97d6eb70 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 23 Jul 2024 20:52:26 +0300 Subject: [PATCH 036/121] Add test --- .../OpenApiStreamReaderTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index 856d5ada7..7bb0fe922 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -1,7 +1,9 @@ // 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; @@ -44,5 +46,20 @@ 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); + } } } From f40afd423d85c6a24f5bb15a0d57fd9139f7bc04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:00:34 +0000 Subject: [PATCH 037/121] Bump Verify.Xunit from 26.0.0 to 26.0.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.0.0 to 26.0.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.0.0...26.0.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 483e1c3c7..28f48e4e3 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From c87ef1f6749a06f1ba7e48b11dbd94bf2124b9d5 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 24 Jul 2024 10:08:51 +0300 Subject: [PATCH 038/121] Bump up lib versions --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 3bbbe339d..d41487182 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.15 + 1.6.16 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index ff795f27a..00d47b331 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.15 + 1.6.16 .NET models with JSON and YAML writers for OpenAPI specification true From 309b0ed355ca3e57b4ea46b4323933653bffe999 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jul 2024 16:38:43 +0300 Subject: [PATCH 039/121] Bump up conversion lib version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 7162a07e9..3cc86e833 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -35,7 +35,7 @@ - + From 8d50bf75ad82574250962a620d714a15b57001ee Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Wed, 24 Jul 2024 16:43:29 +0300 Subject: [PATCH 040/121] Bumps up hidi version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 3cc86e833..05293a686 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.4.6 + 1.4.7 OpenAPI.NET CLI tool for slicing OpenAPI documents true From 32ed80b181747b1306b628f9402b9c9d9594f583 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 24 Jul 2024 23:22:26 +0200 Subject: [PATCH 041/121] Fix securityScheme/securityRequirement serialization The security requirement should not use the full serialization of a securityScheme as those are not the same. The securityRequirement only needs the reference to the securityScheme, not the complete object. --- .../Models/OpenApiReference.cs | 7 ------ .../Models/OpenApiSecurityRequirement.cs | 2 +- ...sync_produceTerseOutput=False.verified.txt | 12 ++++++++++ ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiSecurityRequirementTests.cs | 22 +++++++++++++++++++ ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- .../Models/OpenApiSecuritySchemeTests.cs | 5 ----- 8 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index e366bf10d..37f050473 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -148,13 +148,6 @@ public void SerializeAsV3(IOpenApiWriter writer) return; } - if (Type == ReferenceType.SecurityScheme) - { - // Write the string as property name - writer.WritePropertyName(ReferenceV3); - return; - } - writer.WriteStartObject(); // $ref diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index 76728c957..9fe4498e0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -50,7 +50,7 @@ public void SerializeAsV3(IOpenApiWriter writer) continue; } - securityScheme.SerializeAsV3(writer); + writer.WritePropertyName(securityScheme.Reference.ReferenceV3); writer.WriteStartArray(); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..d225bb5da --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,12 @@ +{ + "scheme1": [ + "scope1", + "scope2", + "scope3" + ], + "scheme2": [ + "scope4", + "scope5" + ], + "scheme3": [ ] +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..fc86e7424 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.SerializeSecurityRequirementAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"scheme1":["scope1","scope2","scope3"],"scheme2":["scope4","scope5"],"scheme3":[ ]} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs index 4c962aaad..9543f6a1a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs @@ -3,9 +3,14 @@ using System; using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; namespace Microsoft.OpenApi.Tests.Models @@ -95,6 +100,23 @@ public void SerializeBasicSecurityRequirementAsV3JsonWorks() actual.Should().Be(expected); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeSecurityRequirementAsV3JsonWorksAsync(bool produceTerseOutput) + { + // Arrange + var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); + var writer = new OpenApiJsonWriter(outputStringWriter, new() { Terse = produceTerseOutput }); + + // Act + SecurityRequirementWithReferencedSecurityScheme.SerializeAsV3(writer); + writer.Flush(); + + // Assert + await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput); + } + [Fact] public void SerializeSecurityRequirementWithReferencedSecuritySchemeAsV3JsonWorks() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index e2f0188e6..5bf57b219 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ { - "sampleSecurityScheme": null + "$ref": "sampleSecurityScheme" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index d74ff6ddf..04a9d3e76 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"sampleSecurityScheme":null} \ No newline at end of file +{"$ref":"sampleSecurityScheme"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 5df97e135..aec0489b1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -314,12 +314,7 @@ public async Task SerializeReferencedSecuritySchemeAsV3JsonWorksAsync(bool produ var writer = new OpenApiJsonWriter(outputStringWriter, new() { Terse = produceTerseOutput }); // Act - // Add dummy start object, value, and end object to allow SerializeAsV3 to output security scheme - // as property name. - writer.WriteStartObject(); ReferencedSecurityScheme.SerializeAsV3(writer); - writer.WriteNull(); - writer.WriteEndObject(); writer.Flush(); // Assert From 9d60ab157ac174fe7474ec929966d80c36bfff04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 21:40:14 +0000 Subject: [PATCH 042/121] Bump Verify.Xunit from 26.0.1 to 26.1.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.0.1 to 26.1.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.0.1...26.1.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 28f48e4e3..670d99f57 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 45b43c3cb0f176f75ebc1eeeae6c393ccb624db9 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 26 Jul 2024 13:35:45 +0300 Subject: [PATCH 043/121] Add missing nuget lib refs --- .../Microsoft.OpenApi.Workbench.csproj | 3 ++- .../Microsoft.OpenApi.SmokeTests.csproj | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 813d8d497..66bcef38a 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -1,4 +1,4 @@ - + net8.0-windows WinExe @@ -8,6 +8,7 @@ true + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 8954143d6..0ab1da271 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -10,6 +10,7 @@ + From 293e6c2dbf13628790bc48516117153707655322 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 26 Jul 2024 13:46:50 +0300 Subject: [PATCH 044/121] Remove added nuget package --- .../Microsoft.OpenApi.SmokeTests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 0ab1da271..8bcded29f 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -10,7 +10,6 @@ - From ecec3dc99d872bc0288aa59634afbe383ef9a8a4 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 26 Jul 2024 13:54:11 +0300 Subject: [PATCH 045/121] Replace Carlos with Gavin as code reviewer --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6b1c21db4..8227ccb46 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @irvinesunday @darrelmiller @zengin @coseguera @millicentachieng @MaggieKimani1 @andrueastman +* @irvinesunday @darrelmiller @zengin @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman From ad44ab8c7a47172e4f42fcc0dcb93bb690240550 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:05:35 +0000 Subject: [PATCH 046/121] Bump Verify.Xunit from 26.1.1 to 26.1.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.1.1 to 26.1.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.1.1...26.1.2) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 670d99f57..0c9123f18 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 1f815a2c11f8a79023a84ceceb0e08ca79927808 Mon Sep 17 00:00:00 2001 From: Mahdi Golestan Date: Sat, 27 Jul 2024 14:54:11 +0330 Subject: [PATCH 047/121] Use ConcurrentDictionary For Improving Get Enum Name --- .../Extensions/EnumExtensions.cs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs index 1eadaa5f4..bc4e86783 100644 --- a/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/EnumExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; @@ -14,6 +15,9 @@ namespace Microsoft.OpenApi.Extensions /// public 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. /// @@ -26,7 +30,13 @@ public static class EnumExtensions 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(); } @@ -36,13 +46,20 @@ public static T GetAttributeOfType(this Enum enumValue) where T : Attribute /// /// The enum value. /// - /// Use if exists. + /// Use if it exists. /// Otherwise, use the standard string representation. /// public static string GetDisplayName(this Enum enumValue) { - var attribute = enumValue.GetAttributeOfType(); - return attribute == null ? enumValue.ToString() : attribute.Name; + // 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; + }); } } } From cecd9e73b0c4f5898efda461d95c0c71c958f15d Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Mon, 29 Jul 2024 13:22:37 +0300 Subject: [PATCH 048/121] Remove packages potentially causing build to fail in AzDo pipeline --- .../Microsoft.OpenApi.Workbench.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 66bcef38a..bdf6181a4 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -8,8 +8,6 @@ true - - From 99e4e929e035b2a323e37df8f25f4335602e4a0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 21:30:57 +0000 Subject: [PATCH 049/121] Bump Verify.Xunit from 26.1.2 to 26.1.5 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.1.2 to 26.1.5. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.1.2...26.1.5) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 0c9123f18..9927ac1b5 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From dcc381687c99c55323809c1bb12ae90982d18222 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:17:40 +0000 Subject: [PATCH 050/121] Bump Verify.Xunit from 26.1.5 to 26.1.6 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.1.5 to 26.1.6. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.1.5...26.1.6) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 9927ac1b5..a4630d78c 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From f63443f98f5b4e77de632c85c7cd367395b30ba2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 2 Aug 2024 18:42:37 +0300 Subject: [PATCH 051/121] Serialize example values with empty arrays for responses --- .../Models/OpenApiMediaType.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 4751c4b28..7e090dfa6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -76,7 +77,7 @@ public void SerializeAsV3(IOpenApiWriter writer) writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e)); // examples - writer.WriteOptionalMap(OpenApiConstants.Examples, Examples, (w, e) => e.SerializeAsV3(w)); + SerializeExamples(writer, Examples); // encoding writer.WriteOptionalMap(OpenApiConstants.Encoding, Encoding, (w, e) => e.SerializeAsV3(w)); @@ -94,5 +95,36 @@ public void SerializeAsV2(IOpenApiWriter writer) { // Media type does not exist in V2. } + + private 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 + * */ + var hasEmptyArray = examples.Values.Any(example => + example.Value is OpenApiArray arr && arr.Count == 0 + ); + + if (hasEmptyArray) + { + writer.WritePropertyName(OpenApiConstants.Examples); + writer.WriteStartObject(); + foreach (var kvp in examples) + { + if (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)); + } + } } } From 0b63d77c6e8deb09c12cecd8493584106f49cb39 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 2 Aug 2024 18:43:56 +0300 Subject: [PATCH 052/121] Add unit test to validate --- .../V3Tests/OpenApiMediaTypeTests.cs | 40 +++++++++++++++++++ .../examplesWithEmptyArray.json | 18 +++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiMediaType/examplesWithEmptyArray.json diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index 8e3a6c864..266809561 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -4,9 +4,11 @@ using System.IO; using FluentAssertions; using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.ParseNodes; using Microsoft.OpenApi.Readers.V3; +using Microsoft.OpenApi.Tests; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V3Tests @@ -77,5 +79,43 @@ public void ParseMediaTypeWithExamplesShouldSucceed() } }); } + + [Fact] + public void ParseMediaTypeWithEmptyArrayInExamplesWorks() + { + // Arrange + var expected = @"{ + ""schema"": { + ""type"": ""array"", + ""items"": { + ""type"": ""object"", + ""properties"": { + ""id"": { + ""type"": ""string"" + } + } + } + }, + ""examples"": { + ""Success response - no results"": { + ""value"": [ ] + } + } +} +"; + MapNode node; + using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "examplesWithEmptyArray.json"))) + { + node = TestHelper.CreateYamlMapNode(stream); + } + + // Act + var mediaType = OpenApiV3Deserializer.LoadMediaType(node); + var serialized = mediaType.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); + + // Assert + serialized.MakeLineBreaksEnvironmentNeutral() + .Should().BeEquivalentTo(expected.MakeLineBreaksEnvironmentNeutral()); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiMediaType/examplesWithEmptyArray.json b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiMediaType/examplesWithEmptyArray.json new file mode 100644 index 000000000..0d13dcaf2 --- /dev/null +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/Samples/OpenApiMediaType/examplesWithEmptyArray.json @@ -0,0 +1,18 @@ +{ + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + } + }, + "examples": { + "Success response - no results": { + "value": [] + } + } +} \ No newline at end of file From 91f83f80bb63653ae9eff2f840553cd919aea88b Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 2 Aug 2024 18:48:39 +0300 Subject: [PATCH 053/121] Update comment --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 7e090dfa6..609ea5ccd 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -99,7 +99,7 @@ public void SerializeAsV2(IOpenApiWriter writer) private 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 + * 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(example => example.Value is OpenApiArray arr && arr.Count == 0 From 28142d5cb4319e6b02a37a56691c150e92ae8957 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 2 Aug 2024 19:12:53 +0300 Subject: [PATCH 054/121] Simplify by using .Where() for sequence filtering --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 609ea5ccd..553e87d09 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -109,15 +109,12 @@ private void SerializeExamples(IOpenApiWriter writer, IDictionary kvp.Value.Value is OpenApiArray arr && arr.Count == 0)) { - if (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.WritePropertyName(kvp.Key); + writer.WriteStartObject(); + writer.WriteRequiredObject(OpenApiConstants.Value, kvp.Value.Value, (w, v) => w.WriteAny(v)); + writer.WriteEndObject(); } writer.WriteEndObject(); } From 2df890a8cc139c8ea4c42adcada4c6cc7ee76aac Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 2 Aug 2024 11:14:55 -0700 Subject: [PATCH 055/121] Add support for unserializable annotations on OpenAPI document --- .../Interfaces/IOpenApiAnnotatable.cs | 19 ++++++++++ .../Models/OpenApiDocument.cs | 6 ++- .../Models/OpenApiOperation.cs | 6 ++- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 6 ++- .../Models/OpenApiDocumentTests.cs | 37 +++++++++++++++++-- .../Models/OpenApiOperationTests.cs | 24 +++++++++++- .../Models/OpenApiSchemaTests.cs | 24 +++++++++++- .../PublicApi/PublicApi.approved.txt | 13 +++++-- 8 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs new file mode 100644 index 000000000..dc1ee84a0 --- /dev/null +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiAnnotatable.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.Collections.Generic; + +namespace Microsoft.OpenApi.Interfaces +{ + /// + /// Represents an Open API element that can be annotated with + /// non-serializable properties in a property bag. + /// + public interface IOpenApiAnnotatable + { + /// + /// A collection of properties associated with the current OpenAPI element. + /// + IDictionary Annotations { get; set; } + } +} diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 8d4526a20..712bddb03 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -17,7 +17,7 @@ namespace Microsoft.OpenApi.Models /// /// Describes an OpenAPI object (OpenAPI document). See: https://swagger.io/specification /// - public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible + public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable { /// /// Related workspace containing OpenApiDocuments that are referenced in this document @@ -70,6 +70,9 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible /// public string HashCode => GenerateHashValue(this); + /// + public IDictionary Annotations { get; set; } + /// /// Parameter-less constructor /// @@ -89,6 +92,7 @@ public OpenApiDocument(OpenApiDocument document) 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; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 360cfe7c1..69054740e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Operation Object. /// - public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible + public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenApiAnnotatable { /// /// Default value for . @@ -105,6 +105,9 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + public IDictionary Annotations { get; set; } + /// /// Parameterless constructor /// @@ -128,6 +131,7 @@ public OpenApiOperation(OpenApiOperation operation) 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; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 40adf9a31..957e0f946 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Schema Object. /// - public class OpenApiSchema : IOpenApiReferenceable, IEffective, IOpenApiExtensible + public class OpenApiSchema : IOpenApiReferenceable, IEffective, IOpenApiExtensible, IOpenApiAnnotatable { /// /// Follow JSON Schema definition. Short text providing information about the data. @@ -241,6 +241,9 @@ public class OpenApiSchema : IOpenApiReferenceable, IEffective, I /// public OpenApiReference Reference { get; set; } + /// + public IDictionary Annotations { get; set; } + /// /// Parameterless constructor /// @@ -290,6 +293,7 @@ public OpenApiSchema(OpenApiSchema schema) Extensions = schema?.Extensions != null ? new Dictionary(schema.Extensions) : null; UnresolvedReference = schema?.UnresolvedReference ?? UnresolvedReference; Reference = schema?.Reference != null ? new(schema?.Reference) : null; + Annotations = schema?.Annotations != null ? new Dictionary(schema?.Annotations) : null; } /// diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 7a7f883f6..168ec3ade 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -29,7 +29,8 @@ public class OpenApiDocumentTests { Type = ReferenceType.Schema, Id = "schema2" - } + }, + Annotations = new Dictionary { { "x-foo", "bar" } } }, ["schema2"] = new() { @@ -38,7 +39,8 @@ public class OpenApiDocumentTests { ["property1"] = new() { - Type = "string" + Type = "string", + Annotations = new Dictionary { { "key1", "value" } } } } }, @@ -56,9 +58,11 @@ public class OpenApiDocumentTests { ["property1"] = new() { - Type = "string" + Type = "string", + Annotations = new Dictionary { { "key1", "value" } } } }, + Annotations = new Dictionary { { "key1", "value" } }, Reference = new() { Type = ReferenceType.Schema, @@ -100,6 +104,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, + Annotations = new Dictionary { { "key1", "value" } }, Components = TopLevelReferencingComponents }; @@ -109,6 +114,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, + Annotations = new Dictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponentsWithOtherProperties }; @@ -118,6 +124,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, + Annotations = new Dictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponents }; @@ -509,6 +516,7 @@ public class OpenApiDocumentTests } } }, + Annotations = new Dictionary { { "key1", "value" } }, Components = AdvancedComponentsWithReference }; @@ -884,6 +892,7 @@ public class OpenApiDocumentTests } } }, + Annotations = new Dictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1272,6 +1281,7 @@ public class OpenApiDocumentTests } } }, + Annotations = new Dictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1827,5 +1837,26 @@ public void SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue() expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); } + + [Fact] + public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds() + { + var baseDocument = new OpenApiDocument + { + Annotations = new Dictionary + { + ["key1"] = "value1", + ["key2"] = 2 + } + }; + + var actualDocument = new OpenApiDocument(baseDocument); + + Assert.Equal(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]); + + baseDocument.Annotations["key1"] = "value2"; + + Assert.NotEqual(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index ec6ca8326..52906e61c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -87,7 +87,8 @@ public class OpenApiOperationTests Url = "http://server.com", Description = "serverDescription" } - } + }, + Annotations = new Dictionary { { "key1", "value1" }, { "key2", 2 } }, }; private static readonly OpenApiOperation _advancedOperationWithTagsAndSecurity = new() @@ -864,5 +865,26 @@ public void EnsureOpenApiOperationCopyConstructor_SerializationResultsInSame() actual.Should().Be(expected); } } + + [Fact] + public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() + { + var baseOperation = new OpenApiOperation + { + Annotations = new Dictionary + { + ["key1"] = "value1", + ["key2"] = 2 + } + }; + + var actualOperation = new OpenApiOperation(baseOperation); + + Assert.Equal(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]); + + baseOperation.Annotations["key1"] = "value2"; + + Assert.NotEqual(baseOperation.Annotations["key1"], actualOperation.Annotations["key1"]); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 0acd55925..1906dbbc4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -36,7 +36,8 @@ public class OpenApiSchemaTests ExternalDocs = new() { Url = new("http://example.com/externalDocs") - } + }, + Annotations = new Dictionary { { "key1", "value1" }, { "key2", 2 } } }; public static readonly OpenApiSchema AdvancedSchemaObject = new() @@ -483,6 +484,27 @@ public void OpenApiSchemaCopyConstructorSucceeds() Assert.True(actualSchema.Nullable); } + [Fact] + public void OpenApiSchemaCopyConstructorWithAnnotationsSucceeds() + { + var baseSchema = new OpenApiSchema + { + Annotations = new Dictionary + { + ["key1"] = "value1", + ["key2"] = 2 + } + }; + + var actualSchema = new OpenApiSchema(baseSchema); + + Assert.Equal(baseSchema.Annotations["key1"], actualSchema.Annotations["key1"]); + + baseSchema.Annotations["key1"] = "value2"; + + Assert.NotEqual(baseSchema.Annotations["key1"], actualSchema.Annotations["key1"]); + } + public static TheoryData SchemaExamples() { return new() diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 82c5f6a88..fbfe564f3 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -302,6 +302,10 @@ namespace Microsoft.OpenApi.Interfaces { T GetEffective(Microsoft.OpenApi.Models.OpenApiDocument document); } + public interface IOpenApiAnnotatable + { + System.Collections.Generic.IDictionary Annotations { get; set; } + } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement { @@ -592,10 +596,11 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiDocument() { } public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument document) { } + public System.Collections.Generic.IDictionary Annotations { get; set; } public Microsoft.OpenApi.Models.OpenApiComponents Components { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; set; } @@ -774,11 +779,12 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiOperation : Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public const bool DeprecatedDefault = false; public OpenApiOperation() { } public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { } + public System.Collections.Generic.IDictionary Annotations { get; set; } public System.Collections.Generic.IDictionary Callbacks { get; set; } public bool Deprecated { get; set; } public string Description { get; set; } @@ -900,13 +906,14 @@ namespace Microsoft.OpenApi.Models public OpenApiResponses() { } public OpenApiResponses(Microsoft.OpenApi.Models.OpenApiResponses openApiResponses) { } } - public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiAnnotatable, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSchema() { } public OpenApiSchema(Microsoft.OpenApi.Models.OpenApiSchema schema) { } public Microsoft.OpenApi.Models.OpenApiSchema AdditionalProperties { get; set; } public bool AdditionalPropertiesAllowed { get; set; } public System.Collections.Generic.IList AllOf { get; set; } + public System.Collections.Generic.IDictionary Annotations { get; set; } public System.Collections.Generic.IList AnyOf { get; set; } public Microsoft.OpenApi.Any.IOpenApiAny Default { get; set; } public bool Deprecated { get; set; } From 38ba98ec054e60de02ee4fb02406e9cefac7b986 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 5 Aug 2024 11:07:44 +0300 Subject: [PATCH 056/121] Update src/Microsoft.OpenApi/Models/OpenApiMediaType.cs Co-authored-by: Andrew Omondi --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 553e87d09..1c0a95b5f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -101,7 +101,7 @@ private void SerializeExamples(IOpenApiWriter writer, IDictionary + var hasEmptyArray = examples.Values.Any( static example => example.Value is OpenApiArray arr && arr.Count == 0 ); From 1c199862c3debef1dc93df361d4088f1329ffb34 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 5 Aug 2024 11:07:52 +0300 Subject: [PATCH 057/121] Update src/Microsoft.OpenApi/Models/OpenApiMediaType.cs Co-authored-by: Andrew Omondi --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 1c0a95b5f..c324c9ee8 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -109,7 +109,7 @@ private void SerializeExamples(IOpenApiWriter writer, IDictionary kvp.Value.Value is OpenApiArray arr && arr.Count == 0)) + foreach (var kvp in examples.Where(static kvp => kvp.Value.Value is OpenApiArray arr && arr.Count == 0)) { writer.WritePropertyName(kvp.Key); writer.WriteStartObject(); From 27258e911c93a932b61837c4f4c202e62a544840 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 5 Aug 2024 11:07:59 +0300 Subject: [PATCH 058/121] Update src/Microsoft.OpenApi/Models/OpenApiMediaType.cs Co-authored-by: Andrew Omondi --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index c324c9ee8..3816fb14f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -96,7 +96,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // Media type does not exist in V2. } - private void SerializeExamples(IOpenApiWriter writer, IDictionary examples) + 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 From 0e95cedfddcc9151b6d259cf96e89f3315733afb Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 6 Aug 2024 10:48:04 +0300 Subject: [PATCH 059/121] Bump lib versions --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index d41487182..c8af22cb3 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.17 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 00d47b331..b2f09236f 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.17 .NET models with JSON and YAML writers for OpenAPI specification true From 79ff30cd7e30dc4d7e53b01f489395ccb88c23a9 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 9 Aug 2024 10:53:47 +0300 Subject: [PATCH 060/121] Add null check --- src/Microsoft.OpenApi/Models/OpenApiMediaType.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 3816fb14f..1ee1ce176 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -77,7 +77,10 @@ public void SerializeAsV3(IOpenApiWriter writer) writer.WriteOptionalObject(OpenApiConstants.Example, Example, (w, e) => w.WriteAny(e)); // examples - SerializeExamples(writer, Examples); + if (Examples != null && Examples.Any()) + { + SerializeExamples(writer, Examples); + } // encoding writer.WriteOptionalMap(OpenApiConstants.Encoding, Encoding, (w, e) => e.SerializeAsV3(w)); From c3d6161898c96aecf1944294b0fedebde7614d77 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 9 Aug 2024 10:54:08 +0300 Subject: [PATCH 061/121] Add test to validate; remove commented out code --- .../Models/OpenApiDocumentTests.cs | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 168ec3ade..c9807f5a2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -1670,27 +1671,6 @@ private static OpenApiDocument ParseInputFile(string filePath) return openApiDoc; } - //[Fact] - //public void CopyConstructorForAdvancedDocumentWorks() - //{ - // // Arrange & Act - // var doc = new OpenApiDocument(AdvancedDocument); - - // var docOpId = doc.Paths["/pets"].Operations[OperationType.Get].OperationId = "findAllMyPets"; - // var advancedDocOpId = AdvancedDocument.Paths["/pets"].Operations[OperationType.Get].OperationId; - // var responseSchemaTypeCopy = doc.Paths["/pets"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema.Type = "object"; - // var advancedDocResponseSchemaType = AdvancedDocument.Paths["/pets"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema.Type; - - // // Assert - // Assert.NotNull(doc.Info); - // Assert.NotNull(doc.Servers); - // Assert.NotNull(doc.Paths); - // Assert.Equal(2, doc.Paths.Count); - // Assert.NotNull(doc.Components); - // Assert.NotEqual(docOpId, advancedDocOpId); - // Assert.NotEqual(responseSchemaTypeCopy, advancedDocResponseSchemaType); - //} - [Fact] public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFormat() { @@ -1858,5 +1838,38 @@ public void OpenApiDocumentCopyConstructorWithAnnotationsSucceeds() Assert.NotEqual(baseDocument.Annotations["key1"], actualDocument.Annotations["key1"]); } - } + + [Fact] + public void SerializeExamplesDoesNotThrowNullReferenceException() + { + OpenApiDocument doc = new OpenApiDocument + { + Paths = new OpenApiPaths + { + ["test"] = new OpenApiPathItem() + { + Operations = new Dictionary() + { + [OperationType.Post] = new OpenApiOperation + { + RequestBody = new OpenApiRequestBody() + { + Content = + { + ["application/json"] = new OpenApiMediaType() + { + Examples = null, + }, + } + } + }, + } + }, + } + }; + + OpenApiJsonWriter apiWriter = new OpenApiJsonWriter(new StringWriter()); + doc.Invoking(d => d.SerializeAsV3(apiWriter)).Should().NotThrow(); + } + } } From a8a40ab9dc94db782c04d4d47ce639c2cb96bf0f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 9 Aug 2024 11:02:24 +0300 Subject: [PATCH 062/121] Bump lib versions --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index c8af22cb3..b75e7009c 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.17 + 1.6.18 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index b2f09236f..2a674f542 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.17 + 1.6.18 .NET models with JSON and YAML writers for OpenAPI specification true From fd4f7521ae519a69ac3409714ebe4387e00f278a Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 9 Aug 2024 11:23:39 +0300 Subject: [PATCH 063/121] Upgrade ESRPCodeSigning tasks --- .azure-pipelines/ci-build.yml | 71 ++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 50407cd50..8a2e7ef18 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -78,16 +78,18 @@ extends: projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.sln' arguments: '--configuration $(BuildConfiguration) --no-build' - - task: EsrpCodeSigning@2 - displayName: 'ESRP CodeSigning' + - task: EsrpCodeSigning@5 inputs: - ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' - FolderPath: src - signConfigType: inlineSignParams + ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection' + AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' + AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' + AuthAKVName: 'akv-prod-eastus' + AuthCertName: 'ReferenceLibraryPrivateCert' + AuthSignCertName: 'ReferencePackagePublisherCertificate' + FolderPath: '$(Build.SourcesDirectory)\src' + Pattern: '*.dll' UseMinimatch: true - Pattern: | - **\*.exe - **\*.dll + signConfigType: 'inlineSignParams' inlineOperation: | [ { @@ -126,7 +128,10 @@ extends: "toolVersion": "1.0" } ] - SessionTimeout: 20 + SessionTimeout: '20' + MaxConcurrency: '50' + MaxRetryAttempts: '5' + PendingAnalysisWaitTimeoutMinutes: '5' # Pack core lib - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg @@ -140,32 +145,38 @@ extends: - pwsh: dotnet pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg displayName: 'pack Hidi' - - task: EsrpCodeSigning@2 - displayName: 'ESRP CodeSigning Nuget Packages' + - task: EsrpCodeSigning@5 inputs: - ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' + ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection' + AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' + AppRegistrationTenantId: 'cdc5aeea-15c5-4db6-b079-fcadd2505dc2' + AuthAKVName: 'akv-prod-eastus' + AuthCertName: 'ReferenceLibraryPrivateCert' + AuthSignCertName: 'ReferencePackagePublisherCertificate' FolderPath: '$(Build.ArtifactStagingDirectory)' Pattern: '*.nupkg' - signConfigType: inlineSignParams - UseMinimatch: true + signConfigType: 'inlineSignParams' inlineOperation: | [ - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetSign", - "parameters": [ ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetVerify", - "parameters": [ ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - SessionTimeout: 20 + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetSign", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetVerify", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: '60' + MaxConcurrency: '50' + MaxRetryAttempts: '5' + PendingAnalysisWaitTimeoutMinutes: '5' - task: PowerShell@2 displayName: "Get Hidi's version-number from .csproj" From ece311110dfe865822d2ed8740391d9c477bdef6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:49:49 +0000 Subject: [PATCH 064/121] Bump Microsoft.OData.Edm from 7.21.3 to 8.0.0 Bumps Microsoft.OData.Edm from 7.21.3 to 8.0.0. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 05293a686..ba264d9c4 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -34,7 +34,7 @@ - + From af252a8673cd942adeb612282f7ad065b115845f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 02:34:18 +0300 Subject: [PATCH 065/121] Bump Verify.Xunit from 26.1.6 to 26.2.0 (#1778) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.1.6 to 26.2.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.1.6...26.2.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index a4630d78c..5399d91d4 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From abb047356a51e00ff72aedcf225236d17fb0b9eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 02:34:43 +0300 Subject: [PATCH 066/121] Bump docker/build-push-action from 6.5.0 to 6.6.1 (#1777) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.5.0 to 6.6.1. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.5.0...v6.6.1) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index be1bd2a64..d6d023117 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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.6.1 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.6.1 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From bbd081d7b021a3da7c623e1a0cbc4d66c57a1c04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:37:25 +0000 Subject: [PATCH 067/121] Bump Microsoft.Windows.Compatibility from 8.0.7 to 8.0.8 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 8.0.7 to 8.0.8. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](https://github.com/dotnet/windowsdesktop/compare/v8.0.7...v8.0.8) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Workbench.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index bdf6181a4..301066766 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -8,7 +8,7 @@ true - + From 0c82895022e6980bc1fc9063e7d08d5ef408ed30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 08:50:55 +0300 Subject: [PATCH 068/121] Bump Newtonsoft.Json from 13.0.1 to 13.0.3 (#1782) Bumps Newtonsoft.Json from 13.0.1 to 13.0.3. --- updated-dependencies: - dependency-name: Newtonsoft.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 1 + 1 file changed, 1 insertion(+) 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..c1147319f 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -14,6 +14,7 @@ + From 19d6e4bcef17bbbd3ae0936bb99f91c045af9d81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:28:35 +0000 Subject: [PATCH 069/121] Bump docker/build-push-action from 6.6.1 to 6.7.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.6.1 to 6.7.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.6.1...v6.7.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d6d023117..ee951983c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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.6.1 + uses: docker/build-push-action@v6.7.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.6.1 + uses: docker/build-push-action@v6.7.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From ca81fa90a4c6cc0385f05f7464478224518fcaf2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:56:55 +0000 Subject: [PATCH 070/121] Bump Microsoft.OData.Edm from 8.0.0 to 8.0.1 Bumps Microsoft.OData.Edm from 8.0.0 to 8.0.1. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ba264d9c4..e635fa5a3 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -34,7 +34,7 @@ - + From e468649482600e1d659df86715c74f85baa3ff0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:00:43 +0000 Subject: [PATCH 071/121] Bump Microsoft.NET.Test.Sdk from 17.10.0 to 17.11.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.10.0 to 17.11.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.10.0...v17.11.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 c1147319f..f5958e5b6 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -12,7 +12,7 @@ - + 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..3b6f7c76e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 8bcded29f..4c93a8354 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 5399d91d4..081f70390 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -11,7 +11,7 @@ - + From 42dda81f3c3fcb15455a7752e3a06942feb4173f Mon Sep 17 00:00:00 2001 From: Caleb Kiage <747955+calebkiage@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:41:49 +0300 Subject: [PATCH 072/121] Add server variable substitution logic. (#1783) * Add server variable substitution logic. --- .../Extensions/OpenApiServerExtensions.cs | 57 ++++++++++ .../Models/OpenApiDocument.cs | 10 +- .../Models/OpenApiServerVariable.cs | 5 +- .../Properties/SRResource.Designer.cs | 19 +++- .../Properties/SRResource.resx | 6 + .../Validations/Rules/OpenApiServerRules.cs | 23 ++++ .../V3Tests/OpenApiDocumentTests.cs | 65 +++++++++++ .../OpenApiServerExtensionsTests.cs | 104 ++++++++++++++++++ .../PublicApi/PublicApi.approved.txt | 4 + 9 files changed, 283 insertions(+), 10 deletions(-) create mode 100644 src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs create mode 100644 test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs new file mode 100644 index 000000000..b885cb235 --- /dev/null +++ b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Properties; + +namespace Microsoft.OpenApi.Extensions; + +/// +/// Extension methods for serialization. +/// +public 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/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 712bddb03..201b321f1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -8,6 +8,7 @@ using System.Security.Cryptography; using System.Text; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Writers; @@ -283,14 +284,7 @@ public void SerializeAsV2(IOpenApiWriter writer) private static string ParseServerUrl(OpenApiServer server) { - var parsedUrl = server.Url; - - var variables = server.Variables; - foreach (var variable in variables.Where(static x => !string.IsNullOrEmpty(x.Value.Default))) - { - parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", variable.Value.Default); - } - return parsedUrl; + return server.ReplaceServerUrlVariables(new Dictionary(0)); } private static void WriteHostInfoV2(IOpenApiWriter writer, IList servers) diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index fe5293cd4..4ab8bdcaa 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -26,7 +26,10 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// /// An enumeration of string values to be used if the substitution options are from a limited set. /// - public List Enum { get; set; } = new(); + /// + /// If the server variable in the OpenAPI document has no enum member, this property will be null. + /// + public List Enum { get; set; } /// /// This object MAY be extended with Specification Extensions. diff --git a/src/Microsoft.OpenApi/Properties/SRResource.Designer.cs b/src/Microsoft.OpenApi/Properties/SRResource.Designer.cs index 1a9ab3014..511f300f7 100644 --- a/src/Microsoft.OpenApi/Properties/SRResource.Designer.cs +++ b/src/Microsoft.OpenApi/Properties/SRResource.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -222,6 +221,24 @@ internal static string OpenApiWriterExceptionGenericError { } } + /// + /// Looks up a localized string similar to Invalid server variable '{0}'. A value was not provided and no default value was provided.. + /// + internal static string ParseServerUrlDefaultValueNotAvailable { + get { + return ResourceManager.GetString("ParseServerUrlDefaultValueNotAvailable", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value '{0}' is not a valid value for variable '{1}'. If an enum is provided, it should not be empty and the value provided should exist in the enum. + /// + internal static string ParseServerUrlValueNotValid { + get { + return ResourceManager.GetString("ParseServerUrlValueNotValid", resourceCulture); + } + } + /// /// Looks up a localized string similar to The given primitive type '{0}' is not supported.. /// diff --git a/src/Microsoft.OpenApi/Properties/SRResource.resx b/src/Microsoft.OpenApi/Properties/SRResource.resx index f0bb497d3..0effa1d44 100644 --- a/src/Microsoft.OpenApi/Properties/SRResource.resx +++ b/src/Microsoft.OpenApi/Properties/SRResource.resx @@ -225,4 +225,10 @@ OpenAPI document must be added to an OpenApiWorkspace to be able to resolve external references. + + Invalid server variable '{0}'. A value was not provided and no default value was provided. + + + Value '{0}' is not a valid value for variable '{1}'. If an enum is provided, it should not be empty and the value provided should exist in the enum + diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs index dd11a661d..35d4b9a25 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiServerRules.cs @@ -26,9 +26,32 @@ public static class OpenApiServerRules context.CreateError(nameof(ServerRequiredFields), String.Format(SRResource.Validation_FieldIsRequired, "url", "server")); } + + context.Exit(); + context.Enter("variables"); + foreach (var variable in server.Variables) + { + context.Enter(variable.Key); + ValidateServerVariableRequiredFields(context, variable.Key, variable.Value); + context.Exit(); + } context.Exit(); }); // add more rules + + /// + /// Validate required fields in server variable + /// + private static void ValidateServerVariableRequiredFields(IValidationContext context, string key, OpenApiServerVariable item) + { + context.Enter("default"); + if (string.IsNullOrEmpty(item.Default)) + { + context.CreateError("ServerVariableMustHaveDefaultValue", + String.Format(SRResource.Validation_FieldIsRequired, "default", key)); + } + context.Exit(); + } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index d67c0054f..bb3db096f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1367,5 +1367,70 @@ public void ParseDocumetWithWrongReferenceTypeShouldReturnADiagnosticError() diagnostic.Errors.Should().BeEquivalentTo(new List { new( new OpenApiException("Invalid Reference Type 'Schema'.")) }); } + + [Fact] + public void ParseBasicDocumentWithServerVariableShouldSucceed() + { + var openApiDoc = new OpenApiStringReader().Read(""" + openapi : 3.0.0 + info: + title: The API + version: 0.9.1 + servers: + - url: http://www.example.org/api/{version} + description: The http endpoint + variables: + version: + default: v2 + enum: [v1, v2] + paths: {} + """, out var diagnostic); + + diagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); + + openApiDoc.Should().BeEquivalentTo( + new OpenApiDocument + { + Info = new() + { + Title = "The API", + Version = "0.9.1", + }, + Servers = + { + new OpenApiServer + { + Url = "http://www.example.org/api/{version}", + Description = "The http endpoint", + Variables = new Dictionary + { + {"version", new OpenApiServerVariable {Default = "v2", Enum = ["v1", "v2"]}} + } + } + }, + Paths = new() + }); + } + + [Fact] + public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail() + { + var openApiDoc = new OpenApiStringReader().Read(""" + openapi : 3.0.0 + info: + title: The API + version: 0.9.1 + servers: + - url: http://www.example.org/api/{version} + description: The http endpoint + variables: + version: + enum: [v1, v2] + paths: {} + """, out var diagnostic); + + diagnostic.Errors.Should().NotBeEmpty(); + } } } diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs new file mode 100644 index 000000000..b8f581541 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using FluentAssertions; +using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Models; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Extensions; + +public class OpenApiServerExtensionsTests +{ + [Fact] + public void ShouldSubstituteServerVariableWithProvidedValues() + { + var variable = new OpenApiServer + { + Url = "http://example.com/api/{version}", + Description = string.Empty, + Variables = new Dictionary + { + { "version", new OpenApiServerVariable { Default = "v1", Enum = ["v1", "v2"]} } + } + }; + + var url = variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v2"}}); + + url.Should().Be("http://example.com/api/v2"); + } + + [Fact] + public void ShouldSubstituteServerVariableWithDefaultValues() + { + var variable = new OpenApiServer + { + Url = "http://example.com/api/{version}", + Description = string.Empty, + Variables = new Dictionary + { + { "version", new OpenApiServerVariable { Default = "v1", Enum = ["v1", "v2"]} } + } + }; + + var url = variable.ReplaceServerUrlVariables(new Dictionary(0)); + + url.Should().Be("http://example.com/api/v1"); + } + + [Fact] + public void ShouldFailIfNoValueIsAvailable() + { + var variable = new OpenApiServer + { + Url = "http://example.com/api/{version}", + Description = string.Empty, + Variables = new Dictionary + { + { "version", new OpenApiServerVariable { Enum = ["v1", "v2"]} } + } + }; + + Assert.Throws(() => + { + variable.ReplaceServerUrlVariables(new Dictionary(0)); + }); + } + + [Fact] + public void ShouldFailIfProvidedValueIsNotInEnum() + { + var variable = new OpenApiServer + { + Url = "http://example.com/api/{version}", + Description = string.Empty, + Variables = new Dictionary + { + { "version", new OpenApiServerVariable { Enum = ["v1", "v2"]} } + } + }; + + Assert.Throws(() => + { + variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v3"}}); + }); + } + + [Fact] + public void ShouldFailIfEnumIsEmpty() + { + var variable = new OpenApiServer + { + Url = "http://example.com/api/{version}", + Description = string.Empty, + Variables = new Dictionary + { + { "version", new OpenApiServerVariable { Enum = []} } + } + }; + + Assert.Throws(() => + { + variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v1"}}); + }); + } +} diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index fbfe564f3..9483e5f6e 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -285,6 +285,10 @@ namespace Microsoft.OpenApi.Extensions public static void SerializeAsYaml(this T element, System.IO.Stream stream, Microsoft.OpenApi.OpenApiSpecVersion specVersion) where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { } } + public static class OpenApiServerExtensions + { + public static string ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.IDictionary values = null) { } + } public static class OpenApiTypeMapper { public static System.Type MapOpenApiPrimitiveTypeToSimpleType(this Microsoft.OpenApi.Models.OpenApiSchema schema) { } From 3f701e950033ededdc6e675700e4f1d7e73af1af Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 23 Aug 2024 12:43:12 +0300 Subject: [PATCH 073/121] Update OData lib and bump Hidi version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index e635fa5a3..309fec2de 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.4.7 + 1.4.8 OpenAPI.NET CLI tool for slicing OpenAPI documents true @@ -35,7 +35,7 @@ - + From ed36696bc8e4ce343cc915e4591d677a147d92c1 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 10:46:14 -0400 Subject: [PATCH 074/121] chore: cleans useless test project --- Microsoft.OpenApi.sln | 7 -- test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs | 105 ------------------ .../GraphTests.cs | 63 ----------- .../Microsoft.OpenApi.SmokeTests.csproj | 28 ----- .../WorkspaceTests.cs | 6 - 5 files changed, 209 deletions(-) delete mode 100644 test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs delete mode 100644 test/Microsoft.OpenApi.SmokeTests/GraphTests.cs delete mode 100644 test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj delete mode 100644 test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index 67f3f0e17..a39756a42 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -24,8 +24,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E546B92F-20A EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2DE4-4900-ADB9-ABC37052040A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" 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}" @@ -58,10 +56,6 @@ Global {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Debug|Any CPU.Build.0 = Debug|Any CPU {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.ActiveCfg = Release|Any CPU {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237}.Release|Any CPU.Build.0 = Release|Any CPU - {AD79B61D-88CF-497C-9ED5-41AE3867C5AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD79B61D-88CF-497C-9ED5-41AE3867C5AC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD79B61D-88CF-497C-9ED5-41AE3867C5AC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD79B61D-88CF-497C-9ED5-41AE3867C5AC}.Release|Any CPU.Build.0 = Release|Any CPU {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -84,7 +78,6 @@ Global {79933258-0126-4382-8755-D50820ECC483} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1} {AD83F991-DBF3-4251-8613-9CC54C826964} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} {1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A} - {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} diff --git a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs b/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs deleted file mode 100644 index b2cd1143b..000000000 --- a/test/Microsoft.OpenApi.SmokeTests/ApiGurus.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.OpenApi.Readers; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.OpenApi.SmokeTests -{ - [Collection("DefaultSettings")] - public class ApisGuruTests - { - private static HttpClient _httpClient; - private readonly ITestOutputHelper _output; - - public ApisGuruTests(ITestOutputHelper output) - { - _output = output; - } - - static ApisGuruTests() - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new(new HttpClientHandler - { - AutomaticDecompression = DecompressionMethods.GZip - }); - _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new("gzip")); - _httpClient.DefaultRequestHeaders.UserAgent.Add(new("OpenApi.Net.Tests", "1.0")); - } - - public static IEnumerable GetSchemas() - { - var listJsonStr = _httpClient - .GetStringAsync("https://api.apis.guru/v2/list.json") - .GetAwaiter().GetResult(); - - var json = JObject.Parse(listJsonStr); - foreach (var item in json.Properties()) - { - if (GetProp(item.Value, "versions") is not JObject versions) - continue; - foreach (var prop in versions.Properties()) - { - var urlToJson = GetProp(prop.Value, "swaggerUrl")?.ToObject(); - if (urlToJson != null) - yield return new object[] { urlToJson }; - - var utlToYaml = GetProp(prop.Value, "swaggerYamlUrl")?.ToObject(); - if (utlToYaml != null) - yield return new object[] { utlToYaml }; - } - } - - JToken GetProp(JToken obj, string prop) - { - if (obj is not JObject jObj) - return null; - if (!jObj.TryGetValue(prop, out var jToken)) - return null; - return jToken; - } - } - - // Disable as some APIs are currently invalid - //[Theory(DisplayName = "APIs.guru")] - //[MemberData(nameof(GetSchemas))] - public async Task EnsureThatICouldParse(string url) - { - var response = await _httpClient.GetAsync(url); - if (!response.IsSuccessStatusCode) - { - _output.WriteLine($"Couldn't load {url}"); - return; - } - - await response.Content.LoadIntoBufferAsync(); - var stream = await response.Content.ReadAsStreamAsync(); - - var stopwatch = new Stopwatch(); - stopwatch.Start(); - - var reader = new OpenApiStreamReader(); - var openApiDocument = reader.Read(stream, out var diagnostic); - - if (diagnostic.Errors.Count > 0) - { - _output.WriteLine($"Errors parsing {url}"); - _output.WriteLine(String.Join('\n', diagnostic.Errors)); - // Assert.True(false); // Uncomment to identify descriptions with errors. - } - - Assert.NotNull(openApiDocument); - stopwatch.Stop(); - _output.WriteLine($"Parsing {url} took {stopwatch.ElapsedMilliseconds} ms."); - } - } -} diff --git a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs b/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs deleted file mode 100644 index 9bd1069a2..000000000 --- a/test/Microsoft.OpenApi.SmokeTests/GraphTests.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Microsoft.OpenApi.Models; -using Microsoft.OpenApi.Readers; -using Microsoft.OpenApi.Services; -using System; -using System.Net; -using System.Net.Http; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.OpenApi.SmokeTests -{ - public class GraphTests - { - OpenApiDocument _graphOpenApi; - HttpClient _httpClient; - private readonly ITestOutputHelper _output; - const string graphOpenApiUrl = "https://github.com/microsoftgraph/microsoft-graph-openapi/blob/master/v1.0.json?raw=true"; - - public GraphTests(ITestOutputHelper output) - { - _output = output; - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - _httpClient = new(new HttpClientHandler - { AutomaticDecompression = DecompressionMethods.GZip - }); - _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new("gzip")); - _httpClient.DefaultRequestHeaders.UserAgent.Add(new("OpenApi.Net.Tests", "1.0")); - - var response = _httpClient.GetAsync(graphOpenApiUrl) - .GetAwaiter().GetResult(); - - if (!response.IsSuccessStatusCode) - { - _output.WriteLine($"Couldn't load graph openapi"); - return; - } - - var stream = response.Content.ReadAsStreamAsync().GetAwaiter().GetResult(); ; - - var reader = new OpenApiStreamReader(); - _graphOpenApi = reader.Read(stream, out var diagnostic); - - if (diagnostic.Errors.Count > 0) - { - _output.WriteLine($"Errors parsing"); - _output.WriteLine(String.Join('\n', diagnostic.Errors)); - // Assert.True(false); // Uncomment to identify descriptions with errors. - } - } - - //[Fact(Skip="Run manually")] - public void LoadOpen() - { - var operations = new[] { "foo","bar" }; - var workspace = new OpenApiWorkspace(); - workspace.AddDocument(graphOpenApiUrl, _graphOpenApi); - var subset = new OpenApiDocument(); - workspace.AddDocument("subset", subset); - - Assert.NotNull(_graphOpenApi); - } - } -} diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj deleted file mode 100644 index 4c93a8354..000000000 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net8.0 - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs b/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs deleted file mode 100644 index 0d0056fe3..000000000 --- a/test/Microsoft.OpenApi.SmokeTests/WorkspaceTests.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Microsoft.OpenApi.SmokeTests -{ - public class WorkspaceTests - { - } -} From 70f510b58ee9b2b40db0ebb15b64749173770f30 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 10:49:48 -0400 Subject: [PATCH 075/121] chore: linting tasks conventions Signed-off-by: Vincent Biret --- .../Handlers/AsyncCommandHandler.cs | 14 ++++ .../Handlers/PluginCommandHandler.cs | 10 +-- .../Handlers/ShowCommandHandler.cs | 10 +-- .../Handlers/TransformCommandHandler.cs | 10 +-- .../Handlers/ValidateCommandHandler.cs | 11 +-- .../Microsoft.OpenApi.Hidi.csproj | 1 + src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 44 ++++++------ .../Interface/IStreamLoader.cs | 3 + .../Microsoft.OpenApi.Readers.csproj | 1 + .../OpenApiYamlDocumentReader.cs | 4 +- .../Services/DefaultStreamLoader.cs | 17 ++--- src/Microsoft.OpenApi.Workbench/MainModel.cs | 4 +- .../MainWindow.xaml.cs | 4 +- .../Microsoft.OpenApi.Workbench.csproj | 1 + .../Microsoft.OpenApi.csproj | 4 ++ .../Services/OpenApiServiceTests.cs | 72 +++++++++---------- .../OpenApiDiagnosticTests.cs | 2 +- .../OpenApiStreamReaderTests.cs | 4 +- .../OpenApiWorkspaceStreamTests.cs | 12 ++-- .../Models/OpenApiCallbackTests.cs | 6 +- .../Models/OpenApiDocumentTests.cs | 14 ++-- .../Models/OpenApiExampleTests.cs | 6 +- .../Models/OpenApiHeaderTests.cs | 12 ++-- .../Services/OpenApiUrlTreeNodeTests.cs | 4 +- .../OpenApiWriterAnyExtensionsTests.cs | 4 +- 25 files changed, 138 insertions(+), 136 deletions(-) create mode 100644 src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs new file mode 100644 index 000000000..385c00931 --- /dev/null +++ b/src/Microsoft.OpenApi.Hidi/Handlers/AsyncCommandHandler.cs @@ -0,0 +1,14 @@ +using System; +using System.CommandLine.Invocation; +using System.Threading.Tasks; + +namespace Microsoft.OpenApi.Hidi.Handlers; + +internal abstract class AsyncCommandHandler : ICommandHandler +{ + public int Invoke(InvocationContext context) + { + throw new InvalidOperationException("This method should not be called"); + } + public abstract Task InvokeAsync(InvocationContext context); +} diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs index bd240f00e..b8f1155c7 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs @@ -11,18 +11,14 @@ namespace Microsoft.OpenApi.Hidi.Handlers { - internal class PluginCommandHandler : ICommandHandler + internal class PluginCommandHandler : AsyncCommandHandler { public CommandOptions CommandOptions { get; } public PluginCommandHandler(CommandOptions commandOptions) { CommandOptions = commandOptions; } - public int Invoke(InvocationContext context) - { - return InvokeAsync(context).GetAwaiter().GetResult(); - } - public async Task InvokeAsync(InvocationContext context) + public override async Task InvokeAsync(InvocationContext context) { var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions); var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken)); @@ -31,7 +27,7 @@ public async Task InvokeAsync(InvocationContext context) var logger = loggerFactory.CreateLogger(); try { - await OpenApiService.PluginManifest(hidiOptions, logger, cancellationToken).ConfigureAwait(false); + await OpenApiService.PluginManifestAsync(hidiOptions, logger, cancellationToken).ConfigureAwait(false); return 0; } diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs index dc2f6d8c8..e4f86c6f5 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs @@ -11,18 +11,14 @@ namespace Microsoft.OpenApi.Hidi.Handlers { - internal class ShowCommandHandler : ICommandHandler + internal class ShowCommandHandler : AsyncCommandHandler { public CommandOptions CommandOptions { get; set; } public ShowCommandHandler(CommandOptions commandOptions) { CommandOptions = commandOptions; } - public int Invoke(InvocationContext context) - { - return InvokeAsync(context).GetAwaiter().GetResult(); - } - public async Task InvokeAsync(InvocationContext context) + public override async Task InvokeAsync(InvocationContext context) { var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions); var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken)); @@ -31,7 +27,7 @@ public async Task InvokeAsync(InvocationContext context) var logger = loggerFactory.CreateLogger(); try { - await OpenApiService.ShowOpenApiDocument(hidiOptions, logger, cancellationToken).ConfigureAwait(false); + await OpenApiService.ShowOpenApiDocumentAsync(hidiOptions, logger, cancellationToken).ConfigureAwait(false); return 0; } diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs index c9f46b7ee..3a9a6322c 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs @@ -11,18 +11,14 @@ namespace Microsoft.OpenApi.Hidi.Handlers { - internal class TransformCommandHandler : ICommandHandler + internal class TransformCommandHandler : AsyncCommandHandler { public CommandOptions CommandOptions { get; } public TransformCommandHandler(CommandOptions commandOptions) { CommandOptions = commandOptions; } - public int Invoke(InvocationContext context) - { - return InvokeAsync(context).GetAwaiter().GetResult(); - } - public async Task InvokeAsync(InvocationContext context) + public override async Task InvokeAsync(InvocationContext context) { var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions); var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken)); @@ -31,7 +27,7 @@ public async Task InvokeAsync(InvocationContext context) var logger = loggerFactory.CreateLogger(); try { - await OpenApiService.TransformOpenApiDocument(hidiOptions, logger, cancellationToken).ConfigureAwait(false); + await OpenApiService.TransformOpenApiDocumentAsync(hidiOptions, logger, cancellationToken).ConfigureAwait(false); return 0; } diff --git a/src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs b/src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs index 4c14cbef6..b2d4a4653 100644 --- a/src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs +++ b/src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Hidi.Handlers { - internal class ValidateCommandHandler : ICommandHandler + internal class ValidateCommandHandler : AsyncCommandHandler { public CommandOptions CommandOptions { get; } @@ -19,12 +19,7 @@ public ValidateCommandHandler(CommandOptions commandOptions) { CommandOptions = commandOptions; } - - public int Invoke(InvocationContext context) - { - return InvokeAsync(context).GetAwaiter().GetResult(); - } - public async Task InvokeAsync(InvocationContext context) + public override async Task InvokeAsync(InvocationContext context) { var hidiOptions = new HidiOptions(context.ParseResult, CommandOptions); var cancellationToken = (CancellationToken)context.BindingContext.GetRequiredService(typeof(CancellationToken)); @@ -33,7 +28,7 @@ public async Task InvokeAsync(InvocationContext context) try { if (hidiOptions.OpenApi is null) throw new InvalidOperationException("OpenApi file is required"); - var isValid = await OpenApiService.ValidateOpenApiDocument(hidiOptions.OpenApi, logger, cancellationToken).ConfigureAwait(false); + var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(hidiOptions.OpenApi, logger, cancellationToken).ConfigureAwait(false); return isValid is not false ? 0 : -1; } #if RELEASE diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 309fec2de..8d1f4d393 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -33,6 +33,7 @@ + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index d3d3fdd8c..d98508a13 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -41,7 +41,7 @@ internal static class OpenApiService /// /// Implementation of the transform command /// - public static async Task TransformOpenApiDocument(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default) + public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(options.OpenApi) && string.IsNullOrEmpty(options.Csdl) && string.IsNullOrEmpty(options.FilterOptions?.FilterByApiManifest)) { @@ -70,7 +70,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l var openApiVersion = options.Version != null ? TryParseOpenApiSpecVersion(options.Version) : OpenApiSpecVersion.OpenApi3_0; // If ApiManifest is provided, set the referenced OpenAPI document - var apiDependency = await FindApiDependency(options.FilterOptions.FilterByApiManifest, logger, cancellationToken).ConfigureAwait(false); + var apiDependency = await FindApiDependencyAsync(options.FilterOptions.FilterByApiManifest, logger, cancellationToken).ConfigureAwait(false); if (apiDependency != null) { options.OpenApi = apiDependency.ApiDescripionUrl; @@ -80,12 +80,12 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l JsonDocument? postmanCollection = null; if (!string.IsNullOrEmpty(options.FilterOptions?.FilterByCollection)) { - using var collectionStream = await GetStream(options.FilterOptions.FilterByCollection, logger, cancellationToken).ConfigureAwait(false); + using var collectionStream = await GetStreamAsync(options.FilterOptions.FilterByCollection, logger, cancellationToken).ConfigureAwait(false); postmanCollection = await JsonDocument.ParseAsync(collectionStream, cancellationToken: cancellationToken).ConfigureAwait(false); } // Load OpenAPI document - var document = await GetOpenApi(options, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); if (options.FilterOptions != null) { @@ -116,7 +116,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l } } - private static async Task FindApiDependency(string? apiManifestPath, ILogger logger, CancellationToken cancellationToken = default) + private static async Task FindApiDependencyAsync(string? apiManifestPath, ILogger logger, CancellationToken cancellationToken = default) { ApiDependency? apiDependency = null; // If API Manifest is provided, load it, use it get the OpenAPI path @@ -130,7 +130,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l { apiDependencyName = apiManifestRef[1]; } - using (var fileStream = await GetStream(apiManifestRef[0], logger, cancellationToken).ConfigureAwait(false)) + using (var fileStream = await GetStreamAsync(apiManifestRef[0], logger, cancellationToken).ConfigureAwait(false)) { var document = await JsonDocument.ParseAsync(fileStream, cancellationToken: cancellationToken).ConfigureAwait(false); apiManifest = ApiManifestDocument.Load(document.RootElement); @@ -212,7 +212,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma } // Get OpenAPI document either from OpenAPI or CSDL - private static async Task GetOpenApi(HidiOptions options, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) + private static async Task GetOpenApiAsync(HidiOptions options, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) { OpenApiDocument document; Stream stream; @@ -223,7 +223,7 @@ private static async Task GetOpenApi(HidiOptions options, ILogg using (logger.BeginScope("Convert CSDL: {Csdl}", options.Csdl)) { stopwatch.Start(); - stream = await GetStream(options.Csdl, logger, cancellationToken).ConfigureAwait(false); + stream = await GetStreamAsync(options.Csdl, logger, cancellationToken).ConfigureAwait(false); Stream? filteredStream = null; if (!string.IsNullOrEmpty(options.CsdlFilter)) { @@ -233,15 +233,15 @@ private static async Task GetOpenApi(HidiOptions options, ILogg await stream.DisposeAsync().ConfigureAwait(false); } - document = await ConvertCsdlToOpenApi(filteredStream ?? stream, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false); + document = await ConvertCsdlToOpenApiAsync(filteredStream ?? stream, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false); stopwatch.Stop(); logger.LogTrace("{Timestamp}ms: Generated OpenAPI with {Paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } } else if (!string.IsNullOrEmpty(options.OpenApi)) { - stream = await GetStream(options.OpenApi, logger, cancellationToken).ConfigureAwait(false); - var result = await ParseOpenApi(options.OpenApi, options.InlineExternal, logger, stream, cancellationToken).ConfigureAwait(false); + stream = await GetStreamAsync(options.OpenApi, logger, cancellationToken).ConfigureAwait(false); + var result = await ParseOpenApiAsync(options.OpenApi, options.InlineExternal, logger, stream, cancellationToken).ConfigureAwait(false); document = result.OpenApiDocument; } else throw new InvalidOperationException("No input file path or URL provided"); @@ -323,7 +323,7 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe /// Implementation of the validate command /// /// when valid, when invalid and when cancelled - public static async Task ValidateOpenApiDocument( + public static async Task ValidateOpenApiDocumentAsync( string openApi, ILogger logger, CancellationToken cancellationToken = default) @@ -337,9 +337,9 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe try { - using var stream = await GetStream(openApi, logger, cancellationToken).ConfigureAwait(false); + using var stream = await GetStreamAsync(openApi, logger, cancellationToken).ConfigureAwait(false); - result = await ParseOpenApi(openApi, false, logger, stream, cancellationToken).ConfigureAwait(false); + result = await ParseOpenApiAsync(openApi, false, logger, stream, cancellationToken).ConfigureAwait(false); using (logger.BeginScope("Calculating statistics")) { @@ -367,7 +367,7 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe return result.OpenApiDiagnostic.Errors.Count == 0; } - private static async Task ParseOpenApi(string openApiFile, bool inlineExternal, ILogger logger, Stream stream, CancellationToken cancellationToken = default) + private static async Task ParseOpenApiAsync(string openApiFile, bool inlineExternal, ILogger logger, Stream stream, CancellationToken cancellationToken = default) { ReadResult result; var stopwatch = Stopwatch.StartNew(); @@ -398,7 +398,7 @@ private static async Task ParseOpenApi(string openApiFile, bool inli /// /// The CSDL stream. /// An OpenAPI document. - public static async Task ConvertCsdlToOpenApi(Stream csdl, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) + public static async Task ConvertCsdlToOpenApiAsync(Stream csdl, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) { using var reader = new StreamReader(csdl); var csdlText = await reader.ReadToEndAsync(token).ConfigureAwait(false); @@ -486,7 +486,7 @@ private static Dictionary> EnumerateJsonDocument(JsonElemen /// /// Reads stream from file system or makes HTTP request depending on the input string /// - private static async Task GetStream(string input, ILogger logger, CancellationToken cancellationToken = default) + private static async Task GetStreamAsync(string input, ILogger logger, CancellationToken cancellationToken = default) { Stream stream; using (logger.BeginScope("Reading input stream")) @@ -562,7 +562,7 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl return extension; } - internal static async Task ShowOpenApiDocument(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default) + internal static async Task ShowOpenApiDocumentAsync(HidiOptions options, ILogger logger, CancellationToken cancellationToken = default) { try { @@ -571,7 +571,7 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl throw new ArgumentException("Please input a file path or URL"); } - var document = await GetOpenApi(options, logger, null, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, logger, null, cancellationToken).ConfigureAwait(false); using (logger.BeginScope("Creating diagram")) { @@ -722,17 +722,17 @@ internal static void WriteTreeDocumentAsHtml(string sourceUrl, OpenApiDocument d writer.WriteLine(" /// /// + [Obsolete("Use the Async overload")] + [EditorBrowsable(EditorBrowsableState.Never)] Stream Load(Uri uri); } } diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index b75e7009c..e8d33f8cd 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 1e1973d37..af9ebcad1 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -102,7 +102,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca if (_settings.LoadExternalRefs) { - var diagnosticExternalRefs = await LoadExternalRefs(document, cancellationToken); + var diagnosticExternalRefs = await LoadExternalRefsAsync(document, cancellationToken); // Merge diagnostics of external reference if (diagnosticExternalRefs != null) { @@ -139,7 +139,7 @@ public async Task ReadAsync(YamlDocument input, CancellationToken ca }; } - private Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken = default) + private Task LoadExternalRefsAsync(OpenApiDocument document, CancellationToken cancellationToken = default) { // Create workspace for all documents to live in. var openApiWorkSpace = new OpenApiWorkspace(); diff --git a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs index 5ef282156..3c7fd8d8a 100644 --- a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.ComponentModel; using System.IO; using System.Net.Http; using System.Threading.Tasks; @@ -22,19 +23,13 @@ public DefaultStreamLoader(Uri baseUrl) this.baseUrl = baseUrl; } + [Obsolete] + [EditorBrowsable(EditorBrowsableState.Never)] public Stream Load(Uri uri) { - var absoluteUri = new Uri(baseUrl, uri); - switch (uri.Scheme) - { - case "file": - return File.OpenRead(absoluteUri.AbsolutePath); - case "http": - case "https": - return _httpClient.GetStreamAsync(absoluteUri).GetAwaiter().GetResult(); - default: - throw new ArgumentException("Unsupported scheme"); - } +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + return LoadAsync(uri).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } public async Task LoadAsync(Uri uri) diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 52a34df81..7068a61e8 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.cs @@ -201,7 +201,7 @@ protected void OnPropertyChanged(string propertyName) /// The core method of the class. /// Runs the parsing and serializing. /// - internal async Task ParseDocument() + internal async Task ParseDocumentAsync() { Stream stream = null; try @@ -291,7 +291,7 @@ internal async Task ParseDocument() if (stream != null) { stream.Close(); - stream.Dispose(); + await stream.DisposeAsync(); } } diff --git a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs index 5f3c3ec38..f9f1773c7 100644 --- a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs +++ b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs @@ -19,11 +19,13 @@ public MainWindow() DataContext = _mainModel; } +#pragma warning disable VSTHRD100 // Avoid async void methods private async void Button_Click(object sender, RoutedEventArgs e) +#pragma warning restore VSTHRD100 // Avoid async void methods { try { - await _mainModel.ParseDocument(); + await _mainModel.ParseDocumentAsync(); } catch (Exception ex) { _mainModel.Errors = ex.Message; diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 301066766..4379c7595 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -8,6 +8,7 @@ true + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 2a674f542..973c6b0d3 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -35,4 +35,8 @@ + + + + diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index e092a1c43..8d9d3ab09 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -27,14 +27,14 @@ public OpenApiServiceTests() } [Fact] - public async Task ReturnConvertedCSDLFile() + public async Task ReturnConvertedCSDLFileAsync() { // Arrange var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); var fileInput = new FileInfo(filePath); var csdlStream = fileInput.OpenRead(); // Act - var openApiDoc = await OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var openApiDoc = await OpenApiService.ConvertCsdlToOpenApiAsync(csdlStream); var expectedPathCount = 5; // Assert @@ -47,7 +47,7 @@ public async Task ReturnConvertedCSDLFile() [InlineData("Todos.Todo.UpdateTodo", null, 1)] [InlineData("Todos.Todo.ListTodo", null, 1)] [InlineData(null, "Todos.Todo", 5)] - public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string? operationIds, string? tags, int expectedPathCount) + public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumentAsync(string? operationIds, string? tags, int expectedPathCount) { // Arrange var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); @@ -55,7 +55,7 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen var csdlStream = fileInput.OpenRead(); // Act - var openApiDoc = await OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var openApiDoc = await OpenApiService.ConvertCsdlToOpenApiAsync(csdlStream); var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, predicate); @@ -170,7 +170,7 @@ public void ShowCommandGeneratesMermaidDiagramAsHtml() } [Fact] - public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() + public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync() { // create a dummy ILogger instance for testing var options = new HidiOptions @@ -179,25 +179,25 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram() Output = new("sample.md") }; - await OpenApiService.ShowOpenApiDocument(options, _logger); + await OpenApiService.ShowOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync(options.Output.FullName); Assert.Contains("graph LR", output, StringComparison.Ordinal); } [Fact] - public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram() + public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync() { var options = new HidiOptions { OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml") }; - var filePath = await OpenApiService.ShowOpenApiDocument(options, _logger); + var filePath = await OpenApiService.ShowOpenApiDocumentAsync(options, _logger); Assert.True(File.Exists(filePath)); } [Fact] - public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram() + public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagramAsync() { var options = new HidiOptions { @@ -207,70 +207,70 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag }; // create a dummy ILogger instance for testing - await OpenApiService.ShowOpenApiDocument(options, _logger); + await OpenApiService.ShowOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync(options.Output.FullName); Assert.Contains("graph LR", output, StringComparison.Ordinal); } [Fact] - public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidating() + public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidatingAsync() { return Assert.ThrowsAsync(() => - OpenApiService.ValidateOpenApiDocument("", _logger)); + OpenApiService.ValidateOpenApiDocumentAsync("", _logger)); } [Fact] - public Task ThrowIfURLIsNotResolvableWhenValidating() + public Task ThrowIfURLIsNotResolvableWhenValidatingAsync() { return Assert.ThrowsAsync(() => - OpenApiService.ValidateOpenApiDocument("https://example.org/itdoesnmatter", _logger)); + OpenApiService.ValidateOpenApiDocumentAsync("https://example.org/itdoesnmatter", _logger)); } [Fact] - public Task ThrowIfFileDoesNotExistWhenValidating() + public Task ThrowIfFileDoesNotExistWhenValidatingAsync() { return Assert.ThrowsAsync(() => - OpenApiService.ValidateOpenApiDocument("aFileThatBetterNotExist.fake", _logger)); + OpenApiService.ValidateOpenApiDocumentAsync("aFileThatBetterNotExist.fake", _logger)); } [Fact] - public async Task ValidateCommandProcessesOpenApi() + public async Task ValidateCommandProcessesOpenApiAsync() { // create a dummy ILogger instance for testing - await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger); + await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger); Assert.True(true); } [Fact] - public async Task ValidFileReturnsTrue() + public async Task ValidFileReturnsTrueAsync() { - var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger); + var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger); Assert.True(isValid); } [Fact] - public async Task InvalidFileReturnsFalse() + public async Task InvalidFileReturnsFalseAsync() { - var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger); + var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger); Assert.False(isValid); } [Fact] - public async Task CancellingValidationReturnsNull() + public async Task CancellingValidationReturnsNullAsync() { using var cts = new CancellationTokenSource(); await cts.CancelAsync(); - var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token); + var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token); Assert.Null(isValid); } [Fact] - public async Task TransformCommandConvertsOpenApi() + public async Task TransformCommandConvertsOpenApiAsync() { var options = new HidiOptions { @@ -282,7 +282,7 @@ public async Task TransformCommandConvertsOpenApi() InlineExternal = false, }; // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocument(options, _logger); + await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync("sample.json"); Assert.NotEmpty(output); @@ -290,7 +290,7 @@ public async Task TransformCommandConvertsOpenApi() [Fact] - public async Task TransformCommandConvertsOpenApiWithDefaultOutputName() + public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAsync() { var options = new HidiOptions { @@ -301,14 +301,14 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputName() InlineExternal = false, }; // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocument(options, _logger); + await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } [Fact] - public async Task TransformCommandConvertsCsdlWithDefaultOutputName() + public async Task TransformCommandConvertsCsdlWithDefaultOutputNameAsync() { var options = new HidiOptions { @@ -319,14 +319,14 @@ public async Task TransformCommandConvertsCsdlWithDefaultOutputName() InlineExternal = false, }; // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocument(options, _logger); + await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } [Fact] - public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormat() + public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormatAsync() { var options = new HidiOptions { @@ -339,14 +339,14 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF InlineExternal = false, }; // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocument(options, _logger); + await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); } [Fact] - public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() + public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmptyAsync() { var options = new HidiOptions { @@ -356,11 +356,11 @@ public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmpty() InlineExternal = false, }; return Assert.ThrowsAsync(() => - OpenApiService.TransformOpenApiDocument(options, _logger)); + OpenApiService.TransformOpenApiDocumentAsync(options, _logger)); } [Fact] - public async Task TransformToPowerShellCompliantOpenApi() + public async Task TransformToPowerShellCompliantOpenApiAsync() { var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json"); var options = new HidiOptions @@ -375,7 +375,7 @@ public async Task TransformToPowerShellCompliantOpenApi() SettingsConfig = SettingsUtilities.GetConfiguration(settingsPath) }; // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocument(options, _logger); + await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); var output = await File.ReadAllTextAsync("output.yml"); Assert.NotEmpty(output); diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs index 7f7c34b26..0977dbcd9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs @@ -37,7 +37,7 @@ public void DetectedSpecificationVersionShouldBeV3_0() } [Fact] - public async Task DiagnosticReportMergedForExternalReference() + public async Task DiagnosticReportMergedForExternalReferenceAsync() { // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new() diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index 7bb0fe922..1b2faa137 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -32,7 +32,7 @@ public void StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue() } [Fact] - public async Task StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue() + public async Task StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrueAsync() { var memoryStream = new MemoryStream(); using var fileStream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml")); @@ -48,7 +48,7 @@ public async Task StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrue() } [Fact] - public async Task StreamShouldReadWhenInitialized() + public async Task StreamShouldReadWhenInitializedAsync() { var httpClient = new HttpClient { diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index e601e5dad..d72594620 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -10,12 +10,10 @@ namespace Microsoft.OpenApi.Readers.Tests.OpenApiWorkspaceTests { public class OpenApiWorkspaceStreamTests { - private const string SampleFolderPath = "V3Tests/Samples/OpenApiWorkspace/"; - // Use OpenApiWorkspace to load a document and a referenced document [Fact] - public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoWorkspace() + public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoWorkspaceAsync() { // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new() @@ -35,8 +33,8 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW paths: {} """; var wr = new StreamWriter(stream); - wr.Write(doc); - wr.Flush(); + await wr.WriteAsync(doc); + await wr.FlushAsync(); stream.Position = 0; var result = await reader.ReadAsync(stream); @@ -45,7 +43,7 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW } [Fact] - public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWorkspace() + public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWorkspaceAsync() { // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new() @@ -95,7 +93,7 @@ public Stream Load(Uri uri) public Task LoadAsync(Uri uri) { - return null; + return Task.FromResult(null); } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index ad26b8288..9dd80c3da 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -99,7 +99,7 @@ public class OpenApiCallbackTests [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedCallbackAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedCallbackAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -116,7 +116,7 @@ public async Task SerializeAdvancedCallbackAsV3JsonWorks(bool produceTerseOutput [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedCallbackAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeReferencedCallbackAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -133,7 +133,7 @@ public async Task SerializeReferencedCallbackAsV3JsonWorks(bool produceTerseOutp [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) + public async Task SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index c9807f5a2..aa9433dfe 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1289,7 +1289,7 @@ public class OpenApiDocumentTests [Theory] [InlineData(false)] [InlineData(true)] - public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedDocumentAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1306,7 +1306,7 @@ public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1323,7 +1323,7 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorks(bool produ [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1340,7 +1340,7 @@ public async Task SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks(bool [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedDocumentAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedDocumentAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1357,7 +1357,7 @@ public async Task SerializeAdvancedDocumentAsV2JsonWorks(bool produceTerseOutput [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeDuplicateExtensionsAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeDuplicateExtensionsAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1374,7 +1374,7 @@ public async Task SerializeDuplicateExtensionsAsV3JsonWorks(bool produceTerseOut [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeDuplicateExtensionsAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeDuplicateExtensionsAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -1391,7 +1391,7 @@ public async Task SerializeDuplicateExtensionsAsV2JsonWorks(bool produceTerseOut [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs index a847016d0..8341ac4e9 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs @@ -102,7 +102,7 @@ public class OpenApiExampleTests [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedExampleAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedExampleAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -119,7 +119,7 @@ public async Task SerializeAdvancedExampleAsV3JsonWorks(bool produceTerseOutput) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedExampleAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeReferencedExampleAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -136,7 +136,7 @@ public async Task SerializeReferencedExampleAsV3JsonWorks(bool produceTerseOutpu [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedExampleAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) + public async Task SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs index 85316cf3b..f8ebfa95a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs @@ -42,7 +42,7 @@ public class OpenApiHeaderTests [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedHeaderAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedHeaderAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -59,7 +59,7 @@ public async Task SerializeAdvancedHeaderAsV3JsonWorks(bool produceTerseOutput) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedHeaderAsV3JsonWorks(bool produceTerseOutput) + public async Task SerializeReferencedHeaderAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -76,7 +76,7 @@ public async Task SerializeReferencedHeaderAsV3JsonWorks(bool produceTerseOutput [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) + public async Task SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -94,7 +94,7 @@ public async Task SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks(bool pr [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeAdvancedHeaderAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeAdvancedHeaderAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -111,7 +111,7 @@ public async Task SerializeAdvancedHeaderAsV2JsonWorks(bool produceTerseOutput) [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedHeaderAsV2JsonWorks(bool produceTerseOutput) + public async Task SerializeReferencedHeaderAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); @@ -128,7 +128,7 @@ public async Task SerializeReferencedHeaderAsV2JsonWorks(bool produceTerseOutput [Theory] [InlineData(true)] [InlineData(false)] - public async Task SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks(bool produceTerseOutput) + public async Task SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 511c6c5bd..8d0bb8cd5 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -452,7 +452,7 @@ public void ThrowsArgumentNullExceptionForNullArgumentInAddAdditionalDataMethod( } [Fact] - public async Task VerifyDiagramFromSampleOpenAPI() + public async Task VerifyDiagramFromSampleOpenAPIAsync() { var doc1 = OpenApiDocumentSample_1; @@ -461,7 +461,7 @@ public async Task VerifyDiagramFromSampleOpenAPI() var writer = new StringWriter(); rootNode.WriteMermaid(writer); - writer.Flush(); + await writer.FlushAsync(); var diagram = writer.GetStringBuilder().ToString(); await Verifier.Verify(diagram); diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index 686e3a08a..87fe6346a 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -201,7 +201,7 @@ public void WriteOpenApiBooleanAsJsonWorks(bool input, bool produceTerseOutput) [Theory] [InlineData(true)] [InlineData(false)] - public async Task WriteOpenApiObjectAsJsonWorks(bool produceTerseOutput) + public async Task WriteOpenApiObjectAsJsonWorksAsync(bool produceTerseOutput) { // Arrange var openApiObject = new OpenApiObject @@ -226,7 +226,7 @@ public async Task WriteOpenApiObjectAsJsonWorks(bool produceTerseOutput) [Theory] [InlineData(true)] [InlineData(false)] - public async Task WriteOpenApiArrayAsJsonWorks(bool produceTerseOutput) + public async Task WriteOpenApiArrayAsJsonWorksAsync(bool produceTerseOutput) { // Arrange var openApiObject = new OpenApiObject From 154d2017df6ef91c7cff54a1fa5ef0a69a0e1379 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 11:00:02 -0400 Subject: [PATCH 076/121] chore: renames unit tests comparison files to match --- ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 20 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 20 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 417 --------------- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 495 ------------------ ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 250 --------- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 296 ----------- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 417 --------------- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 68 --- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 75 --- ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 28 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 27 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 5 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 5 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...erifyDiagramFromSampleOpenAPI.verified.txt | 15 - ...DiagramFromSampleOpenAPIAsync.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 11 - ...Works_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 - ...Works_produceTerseOutput=True.verified.txt | 1 - 86 files changed, 43 insertions(+), 2203 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPI.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 8017028d1..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$request.body#/url": { - "post": { - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "responses": { - "200": { - "description": "Success" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 690cc5e9d..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 8017028d1..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$request.body#/url": { - "post": { - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "responses": { - "200": { - "description": "Success" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 690cc5e9d..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 8c9f1f140..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$ref": "#/components/callbacks/simpleHook" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 20e44f987..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$ref":"#/components/callbacks/simpleHook"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index a2e4fbd4c..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,417 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "query", - "name": "tags", - "description": "tags to filter by", - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "multi" - }, - { - "in": "query", - "name": "limit", - "description": "maximum number of results to return", - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json", - "text/html" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "produces": [ - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 081bcda08..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index a94db37b7..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,495 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "content": { - "application/json": { - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "application/xml": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 72106e400..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 443881617..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,250 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "query", - "name": "tags", - "description": "tags to filter by", - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "multi" - }, - { - "in": "query", - "name": "limit", - "description": "maximum number of results to return", - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/pet" - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "$ref": "#/definitions/errorModel" - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json", - "text/html" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "$ref": "#/definitions/newPet" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "$ref": "#/definitions/errorModel" - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "$ref": "#/definitions/pet" - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "$ref": "#/definitions/errorModel" - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "produces": [ - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "$ref": "#/definitions/errorModel" - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "$ref": "#/definitions/errorModel" - } - } - } - } - } - }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 3818a4799..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index f1da0b354..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,296 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/pet" - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/newPet" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/pet" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/pet" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/pet" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "$ref": "#/components/schemas/errorModel" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index be8dcc627..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}},"application/xml":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/newPet"}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}},"application/xml":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 1656b2bf7..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,417 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "host": "your-resource-name.openai.azure.com", - "basePath": "/openai", - "schemes": [ - "https" - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "query", - "name": "tags", - "description": "tags to filter by", - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "multi" - }, - { - "in": "query", - "name": "limit", - "description": "maximum number of results to return", - "type": "integer", - "format": "int32" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json", - "text/html" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "Pet to add to the store", - "required": true, - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to fetch", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "produces": [ - "text/html" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "description": "ID of pet to delete", - "required": true, - "type": "integer", - "format": "int64" - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "definitions": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "format": "int32", - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 3670fba11..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"your-resource-name.openai.azure.com","basePath":"/openai","schemes":["https"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 671c21ec5..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,68 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "version": "1.0.0" - }, - "host": "petstore.swagger.io", - "basePath": "/api", - "schemes": [ - "http" - ], - "paths": { - "/add/{operand1}/{operand2}": { - "get": { - "operationId": "addByOperand1AndByOperand2", - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "path", - "name": "operand1", - "description": "The first operand", - "required": true, - "type": "integer", - "my-extension": 4 - }, - { - "in": "path", - "name": "operand2", - "description": "The second operand", - "required": true, - "type": "integer", - "my-extension": 4 - } - ], - "responses": { - "200": { - "description": "pet response", - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "format": "int64", - "type": "integer" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 7dd31e201..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","produces":["application/json"],"parameters":[{"in":"path","name":"operand1","description":"The first operand","required":true,"type":"integer","my-extension":4},{"in":"path","name":"operand2","description":"The second operand","required":true,"type":"integer","my-extension":4}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index c2e9f5312..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,75 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/add/{operand1}/{operand2}": { - "get": { - "operationId": "addByOperand1AndByOperand2", - "parameters": [ - { - "name": "operand1", - "in": "path", - "description": "The first operand", - "required": true, - "schema": { - "type": "integer", - "my-extension": 4 - }, - "my-extension": 4 - }, - { - "name": "operand2", - "in": "path", - "description": "The second operand", - "required": true, - "schema": { - "type": "integer", - "my-extension": 4 - }, - "my-extension": 4 - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index da61a8817..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","parameters":[{"name":"operand1","in":"path","description":"The first operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4},{"name":"operand2","in":"path","description":"The second operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 44d48dd73..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,28 +0,0 @@ -{ - "value": { - "versions": [ - { - "status": "Status1", - "id": "v1", - "links": [ - { - "href": "http://example.com/1", - "rel": "sampleRel1", - "bytes": "AQID", - "binary": "Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ" - } - ] - }, - { - "status": "Status2", - "id": "v2", - "links": [ - { - "href": "http://example.com/2", - "rel": "sampleRel2" - } - ] - } - ] - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index c42b2a5ac..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1","bytes":"AQID","binary":"Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index bbe6f7e93..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,27 +0,0 @@ -{ - "value": { - "versions": [ - { - "status": "Status1", - "id": "v1", - "links": [ - { - "href": "http://example.com/1", - "rel": "sampleRel1" - } - ] - }, - { - "status": "Status2", - "id": "v2", - "links": [ - { - "href": "http://example.com/2", - "rel": "sampleRel2" - } - ] - } - ], - "aDate": "2022-12-12" - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index e84267af4..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}],"aDate":"2022-12-12"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 74aae72ef..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$ref": "#/components/examples/example1" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 12898c9c5..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$ref":"#/components/examples/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 5b0eb86be..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "sampleHeader", - "type": "integer", - "format": "int32" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 8feb99289..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 8234610e0..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -{ - "description": "sampleHeader", - "schema": { - "type": "integer", - "format": "int32" - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 37ebf2515..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 5b0eb86be..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "sampleHeader", - "type": "integer", - "format": "int32" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 8feb99289..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 9791d3c4a..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$ref": "#/headers/example1" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 58060ead9..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$ref":"#/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 8234610e0..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -{ - "description": "sampleHeader", - "schema": { - "type": "integer", - "format": "int32" - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 37ebf2515..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 18045b9d2..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "$ref": "#/components/headers/example1" -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 8c4124b8d..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"$ref":"#/components/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPI.verified.txt b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPI.verified.txt deleted file mode 100644 index c24dd943d..000000000 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPI.verified.txt +++ /dev/null @@ -1,15 +0,0 @@ -graph LR -classDef GET fill:lightSteelBlue,stroke:#333,stroke-width:2px -classDef POST fill:Lightcoral,stroke:#333,stroke-width:2px -classDef GET_POST fill:forestGreen,stroke:#333,stroke-width:2px -classDef DELETE_GET_PATCH fill:yellowGreen,stroke:#333,stroke-width:2px -classDef DELETE_GET_PATCH_PUT fill:oliveDrab,stroke:#333,stroke-width:2px -classDef DELETE_GET_PUT fill:olive,stroke:#333,stroke-width:2px -classDef DELETE_GET fill:DarkSeaGreen,stroke:#333,stroke-width:2px -classDef DELETE fill:Tomato,stroke:#333,stroke-width:2px -classDef OTHER fill:White,stroke:#333,stroke-width:2px -/["/"] --> /houses("houses") -class /houses GET_POST -/["/"] --> /cars>"cars"] -class /cars POST -class / GET diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 1a91b1047..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,11 +0,0 @@ -[ - false, - { - "stringProp": "stringValue1", - "objProp": { }, - "arrayProp": [ - false - ] - }, - "stringValue2" -] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index 75f913cf2..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -[false,{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]},"stringValue2"] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt deleted file mode 100644 index 1b6b4d799..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -{ - "stringProp": "stringValue1", - "objProp": { }, - "arrayProp": [ - false - ] -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt deleted file mode 100644 index c2132cb78..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]} \ No newline at end of file From 6322c0ed057cd9f5fd0f949434bb0de3597f912e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 11:07:46 -0400 Subject: [PATCH 077/121] fix: additional async APIs Signed-off-by: Vincent Biret --- .../OpenApiWriterAnyExtensionsTests.cs | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index 87fe6346a..6bc2c711b 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -23,12 +23,12 @@ public class OpenApiWriterAnyExtensionsTests [Theory] [InlineData(true)] [InlineData(false)] - public void WriteOpenApiNullAsJsonWorks(bool produceTerseOutput) + public async Task WriteOpenApiNullAsJsonWorksAsync(bool produceTerseOutput) { // Arrange var nullValue = new OpenApiNull(); - var json = WriteAsJson(nullValue, produceTerseOutput); + var json = await WriteAsJsonAsync(nullValue, produceTerseOutput); // Assert json.Should().Be("null"); @@ -51,12 +51,12 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(IntInputs))] - public void WriteOpenApiIntegerAsJsonWorks(int input, bool produceTerseOutput) + public async Task WriteOpenApiIntegerAsJsonWorksAsync(int input, bool produceTerseOutput) { // Arrange var intValue = new OpenApiInteger(input); - var json = WriteAsJson(intValue, produceTerseOutput); + var json = await WriteAsJsonAsync(intValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); @@ -79,12 +79,12 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(LongInputs))] - public void WriteOpenApiLongAsJsonWorks(long input, bool produceTerseOutput) + public async Task WriteOpenApiLongAsJsonWorksAsync(long input, bool produceTerseOutput) { // Arrange var longValue = new OpenApiLong(input); - var json = WriteAsJson(longValue, produceTerseOutput); + var json = await WriteAsJsonAsync(longValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); @@ -107,12 +107,12 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(FloatInputs))] - public void WriteOpenApiFloatAsJsonWorks(float input, bool produceTerseOutput) + public async Task WriteOpenApiFloatAsJsonWorksAsync(float input, bool produceTerseOutput) { // Arrange var floatValue = new OpenApiFloat(input); - var json = WriteAsJson(floatValue, produceTerseOutput); + var json = await WriteAsJsonAsync(floatValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); @@ -135,12 +135,12 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(DoubleInputs))] - public void WriteOpenApiDoubleAsJsonWorks(double input, bool produceTerseOutput) + public async Task WriteOpenApiDoubleAsJsonWorksAsync(double input, bool produceTerseOutput) { // Arrange var doubleValue = new OpenApiDouble(input); - var json = WriteAsJson(doubleValue, produceTerseOutput); + var json = await WriteAsJsonAsync(doubleValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); @@ -164,13 +164,13 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(StringifiedDateTimes))] - public void WriteOpenApiDateTimeAsJsonWorks(string inputString, bool produceTerseOutput) + public async Task WriteOpenApiDateTimeAsJsonWorksAsync(string inputString, bool produceTerseOutput) { // Arrange var input = DateTimeOffset.Parse(inputString, CultureInfo.InvariantCulture); var dateTimeValue = new OpenApiDateTime(input); - var json = WriteAsJson(dateTimeValue, produceTerseOutput); + var json = await WriteAsJsonAsync(dateTimeValue, produceTerseOutput); var expectedJson = "\"" + input.ToString("o") + "\""; // Assert @@ -187,12 +187,12 @@ from shouldBeTerse in shouldProduceTerseOutputValues [Theory] [MemberData(nameof(BooleanInputs))] - public void WriteOpenApiBooleanAsJsonWorks(bool input, bool produceTerseOutput) + public async Task WriteOpenApiBooleanAsJsonWorksAsync(bool input, bool produceTerseOutput) { // Arrange var boolValue = new OpenApiBoolean(input); - var json = WriteAsJson(boolValue, produceTerseOutput); + var json = await WriteAsJsonAsync(boolValue, produceTerseOutput); // Assert json.Should().Be(input.ToString().ToLower()); @@ -217,7 +217,7 @@ public async Task WriteOpenApiObjectAsJsonWorksAsync(bool produceTerseOutput) } }; - var actualJson = WriteAsJson(openApiObject, produceTerseOutput); + var actualJson = WriteAsJsonAsync(openApiObject, produceTerseOutput); // Assert await Verifier.Verify(actualJson).UseParameters(produceTerseOutput); @@ -249,17 +249,17 @@ public async Task WriteOpenApiArrayAsJsonWorksAsync(bool produceTerseOutput) new OpenApiString("stringValue2") }; - var actualJson = WriteAsJson(array, produceTerseOutput); + var actualJson = WriteAsJsonAsync(array, produceTerseOutput); // Assert await Verifier.Verify(actualJson).UseParameters(produceTerseOutput); } - private static string WriteAsJson(IOpenApiAny any, bool produceTerseOutput = false) + private static async Task WriteAsJsonAsync(IOpenApiAny any, bool produceTerseOutput = false) { // Arrange (continued) - var stream = new MemoryStream(); - IOpenApiWriter writer = new OpenApiJsonWriter( + using var stream = new MemoryStream(); + var writer = new OpenApiJsonWriter( new StreamWriter(stream), new() { Terse = produceTerseOutput }); @@ -268,7 +268,8 @@ private static string WriteAsJson(IOpenApiAny any, bool produceTerseOutput = fal stream.Position = 0; // Act - var value = new StreamReader(stream).ReadToEnd(); + using var sr = new StreamReader(stream); + var value = await sr.ReadToEndAsync(); if (any.AnyType is AnyType.Primitive or AnyType.Null) { From b5046351ccaee708ee6c93a35910508ed8241110 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 11:23:48 -0400 Subject: [PATCH 078/121] chore: additional update of validation files --- ...sync_produceTerseOutput=False.verified.txt | 21 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 21 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 4 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 418 ++++++++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...rks2_produceTerseOutput=False.verified.txt | 495 ----------------- ...orks2_produceTerseOutput=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 496 +++++++++++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 251 ++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 298 ++++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 418 ++++++++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 69 ++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 76 ++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 29 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 28 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 4 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 6 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 8 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 6 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 4 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 8 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 4 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...DiagramFromSampleOpenAPIAsync.verified.txt | 16 +- ...sync_produceTerseOutput=False.verified.txt | 12 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...iArrayAsJsonWorks_terse=False.verified.txt | 11 - ...piArrayAsJsonWorks_terse=True.verified.txt | 1 - ...sync_produceTerseOutput=False.verified.txt | 8 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- 109 files changed, 2266 insertions(+), 613 deletions(-) delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt delete mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..36135796e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,20 @@ - \ No newline at end of file +{ + "$request.body#/url": { + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..586f0ed17 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..36135796e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,20 @@ - \ No newline at end of file +{ + "$request.body#/url": { + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..586f0ed17 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..81907fcb2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,3 @@ - \ No newline at end of file +{ + "$ref": "#/components/callbacks/simpleHook" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..5d2495706 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$ref":"#/components/callbacks/simpleHook"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..bd0084a2b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,417 @@ - \ No newline at end of file +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..b82c2f263 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt deleted file mode 100644 index a94db37b7..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=False.verified.txt +++ /dev/null @@ -1,495 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore (Simple)", - "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", - "termsOfService": "http://helloreverb.com/terms/", - "contact": { - "name": "Swagger API team", - "url": "http://swagger.io", - "email": "foo@example.com" - }, - "license": { - "name": "MIT", - "url": "http://opensource.org/licenses/MIT" - }, - "version": "1.0.0" - }, - "servers": [ - { - "url": "http://petstore.swagger.io/api" - } - ], - "paths": { - "/pets": { - "get": { - "description": "Returns all pets from the system that the user has access to", - "operationId": "findPets", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "tags to filter by", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "limit", - "in": "query", - "description": "maximum number of results to return", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "post": { - "description": "Creates a new pet in the store. Duplicates are allowed", - "operationId": "addPet", - "requestBody": { - "description": "Pet to add to the store", - "content": { - "application/json": { - "schema": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - }, - "/pets/{id}": { - "get": { - "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to fetch", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "pet response", - "content": { - "application/json": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - }, - "application/xml": { - "schema": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - } - } - } - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - }, - "delete": { - "description": "deletes a single pet based on the ID supplied", - "operationId": "deletePet", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "ID of pet to delete", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "pet deleted" - }, - "4XX": { - "description": "unexpected client error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - }, - "5XX": { - "description": "unexpected server error", - "content": { - "text/html": { - "schema": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "pet": { - "required": [ - "id", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "newPet": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "errorModel": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt deleted file mode 100644 index 72106e400..000000000 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks2_produceTerseOutput=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..a94db37b7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,495 @@ - \ No newline at end of file +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..72106e400 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..d66a8f4c2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,250 @@ - \ No newline at end of file +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/pet" + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "$ref": "#/definitions/newPet" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "#/definitions/pet" + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "#/definitions/pet" + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..38ff58647 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..eb23d0c24 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,297 @@ - \ No newline at end of file +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "style": "form", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..01840772e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","style":"form","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}},"application/xml":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/newPet"}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}},"application/xml":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..1656b2bf7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,417 @@ - \ No newline at end of file +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "your-resource-name.openai.azure.com", + "basePath": "/openai", + "schemes": [ + "https" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..3670fba11 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"your-resource-name.openai.azure.com","basePath":"/openai","schemes":["https"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..e2a2dbbab 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,68 @@ - \ No newline at end of file +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/add/{operand1}/{operand2}": { + "get": { + "operationId": "addByOperand1AndByOperand2", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "operand1", + "description": "The first operand", + "required": true, + "type": "integer", + "my-extension": 4 + }, + { + "in": "path", + "name": "operand2", + "description": "The second operand", + "required": true, + "type": "integer", + "my-extension": 4 + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..49072fda2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","produces":["application/json"],"parameters":[{"in":"path","name":"operand1","description":"The first operand","required":true,"type":"integer","my-extension":4},{"in":"path","name":"operand2","description":"The second operand","required":true,"type":"integer","my-extension":4}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..26442924a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,75 @@ - \ No newline at end of file +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/add/{operand1}/{operand2}": { + "get": { + "operationId": "addByOperand1AndByOperand2", + "parameters": [ + { + "name": "operand1", + "in": "path", + "description": "The first operand", + "required": true, + "schema": { + "type": "integer", + "my-extension": 4 + }, + "my-extension": 4 + }, + { + "name": "operand2", + "in": "path", + "description": "The second operand", + "required": true, + "schema": { + "type": "integer", + "my-extension": 4 + }, + "my-extension": 4 + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..c5d124594 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","parameters":[{"name":"operand1","in":"path","description":"The first operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4},{"name":"operand2","in":"path","description":"The second operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..755152dc0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,28 @@ - \ No newline at end of file +{ + "value": { + "versions": [ + { + "status": "Status1", + "id": "v1", + "links": [ + { + "href": "http://example.com/1", + "rel": "sampleRel1", + "bytes": "AQID", + "binary": "Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ" + } + ] + }, + { + "status": "Status2", + "id": "v2", + "links": [ + { + "href": "http://example.com/2", + "rel": "sampleRel2" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..2fd0836a4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1","bytes":"AQID","binary":"Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..ba74d9125 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,27 @@ - \ No newline at end of file +{ + "value": { + "versions": [ + { + "status": "Status1", + "id": "v1", + "links": [ + { + "href": "http://example.com/1", + "rel": "sampleRel1" + } + ] + }, + { + "status": "Status2", + "id": "v2", + "links": [ + { + "href": "http://example.com/2", + "rel": "sampleRel2" + } + ] + } + ], + "aDate": "2022-12-12" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..bbc944fee 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}],"aDate":"2022-12-12"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..852a9bc0b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,3 @@ - \ No newline at end of file +{ + "$ref": "#/components/examples/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..41c47dfbc 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$ref":"#/components/examples/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..112b8c37f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,5 @@ - \ No newline at end of file +{ + "description": "sampleHeader", + "type": "integer", + "format": "int32" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..63c989200 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..6356b0527 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,7 @@ - \ No newline at end of file +{ + "description": "sampleHeader", + "schema": { + "type": "integer", + "format": "int32" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..7d0a160ce 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..112b8c37f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,5 @@ - \ No newline at end of file +{ + "description": "sampleHeader", + "type": "integer", + "format": "int32" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..63c989200 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..3c5b532f0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,3 @@ - \ No newline at end of file +{ + "$ref": "#/headers/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..4e1ff3605 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$ref":"#/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..6356b0527 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,7 @@ - \ No newline at end of file +{ + "description": "sampleHeader", + "schema": { + "type": "integer", + "format": "int32" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..7d0a160ce 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..5b44f6427 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,3 @@ - \ No newline at end of file +{ + "$ref": "#/components/headers/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..fc4d9c306 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"$ref":"#/components/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 2629e0b1c..6beea68d7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "operationId": "operationId1", "parameters": { "parameter1": "$request.path.id" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index c9c1701b5..d517845f1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file +{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 2629e0b1c..6beea68d7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "operationId": "operationId1", "parameters": { "parameter1": "$request.path.id" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index c9c1701b5..d517845f1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file +{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 26fe6229d..8e0fba2e8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/components/links/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 2200957a3..eb4e2d9a7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/links/example1"} \ No newline at end of file +{"$ref":"#/components/links/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt index 1c8e22a01..5d3060ec5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "name": "name1", "in": "query", "description": "description1", diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt index 73c77d79f..a4b87db10 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"name":"name1","in":"query","description":"description1","style":"form","explode":false,"schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file +{"name":"name1","in":"query","description":"description1","style":"form","explode":false,"schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt index 651da1cce..36a9c0168 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "name": "name1", "in": "query", "description": "description1", diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt index 579671130..206902b7b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"name":"name1","in":"query","description":"description1","style":"form","schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file +{"name":"name1","in":"query","description":"description1","style":"form","schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 744f8451c..82c260ad3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "in": "header", "name": "name1", "description": "description1", diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 26b158865..d96c5ec61 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file +{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 744f8451c..82c260ad3 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "in": "header", "name": "name1", "description": "description1", diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 26b158865..d96c5ec61 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file +{"in":"header","name":"name1","description":"description1","required":true,"type":"string","x-examples":{"test":{"summary":"summary3","description":"description3"}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 4127038e5..2be79d6af 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "in": "path", "name": "name1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 8677f0fad..228537b57 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"in":"path","name":"name1"} \ No newline at end of file +{"in":"path","name":"name1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index a9154d617..e4e3b52c5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/parameters/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 712d7ee78..2c9c105db 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/parameters/example1"} \ No newline at end of file +{"$ref":"#/parameters/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 5275532e8..b810c2bc0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "name": "name1", "in": "path" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index ec654beb0..9b65c4a88 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"name":"name1","in":"path"} \ No newline at end of file +{"name":"name1","in":"path"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 654239535..43aade4c4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/components/parameters/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 3d61cb3f8..dc6cfd29f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/parameters/example1"} \ No newline at end of file +{"$ref":"#/components/parameters/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index ccc8d3725..0f8d7659c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "description": "description", "content": { "application/json": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 31161c2f5..767ce7937 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file +{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index ccc8d3725..0f8d7659c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "description": "description", "content": { "application/json": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 31161c2f5..767ce7937 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file +{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index ca9bb966e..aaf06f563 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/components/requestBodies/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 443812023..557936985 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/requestBodies/example1"} \ No newline at end of file +{"$ref":"#/components/requestBodies/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index af5ce3ea5..2bc39b459 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "description": "A complex object array response", "schema": { "type": "array", diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index f9a3f9d5f..4917a08a6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"description":"A complex object array response","schema":{"type":"array","items":{"$ref":"#/definitions/customType"}},"headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","type":"integer"},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","type":"integer"}}} \ No newline at end of file +{"description":"A complex object array response","schema":{"type":"array","items":{"$ref":"#/definitions/customType"}},"headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","type":"integer"},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","type":"integer"}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index ea5aa0d40..c349731bf 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/responses/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index b2058cfd8..20e1f9783 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/responses/example1"} \ No newline at end of file +{"$ref":"#/responses/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 55bad289b..864f3daee 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "description": "A complex object array response", "headers": { "X-Rate-Limit-Limit": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 612fbe919..08b78d5bd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"description":"A complex object array response","headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","schema":{"type":"integer"}},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","schema":{"type":"integer"}}},"content":{"text/plain":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/customType"}}}}} \ No newline at end of file +{"description":"A complex object array response","headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","schema":{"type":"integer"}},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","schema":{"type":"integer"}}},"content":{"text/plain":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/customType"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 115ec60a6..2b7824755 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/components/responses/example1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index e65264a36..bbd27ff18 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/responses/example1"} \ No newline at end of file +{"$ref":"#/components/responses/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 19773c717..2a9b08f98 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "#/components/schemas/schemaObject1" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 34a933101..ca0ce704f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/schemas/schemaObject1"} \ No newline at end of file +{"$ref":"#/components/schemas/schemaObject1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt index 7a3aa9ce8..b431f1607 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "title": "title1", "multipleOf": 3, "maximum": 42, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt index f3407133d..d71a5f0a8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"title":"title1","multipleOf":3,"maximum":42,"minimum":10,"exclusiveMinimum":true,"type":"integer","default":15,"nullable":true,"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file +{"title":"title1","multipleOf":3,"maximum":42,"minimum":10,"exclusiveMinimum":true,"type":"integer","default":15,"nullable":true,"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 49aece921..9ab9fad6f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "title": "title1", "required": [ "property1" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 4777a425c..b0b24d295 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"title":"title1","required":["property1"],"properties":{"property1":{"required":["property3"],"properties":{"property2":{"type":"integer"},"property3":{"maxLength":15,"type":"string"}}},"property4":{"properties":{"property5":{"properties":{"property6":{"type":"boolean"}}},"property7":{"minLength":2,"type":"string"}},"readOnly":true}},"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file +{"title":"title1","required":["property1"],"properties":{"property1":{"required":["property3"],"properties":{"property2":{"type":"integer"},"property3":{"maxLength":15,"type":"string"}}},"property4":{"properties":{"property5":{"properties":{"property6":{"type":"boolean"}}},"property7":{"minLength":2,"type":"string"}},"readOnly":true}},"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 1de104df5..39613f3ae 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "type": "openIdConnect", "description": "description1", "openIdConnectUrl": "https://example.com/openIdConnect" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 5e7183dc8..717cba0a8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"type":"openIdConnect","description":"description1","openIdConnectUrl":"https://example.com/openIdConnect"} \ No newline at end of file +{"type":"openIdConnect","description":"description1","openIdConnectUrl":"https://example.com/openIdConnect"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 5bf57b219..e17924528 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,3 @@ -{ +{ "$ref": "sampleSecurityScheme" } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 04a9d3e76..3866a27aa 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"sampleSecurityScheme"} \ No newline at end of file +{"$ref":"sampleSecurityScheme"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 4e4df0f3b..2afa516e0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "name": "pet", "description": "Pets operations", "externalDocs": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 269fd9e7f..f0a901938 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file +{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 4e4df0f3b..2afa516e0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1,4 +1,4 @@ -{ +{ "name": "pet", "description": "Pets operations", "externalDocs": { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 269fd9e7f..f0a901938 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file +{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 6f31cf5a2..87b8ff218 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -{ } \ No newline at end of file +{ } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 9e26dfeeb..22fdca1b2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{} \ No newline at end of file +{} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt index 6f31cf5a2..87b8ff218 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -{ } \ No newline at end of file +{ } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index 9e26dfeeb..22fdca1b2 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{} \ No newline at end of file +{} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 8c38cc78d..d3d287dca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -"pet" \ No newline at end of file +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt index 5f282702b..c24dd943d 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.VerifyDiagramFromSampleOpenAPIAsync.verified.txt @@ -1 +1,15 @@ - \ No newline at end of file +graph LR +classDef GET fill:lightSteelBlue,stroke:#333,stroke-width:2px +classDef POST fill:Lightcoral,stroke:#333,stroke-width:2px +classDef GET_POST fill:forestGreen,stroke:#333,stroke-width:2px +classDef DELETE_GET_PATCH fill:yellowGreen,stroke:#333,stroke-width:2px +classDef DELETE_GET_PATCH_PUT fill:oliveDrab,stroke:#333,stroke-width:2px +classDef DELETE_GET_PUT fill:olive,stroke:#333,stroke-width:2px +classDef DELETE_GET fill:DarkSeaGreen,stroke:#333,stroke-width:2px +classDef DELETE fill:Tomato,stroke:#333,stroke-width:2px +classDef OTHER fill:White,stroke:#333,stroke-width:2px +/["/"] --> /houses("houses") +class /houses GET_POST +/["/"] --> /cars>"cars"] +class /cars POST +class / GET diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..1a91b1047 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,11 @@ - \ No newline at end of file +[ + false, + { + "stringProp": "stringValue1", + "objProp": { }, + "arrayProp": [ + false + ] + }, + "stringValue2" +] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..75f913cf2 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +[false,{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]},"stringValue2"] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt deleted file mode 100644 index 1a91b1047..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt +++ /dev/null @@ -1,11 +0,0 @@ -[ - false, - { - "stringProp": "stringValue1", - "objProp": { }, - "arrayProp": [ - false - ] - }, - "stringValue2" -] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt deleted file mode 100644 index 75f913cf2..000000000 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt +++ /dev/null @@ -1 +0,0 @@ -[false,{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]},"stringValue2"] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt index 5f282702b..c7812132a 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1 +1,7 @@ - \ No newline at end of file +{ + "stringProp": "stringValue1", + "objProp": { }, + "arrayProp": [ + false + ] +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt index 5f282702b..f9a0cd869 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ - \ No newline at end of file +{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]} \ No newline at end of file From 8c55d1e8b0c73874534ea8daff725f25334fe44c Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 28 Aug 2024 11:23:55 -0400 Subject: [PATCH 079/121] chore: tasks linting --- .../Services/OpenApiServiceTests.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 8d9d3ab09..a7ab42c03 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -382,24 +382,24 @@ public async Task TransformToPowerShellCompliantOpenApiAsync() } [Fact] - public void InvokeTransformCommand() + public async Task InvokeTransformCommandAsync() { var rootCommand = Program.CreateRootCommand(); var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml"); var args = new[] { "transform", "-d", openapi, "-o", "sample.json", "--co" }; var parseResult = rootCommand.Parse(args); - var handler = rootCommand.Subcommands.Where(c => c.Name == "transform").First().Handler; + var handler = rootCommand.Subcommands.First(c => c.Name == "transform").Handler; var context = new InvocationContext(parseResult); - handler!.Invoke(context); + await handler!.InvokeAsync(context); - var output = File.ReadAllText("sample.json"); + var output = await File.ReadAllTextAsync("sample.json"); Assert.NotEmpty(output); } [Fact] - public void InvokeShowCommand() + public async Task InvokeShowCommandAsync() { var rootCommand = Program.CreateRootCommand(); var openApi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml"); @@ -408,14 +408,14 @@ public void InvokeShowCommand() var handler = rootCommand.Subcommands.Where(c => c.Name == "show").First().Handler; var context = new InvocationContext(parseResult); - handler!.Invoke(context); + await handler!.InvokeAsync(context); - var output = File.ReadAllText("sample.md"); + var output = await File.ReadAllTextAsync("sample.md"); Assert.Contains("graph LR", output, StringComparison.Ordinal); } [Fact] - public void InvokePluginCommand() + public async Task InvokePluginCommandAsync() { var rootCommand = Program.CreateRootCommand(); var manifest = Path.Combine(".", "UtilityFiles", "exampleapimanifest.json"); @@ -424,9 +424,9 @@ public void InvokePluginCommand() var handler = rootCommand.Subcommands.Where(c => c.Name == "plugin").First().Handler; var context = new InvocationContext(parseResult); - handler!.Invoke(context); + await handler!.InvokeAsync(context); - using var jsDoc = JsonDocument.Parse(File.ReadAllText("ai-plugin.json")); + using var jsDoc = JsonDocument.Parse(await File.ReadAllTextAsync("ai-plugin.json")); var openAiManifest = OpenAIPluginManifest.Load(jsDoc.RootElement); Assert.NotNull(openAiManifest); From 4a2f20e8c59352ca533d9be2b11e997bad22b62c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 29 Aug 2024 11:59:30 +0300 Subject: [PATCH 080/121] Remove explicit pattern signature to enable signing of all binaries --- .azure-pipelines/ci-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 8a2e7ef18..6116e332f 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -87,8 +87,6 @@ extends: AuthCertName: 'ReferenceLibraryPrivateCert' AuthSignCertName: 'ReferencePackagePublisherCertificate' FolderPath: '$(Build.SourcesDirectory)\src' - Pattern: '*.dll' - UseMinimatch: true signConfigType: 'inlineSignParams' inlineOperation: | [ From cfc69cae3fb9eae97bfd90b51d916eb02ea1fdf8 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 29 Aug 2024 11:59:41 +0300 Subject: [PATCH 081/121] Add display names --- .azure-pipelines/ci-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 6116e332f..77e92b36a 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -79,6 +79,7 @@ extends: arguments: '--configuration $(BuildConfiguration) --no-build' - task: EsrpCodeSigning@5 + displayName: 'ESRP CodeSigning binaries' inputs: ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection' AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' @@ -144,6 +145,7 @@ extends: displayName: 'pack Hidi' - task: EsrpCodeSigning@5 + displayName: 'ESRP CodeSigning Nuget Packages' inputs: ConnectedServiceName: 'Federated DevX ESRP Managed Identity Connection' AppRegistrationClientId: '65035b7f-7357-4f29-bf25-c5ee5c3949f8' From c3f682ead6bd65fabf951d4126d1284465539fa2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 29 Aug 2024 16:45:40 +0300 Subject: [PATCH 082/121] Bump hidi and lib versions --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 8d1f4d393..21a7f677f 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.4.8 + 1.4.9 OpenAPI.NET CLI tool for slicing OpenAPI documents true diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index e8d33f8cd..0a517bbce 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.18 + 1.6.19 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 973c6b0d3..d889cc760 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.18 + 1.6.19 .NET models with JSON and YAML writers for OpenAPI specification true From 93bd0b97e0bfd3ec57702099f9fbdc8b6a1b9bb2 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 29 Aug 2024 17:20:14 +0300 Subject: [PATCH 083/121] Copy over references for all IOpenApiReferenceable objects --- .../Services/CopyReferences.cs | 122 +++++++++++++----- 1 file changed, 90 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index 757471466..d9414f803 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -26,8 +26,8 @@ public override void Visit(IOpenApiReferenceable referenceable) switch (referenceable) { case OpenApiSchema schema: - EnsureComponentsExists(); - EnsureSchemasExists(); + EnsureComponentsExist(); + EnsureSchemasExist(); if (!Components.Schemas.ContainsKey(schema.Reference.Id)) { Components.Schemas.Add(schema.Reference.Id, schema); @@ -35,8 +35,8 @@ public override void Visit(IOpenApiReferenceable referenceable) break; case OpenApiParameter parameter: - EnsureComponentsExists(); - EnsureParametersExists(); + EnsureComponentsExist(); + EnsureParametersExist(); if (!Components.Parameters.ContainsKey(parameter.Reference.Id)) { Components.Parameters.Add(parameter.Reference.Id, parameter); @@ -44,8 +44,8 @@ public override void Visit(IOpenApiReferenceable referenceable) break; case OpenApiResponse response: - EnsureComponentsExists(); - EnsureResponsesExists(); + EnsureComponentsExist(); + EnsureResponsesExist(); if (!Components.Responses.ContainsKey(response.Reference.Id)) { Components.Responses.Add(response.Reference.Id, response); @@ -53,15 +53,60 @@ public override void Visit(IOpenApiReferenceable referenceable) break; case OpenApiRequestBody requestBody: - EnsureComponentsExists(); - EnsureResponsesExists(); - EnsurRequestBodiesExists(); + EnsureComponentsExist(); + EnsureResponsesExist(); + EnsureRequestBodiesExist(); if (!Components.RequestBodies.ContainsKey(requestBody.Reference.Id)) { Components.RequestBodies.Add(requestBody.Reference.Id, requestBody); } break; + case OpenApiExample example: + EnsureComponentsExist(); + EnsureExamplesExist(); + if (!Components.Examples.ContainsKey(example.Reference.Id)) + { + Components.Examples.Add(example.Reference.Id, example); + } + break; + + case OpenApiHeader header: + EnsureComponentsExist(); + EnsureHeadersExist(); + if (!Components.Headers.ContainsKey(header.Reference.Id)) + { + Components.Headers.Add(header.Reference.Id, header); + } + break; + + case OpenApiCallback callback: + EnsureComponentsExist(); + EnsureCallbacksExist(); + if (!Components.Callbacks.ContainsKey(callback.Reference.Id)) + { + Components.Callbacks.Add(callback.Reference.Id, callback); + } + break; + + case OpenApiLink link: + EnsureComponentsExist(); + EnsureLinksExist(); + if (!Components.Links.ContainsKey(link.Reference.Id)) + { + Components.Links.Add(link.Reference.Id, link); + } + break; + + case OpenApiSecurityScheme securityScheme: + EnsureComponentsExist(); + EnsureSecuritySchemesExist(); + if (!Components.SecuritySchemes.ContainsKey(securityScheme.Reference.Id)) + { + Components.SecuritySchemes.Add(securityScheme.Reference.Id, securityScheme); + } + break; + default: break; } @@ -77,8 +122,8 @@ public override void Visit(OpenApiSchema schema) // This is needed to handle schemas used in Responses in components if (schema.Reference != null) { - EnsureComponentsExists(); - EnsureSchemasExists(); + EnsureComponentsExist(); + EnsureSchemasExist(); if (!Components.Schemas.ContainsKey(schema.Reference.Id)) { Components.Schemas.Add(schema.Reference.Id, schema); @@ -87,41 +132,54 @@ public override void Visit(OpenApiSchema schema) base.Visit(schema); } - private void EnsureComponentsExists() + private void EnsureComponentsExist() { - if (_target.Components == null) - { - _target.Components = new(); - } + _target.Components ??= new(); } - private void EnsureSchemasExists() + private void EnsureSchemasExist() { - if (_target.Components.Schemas == null) - { - _target.Components.Schemas = new Dictionary(); - } + _target.Components.Schemas ??= new Dictionary(); } - private void EnsureParametersExists() + private void EnsureParametersExist() { - if (_target.Components.Parameters == null) - { - _target.Components.Parameters = new Dictionary(); - } + _target.Components.Parameters ??= new Dictionary(); } - private void EnsureResponsesExists() + private void EnsureResponsesExist() { - if (_target.Components.Responses == null) - { - _target.Components.Responses = new Dictionary(); - } + _target.Components.Responses ??= new Dictionary(); } - private void EnsurRequestBodiesExists() + private void EnsureRequestBodiesExist() { _target.Components.RequestBodies ??= new Dictionary(); } + + private void EnsureExamplesExist() + { + _target.Components.Examples ??= new Dictionary(); + } + + private void EnsureHeadersExist() + { + _target.Components.Headers ??= new Dictionary(); + } + + private void EnsureCallbacksExist() + { + _target.Components.Callbacks ??= new Dictionary(); + } + + private void EnsureLinksExist() + { + _target.Components.Callbacks ??= new Dictionary(); + } + + private void EnsureSecuritySchemesExist() + { + _target.Components.Callbacks ??= new Dictionary(); + } } } From 269c1c72cb00fa713c6f363d0e8d60be612948af Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 29 Aug 2024 17:24:03 +0300 Subject: [PATCH 084/121] Clean up --- src/Microsoft.OpenApi/Services/CopyReferences.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index d9414f803..b4cc396cb 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -174,12 +174,12 @@ private void EnsureCallbacksExist() private void EnsureLinksExist() { - _target.Components.Callbacks ??= new Dictionary(); + _target.Components.Links ??= new Dictionary(); } private void EnsureSecuritySchemesExist() { - _target.Components.Callbacks ??= new Dictionary(); + _target.Components.SecuritySchemes ??= new Dictionary(); } } } From 82224967e68c53dcf3ba855005616e576c8c3d05 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 30 Aug 2024 11:59:12 +0300 Subject: [PATCH 085/121] Add all Referenceable objects to the subset doc --- .../Services/OpenApiFilterService.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 92051949b..fcc2af0b2 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -278,6 +278,42 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon moreStuff = true; target.RequestBodies.Add(item); } + + foreach (var item in newComponents.Headers + .Where(item => !target.Headers.ContainsKey(item.Key))) + { + moreStuff = true; + target.Headers.Add(item); + } + + foreach (var item in newComponents.Links + .Where(item => !target.Links.ContainsKey(item.Key))) + { + moreStuff = true; + target.Links.Add(item); + } + + foreach (var item in newComponents.Callbacks + .Where(item => !target.Callbacks.ContainsKey(item.Key))) + { + moreStuff = true; + target.Callbacks.Add(item); + } + + foreach (var item in newComponents.Examples + .Where(item => !target.Examples.ContainsKey(item.Key))) + { + moreStuff = true; + target.Examples.Add(item); + } + + foreach (var item in newComponents.SecuritySchemes + .Where(item => !target.SecuritySchemes.ContainsKey(item.Key))) + { + moreStuff = true; + target.SecuritySchemes.Add(item); + } + return moreStuff; } From 6db021654ac61de6c12629d891572256b2dfd903 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 30 Aug 2024 12:00:04 +0300 Subject: [PATCH 086/121] Add test --- .../Services/CopyReferences.cs | 1 + .../Microsoft.OpenApi.Hidi.Tests.csproj | 8 +- .../Services/OpenApiFilterServiceTests.cs | 29 +++++++ .../docWithReusableHeadersAndExamples.yaml | 79 +++++++++++++++++++ 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index b4cc396cb..73bb667b6 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -110,6 +110,7 @@ public override void Visit(IOpenApiReferenceable referenceable) default: break; } + base.Visit(referenceable); } 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 f5958e5b6..75c176305 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -34,4 +34,10 @@ + + + PreserveNewest + + + diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 5fb1b15f9..ac566bf0d 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -3,9 +3,11 @@ using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Tests.UtilityFiles; using Moq; +using SharpYaml.Tokens; using Xunit; namespace Microsoft.OpenApi.Hidi.Tests @@ -170,6 +172,33 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2); } + [Fact] + public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "docWithReusableHeadersAndExamples.yaml"); + var operationIds = "getItems"; + + // Act + using var stream = File.OpenRead(filePath); + var doc = new OpenApiStreamReader().Read(stream, out var diagnostic); + + var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); + + var response = subsetOpenApiDocument.Paths["/items"].Operations[OperationType.Get].Responses["200"]; + var responseHeader = response.Headers["x-custom-header"]; + var mediaTypeExample = response.Content["application/json"].Examples.First().Value; + var targetHeaders = subsetOpenApiDocument.Components.Headers; + var targetExamples = subsetOpenApiDocument.Components.Examples; + + // Assert + Assert.False(responseHeader.UnresolvedReference); + Assert.False(mediaTypeExample.UnresolvedReference); + Assert.Single(targetHeaders); + Assert.Single(targetExamples); + } + [Theory] [InlineData("reports.getTeamsUserActivityUserDetail-a3f1", null)] [InlineData(null, "reports.Functions")] diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml new file mode 100644 index 000000000..2f86d7661 --- /dev/null +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml @@ -0,0 +1,79 @@ +openapi: 3.0.1 +info: + title: Example with Multiple Operations and Local $refs + version: 1.0.0 +paths: + /items: + get: + operationId: getItems + summary: Get a list of items + responses: + '200': + description: A list of items + headers: + x-custom-header: + $ref: '#/components/headers/CustomHeader' + content: + application/json: + schema: + type: array + items: + type: string + examples: + ItemExample: + $ref: '#/components/examples/ItemExample' + post: + operationId: createItem + summary: Create a new item + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + example: + $ref: '#/components/examples/ItemExample' + responses: + '201': + description: Item created + content: + application/json: + schema: + type: object + properties: + id: + type: string + name: + type: string + example: + $ref: '#/components/examples/ItemExample' +components: + schemas: + pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + headers: + CustomHeader: + description: Custom header for authentication + required: true + schema: + type: string + examples: + ItemExample: + summary: Example of a new item to be created + value: + name: "New Item" + From a155a0ca209fb202660168bbf0ce7efd03a2010c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 30 Aug 2024 13:11:20 +0300 Subject: [PATCH 087/121] Add server info --- .../UtilityFiles/docWithReusableHeadersAndExamples.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml index 2f86d7661..3260ea430 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml +++ b/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/docWithReusableHeadersAndExamples.yaml @@ -2,6 +2,8 @@ openapi: 3.0.1 info: title: Example with Multiple Operations and Local $refs version: 1.0.0 +servers: +- url: https://api.github.com paths: /items: get: From e94ea23b7f50e42c90bc1d0ead56ba527d6f1505 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Fri, 30 Aug 2024 13:12:07 +0300 Subject: [PATCH 088/121] Compare the source document's server to that of the resulting subset document for equality --- .../Services/OpenApiFilterServiceTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index ac566bf0d..f91d0db93 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -193,6 +193,7 @@ public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly() var targetExamples = subsetOpenApiDocument.Components.Examples; // Assert + Assert.Same(doc.Servers, subsetOpenApiDocument.Servers); Assert.False(responseHeader.UnresolvedReference); Assert.False(mediaTypeExample.UnresolvedReference); Assert.Single(targetHeaders); From b67e0d7dc478db6b1e632d785fb57eaeae4b72ac Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 30 Aug 2024 08:52:58 -0400 Subject: [PATCH 089/121] fix: directly adds non-vulnerable versions of transitive deps to resolve alerts --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++++ .../Microsoft.OpenApi.Workbench.csproj | 2 ++ .../Microsoft.OpenApi.Readers.Tests.csproj | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 21a7f677f..ee760451f 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -39,6 +39,10 @@ + + diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 4379c7595..0e7205ef0 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -10,6 +10,8 @@ + + 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 3b6f7c76e..ebb063101 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -23,6 +23,8 @@ + + From 7995db95d82686d9eff0e6c6dd18545dda802450 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 30 Aug 2024 14:28:28 -0400 Subject: [PATCH 090/121] ci: upgrades outdated nuget installer task --- .azure-pipelines/ci-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 77e92b36a..f381a4303 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -57,10 +57,10 @@ extends: version: 8.x # Install the nuget tool. - - task: NuGetToolInstaller@0 - displayName: 'Use NuGet >=5.2.0' + - task: NuGetToolInstaller@1 + displayName: 'Use NuGet >=6.11.0' inputs: - versionSpec: '>=5.2.0' + versionSpec: '>=6.11.0' checkLatest: true # Build the Product project From 1f3c5711b4bcdbe9509a401c6734fefeb72261b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 31 Aug 2024 06:51:58 +0300 Subject: [PATCH 091/121] Bump Verify.Xunit from 26.2.0 to 26.3.0 (#1808) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.2.0 to 26.3.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.2.0...26.3.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 081f70390..6d5e1ad49 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From af22a8d9db355c7dd5f5e6e4bf435fd4a558c7fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 08:20:42 +0300 Subject: [PATCH 092/121] Bump Verify.Xunit from 26.3.0 to 26.3.1 (#1811) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.3.0 to 26.3.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.3.0...26.3.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 6d5e1ad49..ce9425dbc 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From cf4201cad806e49b89f3f7c5d7a74f4b2c29748b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:27:42 +0000 Subject: [PATCH 093/121] Bump Moq from 4.20.70 to 4.20.71 Bumps [Moq](https://github.com/moq/moq) from 4.20.70 to 4.20.71. - [Release notes](https://github.com/moq/moq/releases) - [Changelog](https://github.com/devlooped/moq/blob/main/changelog.md) - [Commits](https://github.com/moq/moq/compare/v4.20.70...v4.20.71) --- updated-dependencies: - dependency-name: Moq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 75c176305..a0689b473 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index ce9425dbc..9c91a65ab 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -12,7 +12,7 @@ - + From e85dfd0d8a12183a81e353c9b19b55cb8d5c9ea0 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 4 Sep 2024 12:39:44 +0300 Subject: [PATCH 094/121] Remove empty list initialization --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 5 ++--- src/Microsoft.OpenApi/Models/OpenApiOperation.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 201b321f1..745bb3cdb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -48,8 +48,7 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenAp /// /// A declaration of which security mechanisms can be used across the API. /// - public IList SecurityRequirements { get; set; } = - new List(); + public IList SecurityRequirements { get; set; } /// /// A list of tags used by the specification with additional metadata. diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 69054740e..e4bf5cc39 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -91,7 +91,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenA /// 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(); + public IList Security { get; set; } /// /// An alternative server array to service this operation. From 18d99e6ebd2425a1196a886a740bfbd61ac2fca7 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 4 Sep 2024 12:40:15 +0300 Subject: [PATCH 095/121] Add tests --- .../V3Tests/OpenApiDocumentTests.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index bb3db096f..a0bfa7c80 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -10,6 +10,7 @@ using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.Interface; @@ -1432,5 +1433,65 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail() diagnostic.Errors.Should().NotBeEmpty(); } + + [Fact] + public void ParseDocumentWithMissingSecuritySchemeDefaultsToNull() + { + // Arrange + var input = @"openapi: 3.0.0 +info: + title: test + version: ""1.0"" +paths: + /test: + get: + description: description for test path + responses: + '200': + description: test +components: + securitySchemes: + apiKey0: + type: apiKey, + name: x-api-key, + in: header"; + + // Act && Assert + var doc = new OpenApiStringReader().Read(input, out var diagnostic); + + doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeNull(); + doc.SecurityRequirements.Should().BeNull(); + } + + [Fact] + public void ParseDocumentWithEmptySecuritySchemeDefaultsToEmptyList() + { + // Arrange + var input = @"openapi: 3.0.0 +info: + title: test + version: ""1.0"" +paths: + /test: + get: + description: description for test path + responses: + '200': + description: test + security: [] +security: +- apiKey0: [] +components: + securitySchemes: + apiKey0: + type: apiKey, + name: x-api-key, + in: header"; + + // Act && Assert + var doc = new OpenApiStringReader().Read(input, out var diagnostic); + + doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeEmpty(); + } } } From 7143cd385df4dbe84e199ecfefe18d596fe15097 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 4 Sep 2024 12:57:36 +0300 Subject: [PATCH 096/121] Disable VisualStudio.Threading analyzers to eliminate build failures for dependent projects --- .../Microsoft.OpenApi.Readers.csproj | 9 ++++++++- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 0a517bbce..7768e3a89 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.19 + 1.6.20 OpenAPI.NET Readers for JSON and YAML documents true @@ -22,6 +22,13 @@ + + + + + + + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index d889cc760..5db722570 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.19 + 1.6.20 .NET models with JSON and YAML writers for OpenAPI specification true @@ -39,4 +39,11 @@ + + + + + + + From 693d3e389c3a942eb61621c64b27b3a64addcb45 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 4 Sep 2024 15:38:45 +0300 Subject: [PATCH 097/121] Use privateAssets setting to control dependency assets --- .../Microsoft.OpenApi.Readers.csproj | 12 ++++-------- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 11 +++-------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 7768e3a89..83bc1be2e 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -18,17 +18,13 @@ - + + all + + - - - - - - - diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 5db722570..61680a879 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -37,13 +37,8 @@ - + + all + - - - - - - - From 456914ffaeb632049139cbc9885abd47536b7216 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 4 Sep 2024 11:48:11 -0400 Subject: [PATCH 098/121] fix: uses the correct threading dependency to avoid impacting downstream projects Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 5 ++++- .../Microsoft.OpenApi.Readers.csproj | 6 ++++-- .../Microsoft.OpenApi.Workbench.csproj | 5 ++++- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 5 +++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ee760451f..120210fb0 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -33,7 +33,10 @@ - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 83bc1be2e..5a3ba13b4 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -18,8 +18,10 @@ - - all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 0e7205ef0..5545dc84f 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -8,7 +8,10 @@ true - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 61680a879..4e0757257 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -37,8 +37,9 @@ - - all + + runtime; build; native; contentfiles; analyzers; buildtransitive + all From 7c7c25e8d6f98ad747b4c88de2c7fd8d39d04331 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 5 Sep 2024 12:49:03 +0300 Subject: [PATCH 099/121] Revert security array initialization to avoid a breaking change --- .../Models/OpenApiDocument.cs | 2 +- .../Models/OpenApiOperation.cs | 2 +- .../V3Tests/OpenApiDocumentTests.cs | 60 ------------------- 3 files changed, 2 insertions(+), 62 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 745bb3cdb..1a7035793 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -48,7 +48,7 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenAp /// /// A declaration of which security mechanisms can be used across the API. /// - public IList SecurityRequirements { get; set; } + public IList SecurityRequirements { get; set; } = new List(); /// /// A list of tags used by the specification with additional metadata. diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index e4bf5cc39..69054740e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -91,7 +91,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenA /// 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; } + public IList Security { get; set; } = new List(); /// /// An alternative server array to service this operation. diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index a0bfa7c80..7ce9c0964 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -1433,65 +1433,5 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail() diagnostic.Errors.Should().NotBeEmpty(); } - - [Fact] - public void ParseDocumentWithMissingSecuritySchemeDefaultsToNull() - { - // Arrange - var input = @"openapi: 3.0.0 -info: - title: test - version: ""1.0"" -paths: - /test: - get: - description: description for test path - responses: - '200': - description: test -components: - securitySchemes: - apiKey0: - type: apiKey, - name: x-api-key, - in: header"; - - // Act && Assert - var doc = new OpenApiStringReader().Read(input, out var diagnostic); - - doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeNull(); - doc.SecurityRequirements.Should().BeNull(); - } - - [Fact] - public void ParseDocumentWithEmptySecuritySchemeDefaultsToEmptyList() - { - // Arrange - var input = @"openapi: 3.0.0 -info: - title: test - version: ""1.0"" -paths: - /test: - get: - description: description for test path - responses: - '200': - description: test - security: [] -security: -- apiKey0: [] -components: - securitySchemes: - apiKey0: - type: apiKey, - name: x-api-key, - in: header"; - - // Act && Assert - var doc = new OpenApiStringReader().Read(input, out var diagnostic); - - doc.Paths["/test"].Operations[OperationType.Get].Security.Should().BeEmpty(); - } } } From 7a6f1f7c20dfa9e3354f2216bd62973cfbd5812f Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Thu, 5 Sep 2024 17:08:55 +0300 Subject: [PATCH 100/121] Bump lib versions --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 5a3ba13b4..d33f8a942 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.20 + 1.6.21 OpenAPI.NET Readers for JSON and YAML documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 4e0757257..703291eb4 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.20 + 1.6.21 .NET models with JSON and YAML writers for OpenAPI specification true From 6fd6884eb2791d245d40ec23e1ea341f17600242 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:58:34 +0300 Subject: [PATCH 101/121] Bump Verify.Xunit from 26.3.1 to 26.4.0 (#1825) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.3.1 to 26.4.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.3.1...26.4.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 9c91a65ab..fb957a114 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 102c705dc96a46d4dd5a79eec0d7a2d4207daeba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:59:23 +0300 Subject: [PATCH 102/121] Bump Microsoft.NET.Test.Sdk from 17.11.0 to 17.11.1 (#1824) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.11.0 to 17.11.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.11.0...v17.11.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 a0689b473..5e2c6c882 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -12,7 +12,7 @@ - + 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 ebb063101..b5774a743 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index fb957a114..70410d82d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -11,7 +11,7 @@ - + From 82707adc69152b92a3cf10d795f8605778acb7b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:09:32 +0000 Subject: [PATCH 103/121] Bump Moq from 4.20.71 to 4.20.72 Bumps [Moq](https://github.com/moq/moq) from 4.20.71 to 4.20.72. - [Release notes](https://github.com/moq/moq/releases) - [Changelog](https://github.com/devlooped/moq/blob/main/changelog.md) - [Commits](https://github.com/moq/moq/compare/v4.20.71...v4.20.72) --- updated-dependencies: - dependency-name: Moq dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 5e2c6c882..82af1d032 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 70410d82d..dace40c9b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -12,7 +12,7 @@ - + From ba426af3c5d45ba0d5a5c9c99600c65c1ba6d015 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 06:11:47 +0000 Subject: [PATCH 104/121] Bump Verify.Xunit from 26.4.0 to 26.4.4 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.4.0 to 26.4.4. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.4.0...26.4.4) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index dace40c9b..148448d83 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From b9d206824547a858dd48846b8bb0b557946bf80e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 06:11:56 +0000 Subject: [PATCH 105/121] Bump FluentAssertions from 6.12.0 to 6.12.1 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.12.0 to 6.12.1. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.12.0...6.12.1) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 b5774a743..c08018d50 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index dace40c9b..b8a4c56e0 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -10,7 +10,7 @@ - + From eb332998133b25aab6431fc27942d3ff9872a89b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:27:14 +0300 Subject: [PATCH 106/121] Bump Verify.Xunit from 26.4.4 to 26.4.5 (#1831) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.4.4 to 26.4.5. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.4.4...26.4.5) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index a9894a8cb..fb00411c1 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 2e6b4b5d38c5ea4b238bfe6405387cc877adcfef Mon Sep 17 00:00:00 2001 From: "microsoft-github-policy-service[bot]" <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:31:41 +0300 Subject: [PATCH 107/121] Updated for https://dev.azure.com/microsoftgraph/0985d294-5762-4bc2-a565-161ef349ca3e/_build?definitionId=107 by using baselines generated in https://dev.azure.com/microsoftgraph/0985d294-5762-4bc2-a565-161ef349ca3e/_build/results?buildId=163394 (#1832) Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> --- .config/1espt/PipelineAutobaseliningConfig.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .config/1espt/PipelineAutobaseliningConfig.yml diff --git a/.config/1espt/PipelineAutobaseliningConfig.yml b/.config/1espt/PipelineAutobaseliningConfig.yml new file mode 100644 index 000000000..2425160a4 --- /dev/null +++ b/.config/1espt/PipelineAutobaseliningConfig.yml @@ -0,0 +1,15 @@ +## DO NOT MODIFY THIS FILE MANUALLY. This is part of auto-baselining from 1ES Pipeline Templates. Go to [https://aka.ms/1espt-autobaselining] for more details. + +pipelines: + 107: + usedNonDefaultBranch: true + retail: + source: + credscan: + lastModifiedDate: 2024-09-13 + eslint: + lastModifiedDate: 2024-09-13 + psscriptanalyzer: + lastModifiedDate: 2024-09-13 + armory: + lastModifiedDate: 2024-09-13 From 97e43b620ec3418ae210d2c85e7bb7c1437dac61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:53:42 +0300 Subject: [PATCH 108/121] Bump Verify.Xunit from 26.4.5 to 26.5.0 (#1834) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.4.5 to 26.5.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.4.5...26.5.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index fb00411c1..f6a1e304b 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From e18748fa264cfd01dd817468ad3b8b374c7d3bc3 Mon Sep 17 00:00:00 2001 From: chelkyl <14041823+chelkyl@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:04:15 -0500 Subject: [PATCH 109/121] Align on backslashes Co-authored-by: John L. Armstrong IV --- src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs | 2 +- .../Services/OpenApiUrlTreeNodeTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 425250fc9..e70f129b9 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -155,7 +155,7 @@ public OpenApiUrlTreeNode Attach(string path, // Remove the last element, which is empty, and append the trailing slash to the new last element // This is to support URLs with trailing slashes Array.Resize(ref segments, segments.Length - 1); - segments[segments.Length - 1] += "/"; + segments[segments.Length - 1] += @"\"; } return Attach(segments: segments, diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 4760cf37a..8a6f21dd8 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -470,8 +470,8 @@ public async Task VerifyDiagramFromSampleOpenAPI() public static TheoryData SupportsTrailingSlashesInPathData => new TheoryData { // Path, children up to second to leaf, last expected leaf node name, expected leaf node path - { "/cars/{car-id}/build/", ["cars", "{car-id}"], "build/", @"\cars\{car-id}\build/" }, - { "/cars/", [], "cars/", @"\cars/" }, + { "/cars/{car-id}/build/", ["cars", "{car-id}"], @"build\", @"\cars\{car-id}\build\" }, + { "/cars/", [], @"cars\", @"\cars\" }, }; [Theory] From 5b22ef498b7070c5d0dee949ed19a20fab03ab38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:27:26 +0000 Subject: [PATCH 110/121] Bump Verify.Xunit from 26.5.0 to 26.6.0 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 26.5.0 to 26.6.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/26.5.0...26.6.0) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index f6a1e304b..d39142e56 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From def1b87901457884e78930ed9d48510ec42e0fea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:12:55 +0000 Subject: [PATCH 111/121] Bump xunit from 2.9.0 to 2.9.1 Bumps [xunit](https://github.com/xunit/xunit) from 2.9.0 to 2.9.1. - [Commits](https://github.com/xunit/xunit/compare/2.9.0...2.9.1) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 82af1d032..c5f7d9ee8 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -15,7 +15,7 @@ - + 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 c08018d50..612a08aa8 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index d39142e56..1cd95210d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From 8c0cf477256971db83e1d55cd620a73e12a45653 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 27 Sep 2024 11:35:14 +0300 Subject: [PATCH 112/121] Bump lib versions --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 120210fb0..377f67995 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -9,7 +9,7 @@ enable hidi ./../../artifacts - 1.4.9 + 1.4.10 OpenAPI.NET CLI tool for slicing OpenAPI documents true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 703291eb4..eb0ee6b12 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.21 + 1.6.22 .NET models with JSON and YAML writers for OpenAPI specification true From f7f184dc40689fd803515f8b39aaef5ad73d4a88 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 27 Sep 2024 11:35:46 +0300 Subject: [PATCH 113/121] Update test --- .../Services/OpenApiFilterServiceTests.cs | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index f91d0db93..ebb863461 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using Microsoft.Extensions.Logging; @@ -105,6 +105,57 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() Assert.False(predicate("/foo", OperationType.Patch, null)); } + [Fact] + public void CreateFilteredDocumentUsingPredicateFromRequestUrl() + { + // Arrange + var openApiDocument = new OpenApiDocument + { + Info = new() { Title = "Test", Version = "1.0" }, + Servers = new List { new() { Url = "https://localhost/" } }, + Paths = new() + { + ["/test/{id}"] = new() + { + Operations = new Dictionary + { + { OperationType.Get, new() }, + { OperationType.Patch, new() } + }, + Parameters = new List + { + new() + { + Name = "id", + In = ParameterLocation.Path, + Required = true, + Schema = new() + { + Type = "string" + } + } + } + } + + + } + }; + + var requestUrls = new Dictionary> + { + {"/test/{id}", new List {"GET","PATCH"}} + }; + + // Act + var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: openApiDocument); + var subsetDoc = OpenApiFilterService.CreateFilteredDocument(openApiDocument, predicate); + + // Assert that there's only 1 parameter in the subset document + Assert.NotNull(subsetDoc); + Assert.NotEmpty(subsetDoc.Paths); + Assert.Single(subsetDoc.Paths.First().Value.Parameters); + } + [Fact] public void ShouldParseNestedPostmanCollection() { From c2d3f997e649a12b7dd185f48680dc1468dc7d73 Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Fri, 27 Sep 2024 11:36:14 +0300 Subject: [PATCH 114/121] Ensure unique parameters are added --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index fcc2af0b2..bd351ce0e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -112,7 +112,10 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun { foreach (var parameter in result.Parameters) { - pathItem.Parameters.Add(parameter); + if (!pathItem.Parameters.Contains(parameter)) + { + pathItem.Parameters.Add(parameter); + } } } } From d88a0606e4101ddf8b318d1671d71398140dae28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:18:28 +0000 Subject: [PATCH 115/121] Bump xunit from 2.9.1 to 2.9.2 Bumps [xunit](https://github.com/xunit/xunit) from 2.9.1 to 2.9.2. - [Commits](https://github.com/xunit/xunit/compare/v2-2.9.1...v2-2.9.2) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Hidi.Tests.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 c5f7d9ee8..397831833 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj +++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj @@ -15,7 +15,7 @@ - + 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 612a08aa8..d0740f052 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1cd95210d..e3a9fd2ad 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From dc6fee72c37e3915ea6e353d3773ff9494aa7fda Mon Sep 17 00:00:00 2001 From: Irvine Sunday Date: Mon, 30 Sep 2024 12:20:48 +0300 Subject: [PATCH 116/121] Bump readers lib. --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index d33f8a942..ca868b9b6 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.21 + 1.6.22 OpenAPI.NET Readers for JSON and YAML documents true From 3c644511afba381b0c580f31d7282ac1e98c8d41 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 7 Oct 2024 15:48:53 +0300 Subject: [PATCH 117/121] Fix merge conflicts --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 +- .../Microsoft.OpenApi.csproj | 3 +- .../Models/OpenApiMediaType.cs | 5 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 7 +- .../Reader/OpenApiJsonReader.cs | 4 +- .../Reader/OpenApiModelFactory.cs | 44 +- .../Reader/Services/DefaultStreamLoader.cs | 1 + .../Services/OpenApiFilterServiceTests.cs | 4 +- .../Services/OpenApiServiceTests.cs | 76 +--- .../OpenApiStreamReaderTests.cs | 6 +- .../V3Tests/OpenApiDocumentTests.cs | 68 +-- .../V3Tests/OpenApiMediaTypeTests.cs | 4 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 90 ++-- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 55 +++ ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 57 +++ ...Async_produceTerseOutput=True.verified.txt | 2 +- .../Models/OpenApiDocumentTests.cs | 303 ++++++++++++- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 12 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- ...sync_produceTerseOutput=False.verified.txt | 8 +- ...Async_produceTerseOutput=True.verified.txt | 2 +- .../Models/OpenApiSchemaTests.cs | 407 ++++++++++++++---- .../Models/OpenApiSecuritySchemeTests.cs | 2 +- .../PublicApi/PublicApi.approved.txt | 5 + .../OpenApiWriterAnyExtensionsTests.cs | 7 +- 32 files changed, 917 insertions(+), 283 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 72f691b0e..c981639e9 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -98,7 +98,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog // Load OpenAPI document var format = OpenApiModelFactory.GetFormat(options.OpenApi); - var document = await GetOpenApi(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); if (options.FilterOptions != null) { @@ -225,7 +225,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma } // Get OpenAPI document either from OpenAPI or CSDL - private static async Task GetOpenApi(HidiOptions options, string format, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) + private static async Task GetOpenApiAsync(HidiOptions options, string format, ILogger logger, string? metadataVersion = null, CancellationToken cancellationToken = default) { OpenApiDocument document; Stream stream; @@ -246,7 +246,7 @@ private static async Task GetOpenApi(HidiOptions options, strin await stream.DisposeAsync().ConfigureAwait(false); } - document = await ConvertCsdlToOpenApi(filteredStream ?? stream, format, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false); + document = await ConvertCsdlToOpenApiAsync(filteredStream ?? stream, format, metadataVersion, options.SettingsConfig, cancellationToken).ConfigureAwait(false); stopwatch.Stop(); logger.LogTrace("{Timestamp}ms: Generated OpenAPI with {Paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } @@ -413,7 +413,7 @@ private static async Task ParseOpenApiAsync(string openApiFile, bool /// /// The CSDL stream. /// An OpenAPI document. - public static async Task ConvertCsdlToOpenApi(Stream csdl, string format, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) + public static async Task ConvertCsdlToOpenApiAsync(Stream csdl, string format, string? metadataVersion = null, IConfiguration? settings = null, CancellationToken token = default) { using var reader = new StreamReader(csdl); var csdlText = await reader.ReadToEndAsync(token).ConfigureAwait(false); @@ -588,7 +588,7 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl } var format = OpenApiModelFactory.GetFormat(options.OpenApi); - var document = await GetOpenApi(options, format, logger, null, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, format, logger, null, cancellationToken).ConfigureAwait(false); using (logger.BeginScope("Creating diagram")) { @@ -750,7 +750,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg // Load OpenAPI document var format = OpenApiModelFactory.GetFormat(options.OpenApi); - var document = await GetOpenApi(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); + var document = await GetOpenApiAsync(options, format, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 38a40d65d..d8f9a5e93 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 Latest @@ -22,6 +22,7 @@ true + diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 90f4a269b..76cd19635 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json.Nodes; using Microsoft.OpenApi.Helpers; using Microsoft.OpenApi.Interfaces; @@ -129,14 +130,14 @@ private static void SerializeExamples(IOpenApiWriter writer, IDictionary - example.Value is OpenApiArray arr && arr.Count == 0 + example.Value is JsonArray 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)) + foreach (var kvp in examples.Where(static kvp => kvp.Value.Value is JsonArray arr && arr.Count == 0)) { writer.WritePropertyName(kvp.Key); writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 0df08792b..1adfc8c01 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -14,7 +14,7 @@ namespace Microsoft.OpenApi.Models /// /// The Schema Object allows the definition of input and output data types. /// - public class OpenApiSchema : IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable + public class OpenApiSchema : IOpenApiAnnotatable, IOpenApiExtensible, IOpenApiReferenceable, IOpenApiSerializable { private JsonNode _example; private JsonNode _default; @@ -888,7 +888,10 @@ private void DowncastTypeArrayToV2OrV3(string[] array, IOpenApiWriter writer, Op // Find the non-null value and write it out var nonNullValue = array.First(v => v != OpenApiConstants.Null); writer.WriteProperty(OpenApiConstants.Type, nonNullValue); - writer.WriteProperty(nullableProp, true); + if (!Nullable) + { + writer.WriteProperty(nullableProp, true); + } } } } diff --git a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs index fd17a3643..27aad722e 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs @@ -86,7 +86,7 @@ public async Task ReadAsync(JsonNode jsonNode, if (settings.LoadExternalRefs) { - var diagnosticExternalRefs = await LoadExternalRefs(document, cancellationToken, settings, format); + var diagnosticExternalRefs = await LoadExternalRefsAsync(document, cancellationToken, settings, format); // Merge diagnostics of external reference if (diagnosticExternalRefs != null) { @@ -189,7 +189,7 @@ private JsonNode LoadJsonNodes(TextReader input) return nodes; } - private async Task LoadExternalRefs(OpenApiDocument document, CancellationToken cancellationToken, OpenApiReaderSettings settings, string format = null) + private async Task LoadExternalRefsAsync(OpenApiDocument document, CancellationToken cancellationToken, OpenApiReaderSettings settings, string format = null) { // Create workspace for all documents to live in. var baseUrl = settings.BaseUrl ?? new Uri(OpenApiConstants.BaseRegistryUri); diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index d81bedabb..9fa446bf8 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.VisualStudio.Threading; namespace Microsoft.OpenApi.Reader { @@ -19,6 +20,8 @@ namespace Microsoft.OpenApi.Reader public static class OpenApiModelFactory { private static readonly HttpClient _httpClient = new(); + private static readonly JoinableTaskContext _joinableTaskContext = new(); + private static readonly JoinableTaskFactory _joinableTaskFactory = new(_joinableTaskContext); static OpenApiModelFactory() { @@ -33,7 +36,7 @@ static OpenApiModelFactory() /// An OpenAPI document instance. public static ReadResult Load(string url, OpenApiReaderSettings settings = null) { - return LoadAsync(url, settings).GetAwaiter().GetResult(); + return _joinableTaskFactory.Run(async () => await LoadAsync(url, settings)); } /// @@ -49,7 +52,9 @@ public static ReadResult Load(Stream stream, { settings ??= new OpenApiReaderSettings(); - var result = LoadAsync(stream, format, settings).GetAwaiter().GetResult(); + // Run the async method synchronously using JoinableTaskFactory + var result = _joinableTaskFactory.Run(async () => await LoadAsync(stream, format, settings)); + if (!settings.LeaveStreamOpen) { stream.Dispose(); @@ -69,7 +74,9 @@ public static ReadResult Load(TextReader input, string format, OpenApiReaderSettings settings = null) { - return LoadAsync(input, format, settings).GetAwaiter().GetResult(); + // Run the async method synchronously using JoinableTaskFactory + var result = _joinableTaskFactory.Run(async () => await LoadAsync(input, format, settings)); + return result; } /// @@ -81,7 +88,7 @@ public static ReadResult Load(TextReader input, public static async Task LoadAsync(string url, OpenApiReaderSettings settings = null) { var format = GetFormat(url); - var stream = await GetStream(url); + var stream = await GetStreamAsync(url); return await LoadAsync(stream, format, settings); } @@ -145,7 +152,24 @@ public static ReadResult Parse(string input, format ??= OpenApiConstants.Json; settings ??= new OpenApiReaderSettings(); using var reader = new StringReader(input); - return LoadAsync(reader, format, settings).GetAwaiter().GetResult(); + + return _joinableTaskFactory.Run(async () => await ParseAsync(input, reader, format, settings)); + } + + /// + /// An Async method to prevent synchornously blocking the calling thread. + /// + /// + /// + /// + /// + /// + public static async Task ParseAsync(string input, + StringReader reader, + string format = null, + OpenApiReaderSettings settings = null) + { + return await LoadAsync(reader, format, settings); } /// @@ -183,7 +207,9 @@ public static T Load(string url, OpenApiSpecVersion version, out OpenApiDiagn { var format = GetFormat(url); settings ??= new OpenApiReaderSettings(); - var stream = GetStream(url).GetAwaiter().GetResult(); + + var stream = _joinableTaskFactory.Run(async () => await GetStreamAsync(url)); + return Load(stream, version, format, out diagnostic, settings); } @@ -227,7 +253,8 @@ private static string GetContentType(string url) { if (!string.IsNullOrEmpty(url)) { - var response = _httpClient.GetAsync(url).GetAwaiter().GetResult(); + var response = _joinableTaskFactory.Run(async () => await _httpClient.GetAsync(url)); + //var response = _httpClient.GetAsync(url).GetAwaiter().GetResult(); var mediaType = response.Content.Headers.ContentType.MediaType; return mediaType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).First(); } @@ -260,7 +287,7 @@ public static string GetFormat(string url) return null; } - private static async Task GetStream(string url) + private static async Task GetStreamAsync(string url) { Stream stream; if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) @@ -297,6 +324,5 @@ SecurityException or return stream; } - } } diff --git a/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs b/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs index 5ca2523ef..746ca0c96 100644 --- a/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs +++ b/src/Microsoft.OpenApi/Reader/Services/DefaultStreamLoader.cs @@ -27,6 +27,7 @@ public DefaultStreamLoader(Uri baseUrl) { this.baseUrl = baseUrl; } +/// [Obsolete] [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index ebb863461..83e79d07c 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using Microsoft.Extensions.Logging; @@ -232,7 +232,7 @@ public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly() // Act using var stream = File.OpenRead(filePath); - var doc = new OpenApiStreamReader().Read(stream, out var diagnostic); + var doc = OpenApiDocument.Load(stream, "yaml").OpenApiDocument; var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index d282ded8f..798b7532e 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.CommandLine; @@ -13,6 +13,7 @@ using Microsoft.OpenApi.OData; using Microsoft.OpenApi.Reader; using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Hidi.Tests @@ -27,44 +28,6 @@ public OpenApiServiceTests() _logger = new Logger(_loggerFactory); OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader()); OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); - - [Fact] - public async Task ReturnConvertedCSDLFileAsync() - { - // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); - var fileInput = new FileInfo(filePath); - var csdlStream = fileInput.OpenRead(); - // Act - var openApiDoc = await OpenApiService.ConvertCsdlToOpenApiAsync(csdlStream); - var expectedPathCount = 5; - - // Assert - Assert.NotNull(openApiDoc); - Assert.NotEmpty(openApiDoc.Paths); - Assert.Equal(expectedPathCount, openApiDoc.Paths.Count); - } - - [Theory] - [InlineData("Todos.Todo.UpdateTodo", null, 1)] - [InlineData("Todos.Todo.ListTodo", null, 1)] - [InlineData(null, "Todos.Todo", 5)] - public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumentAsync(string? operationIds, string? tags, int expectedPathCount) - { - // Arrange - var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml"); - var fileInput = new FileInfo(filePath); - var csdlStream = fileInput.OpenRead(); - - // Act - var openApiDoc = await OpenApiService.ConvertCsdlToOpenApiAsync(csdlStream); - var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); - var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, predicate); - - // Assert - Assert.NotNull(subsetOpenApiDocument); - Assert.NotEmpty(subsetOpenApiDocument.Paths); - Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); } [Fact] @@ -198,23 +161,6 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync() Assert.True(File.Exists(filePath)); } - [Fact] - public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagramAsync() - { - var options = new HidiOptions - { - Csdl = Path.Combine("UtilityFiles", "Todo.xml"), - CsdlFilter = "todos", - Output = new("sample.md") - }; - - // create a dummy ILogger instance for testing - await OpenApiService.ShowOpenApiDocumentAsync(options, _logger); - - var output = await File.ReadAllTextAsync(options.Output.FullName); - Assert.Contains("graph LR", output, StringComparison.Ordinal); - } - [Fact] public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidatingAsync() { @@ -309,24 +255,6 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAsync() Assert.NotEmpty(output); } - [Fact] - public async Task TransformCommandConvertsCsdlWithDefaultOutputNameAsync() - { - var options = new HidiOptions - { - Csdl = Path.Combine("UtilityFiles", "Todo.xml"), - CleanOutput = true, - TerseOutput = false, - InlineLocal = false, - InlineExternal = false, - }; - // create a dummy ILogger instance for testing - await OpenApiService.TransformOpenApiDocumentAsync(options, _logger); - - var output = await File.ReadAllTextAsync("output.yml"); - Assert.NotEmpty(output); - } - [Fact] public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormatAsync() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs index ba0e85984..c88c86544 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -64,8 +64,8 @@ public async Task StreamShouldReadWhenInitializedAsync() 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); + var result = OpenApiDocument.Load(stream, "yaml"); + Assert.NotNull(result.OpenApiDocument); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 9bd840d3a..314e22273 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -7,7 +7,6 @@ using System.IO; using System.Linq; using FluentAssertions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; @@ -17,6 +16,7 @@ using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Validations.Rules; using Microsoft.OpenApi.Writers; +using SharpYaml.Model; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V3Tests @@ -112,7 +112,7 @@ public void ParseDocumentFromInlineStringShouldSucceed() [Fact] public void ParseBasicDocumentWithMultipleServersShouldSucceed() { - var path = Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml"); + var path = System.IO.Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml"); var result = OpenApiDocument.Load(path); result.OpenApiDiagnostic.Should().BeEquivalentTo( @@ -152,7 +152,7 @@ public void ParseBasicDocumentWithMultipleServersShouldSucceed() [Fact] public void ParseBrokenMinimalDocumentShouldYieldExpectedDiagnostic() { - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "brokenMinimalDocument.yaml")); + using var stream = Resources.GetStream(System.IO.Path.Combine(SampleFolderPath, "brokenMinimalDocument.yaml")); var result = OpenApiDocument.Load(stream, OpenApiConstants.Yaml); result.OpenApiDocument.Should().BeEquivalentTo( @@ -180,7 +180,7 @@ public void ParseBrokenMinimalDocumentShouldYieldExpectedDiagnostic() [Fact] public void ParseMinimalDocumentShouldSucceed() { - var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "minimalDocument.yaml")); + var result = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "minimalDocument.yaml")); result.OpenApiDocument.Should().BeEquivalentTo( new OpenApiDocument @@ -207,7 +207,7 @@ public void ParseMinimalDocumentShouldSucceed() [Fact] public void ParseStandardPetStoreDocumentShouldSucceed() { - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml")); + using var stream = Resources.GetStream(System.IO.Path.Combine(SampleFolderPath, "petStore.yaml")); var actual = OpenApiDocument.Load(stream, OpenApiConstants.Yaml); var components = new OpenApiComponents @@ -593,7 +593,7 @@ public void ParseStandardPetStoreDocumentShouldSucceed() [Fact] public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() { - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStoreWithTagAndSecurity.yaml")); + using var stream = Resources.GetStream(System.IO.Path.Combine(SampleFolderPath, "petStoreWithTagAndSecurity.yaml")); var actual = OpenApiDocument.Load(stream, OpenApiConstants.Yaml); var components = new OpenApiComponents @@ -1105,7 +1105,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() [Fact] public void ParsePetStoreExpandedShouldSucceed() { - var actual = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "petStoreExpanded.yaml")); + var actual = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "petStoreExpanded.yaml")); // TODO: Create the object in memory and compare with the one read from YAML file. @@ -1116,7 +1116,7 @@ public void ParsePetStoreExpandedShouldSucceed() [Fact] public void GlobalSecurityRequirementShouldReferenceSecurityScheme() { - var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "securedApi.yaml")); + var result = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "securedApi.yaml")); var securityRequirement = result.OpenApiDocument.SecurityRequirements.First(); @@ -1127,7 +1127,7 @@ public void GlobalSecurityRequirementShouldReferenceSecurityScheme() [Fact] public void HeaderParameterShouldAllowExample() { - var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "apiWithFullHeaderComponent.yaml")); + var result = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "apiWithFullHeaderComponent.yaml")); var exampleHeader = result.OpenApiDocument.Components?.Headers?["example-header"]; Assert.NotNull(exampleHeader); @@ -1195,7 +1195,7 @@ public void ParseDocumentWithReferencedSecuritySchemeWorks() ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences }; - var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "docWithSecuritySchemeReference.yaml"), settings); + var result = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "docWithSecuritySchemeReference.yaml"), settings); var securityScheme = result.OpenApiDocument.Components.SecuritySchemes["OAuth2"]; // Assert @@ -1207,7 +1207,7 @@ public void ParseDocumentWithReferencedSecuritySchemeWorks() public void ParseDocumentWithJsonSchemaReferencesWorks() { // Arrange - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "docWithJsonSchema.yaml")); + using var stream = Resources.GetStream(System.IO.Path.Combine(SampleFolderPath, "docWithJsonSchema.yaml")); // Act var settings = new OpenApiReaderSettings @@ -1227,7 +1227,7 @@ public void ParseDocumentWithJsonSchemaReferencesWorks() public void ValidateExampleShouldNotHaveDataTypeMismatch() { // Act - var result = OpenApiDocument.Load(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), new OpenApiReaderSettings + var result = OpenApiDocument.Load(System.IO.Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), new OpenApiReaderSettings { ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences @@ -1327,7 +1327,7 @@ public void ParseDocWithRefsUsingProxyReferencesSucceeds() format: int32 default: 10"; - using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minifiedPetStore.yaml")); + using var stream = Resources.GetStream(System.IO.Path.Combine(SampleFolderPath, "minifiedPetStore.yaml")); // Act var doc = OpenApiDocument.Load(stream, "yaml").OpenApiDocument; @@ -1348,7 +1348,7 @@ public void ParseDocWithRefsUsingProxyReferencesSucceeds() [Fact] public void ParseBasicDocumentWithServerVariableShouldSucceed() { - var openApiDoc = new OpenApiStringReader().Read(""" + var result = OpenApiDocument.Parse(""" openapi : 3.0.0 info: title: The API @@ -1361,20 +1361,16 @@ public void ParseBasicDocumentWithServerVariableShouldSucceed() default: v2 enum: [v1, v2] paths: {} - """, out var diagnostic); + """, "yaml"); - diagnostic.Should().BeEquivalentTo( - new OpenApiDiagnostic { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 }); - - openApiDoc.Should().BeEquivalentTo( - new OpenApiDocument + var expected = new OpenApiDocument + { + Info = new() { - Info = new() - { - Title = "The API", - Version = "0.9.1", - }, - Servers = + Title = "The API", + Version = "0.9.1", + }, + Servers = { new OpenApiServer { @@ -1386,14 +1382,26 @@ public void ParseBasicDocumentWithServerVariableShouldSucceed() } } }, - Paths = new() + Paths = new() + }; + + result.OpenApiDiagnostic.Should().BeEquivalentTo( + new OpenApiDiagnostic + { + SpecificationVersion = OpenApiSpecVersion.OpenApi3_0, + Errors = new List() + { + new OpenApiError("", "Paths is a REQUIRED field at #/") + } }); + + result.OpenApiDocument.Should().BeEquivalentTo(expected, options => options.Excluding(x => x.BaseUri)); } [Fact] public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail() { - var openApiDoc = new OpenApiStringReader().Read(""" + var result = OpenApiDocument.Parse(""" openapi : 3.0.0 info: title: The API @@ -1405,9 +1413,9 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail() version: enum: [v1, v2] paths: {} - """, out var diagnostic); + """, "yaml"); - diagnostic.Errors.Should().NotBeEmpty(); + result.OpenApiDiagnostic.Errors.Should().NotBeEmpty(); } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index 2559a99a2..2c368cc22 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -3,10 +3,12 @@ using System.IO; using FluentAssertions; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Reader; +using Microsoft.OpenApi.Reader.ParseNodes; +using Microsoft.OpenApi.Reader.V3; +using Microsoft.OpenApi.Tests; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V3Tests diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index b82c2f263..0cd09732e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 38ff58647..0cd09732e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 01840772e..81beb028b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","style":"form","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}},"application/xml":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/newPet"}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}},"application/xml":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","style":"form","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 1656b2bf7..ae6572f21 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -55,15 +55,15 @@ "schema": { "type": "array", "items": { + "type": "object", "required": [ "id", "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -78,15 +78,15 @@ "4XX": { "description": "unexpected client error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -97,15 +97,15 @@ "5XX": { "description": "unexpected server error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -132,14 +132,14 @@ "description": "Pet to add to the store", "required": true, "schema": { + "type": "object", "required": [ "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -155,15 +155,15 @@ "200": { "description": "pet response", "schema": { + "type": "object", "required": [ "id", "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -177,15 +177,15 @@ "4XX": { "description": "unexpected client error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -196,15 +196,15 @@ "5XX": { "description": "unexpected server error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -238,15 +238,15 @@ "200": { "description": "pet response", "schema": { + "type": "object", "required": [ "id", "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -260,15 +260,15 @@ "4XX": { "description": "unexpected client error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -279,15 +279,15 @@ "5XX": { "description": "unexpected server error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -320,15 +320,15 @@ "4XX": { "description": "unexpected client error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -339,15 +339,15 @@ "5XX": { "description": "unexpected server error", "schema": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" @@ -361,15 +361,15 @@ }, "definitions": { "pet": { + "type": "object", "required": [ "id", "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -380,14 +380,14 @@ } }, "newPet": { + "type": "object", "required": [ "name" ], - "type": "object", "properties": { "id": { - "format": "int64", - "type": "integer" + "type": "integer", + "format": "int64" }, "name": { "type": "string" @@ -398,15 +398,15 @@ } }, "errorModel": { + "type": "object", "required": [ "code", "message" ], - "type": "object", "properties": { "code": { - "format": "int32", - "type": "integer" + "type": "integer", + "format": "int32" }, "message": { "type": "string" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 3670fba11..5ae9e05e5 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"your-resource-name.openai.azure.com","basePath":"/openai","schemes":["https"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"your-resource-name.openai.azure.com","basePath":"/openai","schemes":["https"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"},"collectionFormat":"multi"},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 8cbd90369..1ba9050ca 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -64,5 +64,60 @@ } } } + }, + "definitions": { + "pet": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index 49072fda2..b61ba4d5a 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","produces":["application/json"],"parameters":[{"in":"path","name":"operand1","description":"The first operand","required":true,"type":"integer","my-extension":4},{"in":"path","name":"operand2","description":"The second operand","required":true,"type":"integer","my-extension":4}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","produces":["application/json"],"parameters":[{"in":"path","name":"operand1","description":"The first operand","required":true,"type":"integer","my-extension":4},{"in":"path","name":"operand2","description":"The second operand","required":true,"type":"integer","my-extension":4}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}},"definitions":{"pet":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"type":"object","required":["name"],"properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 26442924a..c4a235055 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -71,5 +71,62 @@ } } } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index c5d124594..dc50aeb17 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","parameters":[{"name":"operand1","in":"path","description":"The first operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4},{"name":"operand2","in":"path","description":"The second operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}}}} \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","parameters":[{"name":"operand1","in":"path","description":"The first operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4},{"name":"operand2","in":"path","description":"The second operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 98b6365a6..fa7a2048f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -1044,6 +1044,306 @@ public OpenApiDocumentTests() Components = AdvancedComponents }; + public OpenApiDocument AdvancedDocumentWithServerVariable = new() + { + Info = new() + { + Version = "1.0.0", + Title = "Swagger Petstore (Simple)", + Description = + "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + TermsOfService = new("http://helloreverb.com/terms/"), + Contact = new() + { + Name = "Swagger API team", + Email = "foo@example.com", + Url = new("http://swagger.io") + }, + License = new() + { + Name = "MIT", + Url = new("http://opensource.org/licenses/MIT") + } + }, + Servers = new List + { + new() + { + Url = "https://{endpoint}/openai", + Variables = new Dictionary + { + ["endpoint"] = new() + { + Default = "your-resource-name.openai.azure.com" + } + } + } + }, + Paths = new() + { + ["/pets"] = new() + { + Operations = new Dictionary + { + [OperationType.Get] = new() + { + Description = "Returns all pets from the system that the user has access to", + OperationId = "findPets", + Parameters = new List + { + new() + { + Name = "tags", + In = ParameterLocation.Query, + Description = "tags to filter by", + Required = false, + Schema = new() + { + Type = "array", + Items = new() + { + Type = "string" + } + } + }, + new() + { + Name = "limit", + In = ParameterLocation.Query, + Description = "maximum number of results to return", + Required = false, + Schema = new() + { + Type = "integer", + Format = "int32" + } + } + }, + Responses = new() + { + ["200"] = new() + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new() + { + Schema = new() + { + Type = "array", + Items = PetSchema + } + }, + ["application/xml"] = new() + { + Schema = new() + { + Type = "array", + Items = PetSchema + } + } + } + }, + ["4XX"] = new() + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new() + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + } + } + }, + [OperationType.Post] = new() + { + Description = "Creates a new pet in the store. Duplicates are allowed", + OperationId = "addPet", + RequestBody = new() + { + Description = "Pet to add to the store", + Required = true, + Content = new Dictionary + { + ["application/json"] = new() + { + Schema = NewPetSchema + } + } + }, + Responses = new() + { + ["200"] = new() + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new() + { + Schema = PetSchema + }, + } + }, + ["4XX"] = new() + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new() + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + } + } + } + } + }, + ["/pets/{id}"] = new() + { + Operations = new Dictionary + { + [OperationType.Get] = new() + { + Description = + "Returns a user based on a single ID, if the user does not have access to the pet", + OperationId = "findPetById", + Parameters = new List + { + new() + { + Name = "id", + In = ParameterLocation.Path, + Description = "ID of pet to fetch", + Required = true, + Schema = new() + { + Type = "integer", + Format = "int64" + } + } + }, + Responses = new() + { + ["200"] = new() + { + Description = "pet response", + Content = new Dictionary + { + ["application/json"] = new() + { + Schema = PetSchema + }, + ["application/xml"] = new() + { + Schema = PetSchema + } + } + }, + ["4XX"] = new() + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new() + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + } + } + }, + [OperationType.Delete] = new() + { + Description = "deletes a single pet based on the ID supplied", + OperationId = "deletePet", + Parameters = new List + { + new() + { + Name = "id", + In = ParameterLocation.Path, + Description = "ID of pet to delete", + Required = true, + Schema = new() + { + Type = "integer", + Format = "int64" + } + } + }, + Responses = new() + { + ["204"] = new() + { + Description = "pet deleted" + }, + ["4XX"] = new() + { + Description = "unexpected client error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + }, + ["5XX"] = new() + { + Description = "unexpected server error", + Content = new Dictionary + { + ["text/html"] = new() + { + Schema = ErrorModelSchema + } + } + } + } + } + } + } + }, + Annotations = new Dictionary { { "key1", "value" } }, + Components = AdvancedComponents + }; + [Theory] [InlineData(false)] [InlineData(true)] @@ -1606,7 +1906,6 @@ public void SerializeExamplesDoesNotThrowNullReferenceException() OpenApiJsonWriter apiWriter = new OpenApiJsonWriter(new StringWriter()); doc.Invoking(d => d.SerializeAsV3(apiWriter)).Should().NotThrow(); } - } [Theory] [InlineData(true)] diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index 2fd0836a4..4dfb0ce93 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1","bytes":"AQID","binary":"Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1","bytes":"\"AQID\"","binary":"Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt index bbc944fee..c319c88f1 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}],"aDate":"2022-12-12"}} \ No newline at end of file +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}],"aDate":"\"2022-12-12\""}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt index 2a9b08f98..b431f1607 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -1,3 +1,13 @@ { - "$ref": "#/components/schemas/schemaObject1" + "title": "title1", + "multipleOf": 3, + "maximum": 42, + "minimum": 10, + "exclusiveMinimum": true, + "type": "integer", + "default": 15, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt index ca0ce704f..d71a5f0a8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"$ref":"#/components/schemas/schemaObject1"} \ No newline at end of file +{"title":"title1","multipleOf":3,"maximum":42,"minimum":10,"exclusiveMinimum":true,"type":"integer","default":15,"nullable":true,"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt index 9ab9fad6f..e9543ede7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -13,8 +13,8 @@ "type": "integer" }, "property3": { - "maxLength": 15, - "type": "string" + "type": "string", + "maxLength": 15 } } }, @@ -28,8 +28,8 @@ } }, "property7": { - "minLength": 2, - "type": "string" + "type": "string", + "minLength": 2 } }, "readOnly": true diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt index b0b24d295..9ea88dee8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -1 +1 @@ -{"title":"title1","required":["property1"],"properties":{"property1":{"required":["property3"],"properties":{"property2":{"type":"integer"},"property3":{"maxLength":15,"type":"string"}}},"property4":{"properties":{"property5":{"properties":{"property6":{"type":"boolean"}}},"property7":{"minLength":2,"type":"string"}},"readOnly":true}},"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file +{"title":"title1","required":["property1"],"properties":{"property1":{"required":["property3"],"properties":{"property2":{"type":"integer"},"property3":{"type":"string","maxLength":15}}},"property4":{"properties":{"property5":{"properties":{"property6":{"type":"boolean"}}},"property7":{"type":"string","minLength":2}},"readOnly":true}},"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index a88cecf6f..1a19457b4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -1,31 +1,37 @@ // 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.Text.Json.Nodes; using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Services; +using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; -using FluentAssertions; -using Microsoft.OpenApi.Extensions; namespace Microsoft.OpenApi.Tests.Models { + [Collection("DefaultSettings")] public class OpenApiSchemaTests { - public static OpenApiSchema BasicV31Schema = new() + public static OpenApiSchema BasicSchema = new(); + + public static readonly OpenApiSchema AdvancedSchemaNumber = new() { Title = "title1", MultipleOf = 3, Maximum = 42, ExclusiveMinimum = true, Minimum = 10, - Default = new OpenApiInteger(15), + Default = 15, Type = "integer", Nullable = true, @@ -41,85 +47,318 @@ public class OpenApiSchemaTests Title = "title1", Properties = new Dictionary { - ["fruits"] = new OpenApiSchema + ["property1"] = new() { - Type = "array", - Items = new OpenApiSchema + Properties = new Dictionary { - Type = "string" - } + ["property2"] = new() + { + Type = "integer" + }, + ["property3"] = new() + { + Type = "string", + MaxLength = 15 + } + }, }, - ["vegetables"] = new OpenApiSchema + ["property4"] = new() { - Type = "array" - } + Properties = new Dictionary + { + ["property5"] = new() + { + Properties = new Dictionary + { + ["property6"] = new() + { + Type = "boolean" + } + } + }, + ["property7"] = new() + { + Type = "string", + MinLength = 2 + } + }, + }, }, - Definitions = new Dictionary + Nullable = true, + ExternalDocs = new() + { + Url = new("http://example.com/externalDocs") + } + }; + + public static readonly OpenApiSchema AdvancedSchemaWithAllOf = new() + { + Title = "title1", + AllOf = new List { - ["veggie"] = new OpenApiSchema + new() { - Type = "object", - Required = new HashSet{ "veggieName", "veggieLike" }, + Title = "title2", Properties = new Dictionary { - ["veggieName"] = new OpenApiSchema + ["property1"] = new() + { + Type = "integer" + }, + ["property2"] = new() { Type = "string", - Description = "The name of the vegetable." + MaxLength = 15 + } + }, + }, + new() + { + Title = "title3", + Properties = new Dictionary + { + ["property3"] = new() + { + Properties = new Dictionary + { + ["property4"] = new() + { + Type = "boolean" + } + } }, - ["veggieLike"] = new OpenApiSchema + ["property5"] = new() { - Type = "boolean", - Description = "Do I like this vegetable?" + Type = "string", + MinLength = 2 } - } - } + }, + Nullable = true + }, + }, + Nullable = true, + ExternalDocs = new() + { + Url = new("http://example.com/externalDocs") + } + }; + + public static readonly OpenApiSchema ReferencedSchema = new() + { + Title = "title1", + MultipleOf = 3, + Maximum = 42, + ExclusiveMinimum = true, + Minimum = 10, + Default = 15, + Type = "integer", + + Nullable = true, + ExternalDocs = new() + { + Url = new("http://example.com/externalDocs") + } + }; + + public static readonly OpenApiSchema AdvancedSchemaWithRequiredPropertiesObject = new() + { + Title = "title1", + Required = new HashSet { "property1" }, + Properties = new Dictionary + { + ["property1"] = new() + { + Required = new HashSet { "property3" }, + Properties = new Dictionary + { + ["property2"] = new() + { + Type = "integer" + }, + ["property3"] = new() + { + Type = "string", + MaxLength = 15, + ReadOnly = true + } + }, + ReadOnly = true, + }, + ["property4"] = new() + { + Properties = new Dictionary + { + ["property5"] = new() + { + Properties = new Dictionary + { + ["property6"] = new() + { + Type = "boolean" + } + } + }, + ["property7"] = new() + { + Type = "string", + MinLength = 2 + } + }, + ReadOnly = true, + }, + }, + Nullable = true, + ExternalDocs = new() + { + Url = new("http://example.com/externalDocs") } }; [Fact] - public void SerializeBasicV31SchemaWorks() + public void SerializeBasicSchemaAsV3JsonWorks() { // Arrange - var expected = @"{ - ""$id"": ""https://example.com/arrays.schema.json"", - ""$schema"": ""https://json-schema.org/draft/2020-12/schema"", - ""$defs"": { - ""veggie"": { - ""required"": [ - ""veggieName"", - ""veggieLike"" - ], - ""type"": ""object"", - ""properties"": { - ""veggieName"": { - ""type"": ""string"", - ""description"": ""The name of the vegetable."" - }, - ""veggieLike"": { - ""type"": ""boolean"", - ""description"": ""Do I like this vegetable?"" + var expected = @"{ }"; + + // Act + var actual = BasicSchema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); } - } - } - }, - ""type"": ""object"", - ""properties"": { - ""fruits"": { - ""type"": ""array"", - ""items"": { - ""type"": ""string"" - } - }, - ""vegetables"": { - ""type"": ""array"" - } - }, - ""description"": ""A representation of a person, company, organization, or place"" -}"; + + [Fact] + public void SerializeAdvancedSchemaNumberAsV3JsonWorks() + { + // Arrange + var expected = + """ + { + "title": "title1", + "multipleOf": 3, + "maximum": 42, + "minimum": 10, + "exclusiveMinimum": true, + "type": "integer", + "default": 15, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; // Act - var actual = BasicV31Schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_1); + var actual = AdvancedSchemaNumber.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); + } + + [Fact] + public void SerializeAdvancedSchemaObjectAsV3JsonWorks() + { + // Arrange + var expected = + """ + { + "title": "title1", + "properties": { + "property1": { + "properties": { + "property2": { + "type": "integer" + }, + "property3": { + "maxLength": 15, + "type": "string" + } + } + }, + "property4": { + "properties": { + "property5": { + "properties": { + "property6": { + "type": "boolean" + } + } + }, + "property7": { + "minLength": 2, + "type": "string" + } + } + } + }, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; + + // Act + var actual = AdvancedSchemaObject.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); + + // Assert + actual = actual.MakeLineBreaksEnvironmentNeutral(); + expected = expected.MakeLineBreaksEnvironmentNeutral(); + actual.Should().Be(expected); + } + + [Fact] + public void SerializeAdvancedSchemaWithAllOfAsV3JsonWorks() + { + // Arrange + var expected = + """ + { + "title": "title1", + "allOf": [ + { + "title": "title2", + "properties": { + "property1": { + "type": "integer" + }, + "property2": { + "maxLength": 15, + "type": "string" + } + } + }, + { + "title": "title3", + "properties": { + "property3": { + "properties": { + "property4": { + "type": "boolean" + } + } + }, + "property5": { + "minLength": 2, + "type": "string" + } + }, + "nullable": true + } + ], + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } + } + """; + + // Act + var actual = AdvancedSchemaWithAllOf.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); @@ -137,7 +376,7 @@ public async Task SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync(bo var writer = new OpenApiJsonWriter(outputStringWriter, new() { Terse = produceTerseOutput }); // Act - ReferencedSchema.SerializeAsV3WithoutReference(writer); + ReferencedSchema.SerializeAsV3(writer); writer.Flush(); // Assert @@ -211,15 +450,15 @@ public void SerializeAsV2ShouldSetFormatPropertyInParentSchemaIfPresentInChildre "format": "decimal", "allOf": [ { - "format": "decimal", - "type": "number" + "type": "number", + "format": "decimal" } ] } """.MakeLineBreaksEnvironmentNeutral(); // Assert - Assert.Equal(expectedV2Schema, v2Schema); + expectedV2Schema.Should().BeEquivalentTo(v2Schema); } [Fact] @@ -262,30 +501,27 @@ public void OpenApiSchemaCopyConstructorWithAnnotationsSucceeds() Assert.NotEqual(baseSchema.Annotations["key1"], actualSchema.Annotations["key1"]); } - public static TheoryData SchemaExamples() + 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"), + new JsonArray() { "example" }, + new JsonArray { 0, 1, 2 }, // Represent OpenApiBinary as JsonArray of bytes + true, + JsonValue.Create((byte)42), + JsonValue.Create(new DateTime(2024, 07, 19, 12, 34, 56, DateTimeKind.Utc).ToString("o")), // DateTime object + 42.37, + 42.37f, + 42, + null, + JsonValue.Create("secret"), //Represent OpenApiPassword as string + "example", }; } [Theory] [MemberData(nameof(SchemaExamples))] - public void CloningSchemaExamplesWorks(IOpenApiAny example) + public void CloningSchemaExamplesWorks(JsonNode example) { // Arrange var schema = new OpenApiSchema @@ -295,10 +531,11 @@ public void CloningSchemaExamplesWorks(IOpenApiAny example) // Act && Assert var schemaCopy = new OpenApiSchema(schema); - Assert.NotNull(schemaCopy.Example); // Act && Assert - Assert.Equivalent(schema.Example, schemaCopy.Example); + schema.Example.Should().BeEquivalentTo(schemaCopy.Example, options => options + .IgnoringCyclicReferences() + .Excluding(x => x.Options)); } [Fact] @@ -309,7 +546,7 @@ public void CloningSchemaExtensionsWorks() { Extensions = { - { "x-myextension", new OpenApiInteger(42) } + { "x-myextension", new OpenApiAny(42) } } }; @@ -320,7 +557,7 @@ public void CloningSchemaExtensionsWorks() // Act && Assert schemaCopy.Extensions = new Dictionary { - { "x-myextension" , new OpenApiInteger(40) } + { "x-myextension" , new OpenApiAny(40) } }; Assert.NotEqual(schema.Extensions, schemaCopy.Extensions); } @@ -336,7 +573,7 @@ public void OpenApiWalkerVisitsOpenApiSchemaNot() Title = "Inner Schema", Type = "string", } - }; + }; var document = new OpenApiDocument() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index dffbbb045..58794373d 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -311,7 +311,7 @@ public async Task SerializeReferencedSecuritySchemeAsV3JsonWorksAsync(bool produ var writer = new OpenApiJsonWriter(outputStringWriter, new() { Terse = produceTerseOutput }); // Act - ReferencedSecurityScheme.SerializeAsV3(writer); + OpenApiSecuritySchemeReference.SerializeAsV3(writer); writer.Flush(); // Assert diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index d5fd31214..99fe8e8d7 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -200,6 +200,7 @@ namespace Microsoft.OpenApi.Extensions } namespace Microsoft.OpenApi.Interfaces { + public interface IDiagnostic { } public interface IOpenApiAnnotatable { System.Collections.Generic.IDictionary Annotations { get; set; } @@ -235,6 +236,7 @@ namespace Microsoft.OpenApi.Interfaces } public interface IStreamLoader { + [System.Obsolete("Use the Async overload")] System.IO.Stream Load(System.Uri uri); System.Threading.Tasks.Task LoadAsync(System.Uri uri); } @@ -860,6 +862,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiSchema() { } public OpenApiSchema(Microsoft.OpenApi.Models.OpenApiSchema schema) { } + public System.Collections.Generic.IDictionary Annotations { get; set; } public virtual Microsoft.OpenApi.Models.OpenApiSchema AdditionalProperties { get; set; } public virtual bool AdditionalPropertiesAllowed { get; set; } public virtual System.Collections.Generic.IList AllOf { get; set; } @@ -1324,6 +1327,7 @@ namespace Microsoft.OpenApi.Reader public static Microsoft.OpenApi.Reader.ReadResult Parse(string input, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) { } public static T Parse(string input, Microsoft.OpenApi.OpenApiSpecVersion version, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } + public static System.Threading.Tasks.Task ParseAsync(string input, System.IO.StringReader reader, string format = null, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null) { } } public static class OpenApiReaderRegistry { @@ -1393,6 +1397,7 @@ namespace Microsoft.OpenApi.Reader.Services public class DefaultStreamLoader : Microsoft.OpenApi.Interfaces.IStreamLoader { public DefaultStreamLoader(System.Uri baseUrl) { } + [System.Obsolete] public System.IO.Stream Load(System.Uri uri) { } public System.Threading.Tasks.Task LoadAsync(System.Uri uri) { } } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index 8b8d7fd48..2d966e8a5 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -28,7 +28,7 @@ public class OpenApiWriterAnyExtensionsTests public async Task WriteOpenApiNullAsJsonWorksAsync(bool produceTerseOutput) { // Arrange - var json = await WriteAsJsonAsync(nullValue, produceTerseOutput); + var json = await WriteAsJsonAsync(null, produceTerseOutput); // Assert json.Should().Be("null"); @@ -255,7 +255,7 @@ public async Task WriteOpenApiArrayAsJsonWorksAsync(bool produceTerseOutput) await Verifier.Verify(actualJson).UseParameters(produceTerseOutput); } - private static async Task WriteAsJsonAsync(IOpenApiAny any, bool produceTerseOutput = false) + private static async Task WriteAsJsonAsync(JsonNode any, bool produceTerseOutput = false) { // Arrange (continued) using var stream = new MemoryStream(); @@ -268,7 +268,8 @@ private static async Task WriteAsJsonAsync(IOpenApiAny any, bool produce stream.Position = 0; // Act - var value = new StreamReader(stream).ReadToEnd(); + using var sr = new StreamReader(stream); + var value = await sr.ReadToEndAsync(); var element = JsonDocument.Parse(value).RootElement; return element.ValueKind switch { From 63c096e5e1a77cce7dd1da78d7c4121cd01d6d14 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 7 Oct 2024 15:51:46 +0300 Subject: [PATCH 118/121] Update code owners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8227ccb46..a61cbd408 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @irvinesunday @darrelmiller @zengin @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman +* @irvinesunday @darrelmiller @gavinbarron @millicentachieng @MaggieKimani1 @andrueastman From 9c64bea5b2b8ddc63a205b9733bd947b65d43910 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Mon, 7 Oct 2024 20:30:18 +0300 Subject: [PATCH 119/121] Remove commented out code --- src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index 9fa446bf8..9b904b847 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -254,7 +254,6 @@ private static string GetContentType(string url) if (!string.IsNullOrEmpty(url)) { var response = _joinableTaskFactory.Run(async () => await _httpClient.GetAsync(url)); - //var response = _httpClient.GetAsync(url).GetAwaiter().GetResult(); var mediaType = response.Content.Headers.ContentType.MediaType; return mediaType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).First(); } From d04b22b8ec84869a5a9f5cea99c87bd933ca6b39 Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 8 Oct 2024 17:16:01 +0300 Subject: [PATCH 120/121] Remove threading package and disable warnings --- .../Microsoft.OpenApi.csproj | 5 ++- .../Reader/OpenApiModelFactory.cs | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index d8f9a5e93..b6ccd1796 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -21,9 +21,8 @@ true - - - + + diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index 9b904b847..f2bd6d3bc 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -10,7 +10,6 @@ using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using Microsoft.VisualStudio.Threading; namespace Microsoft.OpenApi.Reader { @@ -20,8 +19,6 @@ namespace Microsoft.OpenApi.Reader public static class OpenApiModelFactory { private static readonly HttpClient _httpClient = new(); - private static readonly JoinableTaskContext _joinableTaskContext = new(); - private static readonly JoinableTaskFactory _joinableTaskFactory = new(_joinableTaskContext); static OpenApiModelFactory() { @@ -36,7 +33,9 @@ static OpenApiModelFactory() /// An OpenAPI document instance. public static ReadResult Load(string url, OpenApiReaderSettings settings = null) { - return _joinableTaskFactory.Run(async () => await LoadAsync(url, settings)); +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + return LoadAsync(url, settings).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } /// @@ -52,9 +51,10 @@ public static ReadResult Load(Stream stream, { settings ??= new OpenApiReaderSettings(); - // Run the async method synchronously using JoinableTaskFactory - var result = _joinableTaskFactory.Run(async () => await LoadAsync(stream, format, settings)); - +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + var result = LoadAsync(stream, format, settings).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits + if (!settings.LeaveStreamOpen) { stream.Dispose(); @@ -74,8 +74,9 @@ public static ReadResult Load(TextReader input, string format, OpenApiReaderSettings settings = null) { - // Run the async method synchronously using JoinableTaskFactory - var result = _joinableTaskFactory.Run(async () => await LoadAsync(input, format, settings)); +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + var result = LoadAsync(input, format, settings).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits return result; } @@ -153,7 +154,9 @@ public static ReadResult Parse(string input, settings ??= new OpenApiReaderSettings(); using var reader = new StringReader(input); - return _joinableTaskFactory.Run(async () => await ParseAsync(input, reader, format, settings)); +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + return ParseAsync(input, reader, format, settings).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } /// @@ -208,7 +211,9 @@ public static T Load(string url, OpenApiSpecVersion version, out OpenApiDiagn var format = GetFormat(url); settings ??= new OpenApiReaderSettings(); - var stream = _joinableTaskFactory.Run(async () => await GetStreamAsync(url)); +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + var stream = GetStreamAsync(url).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits return Load(stream, version, format, out diagnostic, settings); } @@ -253,7 +258,10 @@ private static string GetContentType(string url) { if (!string.IsNullOrEmpty(url)) { - var response = _joinableTaskFactory.Run(async () => await _httpClient.GetAsync(url)); +#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits + var response = _httpClient.GetAsync(url).GetAwaiter().GetResult(); +#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits + var mediaType = response.Content.Headers.ContentType.MediaType; return mediaType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).First(); } From d2dc8ecd44dcc4a59e902fd83f6b4b447855264c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 8 Oct 2024 21:53:23 +0300 Subject: [PATCH 121/121] Declare Annotations as nullable to prevent null reference assignment --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiOperation.cs | 2 +- .../Services/OpenApiFilterServiceTests.cs | 16 +++++++++------- .../PublicApi/PublicApi.approved.txt | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 1cc3896b8..0baf31e68 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -89,7 +89,7 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IOpenAp public string HashCode => GenerateHashValue(this); /// - public IDictionary Annotations { get; set; } + public IDictionary? Annotations { get; set; } /// /// Implements IBaseDocument diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index 6917084a7..6e54cd894 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -109,7 +109,7 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible, IOpenA public IDictionary? Extensions { get; set; } = new Dictionary(); /// - public IDictionary Annotations { get; set; } + public IDictionary? Annotations { get; set; } /// /// Parameterless constructor diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 83e79d07c..99e559e37 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -237,17 +237,19 @@ public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly() var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate); - var response = subsetOpenApiDocument.Paths["/items"].Operations[OperationType.Get].Responses["200"]; - var responseHeader = response.Headers["x-custom-header"]; - var mediaTypeExample = response.Content["application/json"].Examples.First().Value; - var targetHeaders = subsetOpenApiDocument.Components.Headers; - var targetExamples = subsetOpenApiDocument.Components.Examples; + var response = subsetOpenApiDocument.Paths["/items"].Operations[OperationType.Get]?.Responses?["200"]; + var responseHeader = response?.Headers["x-custom-header"]; + var mediaTypeExample = response?.Content["application/json"]?.Examples?.First().Value; + var targetHeaders = subsetOpenApiDocument.Components?.Headers; + var targetExamples = subsetOpenApiDocument.Components?.Examples; // Assert Assert.Same(doc.Servers, subsetOpenApiDocument.Servers); - Assert.False(responseHeader.UnresolvedReference); - Assert.False(mediaTypeExample.UnresolvedReference); + Assert.False(responseHeader?.UnresolvedReference); + Assert.False(mediaTypeExample?.UnresolvedReference); + Assert.NotNull(targetHeaders); Assert.Single(targetHeaders); + Assert.NotNull(targetExamples); Assert.Single(targetExamples); } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 6556cfb27..3a7fdbd57 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -543,7 +543,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiDocument() { } public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument? document) { } - public System.Collections.Generic.IDictionary Annotations { get; set; } + public System.Collections.Generic.IDictionary? Annotations { get; set; } public System.Uri BaseUri { get; } public Microsoft.OpenApi.Models.OpenApiComponents? Components { get; set; } public System.Collections.Generic.IDictionary? Extensions { get; set; } @@ -741,7 +741,7 @@ namespace Microsoft.OpenApi.Models public const bool DeprecatedDefault = false; public OpenApiOperation() { } public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation? operation) { } - public System.Collections.Generic.IDictionary Annotations { get; set; } + public System.Collections.Generic.IDictionary? Annotations { get; set; } public System.Collections.Generic.IDictionary? Callbacks { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } @@ -1529,7 +1529,7 @@ namespace Microsoft.OpenApi.Services public System.Uri GetDocumentId(string key) { } public bool RegisterComponent(string location, T component) { } public void RegisterComponents(Microsoft.OpenApi.Models.OpenApiDocument document) { } - public T ResolveReference(string location) { } + public T? ResolveReference(string location) { } } public class OperationSearch : Microsoft.OpenApi.Services.OpenApiVisitorBase {