diff --git a/docs/upgrade-guide-2.md b/docs/upgrade-guide-2.md index f1fd6c23f..7b64da76b 100644 --- a/docs/upgrade-guide-2.md +++ b/docs/upgrade-guide-2.md @@ -504,6 +504,57 @@ var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, Open // After (2.0) var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json); ``` +### Use OrderedDictionary string Instead of Dictionary + +Changed all collections to ordered collections. + +**Example:** + +```csharp +// Before (1.6) +new OpenApiSchema + { + Required = new HashSet { "id", "name" }, + Properties = new Dictionary + { + ["id"] = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int64" + }, + ["name"] = new OpenApiSchema + { + Type = JsonSchemaType.String + }, + ["tag"] = new OpenApiSchema + { + Type = JsonSchemaType.String + } + } + } + +// After (2.0) +new OpenApiSchema + { + Required = new HashSet { "id", "name" }, + Properties = new OrderedDictionary + { + ["id"] = new OpenApiSchema + { + Type = JsonSchemaType.Integer, + Format = "int64" + }, + ["name"] = new OpenApiSchema + { + Type = JsonSchemaType.String + }, + ["tag"] = new OpenApiSchema + { + Type = JsonSchemaType.String + } + } + } +``` ### Bug Fixes diff --git a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs index 368b67e8c..0374ec013 100644 --- a/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs +++ b/src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs @@ -8,12 +8,12 @@ namespace Microsoft.OpenApi.Hidi.Extensions internal static class OpenApiExtensibleExtensions { /// - /// Gets an extension value from the extensions dictionary. + /// Gets an extension value from the extensions OrderedDictionary. /// - /// A dictionary of . + /// A OrderedDictionary of . /// The key corresponding to the . /// A value matching the provided extensionKey. Return null when extensionKey is not found. - internal static string GetExtension(this Dictionary extensions, string extensionKey) + internal static string GetExtension(this OrderedDictionary extensions, string extensionKey) { if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue(out var stringValue)) { diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 52d25ef27..771170e53 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -155,7 +155,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger, ApiDependency? apiDependency, JsonDocument? postmanCollection, OpenApiDocument document) { - Dictionary> requestUrls; + OrderedDictionary> requestUrls; if (apiDependency != null) { requestUrls = GetRequestUrlsFromManifest(apiDependency); @@ -262,7 +262,7 @@ private static async Task WriteOpenApiAsync(HidiOptions options, string openApiF return document; } - private static Func? FilterOpenApiDocument(string? filterByOperationIds, string? filterByTags, Dictionary> requestUrls, OpenApiDocument document, ILogger logger) + private static Func? FilterOpenApiDocument(string? filterByOperationIds, string? filterByTags, OrderedDictionary> requestUrls, OpenApiDocument document, ILogger logger) { Func? predicate = null; @@ -295,18 +295,18 @@ private static async Task WriteOpenApiAsync(HidiOptions options, string openApiF return predicate; } - private static Dictionary> GetRequestUrlsFromManifest(ApiDependency apiDependency) + private static OrderedDictionary> GetRequestUrlsFromManifest(ApiDependency apiDependency) { // Get the request URLs from the API Dependencies in the API manifest var requests = apiDependency .Requests.Where(static r => !r.Exclude && !string.IsNullOrEmpty(r.UriTemplate) && !string.IsNullOrEmpty(r.Method)) .Select(static r => new { UriTemplate = r.UriTemplate!, Method = r.Method! }) .GroupBy(static r => r.UriTemplate) - .ToDictionary(static g => g.Key, static g => g.Select(static r => r.Method).ToList()); + .ToOrderedDictionary(static g => g.Key, static g => g.Select(static r => r.Method).ToList()); // This makes the assumption that the UriTemplate in the ApiManifest matches exactly the UriTemplate in the OpenAPI document // This does not need to be the case. The URI template in the API manifest could map to a set of OpenAPI paths. // Additional logic will be required to handle this scenario. I suggest we build this into the OpenAPI.Net library at some point. - return requests; + return new OrderedDictionary>(requests); } private static XslCompiledTransform GetFilterTransform() @@ -451,10 +451,10 @@ private static async Task ParseOpenApiAsync(string openApiFile, bool /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods /// /// A file stream. - /// A dictionary of request urls and http methods from a collection. - public static Dictionary> ParseJsonCollectionFile(Stream stream, ILogger logger) + /// A OrderedDictionary of request urls and http methods from a collection. + public static OrderedDictionary> ParseJsonCollectionFile(Stream stream, ILogger logger) { - var requestUrls = new Dictionary>(); + var requestUrls = new OrderedDictionary>(); logger.LogTrace("Parsing the json collection file into a JsonDocument"); using var document = JsonDocument.Parse(stream); @@ -466,7 +466,7 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - private static Dictionary> EnumerateJsonDocument(JsonElement itemElement, Dictionary> paths) + private static OrderedDictionary> EnumerateJsonDocument(JsonElement itemElement, OrderedDictionary> paths) { var itemsArray = itemElement.GetProperty("item"); @@ -476,7 +476,7 @@ private static Dictionary> EnumerateJsonDocument(JsonElemen { if (item.TryGetProperty("request", out var request)) { - // Fetch list of methods and urls from collection, store them in a dictionary + // Fetch list of methods and urls from collection, store them in a OrderedDictionary var path = request.GetProperty("url").GetProperty("raw").ToString(); var method = request.GetProperty("method").ToString(); if (paths.TryGetValue(path, out var value)) diff --git a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs index 0f5a9faf4..3a5ac9c9e 100644 --- a/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs @@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema) public int HeaderCount { get; set; } - public override void Visit(Dictionary headers) + public override void Visit(OrderedDictionary headers) { HeaderCount++; } diff --git a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs index cdcdb6af9..68a5fccc3 100644 --- a/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Workbench/StatsVisitor.cs @@ -27,7 +27,7 @@ public override void Visit(IOpenApiSchema schema) public int HeaderCount { get; set; } - public override void Visit(Dictionary headers) + public override void Visit(OrderedDictionary headers) { HeaderCount++; } diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs index befeddaa9..8ce58b305 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiServerExtensions.cs @@ -18,10 +18,10 @@ public static class OpenApiServerExtensions /// A URL with the provided variables substituted. /// /// Thrown when: - /// 1. A substitution has no valid value in both the supplied dictionary and the default + /// 1. A substitution has no valid value in both the supplied OrderedDictionary and the default /// 2. A substitution's value is not available in the enum provided /// - public static string? ReplaceServerUrlVariables(this OpenApiServer server, Dictionary? values = null) + public static string? ReplaceServerUrlVariables(this OpenApiServer server, OrderedDictionary? values = null) { var parsedUrl = server.Url; if (server.Variables is not null && parsedUrl is not null) diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs index 9d6dc60d0..a9e156223 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs @@ -38,7 +38,7 @@ public static string[] ToIdentifiers(this JsonSchemaType schemaType) return schemaType.ToIdentifiersInternal().ToArray(); } - private static readonly Dictionary allSchemaTypes = new() + private static readonly OrderedDictionary allSchemaTypes = new() { { JsonSchemaType.Boolean, "boolean" }, { JsonSchemaType.Integer, "integer" }, @@ -115,7 +115,7 @@ public static JsonSchemaType ToJsonSchemaType(this string identifier) return type; } - private static readonly Dictionary> _simpleTypeToOpenApiSchema = new() + private static readonly OrderedDictionary> _simpleTypeToOpenApiSchema = new() { [typeof(bool)] = () => new() { Type = JsonSchemaType.Boolean }, [typeof(byte)] = () => new() { Type = JsonSchemaType.String, Format = "byte" }, diff --git a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs index d88aeda87..4ad46cfa1 100644 --- a/src/Microsoft.OpenApi/Extensions/StringExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/StringExtensions.cs @@ -47,7 +47,7 @@ internal static class StringExtensions } private static ReadOnlyDictionary GetEnumValues([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] Type enumType) where T : Enum { - var result = new Dictionary(StringComparer.OrdinalIgnoreCase); + var result = new OrderedDictionary(StringComparer.OrdinalIgnoreCase); foreach (var field in enumType.GetFields(BindingFlags.Public | BindingFlags.Static)) { if (field.GetCustomAttribute() is { } displayAttribute diff --git a/src/Microsoft.OpenApi/HashSet.cs b/src/Microsoft.OpenApi/HashSet.cs new file mode 100644 index 000000000..97dfc7a55 --- /dev/null +++ b/src/Microsoft.OpenApi/HashSet.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Microsoft.OpenApi +{ + /// + /// Represents a collection of unique elements that preserves insertion order. + /// + /// The type of elements in the set. + public class HashSet : ICollection + where T : notnull + { + private readonly OrderedDictionary _dict; + + /// + /// Gets the equality comparer used to determine element equality. + /// + public IEqualityComparer Comparer { get; } + + /// + /// Initializes a new instance of the class that is empty + /// and uses the default equality comparer for the type. + /// + public HashSet() : this(EqualityComparer.Default) { } + + /// + /// Initializes a new instance of the class that is empty + /// and uses the specified equality comparer. + /// + /// The comparer to use when determining equality of elements. + /// Thrown if is null. + public HashSet(IEqualityComparer comparer) + { + Comparer = comparer ?? throw new ArgumentNullException(nameof(comparer)); + _dict = new OrderedDictionary(comparer); + } + + /// + /// Initializes a new instance of the class that contains elements copied + /// from the specified collection and uses the specified equality comparer. + /// + /// The collection whose elements are copied to the new set. + /// The comparer to use when determining equality of elements. + /// Thrown if or is null. + public HashSet(IEnumerable collection, IEqualityComparer comparer) + : this(comparer) + { + if (collection is null) throw new ArgumentNullException(nameof(collection)); + + foreach (var item in collection) + { + Add(item); + } + } + + /// + /// Initializes a new instance of the class that contains elements copied + /// from the specified collection and uses the default equality comparer. + /// + /// The collection whose elements are copied to the new set. + /// Thrown if is null. + public HashSet(IEnumerable collection) + : this(collection, EqualityComparer.Default) + { + } + + /// + public int Count => _dict.Count; + + /// + public bool IsReadOnly => false; + + /// + /// Attempts to add the specified element to the set. + /// + /// The element to add. + /// true if the element was added; false if it already exists in the set. + public bool Add(T item) => _dict.TryAdd(item, true); + + void ICollection.Add(T item) => Add(item); + + /// + /// Removes all elements from the set. + /// + public void Clear() => _dict.Clear(); + + /// + /// Determines whether the set contains a specific element. + /// + /// The element to locate. + /// true if the set contains the element; otherwise, false. + public bool Contains(T item) => _dict.ContainsKey(item); + + /// + /// Copies the elements of the set to an array, starting at a particular array index. + /// + /// The destination array. + /// The zero-based index in the array at which copying begins. + /// Thrown if is null. + /// Thrown if is less than 0. + /// Thrown if the number of elements in the source set is greater than the available space in the destination array. + public void CopyTo(T[] array, int arrayIndex) + { + if (array == null) throw new ArgumentNullException(nameof(array)); + if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + if (array.Length - arrayIndex < Count) throw new ArgumentException("The array is too small."); + + foreach (var key in _dict.Keys) + { + array[arrayIndex++] = key; + } + } + + /// + /// Removes the specified element from the set. + /// + /// The element to remove. + /// true if the element was successfully removed; false if it was not found. + public bool Remove(T item) => _dict.Remove(item); + + /// + /// Returns an enumerator that iterates through the set in insertion order. + /// + /// An enumerator for the set. + public IEnumerator GetEnumerator() => _dict.Keys.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } +} diff --git a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs index 4407577df..e0e2dde8d 100644 --- a/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs +++ b/src/Microsoft.OpenApi/Interfaces/IMetadataContainer.cs @@ -14,5 +14,5 @@ public interface IMetadataContainer /// A collection of properties associated with the current OpenAPI element to be used by the application. /// Metadata are NOT (de)serialized with the schema and can be used for custom properties. /// - Dictionary? Metadata { get; set; } + OrderedDictionary? Metadata { get; set; } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs index be7796a24..4c5159458 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiExtensible.cs @@ -13,6 +13,6 @@ public interface IOpenApiExtensible : IOpenApiElement /// /// Specification extensions. /// - Dictionary? Extensions { get; set; } + OrderedDictionary? Extensions { get; set; } } } diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs index fc3d19cfa..49fe3a894 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReadOnlyExtensible.cs @@ -10,6 +10,6 @@ public interface IOpenApiReadOnlyExtensible /// /// Specification extensions. /// - Dictionary? Extensions { get; } + OrderedDictionary? Extensions { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs index 1b18d237b..1c0580917 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiCallback.cs @@ -14,5 +14,5 @@ public interface IOpenApiCallback : IOpenApiReadOnlyExtensible, IShallowCopyable /// /// A Path Item Object used to define a callback request and expected responses. /// - public Dictionary? PathItems { get; } + public OrderedDictionary? PathItems { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs index fc580847c..f31392f1f 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiHeader.cs @@ -55,11 +55,11 @@ public interface IOpenApiHeader : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// Examples of the media type. /// - public Dictionary? Examples { get; } + public OrderedDictionary? Examples { get; } /// /// A map containing the representations for the header. /// - public Dictionary? Content { get; } + public OrderedDictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs index 8a263f59d..30502064f 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiLink.cs @@ -24,7 +24,7 @@ public interface IOpenApiLink : IOpenApiDescribedElement, IOpenApiReadOnlyExtens /// /// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef. /// - public Dictionary? Parameters { get; } + public OrderedDictionary? Parameters { get; } /// /// A literal value or {expression} to use as a request body when calling the target operation. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs index 8340fb698..f77a17c85 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiParameter.cs @@ -81,7 +81,7 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// Furthermore, if referencing a schema which contains an example, /// the examples value SHALL override the example provided by the schema. /// - public Dictionary? Examples { get; } + public OrderedDictionary? Examples { get; } /// /// Example of the media type. The example SHOULD match the specified schema and encoding properties @@ -102,5 +102,5 @@ public interface IOpenApiParameter : IOpenApiDescribedElement, IOpenApiReadOnlyE /// When example or examples are provided in conjunction with the schema object, /// the example MUST follow the prescribed serialization strategy for the parameter. /// - public Dictionary? Content { get; } + public OrderedDictionary? Content { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs index ca105bd76..75cb958c8 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiPathItem.cs @@ -14,7 +14,7 @@ public interface IOpenApiPathItem : IOpenApiDescribedElement, IOpenApiSummarized /// /// Gets the definition of operations on this path. /// - public Dictionary? Operations { get; } + public OrderedDictionary? Operations { get; } /// /// An alternative server array to service all operations in this path. diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs index 966361bfa..e8d465151 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiRequestBody.cs @@ -19,7 +19,7 @@ public interface IOpenApiRequestBody : IOpenApiDescribedElement, IOpenApiReadOnl /// REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it. /// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* /// - public Dictionary? Content { get; } + public OrderedDictionary? Content { get; } /// /// Converts the request body to a body parameter in preparation for a v2 serialization. /// diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs index 0ad10c1e9..98246603a 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiResponse.cs @@ -12,18 +12,18 @@ public interface IOpenApiResponse : IOpenApiDescribedElement, IOpenApiReadOnlyEx /// /// Maps a header name to its definition. /// - public Dictionary? Headers { get; } + public OrderedDictionary? Headers { get; } /// /// A map containing descriptions of potential response payloads. /// The key is a media type or media type range and the value describes it. /// - public Dictionary? Content { get; } + public OrderedDictionary? Content { get; } /// /// A map of operations links that can be followed from the response. /// The key of the map is a short name for the link, /// following the naming constraints of the names for Component Objects. /// - public Dictionary? Links { get; } + public OrderedDictionary? Links { get; } } diff --git a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs index 8ef1dec1a..90cc66805 100644 --- a/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs @@ -36,7 +36,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. /// - public Dictionary? Vocabulary { get; } + public OrderedDictionary? Vocabulary { get; } /// /// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance @@ -52,7 +52,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. /// The keyword does not directly affect the validation result /// - public Dictionary? Definitions { get; } + public OrderedDictionary? Definitions { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -196,7 +196,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced). /// - public Dictionary? Properties { get; } + public OrderedDictionary? Properties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -205,7 +205,7 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// egular expression dialect. Each property value of this object MUST be an object, and each object MUST /// be a valid Schema Object not a standard JSON Schema. /// - public Dictionary? PatternProperties { get; } + public OrderedDictionary? PatternProperties { get; } /// /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 @@ -279,10 +279,10 @@ public interface IOpenApiSchema : IOpenApiDescribedElement, IOpenApiReadOnlyExte /// /// This object stores any unrecognized keywords found in the schema. /// - public Dictionary? UnrecognizedKeywords { get; } + public OrderedDictionary? UnrecognizedKeywords { get; } /// /// Follow JSON Schema definition:https://json-schema.org/draft/2020-12/json-schema-validation#section-6.5.4 /// - public Dictionary>? DependentRequired { get; } + public OrderedDictionary>? DependentRequired { get; } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 8bd90ed7f..9dba7b406 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -16,13 +16,13 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : IOpenApiExtensible, IOpenApiCallback { /// - public Dictionary? PathItems { get; set; } + public OrderedDictionary? PathItems { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -36,7 +36,7 @@ internal OpenApiCallback(IOpenApiCallback callback) { Utils.CheckArgumentNull(callback); PathItems = callback?.PathItems != null ? new(callback.PathItems) : null; - Extensions = callback?.Extensions != null ? new Dictionary(callback.Extensions) : null; + Extensions = callback?.Extensions != null ? new OrderedDictionary(callback.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index fb0129bec..4da524dd1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -19,57 +19,57 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible /// /// An object to hold reusable Objects. /// - public Dictionary? Schemas { get; set; } + public OrderedDictionary? Schemas { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Responses { get; set; } + public OrderedDictionary? Responses { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Parameters { get; set; } + public OrderedDictionary? Parameters { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Examples { get; set; } + public OrderedDictionary? Examples { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? RequestBodies { get; set; } + public OrderedDictionary? RequestBodies { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Headers { get; set; } + public OrderedDictionary? Headers { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? SecuritySchemes { get; set; } + public OrderedDictionary? SecuritySchemes { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Links { get; set; } + public OrderedDictionary? Links { get; set; } /// /// An object to hold reusable Objects. /// - public Dictionary? Callbacks { get; set; } + public OrderedDictionary? Callbacks { get; set; } /// /// An object to hold reusable Object. /// - public Dictionary? PathItems { get; set; } + public OrderedDictionary? PathItems { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -81,17 +81,17 @@ public OpenApiComponents() { } /// public OpenApiComponents(OpenApiComponents? components) { - Schemas = components?.Schemas != null ? new Dictionary(components.Schemas) : null; - Responses = components?.Responses != null ? new Dictionary(components.Responses) : null; - Parameters = components?.Parameters != null ? new Dictionary(components.Parameters) : null; - Examples = components?.Examples != null ? new Dictionary(components.Examples) : null; - RequestBodies = components?.RequestBodies != null ? new Dictionary(components.RequestBodies) : null; - Headers = components?.Headers != null ? new Dictionary(components.Headers) : null; - SecuritySchemes = components?.SecuritySchemes != null ? new Dictionary(components.SecuritySchemes) : null; - Links = components?.Links != null ? new Dictionary(components.Links) : null; - Callbacks = components?.Callbacks != null ? new Dictionary(components.Callbacks) : null; - PathItems = components?.PathItems != null ? new Dictionary(components.PathItems) : null; - Extensions = components?.Extensions != null ? new Dictionary(components.Extensions) : null; + Schemas = components?.Schemas != null ? new OrderedDictionary(components.Schemas) : null; + Responses = components?.Responses != null ? new OrderedDictionary(components.Responses) : null; + Parameters = components?.Parameters != null ? new OrderedDictionary(components.Parameters) : null; + Examples = components?.Examples != null ? new OrderedDictionary(components.Examples) : null; + RequestBodies = components?.RequestBodies != null ? new OrderedDictionary(components.RequestBodies) : null; + Headers = components?.Headers != null ? new OrderedDictionary(components.Headers) : null; + SecuritySchemes = components?.SecuritySchemes != null ? new OrderedDictionary(components.SecuritySchemes) : null; + Links = components?.Links != null ? new OrderedDictionary(components.Links) : null; + Callbacks = components?.Callbacks != null ? new OrderedDictionary(components.Callbacks) : null; + PathItems = components?.PathItems != null ? new OrderedDictionary(components.PathItems) : null; + Extensions = components?.Extensions != null ? new OrderedDictionary(components.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index b6ed82171..ebe9814e9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -32,7 +32,7 @@ public class OpenApiContact : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -47,7 +47,7 @@ public OpenApiContact(OpenApiContact contact) Name = contact?.Name ?? Name; Url = contact?.Url != null ? new Uri(contact.Url.OriginalString, UriKind.RelativeOrAbsolute) : null; Email = contact?.Email ?? Email; - Extensions = contact?.Extensions != null ? new Dictionary(contact.Extensions) : null; + Extensions = contact?.Extensions != null ? new OrderedDictionary(contact.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index 8ad465241..f49efc8e1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -21,12 +21,12 @@ public class OpenApiDiscriminator : IOpenApiSerializable, IOpenApiExtensible /// /// An object to hold mappings between payload values and schema names or references. /// - public Dictionary? Mapping { get; set; } + public OrderedDictionary? Mapping { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -39,8 +39,8 @@ public OpenApiDiscriminator() { } public OpenApiDiscriminator(OpenApiDiscriminator discriminator) { PropertyName = discriminator?.PropertyName ?? PropertyName; - Mapping = discriminator?.Mapping != null ? new Dictionary(discriminator.Mapping) : null; - Extensions = discriminator?.Extensions != null ? new Dictionary(discriminator.Extensions) : null; + Mapping = discriminator?.Mapping != null ? new OrderedDictionary(discriminator.Mapping) : null; + Extensions = discriminator?.Extensions != null ? new OrderedDictionary(discriminator.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index c5ac5f759..2b14e1bc7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -61,7 +61,7 @@ public void RegisterComponents() /// A map of requests initiated other than by an API call, for example by an out of band registration. /// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses /// - public Dictionary? Webhooks { get; set; } + public OrderedDictionary? Webhooks { get; set; } /// /// An element to hold various schemas for the specification. @@ -103,10 +103,10 @@ public HashSet? Tags /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// - public Dictionary? Metadata { get; set; } + public OrderedDictionary? Metadata { get; set; } /// /// Absolute location of the document or a generated placeholder if location is not given @@ -134,13 +134,13 @@ public OpenApiDocument(OpenApiDocument? document) JsonSchemaDialect = document?.JsonSchemaDialect ?? JsonSchemaDialect; Servers = document?.Servers != null ? [.. document.Servers] : null; Paths = document?.Paths != null ? new(document.Paths) : []; - Webhooks = document?.Webhooks != null ? new Dictionary(document.Webhooks) : null; + Webhooks = document?.Webhooks != null ? new OrderedDictionary(document.Webhooks) : null; Components = document?.Components != null ? new(document?.Components) : null; Security = document?.Security != null ? [.. document.Security] : null; Tags = document?.Tags != null ? new HashSet(document.Tags, OpenApiTagComparer.Instance) : null; ExternalDocs = document?.ExternalDocs != null ? new(document.ExternalDocs) : null; - Extensions = document?.Extensions != null ? new Dictionary(document.Extensions) : null; - Metadata = document?.Metadata != null ? new Dictionary(document.Metadata) : null; + Extensions = document?.Extensions != null ? new OrderedDictionary(document.Extensions) : null; + Metadata = document?.Metadata != null ? new OrderedDictionary(document.Metadata) : null; BaseUri = document?.BaseUri != null ? document.BaseUri : new(OpenApiConstants.BaseRegistryUri + Guid.NewGuid()); } @@ -295,7 +295,7 @@ public void SerializeAsV2(IOpenApiWriter writer) .Distinct() .OfType() .Where(k => k.Reference?.Id is not null) - .ToDictionary( + .ToOrderedDictionary( k => k.Reference.Id!, v => v ); @@ -331,7 +331,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // parameters var parameters = Components?.Parameters != null - ? new Dictionary(Components.Parameters) + ? new OrderedDictionary(Components.Parameters) : []; if (Components?.RequestBodies != null) @@ -712,13 +712,14 @@ public bool AddComponent(string id, T componentToRegister) } return Workspace?.RegisterComponentForDocument(this, componentToRegister, id) ?? false; } + } internal class FindSchemaReferences : OpenApiVisitorBase { - private Dictionary Schemas = new(StringComparer.Ordinal); + private OrderedDictionary Schemas = new(); - public static void ResolveSchemas(OpenApiComponents? components, Dictionary schemas) + public static void ResolveSchemas(OpenApiComponents? components, OrderedDictionary schemas) { var visitor = new FindSchemaReferences { diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index cc9340317..965c4756e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -25,7 +25,7 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// /// A map allowing additional information to be provided as headers. /// - public Dictionary? Headers { get; set; } + public OrderedDictionary? Headers { get; set; } /// /// Describes how a specific property value will be serialized depending on its type. @@ -52,7 +52,7 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -65,11 +65,11 @@ public OpenApiEncoding() { } public OpenApiEncoding(OpenApiEncoding encoding) { ContentType = encoding?.ContentType ?? ContentType; - Headers = encoding?.Headers != null ? new Dictionary(encoding.Headers) : null; + Headers = encoding?.Headers != null ? new OrderedDictionary(encoding.Headers) : null; Style = encoding?.Style ?? Style; Explode = encoding?.Explode ?? Explode; AllowReserved = encoding?.AllowReserved ?? AllowReserved; - Extensions = encoding?.Extensions != null ? new Dictionary(encoding.Extensions) : null; + Extensions = encoding?.Extensions != null ? new OrderedDictionary(encoding.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 6ffb26f2e..8315dccce 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -28,7 +28,7 @@ public class OpenApiExample : IOpenApiExtensible, IOpenApiExample public JsonNode? Value { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -46,7 +46,7 @@ internal OpenApiExample(IOpenApiExample example) Description = example.Description ?? Description; Value = example.Value != null ? JsonNodeCloneHelper.Clone(example.Value) : null; ExternalValue = example.ExternalValue ?? ExternalValue; - Extensions = example.Extensions != null ? new Dictionary(example.Extensions) : null; + Extensions = example.Extensions != null ? new OrderedDictionary(example.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs index 7e4f9f686..de300feaa 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs @@ -9,10 +9,10 @@ namespace Microsoft.OpenApi.Models { /// - /// Generic dictionary type for Open API dictionary element. + /// Generic OrderedDictionary type for Open API OrderedDictionary element. /// /// The Open API element, - public abstract class OpenApiExtensibleDictionary : Dictionary, + public abstract class OpenApiExtensibleDictionary : OrderedDictionary, IOpenApiSerializable, IOpenApiExtensible where T : IOpenApiSerializable @@ -24,19 +24,19 @@ protected OpenApiExtensibleDictionary():this([]) { } /// /// Initializes a copy of class. /// - /// The generic dictionary. - /// The dictionary of . + /// The generic OrderedDictionary. + /// The OrderedDictionary of . protected OpenApiExtensibleDictionary( - Dictionary dictionary, - Dictionary? extensions = null) : base(dictionary is null ? [] : dictionary) + OrderedDictionary OrderedDictionary, + OrderedDictionary? extensions = null) : base(OrderedDictionary is null ? [] : OrderedDictionary) { - Extensions = extensions != null ? new Dictionary(extensions) : []; + Extensions = extensions != null ? new OrderedDictionary(extensions) : []; } /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index 381ee53bb..76c3cc0d4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -26,7 +26,7 @@ public class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -40,7 +40,7 @@ public OpenApiExternalDocs(OpenApiExternalDocs externalDocs) { Description = externalDocs?.Description ?? Description; Url = externalDocs?.Url != null ? new Uri(externalDocs.Url.OriginalString, UriKind.RelativeOrAbsolute) : null; - Extensions = externalDocs?.Extensions != null ? new Dictionary(externalDocs.Extensions) : null; + Extensions = externalDocs?.Extensions != null ? new OrderedDictionary(externalDocs.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 62bb09b89..26407a754 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -47,13 +47,13 @@ public class OpenApiHeader : IOpenApiHeader, IOpenApiExtensible public JsonNode? Example { get; set; } /// - public Dictionary? Examples { get; set; } + public OrderedDictionary? Examples { get; set; } /// - public Dictionary? Content { get; set; } + public OrderedDictionary? Content { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -75,9 +75,9 @@ internal OpenApiHeader(IOpenApiHeader header) AllowReserved = header.AllowReserved; Schema = header.Schema?.CreateShallowCopy(); Example = header.Example != null ? JsonNodeCloneHelper.Clone(header.Example) : null; - 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; + Examples = header.Examples != null ? new OrderedDictionary(header.Examples) : null; + Content = header.Content != null ? new OrderedDictionary(header.Content) : null; + Extensions = header.Extensions != null ? new OrderedDictionary(header.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index 119ae7eb1..12735995b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -51,7 +51,7 @@ public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -70,7 +70,7 @@ public OpenApiInfo(OpenApiInfo info) TermsOfService = info?.TermsOfService ?? TermsOfService; Contact = info?.Contact != null ? new(info.Contact) : null; License = info?.License != null ? new(info.License) : null; - Extensions = info?.Extensions != null ? new Dictionary(info.Extensions) : null; + Extensions = info?.Extensions != null ? new OrderedDictionary(info.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index c3c36812c..41f291551 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -31,7 +31,7 @@ public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -46,7 +46,7 @@ public OpenApiLicense(OpenApiLicense license) Name = license?.Name ?? Name; Identifier = license?.Identifier ?? Identifier; Url = license?.Url != null ? new Uri(license.Url.OriginalString, UriKind.RelativeOrAbsolute) : null; - Extensions = license?.Extensions != null ? new Dictionary(license.Extensions) : null; + Extensions = license?.Extensions != null ? new OrderedDictionary(license.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index ea9202186..edea05ed0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -21,7 +21,7 @@ public class OpenApiLink : IOpenApiExtensible, IOpenApiLink public string? OperationId { get; set; } /// - public Dictionary? Parameters { get; set; } + public OrderedDictionary? Parameters { get; set; } /// public RuntimeExpressionAnyWrapper? RequestBody { get; set; } @@ -33,7 +33,7 @@ public class OpenApiLink : IOpenApiExtensible, IOpenApiLink public OpenApiServer? Server { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -48,11 +48,11 @@ internal OpenApiLink(IOpenApiLink link) Utils.CheckArgumentNull(link); OperationRef = link.OperationRef ?? OperationRef; OperationId = link.OperationId ?? OperationId; - Parameters = link.Parameters != null ? new Dictionary(link.Parameters) : null; + Parameters = link.Parameters != null ? new OrderedDictionary(link.Parameters) : null; RequestBody = link.RequestBody != null ? new(link.RequestBody) : null; Description = link.Description ?? Description; Server = link.Server != null ? new(link.Server) : null; - Extensions = link.Extensions != null ? new Dictionary(link.Extensions) : null; + Extensions = link.Extensions != null ? new OrderedDictionary(link.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index a16f8d11f..86c3729a2 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -32,7 +32,7 @@ public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible /// Examples of the media type. /// Each example object SHOULD match the media type and specified schema if present. /// - public Dictionary? Examples { get; set; } + public OrderedDictionary? Examples { get; set; } /// /// A map between a property name and its encoding information. @@ -40,12 +40,12 @@ public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible /// The encoding object SHALL only apply to requestBody objects /// when the media type is multipart or application/x-www-form-urlencoded. /// - public Dictionary? Encoding { get; set; } + public OrderedDictionary? Encoding { get; set; } /// /// Serialize to Open Api v3.0. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -59,9 +59,9 @@ public OpenApiMediaType(OpenApiMediaType? mediaType) { Schema = mediaType?.Schema?.CreateShallowCopy(); Example = mediaType?.Example != null ? JsonNodeCloneHelper.Clone(mediaType.Example) : null; - 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; + Examples = mediaType?.Examples != null ? new OrderedDictionary(mediaType.Examples) : null; + Encoding = mediaType?.Encoding != null ? new OrderedDictionary(mediaType.Encoding) : null; + Extensions = mediaType?.Extensions != null ? new OrderedDictionary(mediaType.Extensions) : null; } /// @@ -119,7 +119,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // Media type does not exist in V2. } - private static void SerializeExamples(IOpenApiWriter writer, Dictionary examples) + private static void SerializeExamples(IOpenApiWriter writer, OrderedDictionary 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 diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index 05c8da5e1..1aed10617 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -33,12 +33,12 @@ public class OpenApiOAuthFlow : IOpenApiSerializable, IOpenApiExtensible /// /// REQUIRED. A map between the scope name and a short description for it. /// - public Dictionary? Scopes { get; set; } + public OrderedDictionary? Scopes { get; set; } /// /// Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -53,8 +53,8 @@ public OpenApiOAuthFlow(OpenApiOAuthFlow oAuthFlow) AuthorizationUrl = oAuthFlow?.AuthorizationUrl != null ? new Uri(oAuthFlow.AuthorizationUrl.OriginalString, UriKind.RelativeOrAbsolute) : null; TokenUrl = oAuthFlow?.TokenUrl != null ? new Uri(oAuthFlow.TokenUrl.OriginalString, UriKind.RelativeOrAbsolute) : null; RefreshUrl = oAuthFlow?.RefreshUrl != null ? new Uri(oAuthFlow.RefreshUrl.OriginalString, UriKind.RelativeOrAbsolute) : null; - Scopes = oAuthFlow?.Scopes != null ? new Dictionary(oAuthFlow.Scopes) : null; - Extensions = oAuthFlow?.Extensions != null ? new Dictionary(oAuthFlow.Extensions) : null; + Scopes = oAuthFlow?.Scopes != null ? new OrderedDictionary(oAuthFlow.Scopes) : null; + Extensions = oAuthFlow?.Extensions != null ? new OrderedDictionary(oAuthFlow.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index b46b41da1..7443dc23a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -36,7 +36,7 @@ public class OpenApiOAuthFlows : IOpenApiSerializable, IOpenApiExtensible /// /// Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -53,7 +53,7 @@ public OpenApiOAuthFlows(OpenApiOAuthFlows oAuthFlows) Password = oAuthFlows?.Password != null ? new(oAuthFlows.Password) : null; ClientCredentials = oAuthFlows?.ClientCredentials != null ? new(oAuthFlows.ClientCredentials) : null; AuthorizationCode = oAuthFlows?.AuthorizationCode != null ? new(oAuthFlows.AuthorizationCode) : null; - Extensions = oAuthFlows?.Extensions != null ? new Dictionary(oAuthFlows.Extensions) : null; + Extensions = oAuthFlows?.Extensions != null ? new OrderedDictionary(oAuthFlows.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index b446ccbd4..14314b3a3 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -97,7 +97,7 @@ public HashSet? Tags /// The key value used to identify the callback object is an expression, evaluated at runtime, /// that identifies a URL to use for the callback operation. /// - public Dictionary? Callbacks { get; set; } + public OrderedDictionary? Callbacks { get; set; } /// /// Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. @@ -123,10 +123,10 @@ public HashSet? Tags /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// - public Dictionary? Metadata { get; set; } + public OrderedDictionary? Metadata { get; set; } /// /// Parameterless constructor @@ -147,12 +147,12 @@ public OpenApiOperation(OpenApiOperation operation) Parameters = operation.Parameters != null ? [.. operation.Parameters] : null; RequestBody = operation.RequestBody?.CreateShallowCopy(); Responses = operation.Responses != null ? new(operation.Responses) : null; - Callbacks = operation.Callbacks != null ? new Dictionary(operation.Callbacks) : null; + Callbacks = operation.Callbacks != null ? new OrderedDictionary(operation.Callbacks) : null; Deprecated = operation.Deprecated; Security = operation.Security != null ? [.. operation.Security] : null; Servers = operation.Servers != null ? [.. operation.Servers] : null; - Extensions = operation.Extensions != null ? new Dictionary(operation.Extensions) : null; - Metadata = operation.Metadata != null ? new Dictionary(operation.Metadata) : null; + Extensions = operation.Extensions != null ? new OrderedDictionary(operation.Extensions) : null; + Metadata = operation.Metadata != null ? new OrderedDictionary(operation.Metadata) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index a990ddcbb..02878fbd4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -61,16 +61,16 @@ public bool Explode public IOpenApiSchema? Schema { get; set; } /// - public Dictionary? Examples { get; set; } + public OrderedDictionary? Examples { get; set; } /// public JsonNode? Example { get; set; } /// - public Dictionary? Content { get; set; } + public OrderedDictionary? Content { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// A parameterless constructor @@ -91,10 +91,10 @@ internal OpenApiParameter(IOpenApiParameter parameter) Explode = parameter.Explode; AllowReserved = parameter.AllowReserved; Schema = parameter.Schema?.CreateShallowCopy(); - Examples = parameter.Examples != null ? new Dictionary(parameter.Examples) : null; + Examples = parameter.Examples != null ? new OrderedDictionary(parameter.Examples) : null; Example = parameter.Example != null ? JsonNodeCloneHelper.Clone(parameter.Example) : null; - Content = parameter.Content != null ? new Dictionary(parameter.Content) : null; - Extensions = parameter.Extensions != null ? new Dictionary(parameter.Extensions) : null; + Content = parameter.Content != null ? new OrderedDictionary(parameter.Content) : null; + Extensions = parameter.Extensions != null ? new OrderedDictionary(parameter.Extensions) : null; AllowEmptyValue = parameter.AllowEmptyValue; Deprecated = parameter.Deprecated; } @@ -179,7 +179,7 @@ internal virtual void WriteInPropertyForV2(IOpenApiWriter writer) /// /// Writer to use for the serialization /// Extensions clone - internal virtual void WriteRequestBodySchemaForV2(IOpenApiWriter writer, Dictionary? extensionsClone) + internal virtual void WriteRequestBodySchemaForV2(IOpenApiWriter writer, OrderedDictionary? extensionsClone) { // In V2 parameter's type can't be a reference to a custom object schema or can't be of type object // So in that case map the type as string. @@ -269,7 +269,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // deprecated writer.WriteProperty(OpenApiConstants.Deprecated, Deprecated, false); - var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; + var extensionsClone = Extensions is not null ? Extensions : null; // schema WriteRequestBodySchemaForV2(writer, extensionsClone); @@ -317,7 +317,7 @@ public IOpenApiParameter CreateShallowCopy() /// internal class OpenApiBodyParameter : OpenApiParameter { - internal override void WriteRequestBodySchemaForV2(IOpenApiWriter writer, Dictionary? extensionsClone) + internal override void WriteRequestBodySchemaForV2(IOpenApiWriter writer, OrderedDictionary? extensionsClone) { writer.WriteOptionalObject(OpenApiConstants.Schema, Schema, (w, s) => s.SerializeAsV2(w)); } diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index a001b922c..2df1f47a3 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -23,7 +23,7 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiPathItem public string? Description { get; set; } /// - public Dictionary? Operations { get; set; } + public OrderedDictionary? Operations { get; set; } /// public List? Servers { get; set; } @@ -32,7 +32,7 @@ public class OpenApiPathItem : IOpenApiExtensible, IOpenApiPathItem public List? Parameters { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Add one operation into this path item. @@ -58,10 +58,10 @@ internal OpenApiPathItem(IOpenApiPathItem pathItem) Utils.CheckArgumentNull(pathItem); Summary = pathItem.Summary ?? Summary; Description = pathItem.Description ?? Description; - Operations = pathItem.Operations != null ? new Dictionary(pathItem.Operations) : null; + Operations = pathItem.Operations != null ? new OrderedDictionary(pathItem.Operations) : null; Servers = pathItem.Servers != null ? [.. pathItem.Servers] : null; Parameters = pathItem.Parameters != null ? [.. pathItem.Parameters] : null; - Extensions = pathItem.Extensions != null ? new Dictionary(pathItem.Extensions) : null; + Extensions = pathItem.Extensions != null ? new OrderedDictionary(pathItem.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs index a15fed843..7c8d52752 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs @@ -19,6 +19,6 @@ public OpenApiPaths() { } /// Initializes a copy of object /// /// The . - public OpenApiPaths(OpenApiPaths paths) : base(dictionary: paths) { } + public OpenApiPaths(OpenApiPaths paths) : base(OrderedDictionary: paths) { } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 302cfc5ae..d236f1573 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -25,10 +25,10 @@ public class OpenApiRequestBody : IOpenApiExtensible, IOpenApiRequestBody public bool Required { get; set; } /// - public Dictionary? Content { get; set; } + public OrderedDictionary? Content { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameter-less constructor @@ -43,8 +43,8 @@ internal OpenApiRequestBody(IOpenApiRequestBody requestBody) Utils.CheckArgumentNull(requestBody); Description = requestBody.Description ?? Description; Required = requestBody.Required; - Content = requestBody.Content != null ? new Dictionary(requestBody.Content) : null; - Extensions = requestBody.Extensions != null ? new Dictionary(requestBody.Extensions) : null; + Content = requestBody.Content != null ? new OrderedDictionary(requestBody.Content) : null; + Extensions = requestBody.Extensions != null ? new OrderedDictionary(requestBody.Extensions) : null; } /// @@ -105,7 +105,7 @@ public IOpenApiParameter ConvertToBodyParameter(IOpenApiWriter writer) Schema = Content?.Values.FirstOrDefault()?.Schema ?? new OpenApiSchema(), Examples = Content?.Values.FirstOrDefault()?.Examples, Required = Required, - Extensions = Extensions?.ToDictionary(static k => k.Key, static v => v.Value) + Extensions = Extensions?.ToOrderedDictionary(static k => k.Key, static v => v.Value) }; // Clone extensions so we can remove the x-bodyName extensions from the output V2 model. if (bodyParameter.Extensions is not null && diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 13ab81152..5625271c8 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -19,16 +19,16 @@ public class OpenApiResponse : IOpenApiExtensible, IOpenApiResponse public string? Description { get; set; } /// - public Dictionary? Headers { get; set; } + public OrderedDictionary? Headers { get; set; } /// - public Dictionary? Content { get; set; } + public OrderedDictionary? Content { get; set; } /// - public Dictionary? Links { get; set; } + public OrderedDictionary? Links { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -42,10 +42,10 @@ internal OpenApiResponse(IOpenApiResponse response) { Utils.CheckArgumentNull(response); Description = response.Description ?? Description; - Headers = response.Headers != null ? new Dictionary(response.Headers) : null; - Content = response.Content != null ? new Dictionary(response.Content) : null; - Links = response.Links != null ? new Dictionary(response.Links) : null; - Extensions = response.Extensions != null ? new Dictionary(response.Extensions) : null; + Headers = response.Headers != null ? new OrderedDictionary(response.Headers) : null; + Content = response.Content != null ? new OrderedDictionary(response.Content) : null; + Links = response.Links != null ? new OrderedDictionary(response.Links) : null; + Extensions = response.Extensions != null ? new OrderedDictionary(response.Extensions) : null; } /// @@ -101,7 +101,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // description writer.WriteRequiredProperty(OpenApiConstants.Description, Description); - var extensionsClone = Extensions is not null ? new Dictionary(Extensions) : null; + var extensionsClone = Extensions is not null ? Extensions : null; if (Content != null) { @@ -136,7 +136,7 @@ public void SerializeAsV2(IOpenApiWriter writer) foreach (var example in Content .Select(static x => x.Value.Examples) - .OfType>() + .OfType>() .SelectMany(static x => x)) { writer.WritePropertyName(example.Key); diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs index 855ac6834..8c06c888a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs @@ -19,6 +19,6 @@ public OpenApiResponses() { } /// Initializes a copy of object /// /// The - public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses) { } + public OpenApiResponses(OpenApiResponses openApiResponses) : base(OrderedDictionary: openApiResponses) { } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 94d0d9299..77ecc2d37 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -33,7 +33,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema, IMetadataContai public string? Comment { get; set; } /// - public Dictionary? Vocabulary { get; set; } + public OrderedDictionary? Vocabulary { get; set; } /// public string? DynamicRef { get; set; } @@ -42,7 +42,7 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiSchema, IMetadataContai public string? DynamicAnchor { get; set; } /// - public Dictionary? Definitions { get; set; } + public OrderedDictionary? Definitions { get; set; } private string? _exclusiveMaximum; /// @@ -200,10 +200,10 @@ public string? Minimum public bool? UniqueItems { get; set; } /// - public Dictionary? Properties { get; set; } + public OrderedDictionary? Properties { get; set; } /// - public Dictionary? PatternProperties { get; set; } + public OrderedDictionary? PatternProperties { get; set; } /// public int? MaxProperties { get; set; } @@ -242,16 +242,16 @@ public string? Minimum public OpenApiXml? Xml { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// - public Dictionary? UnrecognizedKeywords { get; set; } + public OrderedDictionary? UnrecognizedKeywords { get; set; } /// - public Dictionary? Metadata { get; set; } + public OrderedDictionary? Metadata { get; set; } /// - public Dictionary>? DependentRequired { get; set; } + public OrderedDictionary>? DependentRequired { get; set; } /// /// Parameterless constructor @@ -270,10 +270,10 @@ internal OpenApiSchema(IOpenApiSchema schema) Const = schema.Const ?? Const; Schema = schema.Schema ?? Schema; Comment = schema.Comment ?? Comment; - Vocabulary = schema.Vocabulary != null ? new Dictionary(schema.Vocabulary) : null; + Vocabulary = schema.Vocabulary != null ? new OrderedDictionary(schema.Vocabulary) : null; DynamicAnchor = schema.DynamicAnchor ?? DynamicAnchor; DynamicRef = schema.DynamicRef ?? DynamicRef; - Definitions = schema.Definitions != null ? new Dictionary(schema.Definitions) : null; + Definitions = schema.Definitions != null ? new OrderedDictionary(schema.Definitions) : null; UnevaluatedProperties = schema.UnevaluatedProperties; ExclusiveMaximum = schema.ExclusiveMaximum ?? ExclusiveMaximum; ExclusiveMinimum = schema.ExclusiveMinimum ?? ExclusiveMinimum; @@ -303,8 +303,8 @@ internal OpenApiSchema(IOpenApiSchema schema) MaxItems = schema.MaxItems ?? MaxItems; MinItems = schema.MinItems ?? MinItems; UniqueItems = schema.UniqueItems ?? UniqueItems; - Properties = schema.Properties != null ? new Dictionary(schema.Properties) : null; - PatternProperties = schema.PatternProperties != null ? new Dictionary(schema.PatternProperties) : null; + Properties = schema.Properties != null ? new OrderedDictionary(schema.Properties) : null; + PatternProperties = schema.PatternProperties != null ? new OrderedDictionary(schema.PatternProperties) : null; MaxProperties = schema.MaxProperties ?? MaxProperties; MinProperties = schema.MinProperties ?? MinProperties; AdditionalPropertiesAllowed = schema.AdditionalPropertiesAllowed; @@ -316,10 +316,10 @@ internal OpenApiSchema(IOpenApiSchema schema) ExternalDocs = schema.ExternalDocs != null ? new(schema.ExternalDocs) : null; Deprecated = schema.Deprecated; Xml = schema.Xml != null ? new(schema.Xml) : null; - Extensions = schema.Extensions != null ? new Dictionary(schema.Extensions) : null; - Metadata = schema is IMetadataContainer { Metadata: not null } mContainer ? new Dictionary(mContainer.Metadata) : null; - UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new Dictionary(schema.UnrecognizedKeywords) : null; - DependentRequired = schema.DependentRequired != null ? new Dictionary>(schema.DependentRequired) : null; + Extensions = schema.Extensions != null ? new OrderedDictionary(schema.Extensions) : null; + Metadata = schema is IMetadataContainer { Metadata: not null } mContainer ? new OrderedDictionary(mContainer.Metadata) : null; + UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new OrderedDictionary(schema.UnrecognizedKeywords) : null; + DependentRequired = schema.DependentRequired != null ? new OrderedDictionary>(schema.DependentRequired) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs index f9d40682b..3fa8acd76 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityRequirement.cs @@ -19,7 +19,7 @@ namespace Microsoft.OpenApi.Models /// then the value is a list of scope names required for the execution. /// For other security scheme types, the array MUST be empty. /// - public class OpenApiSecurityRequirement : Dictionary>, + public class OpenApiSecurityRequirement : OrderedDictionary>, IOpenApiSerializable { /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 992fe7986..902a5aaf5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -40,7 +40,7 @@ public class OpenApiSecurityScheme : IOpenApiExtensible, IOpenApiSecurityScheme public Uri? OpenIdConnectUrl { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -61,7 +61,7 @@ internal OpenApiSecurityScheme(IOpenApiSecurityScheme securityScheme) BearerFormat = securityScheme.BearerFormat ?? BearerFormat; Flows = securityScheme.Flows != null ? new(securityScheme.Flows) : null; OpenIdConnectUrl = securityScheme.OpenIdConnectUrl != null ? new Uri(securityScheme.OpenIdConnectUrl.OriginalString, UriKind.RelativeOrAbsolute) : null; - Extensions = securityScheme.Extensions != null ? new Dictionary(securityScheme.Extensions) : null; + Extensions = securityScheme.Extensions != null ? new OrderedDictionary(securityScheme.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index 9c5b3cfca..f635cb3ce 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -28,12 +28,12 @@ public class OpenApiServer : IOpenApiSerializable, IOpenApiExtensible /// /// A map between a variable name and its value. The value is used for substitution in the server's URL template. /// - public Dictionary? Variables { get; set; } + public OrderedDictionary? Variables { get; set; } /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -47,8 +47,8 @@ public OpenApiServer(OpenApiServer server) { Description = server?.Description ?? Description; Url = server?.Url ?? Url; - Variables = server?.Variables != null ? new Dictionary(server.Variables) : null; - Extensions = server?.Extensions != null ? new Dictionary(server.Extensions) : null; + Variables = server?.Variables != null ? new OrderedDictionary(server.Variables) : null; + Extensions = server?.Extensions != null ? new OrderedDictionary(server.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 793c94d6c..3910e2a64 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -34,7 +34,7 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// /// This object MAY be extended with Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -49,7 +49,7 @@ public OpenApiServerVariable(OpenApiServerVariable serverVariable) Description = serverVariable?.Description; Default = serverVariable?.Default; Enum = serverVariable?.Enum != null ? new(serverVariable.Enum) : serverVariable?.Enum; - Extensions = serverVariable?.Extensions != null ? new Dictionary(serverVariable.Extensions) : serverVariable?.Extensions; + Extensions = serverVariable?.Extensions != null ? new OrderedDictionary(serverVariable.Extensions) : serverVariable?.Extensions; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index 253fab1de..f453a5013 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -24,7 +24,7 @@ public class OpenApiTag : IOpenApiExtensible, IOpenApiTag, IOpenApiDescribedElem public OpenApiExternalDocs? ExternalDocs { get; set; } /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -40,7 +40,7 @@ internal OpenApiTag(IOpenApiTag tag) Name = tag.Name ?? Name; Description = tag.Description ?? Description; ExternalDocs = tag.ExternalDocs != null ? new(tag.ExternalDocs) : null; - Extensions = tag.Extensions != null ? new Dictionary(tag.Extensions) : null; + Extensions = tag.Extensions != null ? new OrderedDictionary(tag.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index ae8a94a46..8c8bb7729 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -43,7 +43,7 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible /// /// Specification Extensions. /// - public Dictionary? Extensions { get; set; } + public OrderedDictionary? Extensions { get; set; } /// /// Parameterless constructor @@ -60,7 +60,7 @@ public OpenApiXml(OpenApiXml xml) Prefix = xml?.Prefix ?? Prefix; Attribute = xml?.Attribute ?? Attribute; Wrapped = xml?.Wrapped ?? Wrapped; - Extensions = xml?.Extensions != null ? new Dictionary(xml.Extensions) : null; + Extensions = xml?.Extensions != null ? new OrderedDictionary(xml.Extensions) : null; } /// diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs index 1211561e4..a6eb6dd7d 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiCallbackReference.cs @@ -38,10 +38,10 @@ private OpenApiCallbackReference(OpenApiCallbackReference callback):base(callbac } /// - public Dictionary? PathItems { get => Target?.PathItems; } + public OrderedDictionary? PathItems { get => Target?.PathItems; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(IOpenApiCallback source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs index 59cb7319e..143d7f103 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiExampleReference.cs @@ -51,7 +51,7 @@ public string? Summary } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public string? ExternalValue { get => Target?.ExternalValue; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs index fa8fe15eb..af69ed600 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiHeaderReference.cs @@ -68,13 +68,13 @@ public string? Description public JsonNode? Example { get => Target?.Example; } /// - public Dictionary? Examples { get => Target?.Examples; } + public OrderedDictionary? Examples { get => Target?.Examples; } /// - public Dictionary? Content { get => Target?.Content; } + public OrderedDictionary? Content { get => Target?.Content; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiHeader CopyReferenceAsTargetElementWithOverrides(IOpenApiHeader source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs index 71f52ecd9..16f39d87a 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiLinkReference.cs @@ -52,13 +52,13 @@ public string? Description public OpenApiServer? Server { get => Target?.Server; } /// - public Dictionary? Parameters { get => Target?.Parameters; } + public OrderedDictionary? Parameters { get => Target?.Parameters; } /// public RuntimeExpressionAnyWrapper? RequestBody { get => Target?.RequestBody; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override void SerializeAsV2(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs index ae9322e41..b7dc8bb2e 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiParameterReference.cs @@ -61,7 +61,7 @@ public string? Description public IOpenApiSchema? Schema { get => Target?.Schema; } /// - public Dictionary? Examples { get => Target?.Examples; } + public OrderedDictionary? Examples { get => Target?.Examples; } /// public JsonNode? Example { get => Target?.Example; } @@ -76,10 +76,10 @@ public string? Description public bool Explode { get => Target?.Explode ?? default; } /// - public Dictionary? Content { get => Target?.Content; } + public OrderedDictionary? Content { get => Target?.Content; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiParameter CopyReferenceAsTargetElementWithOverrides(IOpenApiParameter source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs index a6ae2d405..5d3e33576 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiPathItemReference.cs @@ -53,7 +53,7 @@ public string? Description } /// - public Dictionary? Operations { get => Target?.Operations; } + public OrderedDictionary? Operations { get => Target?.Operations; } /// public List? Servers { get => Target?.Servers; } @@ -62,7 +62,7 @@ public string? Description public List? Parameters { get => Target?.Parameters; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiPathItem CopyReferenceAsTargetElementWithOverrides(IOpenApiPathItem source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs index f6bee476b..cd86752c5 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs @@ -45,13 +45,13 @@ public string? Description } /// - public Dictionary? Content { get => Target?.Content; } + public OrderedDictionary? Content { get => Target?.Content; } /// public bool Required { get => Target?.Required ?? false; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiRequestBody CopyReferenceAsTargetElementWithOverrides(IOpenApiRequestBody source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs index 648b9c4c6..4ec8f0b49 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiResponseReference.cs @@ -43,16 +43,16 @@ public string? Description } /// - public Dictionary? Content { get => Target?.Content; } + public OrderedDictionary? Content { get => Target?.Content; } /// - public Dictionary? Headers { get => Target?.Headers; } + public OrderedDictionary? Headers { get => Target?.Headers; } /// - public Dictionary? Links { get => Target?.Links; } + public OrderedDictionary? Links { get => Target?.Links; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public override IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(IOpenApiResponse source) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs index 6c191c8e5..410b26ff8 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs @@ -52,13 +52,13 @@ public string? Description /// public string? Comment { get => Target?.Comment; } /// - public Dictionary? Vocabulary { get => Target?.Vocabulary; } + public OrderedDictionary? Vocabulary { get => Target?.Vocabulary; } /// public string? DynamicRef { get => Target?.DynamicRef; } /// public string? DynamicAnchor { get => Target?.DynamicAnchor; } /// - public Dictionary? Definitions { get => Target?.Definitions; } + public OrderedDictionary? Definitions { get => Target?.Definitions; } /// public string? ExclusiveMaximum { get => Target?.ExclusiveMaximum; } /// @@ -106,9 +106,9 @@ public string? Description /// public bool? UniqueItems { get => Target?.UniqueItems; } /// - public Dictionary? Properties { get => Target?.Properties; } + public OrderedDictionary? Properties { get => Target?.Properties; } /// - public Dictionary? PatternProperties { get => Target?.PatternProperties; } + public OrderedDictionary? PatternProperties { get => Target?.PatternProperties; } /// public int? MaxProperties { get => Target?.MaxProperties; } /// @@ -134,13 +134,13 @@ public string? Description /// public OpenApiXml? Xml { get => Target?.Xml; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// - public Dictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } + public OrderedDictionary? UnrecognizedKeywords { get => Target?.UnrecognizedKeywords; } /// - public Dictionary>? DependentRequired { get => Target?.DependentRequired; } + public OrderedDictionary>? DependentRequired { get => Target?.DependentRequired; } /// public override void SerializeAsV31(IOpenApiWriter writer) diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs index ff9c5b396..d1640f923 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiSecuritySchemeReference.cs @@ -57,7 +57,7 @@ public string? Description public Uri? OpenIdConnectUrl { get => Target?.OpenIdConnectUrl; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public SecuritySchemeType? Type { get => Target?.Type; } diff --git a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs index 769764c9d..ab604c9df 100644 --- a/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs +++ b/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs @@ -56,7 +56,7 @@ public string? Description public OpenApiExternalDocs? ExternalDocs { get => Target?.ExternalDocs; } /// - public Dictionary? Extensions { get => Target?.Extensions; } + public OrderedDictionary? Extensions { get => Target?.Extensions; } /// public string? Name { get => Target?.Name; } diff --git a/src/Microsoft.OpenApi/OrderedDictionary.cs b/src/Microsoft.OpenApi/OrderedDictionary.cs new file mode 100644 index 000000000..4f30f9640 --- /dev/null +++ b/src/Microsoft.OpenApi/OrderedDictionary.cs @@ -0,0 +1,296 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.OpenApi +{ + /// + /// Represents a generic dictionary that preserves the order in which keys and values are added. + /// + /// The type of keys in the dictionary. Must be non-nullable. + /// The type of values in the dictionary. + public class OrderedDictionary : IDictionary + where TKey : notnull + { + private readonly List> _items = new(); + private readonly Dictionary _indexMap; + + /// + /// Gets the number of key-value pairs contained in the dictionary. + /// + public int Count => _items.Count; + + /// + /// Gets a value indicating whether the dictionary is read-only. Always returns false. + /// + public bool IsReadOnly => false; + + /// + /// Gets a collection containing the keys in the dictionary, in insertion order. + /// + public ICollection Keys => _items.Select(kvp => kvp.Key).ToList(); + + /// + /// Gets a collection containing the values in the dictionary, in insertion order. + /// + public ICollection Values => _items.Select(kvp => kvp.Value).ToList(); + + /// + /// Initializes a new instance of the class + /// using the default equality comparer for the key type. + /// + public OrderedDictionary() + : this((IEqualityComparer?)null) + { + } + + /// + /// Initializes a new instance of the class + /// using the specified equality comparer for the keys. + /// + /// + /// The implementation to use when comparing keys, + /// or null to use the default equality comparer for the type of the key. + /// + public OrderedDictionary(IEqualityComparer? comparer) + { + _indexMap = new Dictionary(comparer); + } + + /// + /// Initializes a new instance of the class + /// by copying elements from an existing , + /// preserving the key comparer used by the source. + /// + /// The source to copy from. + /// Thrown when the source dictionary is null. + public OrderedDictionary(OrderedDictionary source) + : this(source == null ? throw new ArgumentNullException(nameof(source)) : source._indexMap.Comparer) + { + foreach (var kvp in source) + { + Add(kvp.Key, kvp.Value); + } + } + + /// + /// Gets or sets the value associated with the specified key. + /// + /// The key of the value to get or set. + /// The value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (!_indexMap.TryGetValue(key, out int index)) + throw new KeyNotFoundException($"Key '{key}' not found."); + return _items[index].Value; + } + set + { + if (_indexMap.TryGetValue(key, out int index)) + { + _items[index] = new KeyValuePair(key, value); + } + else + { + _items.Add(new KeyValuePair(key, value)); + _indexMap[key] = _items.Count - 1; + } + } + } + + /// + /// Adds the specified key and value to the dictionary. + /// + /// The key of the element to add. + /// The value of the element to add. + /// Thrown when the key already exists in the dictionary. + public void Add(TKey key, TValue value) + { + if (_indexMap.ContainsKey(key)) + throw new ArgumentException($"An item with the same key '{key}' already exists."); + + _items.Add(new KeyValuePair(key, value)); + _indexMap[key] = _items.Count - 1; + } + + /// + /// Adds the specified key-value pair to the dictionary. + /// + /// The key-value pair to add. + public void Add(KeyValuePair item) => Add(item.Key, item.Value); + + /// + /// Determines whether the dictionary contains an element with the specified key. + /// + /// The key to locate in the dictionary. + /// true if the dictionary contains an element with the key; otherwise, false. + public bool ContainsKey(TKey key) => _indexMap.ContainsKey(key); + + /// + /// Determines whether the dictionary contains the specified key-value pair. + /// + /// The key-value pair to locate in the dictionary. + /// true if the key-value pair is found; otherwise, false. + public bool Contains(KeyValuePair item) => + _indexMap.TryGetValue(item.Key, out int index) && + EqualityComparer.Default.Equals(_items[index].Value, item.Value); + + /// + /// Attempts to get the value associated with the specified key. + /// + /// The key of the value to get. + /// The value associated with the specified key, if found. + /// true if the key was found; otherwise, false. + public bool TryGetValue(TKey key, out TValue value) + { + if (_indexMap.TryGetValue(key, out int index)) + { + value = _items[index].Value; + return true; + } + value = default!; + return false; + } + + /// + /// Removes the value with the specified key from the dictionary. + /// + /// The key of the element to remove. + /// true if the element is successfully removed; otherwise, false. + public bool Remove(TKey key) + { + if (!_indexMap.TryGetValue(key, out int index)) + return false; + + _items.RemoveAt(index); + _indexMap.Remove(key); + ReindexFrom(index); + return true; + } + + /// + /// Removes the specified key-value pair from the dictionary. + /// + /// The key-value pair to remove. + /// true if the item was successfully removed; otherwise, false. + public bool Remove(KeyValuePair item) + { + if (!Contains(item)) + return false; + + return Remove(item.Key); + } + + /// + /// Removes all keys and values from the dictionary. + /// + public void Clear() + { + _items.Clear(); + _indexMap.Clear(); + } + + /// + /// Copies the elements of the dictionary to an array, starting at the specified array index. + /// + /// The destination array. + /// The zero-based index in the array at which copying begins. + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + _items.CopyTo(array, arrayIndex); + } + + /// + /// Returns an enumerator that iterates through the dictionary. + /// + /// An enumerator for the dictionary. + public IEnumerator> GetEnumerator() => _items.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// + /// Inserts a key-value pair at the specified index. If index equals Count, behaves like Add. + /// + /// The zero-based index at which the key-value pair should be inserted. + /// The key of the element to insert. + /// The value of the element to insert. + /// Thrown when the index is not in a valid range. + /// Thrown when the key already exists. + public void Insert(int index, TKey key, TValue value) + { + if (_indexMap.ContainsKey(key)) + throw new ArgumentException($"An item with the same key '{key}' already exists."); + + if (index < 0 || index > _items.Count) + throw new ArgumentOutOfRangeException(nameof(index)); + + _items.Insert(index, new KeyValuePair(key, value)); + ReindexFrom(index); + } + + /// + /// Attempts to add the specified key and value to the dictionary if the key does not already exist. + /// + /// The key of the element to add. + /// The value of the element to add. + /// true if the key-value pair was added; false if the key already exists. + public bool TryAdd(TKey key, TValue value) + { + if (_indexMap.ContainsKey(key)) + return false; + Add(key, value); + return true; + } + + /// + /// Updates the index mapping starting from the specified index. + /// + /// The starting index to begin reindexing. + private void ReindexFrom(int startIndex) + { + for (int i = startIndex; i < _items.Count; i++) + { + _indexMap[_items[i].Key] = i; + } + } + } + + /// + /// Provides extension methods for converting collections to . + /// + public static class OrderedDictionaryExtensions + { + /// + /// Creates an from an + /// using the specified key and value selector functions. + /// + /// The type of the elements of the source sequence. + /// The type of keys in the resulting dictionary. + /// The type of values in the resulting dictionary. + /// The source sequence to convert. + /// A function to extract the key from each element. + /// A function to extract the value from each element. + /// An containing keys and values selected from the source sequence. + /// Thrown when any argument is null. + public static OrderedDictionary ToOrderedDictionary( + this IEnumerable source, + Func keySelector, + Func valueSelector) + where TKey : notnull + { + if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (valueSelector == null) throw new ArgumentNullException(nameof(valueSelector)); + + var dict = new OrderedDictionary(); + foreach (var item in source) + { + dict.Add(keySelector(item), valueSelector(item)); + } + return dict; + } + } +} diff --git a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs index 6f15fa5f6..94e355f9d 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiReaderSettings.cs @@ -107,7 +107,7 @@ public Dictionary Readers /// /// Dictionary of parsers for converting extensions into strongly typed classes /// - public Dictionary>? ExtensionParsers { get; set; } = new(); + public OrderedDictionary>? ExtensionParsers { get; set; } = new(); /// /// Rules to use for validating OpenAPI specification. If none are provided a default set of rules are applied. diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMap.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMap.cs index f1c76d315..4f8f6b9f1 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMap.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyFieldMap.cs @@ -5,7 +5,7 @@ namespace Microsoft.OpenApi.Reader.ParseNodes { - internal class AnyFieldMap : Dictionary> + internal class AnyFieldMap : OrderedDictionary> { } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMap.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMap.cs index 578d6b68e..03ed9bb24 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMap.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyListFieldMap.cs @@ -5,7 +5,7 @@ namespace Microsoft.OpenApi.Reader.ParseNodes { - internal class AnyListFieldMap : Dictionary> + internal class AnyListFieldMap : OrderedDictionary> { } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMap.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMap.cs index cc4128740..fac402f0b 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMap.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMap.cs @@ -5,7 +5,7 @@ namespace Microsoft.OpenApi.Reader.ParseNodes { - internal class AnyMapFieldMap : Dictionary> + internal class AnyMapFieldMap : OrderedDictionary> { } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs index 883aa137b..1e7f25a87 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/AnyMapFieldMapParameter.cs @@ -15,7 +15,7 @@ internal class AnyMapFieldMapParameter /// Constructor /// public AnyMapFieldMapParameter( - Func?> propertyMapGetter, + Func?> propertyMapGetter, Func propertyGetter, Action propertySetter, Func schemaGetter) @@ -29,7 +29,7 @@ public AnyMapFieldMapParameter( /// /// Function to retrieve the property that is a map from string to an inner element containing IOpenApiAny. /// - public Func?> PropertyMapGetter { get; } + public Func?> PropertyMapGetter { get; } /// /// Function to retrieve the value of the property from an inner element. diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/FixedFieldMap.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/FixedFieldMap.cs index 139f38c6a..6b37c1e7a 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/FixedFieldMap.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/FixedFieldMap.cs @@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Reader.ParseNodes { - internal class FixedFieldMap : Dictionary> + internal class FixedFieldMap : OrderedDictionary> { } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs index ae7adefa6..d160d008a 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs @@ -48,7 +48,7 @@ public PropertyNode? this[string key] } } - public override Dictionary CreateMap(Func map, OpenApiDocument hostDocument) + public override OrderedDictionary CreateMap(Func map, OpenApiDocument hostDocument) { var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); var nodes = jsonMap.Select( @@ -75,10 +75,10 @@ public override Dictionary CreateMap(Func k.key, v => v.value); + return nodes.ToOrderedDictionary(k => k.key, v => v.value); } - public override Dictionary CreateSimpleMap(Func map) + public override OrderedDictionary CreateSimpleMap(Func map) { var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); var nodes = jsonMap.Select( @@ -99,10 +99,10 @@ public override Dictionary CreateSimpleMap(Func map) } }); - return nodes.ToDictionary(k => k.key, v => v.value); + return nodes.ToOrderedDictionary(k => k.key, v => v.value); } - public override Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) + public override OrderedDictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) { var jsonMap = _node ?? throw new OpenApiReaderException($"Expected map while parsing {typeof(T).Name}", Context); @@ -127,7 +127,7 @@ public override Dictionary> CreateArrayMap(Func kvp.key, kvp => kvp.values); + return nodes.ToOrderedDictionary(kvp => kvp.key, kvp => kvp.values); } public IEnumerator GetEnumerator() diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs index 6c62fa0b8..bc3856741 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/ParseNode.cs @@ -51,7 +51,7 @@ public virtual List CreateList(Func map, Open throw new OpenApiReaderException("Cannot create list from this type of node.", Context); } - public virtual Dictionary CreateMap(Func map, OpenApiDocument hostDocument) + public virtual OrderedDictionary CreateMap(Func map, OpenApiDocument hostDocument) { throw new OpenApiReaderException("Cannot create map from this type of node.", Context); } @@ -61,7 +61,7 @@ public virtual List CreateSimpleList(Func throw new OpenApiReaderException("Cannot create simple list from this type of node.", Context); } - public virtual Dictionary CreateSimpleMap(Func map) + public virtual OrderedDictionary CreateSimpleMap(Func map) { throw new OpenApiReaderException("Cannot create simple map from this type of node.", Context); } @@ -86,7 +86,8 @@ public virtual List CreateListOfAny() throw new OpenApiReaderException("Cannot create a list from this type of node.", Context); } - public virtual Dictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) + public virtual OrderedDictionary> CreateArrayMap(Func map, OpenApiDocument? openApiDocument) + where T : notnull { throw new OpenApiReaderException("Cannot create array map from this type of node.", Context); } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/PatternFieldMap.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/PatternFieldMap.cs index 79caf3221..2d35e17f4 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/PatternFieldMap.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/PatternFieldMap.cs @@ -7,7 +7,7 @@ namespace Microsoft.OpenApi.Reader.ParseNodes { - internal class PatternFieldMap : Dictionary, Action> + internal class PatternFieldMap : OrderedDictionary, Action> { } } diff --git a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs index 4a3fd0336..e68981c60 100644 --- a/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs +++ b/src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs @@ -25,8 +25,8 @@ public PropertyNode(ParsingContext context, string name, JsonNode node) : base( public void ParseField( T parentInstance, - Dictionary> fixedFields, - Dictionary, Action> patternFields, + OrderedDictionary> fixedFields, + OrderedDictionary, Action> patternFields, OpenApiDocument hostDocument) { if (fixedFields.TryGetValue(Name, out var fixedFieldMap)) diff --git a/src/Microsoft.OpenApi/Reader/ParsingContext.cs b/src/Microsoft.OpenApi/Reader/ParsingContext.cs index 68d06933a..728045ab5 100644 --- a/src/Microsoft.OpenApi/Reader/ParsingContext.cs +++ b/src/Microsoft.OpenApi/Reader/ParsingContext.cs @@ -21,14 +21,14 @@ namespace Microsoft.OpenApi.Reader public class ParsingContext { private readonly Stack _currentLocation = new(); - private readonly Dictionary _tempStorage = new(); - private readonly Dictionary> _scopedTempStorage = new(); - private readonly Dictionary> _loopStacks = new(); + private readonly OrderedDictionary _tempStorage = new(); + private readonly OrderedDictionary> _scopedTempStorage = new(); + private readonly OrderedDictionary> _loopStacks = new(); /// /// Extension parsers /// - public Dictionary>? ExtensionParsers { get; set; } = + public OrderedDictionary>? ExtensionParsers { get; set; } = new(); internal RootNode? RootNode { get; set; } @@ -176,7 +176,7 @@ public string GetLocation() /// public T? GetFromTempStorage(string key, object? scope = null) { - Dictionary? storage; + OrderedDictionary? storage; if (scope == null) { @@ -195,7 +195,7 @@ public string GetLocation() /// public void SetTempStorage(string key, object? value, object? scope = null) { - Dictionary? storage; + OrderedDictionary? storage; if (scope == null) { diff --git a/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs b/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs index c95955609..583c54f49 100644 --- a/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs +++ b/src/Microsoft.OpenApi/Reader/Services/OpenApiRemoteReferenceCollector.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.Reader.Services /// internal class OpenApiRemoteReferenceCollector : OpenApiVisitorBase { - private readonly Dictionary _references = new(); + private readonly OrderedDictionary _references = new(); /// /// List of all external references collected from OpenApiDocument diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs index 44dc3f313..cfe7881a5 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiDocumentDeserializer.cs @@ -72,7 +72,7 @@ internal static partial class OpenApiV2Deserializer o.Components.Parameters = n.CreateMap(LoadParameter, o) .Where(kvp => kvp.Value != null) - .ToDictionary(kvp => kvp.Key, kvp => kvp.Value!); + .ToOrderedDictionary(kvp => kvp.Key, kvp => kvp.Value!); o.Components.RequestBodies = n.CreateMap((p, d) => { @@ -81,7 +81,7 @@ internal static partial class OpenApiV2Deserializer }, doc ).Where(kvp => kvp.Value != null) - .ToDictionary(kvp => kvp.Key, kvp => kvp.Value!); + .ToOrderedDictionary(kvp => kvp.Key, kvp => kvp.Value!); } }, { @@ -313,8 +313,8 @@ private static bool IsHostValid(string host) internal class RequestBodyReferenceFixer : OpenApiVisitorBase { - private readonly Dictionary _requestBodies; - public RequestBodyReferenceFixer(Dictionary requestBodies) + private readonly OrderedDictionary _requestBodies; + public RequestBodyReferenceFixer(OrderedDictionary requestBodies) { _requestBodies = requestBodies; } diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs index 4e53273e8..f57559e91 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs @@ -178,7 +178,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List p.Name != null) - .ToDictionary( + .ToOrderedDictionary( k => k.Name!, v => { @@ -200,7 +200,7 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List k, _ => mediaType) }; @@ -229,7 +229,7 @@ internal static IOpenApiRequestBody CreateRequestBody( { Description = bodyParameter.Description, Required = bodyParameter.Required, - Content = consumes.ToDictionary( + Content = consumes.ToOrderedDictionary( k => k, _ => new OpenApiMediaType { diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs index 0ff7773e9..d86784a19 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs @@ -294,7 +294,7 @@ private static void ProcessIn(OpenApiParameter o, ParseNode n, OpenApiDocument h } // load examples from storage and add them to the parameter - var examples = node.Context.GetFromTempStorage>(TempStorageKeys.Examples, parameter); + var examples = node.Context.GetFromTempStorage>(TempStorageKeys.Examples, parameter); if (examples != null) { parameter.Examples = examples; diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs index 3560a3258..d55ec7be1 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs @@ -75,7 +75,7 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P ?? context.DefaultContentType ?? ["application/octet-stream"]; var schema = context.GetFromTempStorage(TempStorageKeys.ResponseSchema, response); - var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response); + var examples = context.GetFromTempStorage>(TempStorageKeys.Examples, response); foreach (var produce in produces) { @@ -110,10 +110,10 @@ private static void LoadResponseExamplesExtension(OpenApiResponse response, Pars node.Context.SetTempStorage(TempStorageKeys.Examples, examples, response); } - private static Dictionary LoadExamplesExtension(ParseNode node) + private static OrderedDictionary LoadExamplesExtension(ParseNode node) { var mapNode = node.CheckMapNode(OpenApiConstants.ExamplesExtension); - var examples = new Dictionary(); + var examples = new OrderedDictionary(); foreach (var examplesNode in mapNode) { @@ -159,7 +159,7 @@ private static void LoadExample(OpenApiResponse response, string mediaType, Pars { var exampleNode = node.CreateAny(); - response.Content ??= new Dictionary(); + response.Content ??= new OrderedDictionary(); OpenApiMediaType mediaTypeObject; if (response.Content.TryGetValue(mediaType, out var value)) diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs index af9ff89f9..49fcf887f 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs @@ -92,8 +92,8 @@ internal static partial class OpenApiV2Deserializer { _flow.Scopes = n.CreateSimpleMap(LoadString) .Where(kv => kv.Value != null) - .ToDictionary(kv => kv.Key, kv => kv.Value!); - } + .ToOrderedDictionary(kv => kv.Key, kv => kv.Value!); + } } } }; diff --git a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs index ec46036e0..e27fd110c 100644 --- a/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs @@ -29,7 +29,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) Diagnostic = diagnostic; } - private readonly Dictionary> _loaders = new() + private readonly OrderedDictionary> _loaders = new() { [typeof(OpenApiAny)] = OpenApiV2Deserializer.LoadAny, [typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact, diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs index 1771f1407..674f11c40 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiOAuthFlowDeserializer.cs @@ -51,7 +51,7 @@ internal static partial class OpenApiV3Deserializer } } }, - {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!)} + {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToOrderedDictionary(kv => kv.Key, kv => kv.Value!)} }; private static readonly PatternFieldMap _oAuthFlowPatternFields = diff --git a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs index 34ad86fe3..507551295 100644 --- a/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V3/OpenApiV3VersionService.cs @@ -30,7 +30,7 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) Diagnostic = diagnostic; } - private readonly Dictionary> _loaders = new() + private readonly OrderedDictionary> _loaders = new() { [typeof(OpenApiAny)] = OpenApiV3Deserializer.LoadAny, [typeof(OpenApiCallback)] = OpenApiV3Deserializer.LoadCallback, diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs index ab5f29350..852f6fea0 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiOAuthFlowDeserializer.cs @@ -48,7 +48,7 @@ internal static partial class OpenApiV31Deserializer } } }, - {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToDictionary(kv => kv.Key, kv => kv.Value!)} + {"scopes", (o, n, _) => o.Scopes = n.CreateSimpleMap(LoadString).Where(kv => kv.Value is not null).ToOrderedDictionary(kv => kv.Key, kv => kv.Value!)} }; private static readonly PatternFieldMap _oAuthFlowPatternFields = diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 71265aa8c..5095b8155 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -36,7 +36,7 @@ internal static partial class OpenApiV31Deserializer }, { "$vocabulary", - (o, n, _) => o.Vocabulary = n.CreateSimpleMap(LoadBool).ToDictionary(kvp => kvp.Key, kvp => kvp.Value ?? false) + (o, n, _) => o.Vocabulary = n.CreateSimpleMap(LoadBool).ToOrderedDictionary(kvp => kvp.Key, kvp => kvp.Value ?? false) }, { "$dynamicRef", @@ -385,7 +385,7 @@ public static IOpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocu } else if (propertyNode.JsonNode is not null) { - schema.UnrecognizedKeywords ??= new Dictionary(StringComparer.Ordinal); + schema.UnrecognizedKeywords ??= new OrderedDictionary(); schema.UnrecognizedKeywords[propertyNode.Name] = propertyNode.JsonNode; } } diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs index 90d8e86aa..d5581e8ad 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiV31VersionService.cs @@ -29,7 +29,7 @@ public OpenApiV31VersionService(OpenApiDiagnostic diagnostic) Diagnostic = diagnostic; } - private readonly Dictionary> _loaders = new Dictionary> + private readonly OrderedDictionary> _loaders = new OrderedDictionary> { [typeof(OpenApiAny)] = OpenApiV31Deserializer.LoadAny, [typeof(OpenApiCallback)] = OpenApiV31Deserializer.LoadCallback, diff --git a/src/Microsoft.OpenApi/Services/LoopDetector.cs b/src/Microsoft.OpenApi/Services/LoopDetector.cs index dd9c0919f..23de6affe 100644 --- a/src/Microsoft.OpenApi/Services/LoopDetector.cs +++ b/src/Microsoft.OpenApi/Services/LoopDetector.cs @@ -5,7 +5,7 @@ namespace Microsoft.OpenApi.Services { internal class LoopDetector { - private readonly Dictionary> _loopStacks = new(); + private readonly OrderedDictionary> _loopStacks = new(); /// /// Maintain history of traversals to avoid stack overflows from cycles @@ -57,7 +57,7 @@ public void SaveLoop(T loop) /// /// List of Loops detected /// - public Dictionary> Loops { get; } = new(); + public OrderedDictionary> Loops { get; } = new(); /// /// Reset loop tracking stack diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index f58053b1c..58e15128e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -23,13 +23,13 @@ public static class OpenApiFilterService /// /// Comma delimited list of operationIds or * for all operations. /// Comma delimited list of tags or a single regex. - /// A dictionary of requests from a postman collection. + /// A OrderedDictionary of requests from a postman collection. /// The input OpenAPI document. /// A predicate. public static Func CreatePredicate( string? operationIds = null, string? tags = null, - Dictionary>? requestUrls = null, + OrderedDictionary>? requestUrls = null, OpenApiDocument? source = null) { Func predicate; @@ -141,9 +141,9 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun /// /// Creates an from a collection of . /// - /// Dictionary of labels and their corresponding objects. + /// OrderedDictionary of labels and their corresponding objects. /// The created . - public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary sources) + public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(OrderedDictionary sources) { var rootNode = OpenApiUrlTreeNode.Create(); foreach (var source in sources) @@ -153,7 +153,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) + private static OrderedDictionary? GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) { if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) { @@ -162,7 +162,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary? operations = null; + OrderedDictionary? operations = null; var targetChild = rootNode; @@ -365,7 +365,7 @@ private static string ExtractPath(string url, List? serverList) : url.Split(new[] { baseUrl }, StringSplitOptions.None)[1]; } - private static void ValidateFilters(Dictionary>? requestUrls, string? operationIds, string? tags) + private static void ValidateFilters(OrderedDictionary>? requestUrls, string? operationIds, string? tags) { if (requestUrls != null && (operationIds != null || tags != null)) { @@ -404,7 +404,7 @@ private static Func GetTagsPredicate } } - private static Func GetRequestUrlsPredicate(Dictionary> requestUrls, OpenApiDocument source) + private static Func GetRequestUrlsPredicate(OrderedDictionary> requestUrls, OpenApiDocument source) { var operationTypes = new List(); if (source != null) @@ -412,10 +412,10 @@ private static Func GetRequestUrlsPr var apiVersion = source.Info.Version; if (apiVersion is not null) { - var sources = new Dictionary { { apiVersion, source } }; + var sources = new OrderedDictionary { { apiVersion, source } }; var rootNode = CreateOpenApiUrlTreeNode(sources); - // Iterate through urls dictionary and fetch operations for each url + // Iterate through urls OrderedDictionary and fetch operations for each url foreach (var url in requestUrls) { var serverList = source.Servers; @@ -440,7 +440,7 @@ private static Func GetRequestUrlsPr return (path, operationType, _) => operationTypes.Contains(operationType + path); } - private static List GetOperationTypes(Dictionary openApiOperations, List url, string path) + private static List GetOperationTypes(OrderedDictionary openApiOperations, List url, string path) { // Add the available ops if they are in the postman collection. See path.Value return openApiOperations.Where(ops => url.Contains(ops.Key.ToString().ToUpper())) diff --git a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs index 5e4029c4d..06ff60713 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs @@ -21,7 +21,7 @@ public class OpenApiUrlTreeNode /// /// All the subdirectories of a node. /// - public Dictionary Children { get; } = new Dictionary(); + public OrderedDictionary Children { get; } = new OrderedDictionary(); /// /// The relative directory path of the current node from the root node. @@ -29,14 +29,14 @@ public class OpenApiUrlTreeNode public string Path { get; set; } = ""; /// - /// Dictionary of labels and Path Item objects that describe the operations available on a node. + /// OrderedDictionary of labels and Path Item objects that describe the operations available on a node. /// - public Dictionary PathItems { get; } = new Dictionary(); + public OrderedDictionary PathItems { get; } = new OrderedDictionary(); /// - /// A dictionary of key value pairs that contain information about a node. + /// A OrderedDictionary of key value pairs that contain information about a node. /// - public Dictionary> AdditionalData { get; set; } = new Dictionary>(); + public OrderedDictionary> AdditionalData { get; set; } = new OrderedDictionary>(); /// /// Flag indicating whether a node segment is a path parameter. @@ -49,11 +49,11 @@ public class OpenApiUrlTreeNode public string Segment { get; private set; } /// - /// Flag indicating whether the node's PathItems dictionary has operations + /// Flag indicating whether the node's PathItems OrderedDictionary has operations /// under a given label. /// /// The name of the key for the target operations - /// in the node's PathItems dictionary. + /// in the node's PathItems OrderedDictionary. /// true or false. public bool HasOperations(string label) { @@ -223,8 +223,8 @@ private OpenApiUrlTreeNode Attach(IEnumerable segments, /// /// Adds additional data information to the AdditionalData property of the node. /// - /// A dictionary of key value pairs that contain information about a node. - public void AddAdditionalData(Dictionary> additionalData) + /// A OrderedDictionary of key value pairs that contain information about a node. + public void AddAdditionalData(OrderedDictionary> additionalData) { Utils.CheckArgumentNull(additionalData); @@ -250,7 +250,7 @@ public void WriteMermaid(TextWriter writer) } /// - /// Dictionary that maps a set of HTTP methods to HTML color. Keys are sorted, upper-cased, concatenated HTTP methods. + /// OrderedDictionary that maps a set of HTTP methods to HTML color. Keys are sorted, upper-cased, concatenated HTTP methods. /// public readonly static IReadOnlyDictionary MermaidNodeStyles = new Dictionary(StringComparer.OrdinalIgnoreCase) { diff --git a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs index 3f6cb1a92..2782950a6 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs @@ -107,7 +107,7 @@ public virtual void Visit(OpenApiPaths paths) /// /// Visits Webhooks> /// - public virtual void Visit(Dictionary webhooks) + public virtual void Visit(OrderedDictionary webhooks) { } @@ -128,7 +128,7 @@ public virtual void Visit(OpenApiServerVariable serverVariable) /// /// Visits the operations. /// - public virtual void Visit(Dictionary operations) + public virtual void Visit(OrderedDictionary operations) { } @@ -163,14 +163,14 @@ public virtual void Visit(IOpenApiRequestBody requestBody) /// /// Visits headers. /// - public virtual void Visit(Dictionary headers) + public virtual void Visit(OrderedDictionary headers) { } /// /// Visits callbacks. /// - public virtual void Visit(Dictionary callbacks) + public virtual void Visit(OrderedDictionary callbacks) { } @@ -191,7 +191,7 @@ public virtual void Visit(OpenApiResponses response) /// /// Visits media type content. /// - public virtual void Visit(Dictionary content) + public virtual void Visit(OrderedDictionary content) { } @@ -212,7 +212,7 @@ public virtual void Visit(OpenApiEncoding encoding) /// /// Visits the examples. /// - public virtual void Visit(Dictionary examples) + public virtual void Visit(OrderedDictionary examples) { } @@ -240,7 +240,7 @@ public virtual void Visit(IOpenApiSchema schema) /// /// Visits the links. /// - public virtual void Visit(Dictionary links) + public virtual void Visit(OrderedDictionary links) { } @@ -350,17 +350,17 @@ public virtual void Visit(List example) } /// - /// Visits a dictionary of server variables + /// Visits a OrderedDictionary of server variables /// - public virtual void Visit(Dictionary serverVariables) + public virtual void Visit(OrderedDictionary serverVariables) { } /// - /// Visits a dictionary of encodings + /// Visits a OrderedDictionary of encodings /// /// - public virtual void Visit(Dictionary encodings) + public virtual void Visit(OrderedDictionary encodings) { } diff --git a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs index c0cc15979..e8e5875f4 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWalker.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWalker.cs @@ -283,7 +283,7 @@ internal void Walk(OpenApiPaths paths) /// /// Visits Webhooks and child objects /// - internal void Walk(Dictionary? webhooks) + internal void Walk(OrderedDictionary? webhooks) { if (webhooks == null) { @@ -346,7 +346,7 @@ internal void Walk(OpenApiInfo info) } /// - /// Visits dictionary of extensions + /// Visits OrderedDictionary of extensions /// internal void Walk(IOpenApiExtensible? openApiExtensible) { @@ -487,9 +487,9 @@ internal void Walk(OpenApiServer? server) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? serverVariables) + internal void Walk(OrderedDictionary? serverVariables) { if (serverVariables == null) { @@ -564,9 +564,9 @@ internal void Walk(IOpenApiPathItem pathItem, bool isComponent = false) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? operations) + internal void Walk(OrderedDictionary? operations) { if (operations == null) { @@ -746,9 +746,9 @@ internal void Walk(IOpenApiRequestBody? requestBody, bool isComponent = false) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? headers) + internal void Walk(OrderedDictionary? headers) { if (headers == null) { @@ -768,9 +768,9 @@ internal void Walk(Dictionary? headers) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? callbacks) + internal void Walk(OrderedDictionary? callbacks) { if (callbacks == null) { @@ -790,9 +790,9 @@ internal void Walk(Dictionary? callbacks) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? content) + internal void Walk(OrderedDictionary? content) { if (content == null) { @@ -830,9 +830,9 @@ internal void Walk(OpenApiMediaType mediaType) } /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? encodings) + internal void Walk(OrderedDictionary? encodings) { if (encodings == null) { @@ -942,9 +942,9 @@ internal void Walk(IOpenApiSchema? schema, bool isComponent = false) /// - /// Visits dictionary of + /// Visits OrderedDictionary of /// - internal void Walk(Dictionary? examples) + internal void Walk(OrderedDictionary? examples) { if (examples == null) { @@ -1067,9 +1067,9 @@ internal void Walk(OpenApiOAuthFlow oAuthFlow) } /// - /// Visits dictionary of and child objects + /// Visits OrderedDictionary of and child objects /// - internal void Walk(Dictionary? links) + internal void Walk(OrderedDictionary? links) { if (links == null) { @@ -1202,11 +1202,11 @@ internal void Walk(IOpenApiElement element) case IOpenApiCallback e: Walk(e); break; case OpenApiEncoding e: Walk(e); break; case IOpenApiExample e: Walk(e); break; - case Dictionary e: Walk(e); break; + case OrderedDictionary e: Walk(e); break; case OpenApiExternalDocs e: Walk(e); break; case OpenApiHeader e: Walk(e); break; case OpenApiLink e: Walk(e); break; - case Dictionary e: Walk(e); break; + case OrderedDictionary e: Walk(e); break; case OpenApiMediaType e: Walk(e); break; case OpenApiOAuthFlows e: Walk(e); break; case OpenApiOAuthFlow e: Walk(e); break; diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index 5519696d9..4440c77d2 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -16,9 +16,9 @@ namespace Microsoft.OpenApi.Services /// public class OpenApiWorkspace { - private readonly Dictionary _documentsIdRegistry = new(); - private readonly Dictionary _artifactsRegistry = new(); - private readonly Dictionary _IOpenApiReferenceableRegistry = new(new UriWithFragmentEquailityComparer()); + private readonly OrderedDictionary _documentsIdRegistry = new(); + private readonly OrderedDictionary _artifactsRegistry = new(); + private readonly OrderedDictionary _IOpenApiReferenceableRegistry = new(new UriWithFragmentEquailityComparer()); private class UriWithFragmentEquailityComparer : IEqualityComparer { diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index 850d23635..a3d7cb7c2 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -149,21 +149,21 @@ public void AddWarning(OpenApiValidatorWarning warning) /// public override void Visit(OpenApiOperation operation) => Validate(operation); /// - public override void Visit(Dictionary operations) => Validate(operations, operations.GetType()); + public override void Visit(OrderedDictionary operations) => Validate(operations, operations.GetType()); /// - public override void Visit(Dictionary headers) => Validate(headers, headers.GetType()); + public override void Visit(OrderedDictionary headers) => Validate(headers, headers.GetType()); /// - public override void Visit(Dictionary callbacks) => Validate(callbacks, callbacks.GetType()); + public override void Visit(OrderedDictionary callbacks) => Validate(callbacks, callbacks.GetType()); /// - public override void Visit(Dictionary content) => Validate(content, content.GetType()); + public override void Visit(OrderedDictionary content) => Validate(content, content.GetType()); /// - public override void Visit(Dictionary examples) => Validate(examples, examples.GetType()); + public override void Visit(OrderedDictionary examples) => Validate(examples, examples.GetType()); /// - public override void Visit(Dictionary links) => Validate(links, links.GetType()); + public override void Visit(OrderedDictionary links) => Validate(links, links.GetType()); /// - public override void Visit(Dictionary serverVariables) => Validate(serverVariables, serverVariables.GetType()); + public override void Visit(OrderedDictionary serverVariables) => Validate(serverVariables, serverVariables.GetType()); /// - public override void Visit(Dictionary encodings) => Validate(encodings, encodings.GetType()); + public override void Visit(OrderedDictionary encodings) => Validate(encodings, encodings.GetType()); private void Validate(T item) { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs index 34d84b796..76fa8ebd2 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiNonDefaultRules.cs @@ -90,7 +90,7 @@ public static class OpenApiNonDefaultRules private static void ValidateMismatchedDataType(IValidationContext context, string ruleName, JsonNode? example, - Dictionary? examples, + OrderedDictionary? examples, IOpenApiSchema? schema) { // example diff --git a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs index 943b88e6b..cde1a9aa8 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationRuleSet.cs @@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.Validations /// public sealed class ValidationRuleSet { - private Dictionary> _rulesDictionary = new(); + private OrderedDictionary> _rulesDictionary = new(); private static ValidationRuleSet? _defaultRuleSet; @@ -85,7 +85,7 @@ public static ValidationRuleSet GetEmptyRuleSet() /// The rule set to add validation rules to. /// The validation rules to be added to the rules set. /// Throws a null argument exception if the arguments are null. - public static void AddValidationRules(ValidationRuleSet ruleSet, Dictionary> rules) + public static void AddValidationRules(ValidationRuleSet ruleSet, OrderedDictionary> rules) { if (ruleSet == null || rules == null) { @@ -119,7 +119,7 @@ public ValidationRuleSet(ValidationRuleSet ruleSet) /// Initializes a new instance of the class. /// /// Rules to be contained in this ruleset. - public ValidationRuleSet(Dictionary> rules) + public ValidationRuleSet(OrderedDictionary> rules) { if (rules == null) { @@ -199,13 +199,18 @@ public bool Remove(Type key) /// Name of the rule. public void Remove(string ruleName) { - foreach (KeyValuePair> rule in _rulesDictionary) + var updatedRules = new OrderedDictionary>(); + + foreach (var kvp in _rulesDictionary) { - _rulesDictionary[rule.Key] = rule.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); + var filteredRules = kvp.Value.Where(vr => !vr.Name.Equals(ruleName, StringComparison.Ordinal)).ToList(); + if (filteredRules.Any()) + { + updatedRules.Add(kvp.Key, filteredRules); + } } - // Remove types with no rule - _rulesDictionary = _rulesDictionary.Where(r => r.Value.Any()).ToDictionary(r => r.Key, r => r.Value); + _rulesDictionary = updatedRules; } /// diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index 09ee79309..8f0af1008 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -22,7 +22,7 @@ public static class OpenApiWriterAnyExtensions /// The Open API writer. /// The specification extensions. /// Version of the OpenAPI specification that that will be output. - public static void WriteExtensions(this IOpenApiWriter writer, Dictionary? extensions, OpenApiSpecVersion specVersion) + public static void WriteExtensions(this IOpenApiWriter writer, OrderedDictionary? extensions, OpenApiSpecVersion specVersion) { Utils.CheckArgumentNull(writer); diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs index 31f60d0fd..cafb4f478 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs @@ -246,7 +246,7 @@ public static void WriteRequiredCollection( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { writer.WriteMapInternal(name, elements, action); @@ -262,7 +262,7 @@ public static void WriteRequiredMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -281,7 +281,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -300,7 +300,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { if (elements != null && elements.Any()) @@ -319,7 +319,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary>? elements, + OrderedDictionary>? elements, Action> action) { if (elements != null && elements.Any()) @@ -339,7 +339,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) where T : IOpenApiElement { @@ -360,7 +360,7 @@ public static void WriteOptionalMap( public static void WriteOptionalMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) where T : IOpenApiElement { @@ -381,7 +381,7 @@ public static void WriteOptionalMap( public static void WriteRequiredMap( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) where T : IOpenApiElement { @@ -419,7 +419,7 @@ private static void WriteCollectionInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { WriteMapInternal(writer, name, elements, (w, _, s) => action(w, s)); @@ -428,7 +428,7 @@ private static void WriteMapInternal( private static void WriteMapInternal( this IOpenApiWriter writer, string name, - Dictionary? elements, + OrderedDictionary? elements, Action action) { Utils.CheckArgumentNull(action); diff --git a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs index 22388b076..7ad80c024 100644 --- a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs @@ -65,7 +65,7 @@ public static class SpecialCharacterStringExtensions // Double-quoted strings are needed for these non-printable control characters. // http://www.yaml.org/spec/1.2/spec.html#style/flow/double-quoted - private static readonly Dictionary _yamlControlCharacterCharReplacements = new() + private static readonly OrderedDictionary _yamlControlCharacterCharReplacements = new() { {'\0', "\\0"}, {'\x01', "\\x01"}, @@ -101,8 +101,8 @@ public static class SpecialCharacterStringExtensions {'\x1f', "\\x1f"}, }; - private static readonly Dictionary _yamlControlCharacterStringReplacements = _yamlControlCharacterCharReplacements - .ToDictionary(x => x.Key.ToString(), x => x.Value); + private static readonly OrderedDictionary _yamlControlCharacterStringReplacements = _yamlControlCharacterCharReplacements + .ToOrderedDictionary(x => x.Key.ToString(), x => x.Value); /// /// Escapes all special characters and put the string in quotes if necessary to diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 4b17ad699..6b0f4359e 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -95,7 +95,7 @@ public void TestPredicateFiltersUsingRelativeRequestUrls() }; // Given a set of RequestUrls - var requestUrls = new Dictionary> + var requestUrls = new OrderedDictionary> { {"/foo", ["GET","POST"]} }; @@ -145,7 +145,7 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl() } }; - var requestUrls = new Dictionary> + var requestUrls = new OrderedDictionary> { {"/test/{id}",["GET","PATCH"]} }; diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs index 97c27fe37..54533a14f 100644 --- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs @@ -54,7 +54,7 @@ public void CreateFilteredDocumentOnMinimalOpenApi() }; // Act - var requestUrls = new Dictionary>() + var requestUrls = new OrderedDictionary>() { { "/test", ["GET"] } }; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index a8eb30cc3..6971ad525 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -111,7 +111,7 @@ public async Task LoadDocumentWithExternalReferencesInSubDirectories() Assert.Equivalent(new OpenApiSchema { Required = new HashSet { "id", "name" }, - Properties = new Dictionary + Properties = new OrderedDictionary { ["id"] = new OpenApiSchema { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs index 3d40535c6..cade05018 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs @@ -545,7 +545,7 @@ public async Task SerializesBodyReferencesWorks() openApiDocument.AddComponent("UserSchema", new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new OrderedDictionary { ["name"] = new OpenApiSchema { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 86d7943fb..1eef3c9ca 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -95,7 +95,7 @@ public void ParseOAuth2ImplicitSecuritySchemeShouldSucceed() Implicit = new() { AuthorizationUrl = new("http://swagger.io/api/oauth/dialog"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -130,7 +130,7 @@ public void ParseOAuth2PasswordSecuritySchemeShouldSucceed() Password = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -165,7 +165,7 @@ public void ParseOAuth2ApplicationSecuritySchemeShouldSucceed() ClientCredentials = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" @@ -201,7 +201,7 @@ public void ParseOAuth2AccessCodeSecuritySchemeShouldSucceed() AuthorizationCode = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("http://swagger.io/api/oauth/dialog"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs index 03724efa1..e9644eb77 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs @@ -62,14 +62,14 @@ public async Task Serialize_DoesNotMutateDom(OpenApiSpecVersion version) } } - public class HttpMethodOperationDictionaryConverter : JsonConverter> + public class HttpMethodOperationDictionaryConverter : JsonConverter> { - public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override OrderedDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { throw new NotImplementedException(); } - public override void Write(Utf8JsonWriter writer, Dictionary value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, OrderedDictionary value, JsonSerializerOptions options) { writer.WriteStartObject(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs index 0919471b2..85776a827 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs @@ -42,7 +42,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() "id", "name" }, - DependentRequired = new Dictionary> + DependentRequired = new OrderedDictionary> { { "tag", new HashSet { "category" } } }, @@ -74,7 +74,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() { "name" }, - DependentRequired = new Dictionary> + DependentRequired = new OrderedDictionary> { { "tag", new HashSet { "category" } } }, @@ -109,7 +109,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed() Version = "1.0.0", Title = "Webhook Example" }, - Webhooks = new Dictionary + Webhooks = new OrderedDictionary { ["pets"] = new OpenApiPathItem { @@ -234,7 +234,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() "id", "name" }, - DependentRequired = new Dictionary> + DependentRequired = new OrderedDictionary> { { "tag", new HashSet { "category" } } }, @@ -266,7 +266,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() { "name" }, - DependentRequired = new Dictionary> + DependentRequired = new OrderedDictionary> { { "tag", new HashSet { "category" } } }, @@ -299,7 +299,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() var newPetSchema = new OpenApiSchemaReference("newPetSchema", actual.Document); - components.PathItems = new Dictionary + components.PathItems = new OrderedDictionary { ["pets"] = new OpenApiPathItem { @@ -407,7 +407,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds() Version = "1.0.0" }, JsonSchemaDialect = new Uri("http://json-schema.org/draft-07/schema#"), - Webhooks = new Dictionary + Webhooks = new OrderedDictionary { ["pets"] = components.PathItems["pets"] }, diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs index 9ccb8d0ee..a06466c58 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs @@ -56,7 +56,7 @@ public async Task ParseBasicV31SchemaShouldSucceed() Type = JsonSchemaType.Array } }, - Definitions = new Dictionary + Definitions = new OrderedDictionary { ["veggie"] = new OpenApiSchema { @@ -66,7 +66,7 @@ public async Task ParseBasicV31SchemaShouldSucceed() "veggieName", "veggieLike" }, - DependentRequired = new Dictionary> + DependentRequired = new OrderedDictionary> { { "veggieType", new HashSet { "veggieColor", "veggieSize" } } }, @@ -475,7 +475,7 @@ public async Task SerializeSchemaWithJsonSchemaKeywordsWorks() var schemaString = writer.ToString(); // Assert - Assert.Equal(5, schema.Vocabulary.Keys.Count); + Assert.Equal(5, schema.Vocabulary.Keys.Count()); Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), schemaString.MakeLineBreaksEnvironmentNeutral()); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index 2b131f263..0dd7707b4 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -29,19 +29,19 @@ public async Task ParseBasicCallbackShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = new Dictionary + PathItems = new OrderedDictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Post] = new OpenApiOperation { RequestBody = new OpenApiRequestBody { - Content = new Dictionary + Content = new OrderedDictionary { ["application/json"] = null } @@ -83,13 +83,13 @@ public async Task ParseCallbackWithReferenceShouldSucceed() PathItems = { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = new Dictionary + Content = new OrderedDictionary { ["application/json"] = new OpenApiMediaType { @@ -134,13 +134,13 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() PathItems = { [RuntimeExpression.Build("$request.body#/url")]= new OpenApiPathItem { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = new Dictionary + Content = new OrderedDictionary { ["application/json"] = new OpenApiMediaType { @@ -167,17 +167,17 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = new Dictionary + PathItems = new OrderedDictionary { [RuntimeExpression.Build("/simplePath")]= new OpenApiPathItem { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { Description = "Callback 2", - Content = new Dictionary + Content = new OrderedDictionary { ["application/json"] = new OpenApiMediaType { @@ -204,16 +204,16 @@ public async Task ParseMultipleCallbacksWithReferenceShouldSucceed() Assert.Equivalent( new OpenApiCallback { - PathItems = new Dictionary + PathItems = new OrderedDictionary { [RuntimeExpression.Build(@"http://example.com?transactionId={$request.body#/id}&email={$request.body#/email}")] = new OpenApiPathItem { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Post] = new OpenApiOperation() { RequestBody = new OpenApiRequestBody { - Content = new Dictionary + Content = new OrderedDictionary { ["application/xml"] = new OpenApiMediaType { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs index f0eb50953..379a6c782 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs @@ -36,7 +36,7 @@ public async Task ParseBasicDiscriminatorShouldSucceed() new OpenApiDiscriminator { PropertyName = "pet_type", - Mapping = new Dictionary + Mapping = new OrderedDictionary { ["puppy"] = new OpenApiSchemaReference("Dog", openApiDocument), ["kitten"] = new OpenApiSchemaReference("Cat" , openApiDocument, "https://gigantic-server.com/schemas/animals.json"), diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index d6b393404..7134fc042 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -649,7 +649,7 @@ public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } }, }, - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["securitySchemeName1"] = new OpenApiSecurityScheme { @@ -1101,7 +1101,7 @@ public async Task HeaderParameterShouldAllowExample() AllowReserved = true, Style = ParameterStyle.Simple, Explode = true, - Examples = new Dictionary + Examples = new OrderedDictionary { { "uuid1", new OpenApiExample() { @@ -1354,7 +1354,7 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds() }, Components = new OpenApiComponents { - Parameters = new Dictionary + Parameters = new OrderedDictionary { ["LimitParameter"] = parameter } @@ -1441,7 +1441,7 @@ public void ParseBasicDocumentWithServerVariableShouldSucceed() { Url = "http://www.example.org/api/{version}", Description = "The http endpoint", - Variables = new Dictionary + Variables = new OrderedDictionary { {"version", new OpenApiServerVariable {Default = "v2", Enum = ["v1", "v2"]}} } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs index dee46bc98..730b52359 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs @@ -43,7 +43,7 @@ public async Task ParseAdvancedEncodingShouldSucceed() new OpenApiEncoding { ContentType = "image/png, image/jpeg", - Headers = new Dictionary + Headers = new OrderedDictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs index fd7c5e478..3beeeb7fe 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs @@ -37,7 +37,7 @@ public async Task ParseAdvancedInfoShouldSucceed() Contact = new OpenApiContact { Email = "example@example.com", - Extensions = new Dictionary + Extensions = new OrderedDictionary { ["x-twitter"] = new OpenApiAny("@exampleTwitterHandler") }, @@ -46,14 +46,14 @@ public async Task ParseAdvancedInfoShouldSucceed() }, License = new OpenApiLicense { - Extensions = new Dictionary + Extensions = new OrderedDictionary { ["x-disclaimer"] = new OpenApiAny("Sample Extension String Disclaimer") }, Name = "licenseName", Url = new Uri("http://www.example.com/url2") }, - Extensions = new Dictionary + Extensions = new OrderedDictionary { ["x-something"] = new OpenApiAny("Sample Extension String Something"), ["x-contact"] = new OpenApiAny(new JsonObject() diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs index 7bdcf6047..47a804949 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs @@ -52,7 +52,7 @@ public async Task ParseMediaTypeWithExamplesShouldSucceed() mediaType.Should().BeEquivalentTo( new OpenApiMediaType { - Examples = new Dictionary + Examples = new OrderedDictionary { ["example1"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs index 7765545aa..108b0ba65 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs @@ -273,7 +273,7 @@ public async Task ParseParameterWithExamplesShouldSucceed() Name = "username", Description = "username to fetch", Required = true, - Examples = new Dictionary + Examples = new OrderedDictionary { ["example1"] = new OpenApiExample() { @@ -347,7 +347,7 @@ public void ParseParameterWithReferenceWorks() }, Components = new OpenApiComponents { - Parameters = new Dictionary() + Parameters = new OrderedDictionary() { ["tagsParameter"] = parameter, } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index cdab5c3ef..686c71509 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -77,7 +77,7 @@ public async Task ParseOAuth2SecuritySchemeShouldSucceed() Implicit = new OpenApiOAuthFlow { AuthorizationUrl = new Uri("https://example.com/api/oauth/dialog"), - Scopes = new System.Collections.Generic.Dictionary + Scopes = new OrderedDictionary { ["write:pets"] = "modify pets in your account", ["read:pets"] = "read your pets" diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs index e15527c64..c13a44b52 100644 --- a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiServerExtensionsTests.cs @@ -15,13 +15,13 @@ public void ShouldSubstituteServerVariableWithProvidedValues() { Url = "http://example.com/api/{version}", Description = string.Empty, - Variables = new Dictionary + Variables = new OrderedDictionary { { "version", new OpenApiServerVariable { Default = "v1", Enum = ["v1", "v2"]} } } }; - var url = variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v2"}}); + var url = variable.ReplaceServerUrlVariables(new OrderedDictionary {{"version", "v2"}}); Assert.Equal("http://example.com/api/v2", url); } @@ -33,13 +33,13 @@ public void ShouldSubstituteServerVariableWithDefaultValues() { Url = "http://example.com/api/{version}", Description = string.Empty, - Variables = new Dictionary + Variables = new OrderedDictionary { { "version", new OpenApiServerVariable { Default = "v1", Enum = ["v1", "v2"]} } } }; - var url = variable.ReplaceServerUrlVariables(new Dictionary(0)); + var url = variable.ReplaceServerUrlVariables(new OrderedDictionary()); Assert.Equal("http://example.com/api/v1", url); } @@ -51,7 +51,7 @@ public void ShouldFailIfNoValueIsAvailable() { Url = "http://example.com/api/{version}", Description = string.Empty, - Variables = new Dictionary + Variables = new OrderedDictionary { { "version", new OpenApiServerVariable { Enum = ["v1", "v2"]} } } @@ -59,7 +59,7 @@ public void ShouldFailIfNoValueIsAvailable() Assert.Throws(() => { - variable.ReplaceServerUrlVariables(new Dictionary(0)); + variable.ReplaceServerUrlVariables(new OrderedDictionary()); }); } @@ -70,7 +70,7 @@ public void ShouldFailIfProvidedValueIsNotInEnum() { Url = "http://example.com/api/{version}", Description = string.Empty, - Variables = new Dictionary + Variables = new OrderedDictionary { { "version", new OpenApiServerVariable { Enum = ["v1", "v2"]} } } @@ -78,7 +78,7 @@ public void ShouldFailIfProvidedValueIsNotInEnum() Assert.Throws(() => { - variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v3"}}); + variable.ReplaceServerUrlVariables(new OrderedDictionary {{"version", "v3"}}); }); } @@ -89,7 +89,7 @@ public void ShouldFailIfEnumIsEmpty() { Url = "http://example.com/api/{version}", Description = string.Empty, - Variables = new Dictionary + Variables = new OrderedDictionary { { "version", new OpenApiServerVariable { Enum = []} } } @@ -97,7 +97,7 @@ public void ShouldFailIfEnumIsEmpty() Assert.Throws(() => { - variable.ReplaceServerUrlVariables(new Dictionary {{"version", "v1"}}); + variable.ReplaceServerUrlVariables(new OrderedDictionary {{"version", "v1"}}); }); } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index a6f724c66..65fb6f182 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -21,7 +21,7 @@ public class OpenApiCallbackTests { private static OpenApiCallback AdvancedCallback => new() { - PathItems = new Dictionary + PathItems = new OrderedDictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem() @@ -61,7 +61,7 @@ public class OpenApiCallbackTests private static OpenApiCallback ReferencedCallback => new() { - PathItems = new Dictionary + PathItems = new OrderedDictionary { [RuntimeExpression.Build("$request.body#/url")] = new OpenApiPathItem() diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 65c53b322..8bb8b4823 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -35,7 +35,7 @@ public class OpenApiComponentsTests } } }, - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["securityScheme1"] = new OpenApiSecurityScheme() { @@ -45,7 +45,7 @@ public class OpenApiComponentsTests { Implicit = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" @@ -90,7 +90,7 @@ public class OpenApiComponentsTests } }, }, - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["securityScheme1"] = new OpenApiSecurityScheme() { @@ -100,7 +100,7 @@ public class OpenApiComponentsTests { Implicit = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" @@ -232,7 +232,7 @@ public class OpenApiComponentsTests } } }, - PathItems = new Dictionary + PathItems = new OrderedDictionary { ["/pets"] = new OpenApiPathItem { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index 48310df15..206241b98 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -36,7 +36,7 @@ public class OpenApiDocumentTests ["property1"] = new OpenApiSchema() { Type = JsonSchemaType.String, - Metadata = new Dictionary { { "key1", "value" } } + Metadata = new OrderedDictionary { { "key1", "value" } } } } }, @@ -55,10 +55,10 @@ public class OpenApiDocumentTests ["property1"] = new OpenApiSchema() { Type = JsonSchemaType.String, - Metadata = new Dictionary { { "key1", "value" } } + Metadata = new OrderedDictionary { { "key1", "value" } } } }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, }, ["schema2"] = new OpenApiSchema() { @@ -91,7 +91,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = TopLevelReferencingComponents }; @@ -101,7 +101,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponentsWithOtherProperties }; @@ -111,7 +111,7 @@ public class OpenApiDocumentTests { Version = "1.0.0" }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = TopLevelSelfReferencingComponents }; @@ -488,7 +488,7 @@ public class OpenApiDocumentTests } } }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = AdvancedComponentsWithReference }; @@ -864,7 +864,7 @@ public class OpenApiDocumentTests } } }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -875,7 +875,7 @@ public class OpenApiDocumentTests Title = "Webhook Example", Version = "1.0.0" }, - Webhooks = new Dictionary + Webhooks = new OrderedDictionary { ["newPet"] = new OpenApiPathItem { @@ -936,7 +936,7 @@ public class OpenApiDocumentTests } }; - public static readonly OpenApiDocument DuplicateExtensions = new OpenApiDocument + public static OpenApiDocument DuplicateExtensions() => new OpenApiDocument { Info = new OpenApiInfo { @@ -1023,7 +1023,7 @@ public class OpenApiDocumentTests } } }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1053,7 +1053,7 @@ public class OpenApiDocumentTests new() { Url = "https://{endpoint}/openai", - Variables = new Dictionary + Variables = new OrderedDictionary { ["endpoint"] = new() { @@ -1323,7 +1323,7 @@ public class OpenApiDocumentTests } } }, - Metadata = new Dictionary { { "key1", "value" } }, + Metadata = new OrderedDictionary { { "key1", "value" } }, Components = AdvancedComponents }; @@ -1405,7 +1405,8 @@ public async Task SerializeDuplicateExtensionsAsV3JsonWorksAsync(bool produceTer var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act - DuplicateExtensions.SerializeAsV3(writer); + var doc = DuplicateExtensions(); + doc.SerializeAsV3(writer); await writer.FlushAsync(); // Assert @@ -1422,7 +1423,8 @@ public async Task SerializeDuplicateExtensionsAsV2JsonWorksAsync(bool produceTer var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act - DuplicateExtensions.SerializeAsV2(writer); + var doc = DuplicateExtensions(); + doc.SerializeAsV2(writer); await writer.FlushAsync(); // Assert diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index 03b406adf..a4a17c43e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -23,7 +23,7 @@ public class OpenApiLinkTests private static OpenApiLink AdvancedLink => new() { OperationId = "operationId1", - Parameters = new Dictionary + Parameters = new OrderedDictionary { ["parameter1"] = new() { @@ -48,7 +48,7 @@ public class OpenApiLinkTests private static OpenApiLink ReferencedLink => new() { OperationId = "operationId1", - Parameters = new Dictionary + Parameters = new OrderedDictionary { ["parameter1"] = new() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs index 6eff288ad..e7cdd8d80 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs @@ -21,7 +21,7 @@ public class OpenApiMediaTypeTests public static OpenApiMediaType AdvanceMediaType = new() { Example = 42, - Encoding = new Dictionary + Encoding = new OrderedDictionary { {"testEncoding", OpenApiEncodingTests.AdvanceEncoding} } @@ -62,7 +62,7 @@ public class OpenApiMediaTypeTests } } }, - Encoding = new Dictionary + Encoding = new OrderedDictionary { {"testEncoding", OpenApiEncodingTests.AdvanceEncoding} } @@ -71,7 +71,7 @@ public class OpenApiMediaTypeTests public static OpenApiMediaType MediaTypeWithXmlExample = new() { Example = "123", - Encoding = new Dictionary + Encoding = new OrderedDictionary { {"testEncoding", OpenApiEncodingTests.AdvanceEncoding} } @@ -79,7 +79,7 @@ public class OpenApiMediaTypeTests public static OpenApiMediaType MediaTypeWithObjectExamples = new() { - Examples = new Dictionary + Examples = new OrderedDictionary { ["object1"] = new OpenApiExample() { @@ -118,7 +118,7 @@ public class OpenApiMediaTypeTests } } }, - Encoding = new Dictionary + Encoding = new OrderedDictionary { {"testEncoding", OpenApiEncodingTests.AdvanceEncoding} } @@ -435,8 +435,8 @@ public void MediaTypeCopyConstructorWorks() var clone = new OpenApiMediaType(MediaTypeWithObjectExamples) { Example = 42, - Examples = new Dictionary(), - Encoding = new Dictionary(), + Examples = new OrderedDictionary(), + Encoding = new OrderedDictionary(), Extensions = new() }; diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs index b3e788625..347f234d7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowTests.cs @@ -17,7 +17,7 @@ public class OpenApiOAuthFlowTests public static OpenApiOAuthFlow PartialOAuthFlow = new() { AuthorizationUrl = new("http://example.com/authorization"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["scopeName3"] = "description3", ["scopeName4"] = "description4" @@ -29,7 +29,7 @@ public class OpenApiOAuthFlowTests AuthorizationUrl = new("http://example.com/authorization"), TokenUrl = new("http://example.com/token"), RefreshUrl = new("http://example.com/refresh"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["scopeName3"] = "description3", ["scopeName4"] = "description4" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs index 161c669fa..248d107f7 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOAuthFlowsTests.cs @@ -19,7 +19,7 @@ public class OpenApiOAuthFlowsTests Implicit = new() { AuthorizationUrl = new("http://example.com/authorization"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["scopeName1"] = "description1", ["scopeName2"] = "description2" @@ -32,7 +32,7 @@ public class OpenApiOAuthFlowsTests Implicit = new() { AuthorizationUrl = new("http://example.com/authorization"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["scopeName1"] = "description1", ["scopeName2"] = "description2" @@ -42,7 +42,7 @@ public class OpenApiOAuthFlowsTests { TokenUrl = new("http://example.com/token"), RefreshUrl = new("http://example.com/refresh"), - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["scopeName3"] = "description3", ["scopeName4"] = "description4" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs index 351365065..581e93d64 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs @@ -85,7 +85,7 @@ public class OpenApiOperationTests Description = "serverDescription" } ], - Metadata = new Dictionary { { "key1", "value1" }, { "key2", 2 } }, + Metadata = new OrderedDictionary { { "key1", "value1" }, { "key2", 2 } }, }; private static OpenApiOperation _advancedOperationWithTagsAndSecurity => new() @@ -180,7 +180,7 @@ private static OpenApiDocument __advancedOperationWithTagsAndSecurity_supporting { Components = new() { - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["securitySchemeId1"] = new OpenApiSecurityScheme { @@ -845,7 +845,7 @@ public void OpenApiOperationCopyConstructorWithAnnotationsSucceeds() { var baseOperation = new OpenApiOperation { - Metadata = new Dictionary + Metadata = new OrderedDictionary { ["key1"] = "value1", ["key2"] = 2 diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index a9bb4ba78..4098e4c48 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -52,7 +52,7 @@ public class OpenApiParameterTests new OpenApiSchema() { Type = JsonSchemaType.String } ] }, - Examples = new Dictionary + Examples = new OrderedDictionary { ["test"] = new OpenApiExample() { @@ -132,7 +132,7 @@ public class OpenApiParameterTests { Type = JsonSchemaType.Object }, - Examples = new Dictionary + Examples = new OrderedDictionary { ["test"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 4c579fb9e..679c605b0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -26,7 +26,7 @@ public class OpenApiResponseTests private static OpenApiResponse AdvancedV2Response => new OpenApiResponse { Description = "A complex object array response", - Content = new Dictionary + Content = new OrderedDictionary { ["text/plain"] = new OpenApiMediaType { @@ -42,7 +42,7 @@ public class OpenApiResponseTests }, } }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -65,7 +65,7 @@ public class OpenApiResponseTests private static OpenApiResponse AdvancedV3Response => new OpenApiResponse { Description = "A complex object array response", - Content = new Dictionary + Content = new OrderedDictionary { ["text/plain"] = new OpenApiMediaType { @@ -81,7 +81,7 @@ public class OpenApiResponseTests }, } }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -106,7 +106,7 @@ public class OpenApiResponseTests private static OpenApiResponse ReferencedV2Response => new OpenApiResponse { Description = "A complex object array response", - Content = new Dictionary + Content = new OrderedDictionary { ["text/plain"] = new OpenApiMediaType { @@ -117,7 +117,7 @@ public class OpenApiResponseTests } } }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { @@ -142,7 +142,7 @@ public class OpenApiResponseTests private static OpenApiResponse ReferencedV3Response => new OpenApiResponse { Description = "A complex object array response", - Content = new Dictionary + Content = new OrderedDictionary { ["text/plain"] = new OpenApiMediaType { @@ -153,7 +153,7 @@ public class OpenApiResponseTests } } }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["X-Rate-Limit-Limit"] = new OpenApiHeader { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 779a87e3e..f42c650bf 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -38,7 +38,7 @@ public class OpenApiSchemaTests { Url = new("http://example.com/externalDocs") }, - Metadata = new Dictionary { { "key1", "value1" }, { "key2", 2 } } + Metadata = new OrderedDictionary { { "key1", "value1" }, { "key2", 2 } } }; public static readonly OpenApiSchema AdvancedSchemaObject = new() @@ -477,7 +477,7 @@ public void OpenApiSchemaCopyConstructorWithMetadataSucceeds() { var baseSchema = new OpenApiSchema { - Metadata = new Dictionary + Metadata = new OrderedDictionary { ["key1"] = "value1", ["key2"] = 2 @@ -601,7 +601,7 @@ public async Task SerializeSchemaWithUnrecognizedPropertiesWorks() // Arrange var schema = new OpenApiSchema { - UnrecognizedKeywords = new Dictionary() + UnrecognizedKeywords = new OrderedDictionary() { ["customKeyWord"] = "bar", ["anotherKeyword"] = 42 diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs index cfbe0ae50..4281117bd 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecurityRequirementTests.cs @@ -53,7 +53,7 @@ public static OpenApiDocument SecurityRequirementWithReferencedSecurityScheme_su { Components = new() { - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["scheme1"] = new OpenApiSecurityScheme { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 12db6c1e8..4e6fdad01 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -48,7 +48,7 @@ public class OpenApiSecuritySchemeTests { Implicit = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" @@ -66,7 +66,7 @@ public class OpenApiSecuritySchemeTests { Implicit = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" @@ -75,7 +75,7 @@ public class OpenApiSecuritySchemeTests }, ClientCredentials = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" @@ -85,7 +85,7 @@ public class OpenApiSecuritySchemeTests }, AuthorizationCode = new() { - Scopes = new Dictionary + Scopes = new OrderedDictionary { ["operation1:object1"] = "operation 1 on object 1", ["operation2:object2"] = "operation 2 on object 2" diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs index bbfacf01c..ffc18293b 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiServerTests.cs @@ -22,7 +22,7 @@ public class OpenApiServerTests { Description = "description1", Url = "https://{username}.example.com:{port}/{basePath}", - Variables = new Dictionary + Variables = new OrderedDictionary { ["username"] = new() { diff --git a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs index 02a7308a3..159ed52ac 100644 --- a/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/References/OpenApiHeaderReferenceTests.cs @@ -173,7 +173,7 @@ public void OpenApiHeaderTargetShouldResolveReference() { Components = new OpenApiComponents { - Headers = new Dictionary + Headers = new OrderedDictionary { { "header1", new OpenApiHeader { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 1e3c88ec0..d9327f61b 100644 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -183,7 +183,7 @@ namespace Microsoft.OpenApi.Extensions } public static class OpenApiServerExtensions { - public static string? ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, System.Collections.Generic.Dictionary? values = null) { } + public static string? ReplaceServerUrlVariables(this Microsoft.OpenApi.Models.OpenApiServer server, Microsoft.OpenApi.OrderedDictionary? values = null) { } } public static class OpenApiTypeMapper { @@ -195,17 +195,79 @@ namespace Microsoft.OpenApi.Extensions public static Microsoft.OpenApi.Models.JsonSchemaType? ToJsonSchemaType(this string[] identifier) { } } } +namespace Microsoft.OpenApi +{ + public class HashSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + where T : notnull + { + public HashSet() { } + public HashSet(System.Collections.Generic.IEnumerable collection) { } + public HashSet(System.Collections.Generic.IEqualityComparer comparer) { } + public HashSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IEqualityComparer comparer) { } + public System.Collections.Generic.IEqualityComparer Comparer { get; } + public int Count { get; } + public bool IsReadOnly { get; } + public bool Add(T item) { } + public void Clear() { } + public bool Contains(T item) { } + public void CopyTo(T[] array, int arrayIndex) { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public bool Remove(T item) { } + } + public class JsonPointer + { + public JsonPointer(string pointer) { } + public Microsoft.OpenApi.JsonPointer? ParentPointer { get; } + public string[] Tokens { get; } + public override string ToString() { } + } + public enum OpenApiSpecVersion + { + OpenApi2_0 = 0, + OpenApi3_0 = 1, + OpenApi3_1 = 2, + } + public static class OrderedDictionaryExtensions + { + public static Microsoft.OpenApi.OrderedDictionary ToOrderedDictionary(this System.Collections.Generic.IEnumerable source, System.Func keySelector, System.Func valueSelector) + where TKey : notnull { } + } + public class OrderedDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + where TKey : notnull + { + public OrderedDictionary() { } + public OrderedDictionary(Microsoft.OpenApi.OrderedDictionary source) { } + public OrderedDictionary(System.Collections.Generic.IEqualityComparer? comparer) { } + public int Count { get; } + public bool IsReadOnly { get; } + public TValue this[TKey key] { get; set; } + public System.Collections.Generic.ICollection Keys { get; } + public System.Collections.Generic.ICollection Values { get; } + public void Add(System.Collections.Generic.KeyValuePair item) { } + public void Add(TKey key, TValue value) { } + public void Clear() { } + public bool Contains(System.Collections.Generic.KeyValuePair item) { } + public bool ContainsKey(TKey key) { } + public void CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { } + public System.Collections.Generic.IEnumerator> GetEnumerator() { } + public void Insert(int index, TKey key, TValue value) { } + public bool Remove(System.Collections.Generic.KeyValuePair item) { } + public bool Remove(TKey key) { } + public bool TryAdd(TKey key, TValue value) { } + public bool TryGetValue(TKey key, out TValue value) { } + } +} namespace Microsoft.OpenApi.Interfaces { public interface IDiagnostic { } public interface IMetadataContainer { - System.Collections.Generic.Dictionary? Metadata { get; set; } + Microsoft.OpenApi.OrderedDictionary? Metadata { get; set; } } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement { - System.Collections.Generic.Dictionary? Extensions { get; set; } + Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } } public interface IOpenApiExtension { @@ -213,7 +275,7 @@ namespace Microsoft.OpenApi.Interfaces } public interface IOpenApiReadOnlyExtensible { - System.Collections.Generic.Dictionary? Extensions { get; } + Microsoft.OpenApi.OrderedDictionary? Extensions { get; } } public interface IOpenApiReader { @@ -250,22 +312,6 @@ namespace Microsoft.OpenApi.Interfaces System.Threading.Tasks.Task LoadAsync(System.Uri baseUrl, System.Uri uri, System.Threading.CancellationToken cancellationToken = default); } } -namespace Microsoft.OpenApi -{ - public class JsonPointer - { - public JsonPointer(string pointer) { } - public Microsoft.OpenApi.JsonPointer? ParentPointer { get; } - public string[] Tokens { get; } - public override string ToString() { } - } - public enum OpenApiSpecVersion - { - OpenApi2_0 = 0, - OpenApi3_0 = 1, - OpenApi3_1 = 2, - } -} namespace Microsoft.OpenApi.MicrosoftExtensions { public class EnumDescription : Microsoft.OpenApi.Interfaces.IOpenApiElement @@ -335,7 +381,7 @@ namespace Microsoft.OpenApi.Models.Interfaces { public interface IOpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable { - System.Collections.Generic.Dictionary? PathItems { get; } + Microsoft.OpenApi.OrderedDictionary? PathItems { get; } } public interface IOpenApiDescribedElement : Microsoft.OpenApi.Interfaces.IOpenApiElement { @@ -350,10 +396,10 @@ namespace Microsoft.OpenApi.Models.Interfaces { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.Dictionary? Content { get; } + Microsoft.OpenApi.OrderedDictionary? Content { get; } bool Deprecated { get; } System.Text.Json.Nodes.JsonNode? Example { get; } - System.Collections.Generic.Dictionary? Examples { get; } + Microsoft.OpenApi.OrderedDictionary? Examples { get; } bool Explode { get; } bool Required { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } @@ -363,7 +409,7 @@ namespace Microsoft.OpenApi.Models.Interfaces { string? OperationId { get; } string? OperationRef { get; } - System.Collections.Generic.Dictionary? Parameters { get; } + Microsoft.OpenApi.OrderedDictionary? Parameters { get; } Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } Microsoft.OpenApi.Models.OpenApiServer? Server { get; } } @@ -371,10 +417,10 @@ namespace Microsoft.OpenApi.Models.Interfaces { bool AllowEmptyValue { get; } bool AllowReserved { get; } - System.Collections.Generic.Dictionary? Content { get; } + Microsoft.OpenApi.OrderedDictionary? Content { get; } bool Deprecated { get; } System.Text.Json.Nodes.JsonNode? Example { get; } - System.Collections.Generic.Dictionary? Examples { get; } + Microsoft.OpenApi.OrderedDictionary? Examples { get; } bool Explode { get; } Microsoft.OpenApi.Models.ParameterLocation? In { get; } string? Name { get; } @@ -384,7 +430,7 @@ namespace Microsoft.OpenApi.Models.Interfaces } public interface IOpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiSummarizedElement { - System.Collections.Generic.Dictionary? Operations { get; } + Microsoft.OpenApi.OrderedDictionary? Operations { get; } System.Collections.Generic.List? Parameters { get; } System.Collections.Generic.List? Servers { get; } } @@ -394,16 +440,16 @@ namespace Microsoft.OpenApi.Models.Interfaces } public interface IOpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.Dictionary? Content { get; } + Microsoft.OpenApi.OrderedDictionary? Content { get; } bool Required { get; } Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer); System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer); } public interface IOpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { - System.Collections.Generic.Dictionary? Content { get; } - System.Collections.Generic.Dictionary? Headers { get; } - System.Collections.Generic.Dictionary? Links { get; } + Microsoft.OpenApi.OrderedDictionary? Content { get; } + Microsoft.OpenApi.OrderedDictionary? Headers { get; } + Microsoft.OpenApi.OrderedDictionary? Links { get; } } public interface IOpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement { @@ -414,8 +460,8 @@ namespace Microsoft.OpenApi.Models.Interfaces string? Comment { get; } string? Const { get; } System.Text.Json.Nodes.JsonNode? Default { get; } - System.Collections.Generic.Dictionary? Definitions { get; } - System.Collections.Generic.Dictionary>? DependentRequired { get; } + Microsoft.OpenApi.OrderedDictionary? Definitions { get; } + Microsoft.OpenApi.OrderedDictionary>? DependentRequired { get; } bool Deprecated { get; } Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } string? DynamicAnchor { get; } @@ -441,17 +487,17 @@ namespace Microsoft.OpenApi.Models.Interfaces Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } System.Collections.Generic.List? OneOf { get; } string? Pattern { get; } - System.Collections.Generic.Dictionary? PatternProperties { get; } - System.Collections.Generic.Dictionary? Properties { get; } + Microsoft.OpenApi.OrderedDictionary? PatternProperties { get; } + Microsoft.OpenApi.OrderedDictionary? Properties { get; } bool ReadOnly { get; } - System.Collections.Generic.HashSet? Required { get; } + Microsoft.OpenApi.HashSet? Required { get; } System.Uri? Schema { get; } string? Title { get; } Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } bool UnevaluatedProperties { get; } bool? UniqueItems { get; } - System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; } - System.Collections.Generic.Dictionary? Vocabulary { get; } + Microsoft.OpenApi.OrderedDictionary? UnrecognizedKeywords { get; } + Microsoft.OpenApi.OrderedDictionary? Vocabulary { get; } bool WriteOnly { get; } Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } } @@ -491,8 +537,8 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallback() { } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? PathItems { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? PathItems { get; set; } public void AddPathItem(Microsoft.OpenApi.Expressions.RuntimeExpression expression, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -503,17 +549,17 @@ namespace Microsoft.OpenApi.Models { public OpenApiComponents() { } public OpenApiComponents(Microsoft.OpenApi.Models.OpenApiComponents? components) { } - public System.Collections.Generic.Dictionary? Callbacks { get; set; } - public System.Collections.Generic.Dictionary? Examples { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? Headers { get; set; } - public System.Collections.Generic.Dictionary? Links { get; set; } - public System.Collections.Generic.Dictionary? Parameters { get; set; } - public System.Collections.Generic.Dictionary? PathItems { get; set; } - public System.Collections.Generic.Dictionary? RequestBodies { get; set; } - public System.Collections.Generic.Dictionary? Responses { get; set; } - public System.Collections.Generic.Dictionary? Schemas { get; set; } - public System.Collections.Generic.Dictionary? SecuritySchemes { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Callbacks { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Headers { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Links { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Parameters { get; set; } + public Microsoft.OpenApi.OrderedDictionary? PathItems { get; set; } + public Microsoft.OpenApi.OrderedDictionary? RequestBodies { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Responses { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Schemas { get; set; } + public Microsoft.OpenApi.OrderedDictionary? SecuritySchemes { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -681,7 +727,7 @@ namespace Microsoft.OpenApi.Models public OpenApiContact() { } public OpenApiContact(Microsoft.OpenApi.Models.OpenApiContact contact) { } public string? Email { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -692,8 +738,8 @@ namespace Microsoft.OpenApi.Models { public OpenApiDiscriminator() { } public OpenApiDiscriminator(Microsoft.OpenApi.Models.OpenApiDiscriminator discriminator) { } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? Mapping { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Mapping { get; set; } public string? PropertyName { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -705,16 +751,16 @@ namespace Microsoft.OpenApi.Models public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument? document) { } public System.Uri BaseUri { get; } public Microsoft.OpenApi.Models.OpenApiComponents? Components { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; } public System.Uri? JsonSchemaDialect { get; set; } - public System.Collections.Generic.Dictionary? Metadata { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Metadata { get; set; } public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; } public System.Collections.Generic.List? Security { get; set; } public System.Collections.Generic.List? Servers { get; set; } - public System.Collections.Generic.HashSet? Tags { get; set; } - public System.Collections.Generic.Dictionary? Webhooks { get; set; } + public Microsoft.OpenApi.HashSet? Tags { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Webhooks { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace? Workspace { get; set; } public bool AddComponent(string id, T componentToRegister) { } public System.Threading.Tasks.Task GetHashCodeAsync(System.Threading.CancellationToken cancellationToken = default) { } @@ -736,8 +782,8 @@ namespace Microsoft.OpenApi.Models public bool? AllowReserved { get; set; } public string? ContentType { get; set; } public bool? Explode { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? Headers { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Headers { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -756,7 +802,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiExample() { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? ExternalValue { get; set; } public string? Summary { get; set; } public System.Text.Json.Nodes.JsonNode? Value { get; set; } @@ -765,12 +811,12 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public abstract class OpenApiExtensibleDictionary : System.Collections.Generic.Dictionary, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public abstract class OpenApiExtensibleDictionary : Microsoft.OpenApi.OrderedDictionary, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable where T : Microsoft.OpenApi.Interfaces.IOpenApiSerializable { protected OpenApiExtensibleDictionary() { } - protected OpenApiExtensibleDictionary(System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.Dictionary? extensions = null) { } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + protected OpenApiExtensibleDictionary(Microsoft.OpenApi.OrderedDictionary OrderedDictionary, Microsoft.OpenApi.OrderedDictionary? extensions = null) { } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -780,7 +826,7 @@ namespace Microsoft.OpenApi.Models public OpenApiExternalDocs() { } public OpenApiExternalDocs(Microsoft.OpenApi.Models.OpenApiExternalDocs externalDocs) { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public System.Uri? Url { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -791,13 +837,13 @@ namespace Microsoft.OpenApi.Models public OpenApiHeader() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.Dictionary? Content { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.Dictionary? Examples { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public bool Required { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } @@ -812,7 +858,7 @@ namespace Microsoft.OpenApi.Models public OpenApiInfo(Microsoft.OpenApi.Models.OpenApiInfo info) { } public Microsoft.OpenApi.Models.OpenApiContact? Contact { get; set; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiLicense? License { get; set; } public string? Summary { get; set; } public System.Uri? TermsOfService { get; set; } @@ -826,7 +872,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiLicense() { } public OpenApiLicense(Microsoft.OpenApi.Models.OpenApiLicense license) { } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? Identifier { get; set; } public string? Name { get; set; } public System.Uri? Url { get; set; } @@ -838,10 +884,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiLink() { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? OperationId { get; set; } public string? OperationRef { get; set; } - public System.Collections.Generic.Dictionary? Parameters { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Parameters { get; set; } public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; set; } public Microsoft.OpenApi.Models.OpenApiServer? Server { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CreateShallowCopy() { } @@ -853,10 +899,10 @@ namespace Microsoft.OpenApi.Models { public OpenApiMediaType() { } public OpenApiMediaType(Microsoft.OpenApi.Models.OpenApiMediaType? mediaType) { } - public System.Collections.Generic.Dictionary? Encoding { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Encoding { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.Dictionary? Examples { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -867,9 +913,9 @@ namespace Microsoft.OpenApi.Models public OpenApiOAuthFlow() { } public OpenApiOAuthFlow(Microsoft.OpenApi.Models.OpenApiOAuthFlow oAuthFlow) { } public System.Uri? AuthorizationUrl { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public System.Uri? RefreshUrl { get; set; } - public System.Collections.Generic.Dictionary? Scopes { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Scopes { get; set; } public System.Uri? TokenUrl { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -881,7 +927,7 @@ namespace Microsoft.OpenApi.Models public OpenApiOAuthFlows(Microsoft.OpenApi.Models.OpenApiOAuthFlows oAuthFlows) { } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? AuthorizationCode { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? ClientCredentials { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Implicit { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow? Password { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -893,12 +939,12 @@ namespace Microsoft.OpenApi.Models public const bool DeprecatedDefault = false; public OpenApiOperation() { } public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { } - public System.Collections.Generic.Dictionary? Callbacks { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Callbacks { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } - public System.Collections.Generic.Dictionary? Metadata { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Metadata { get; set; } public string? OperationId { get; set; } public System.Collections.Generic.List? Parameters { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody? RequestBody { get; set; } @@ -906,7 +952,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.List? Security { get; set; } public System.Collections.Generic.List? Servers { get; set; } public string? Summary { get; set; } - public System.Collections.Generic.HashSet? Tags { get; set; } + public Microsoft.OpenApi.HashSet? Tags { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -916,13 +962,13 @@ namespace Microsoft.OpenApi.Models public OpenApiParameter() { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } - public System.Collections.Generic.Dictionary? Content { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; set; } - public System.Collections.Generic.Dictionary? Examples { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; set; } public bool Explode { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } public string? Name { get; set; } public bool Required { get; set; } @@ -937,8 +983,8 @@ namespace Microsoft.OpenApi.Models { public OpenApiPathItem() { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? Operations { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Operations { get; set; } public System.Collections.Generic.List? Parameters { get; set; } public System.Collections.Generic.List? Servers { get; set; } public string? Summary { get; set; } @@ -975,9 +1021,9 @@ namespace Microsoft.OpenApi.Models public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBody() { } - public System.Collections.Generic.Dictionary? Content { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; set; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public bool Required { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -989,11 +1035,11 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponse() { } - public System.Collections.Generic.Dictionary? Content { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; set; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } - public System.Collections.Generic.Dictionary? Headers { get; set; } - public System.Collections.Generic.Dictionary? Links { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Headers { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Links { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1014,8 +1060,8 @@ namespace Microsoft.OpenApi.Models public string? Comment { get; set; } public string? Const { get; set; } public System.Text.Json.Nodes.JsonNode? Default { get; set; } - public System.Collections.Generic.Dictionary? Definitions { get; set; } - public System.Collections.Generic.Dictionary>? DependentRequired { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Definitions { get; set; } + public Microsoft.OpenApi.OrderedDictionary>? DependentRequired { get; set; } public bool Deprecated { get; set; } public string? Description { get; set; } public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; set; } @@ -1026,7 +1072,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.List? Examples { get; set; } public string? ExclusiveMaximum { get; set; } public string? ExclusiveMinimum { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Format { get; set; } public string? Id { get; set; } @@ -1035,7 +1081,7 @@ namespace Microsoft.OpenApi.Models public int? MaxLength { get; set; } public int? MaxProperties { get; set; } public string? Maximum { get; set; } - public System.Collections.Generic.Dictionary? Metadata { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Metadata { get; set; } public int? MinItems { get; set; } public int? MinLength { get; set; } public int? MinProperties { get; set; } @@ -1044,17 +1090,17 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; set; } public System.Collections.Generic.List? OneOf { get; set; } public string? Pattern { get; set; } - public System.Collections.Generic.Dictionary? PatternProperties { get; set; } - public System.Collections.Generic.Dictionary? Properties { get; set; } + public Microsoft.OpenApi.OrderedDictionary? PatternProperties { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Properties { get; set; } public bool ReadOnly { get; set; } - public System.Collections.Generic.HashSet? Required { get; set; } + public Microsoft.OpenApi.HashSet? Required { get; set; } public System.Uri? Schema { get; set; } public string? Title { get; set; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; set; } public bool UnevaluatedProperties { get; set; } public bool? UniqueItems { get; set; } - public System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; set; } - public System.Collections.Generic.Dictionary? Vocabulary { get; set; } + public Microsoft.OpenApi.OrderedDictionary? UnrecognizedKeywords { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Vocabulary { get; set; } public bool WriteOnly { get; set; } public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CreateShallowCopy() { } @@ -1062,7 +1108,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiSecurityRequirement : System.Collections.Generic.Dictionary>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiSecurityRequirement : Microsoft.OpenApi.OrderedDictionary>, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSecurityRequirement() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1074,7 +1120,7 @@ namespace Microsoft.OpenApi.Models public OpenApiSecurityScheme() { } public string? BearerFormat { get; set; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; set; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; set; } public string? Name { get; set; } @@ -1091,9 +1137,9 @@ namespace Microsoft.OpenApi.Models public OpenApiServer() { } public OpenApiServer(Microsoft.OpenApi.Models.OpenApiServer server) { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? Url { get; set; } - public System.Collections.Generic.Dictionary? Variables { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Variables { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1105,7 +1151,7 @@ namespace Microsoft.OpenApi.Models public string? Default { get; set; } public string? Description { get; set; } public System.Collections.Generic.List? Enum { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV31(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1114,7 +1160,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiTag() { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; } public string? Name { get; set; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiTag CreateShallowCopy() { } @@ -1127,7 +1173,7 @@ namespace Microsoft.OpenApi.Models public OpenApiXml() { } public OpenApiXml(Microsoft.OpenApi.Models.OpenApiXml xml) { } public bool Attribute { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; set; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; set; } public string? Name { get; set; } public System.Uri? Namespace { get; set; } public string? Prefix { get; set; } @@ -1229,8 +1275,8 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiCallbackReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback { public OpenApiCallbackReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.Dictionary? Extensions { get; } - public System.Collections.Generic.Dictionary? PathItems { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? PathItems { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiCallback CreateShallowCopy() { } public override void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1239,7 +1285,7 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiExampleReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public string? ExternalValue { get; } public string? Summary { get; set; } public System.Text.Json.Nodes.JsonNode? Value { get; } @@ -1252,13 +1298,13 @@ namespace Microsoft.OpenApi.Models.References public OpenApiHeaderReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.Dictionary? Content { get; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; } public bool Deprecated { get; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; } - public System.Collections.Generic.Dictionary? Examples { get; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public bool Required { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Schema { get; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; } @@ -1269,10 +1315,10 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiLinkReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public string? OperationId { get; } public string? OperationRef { get; } - public System.Collections.Generic.Dictionary? Parameters { get; } + public Microsoft.OpenApi.OrderedDictionary? Parameters { get; } public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper? RequestBody { get; } public Microsoft.OpenApi.Models.OpenApiServer? Server { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiLink CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiLink source) { } @@ -1284,13 +1330,13 @@ namespace Microsoft.OpenApi.Models.References public OpenApiParameterReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public bool AllowEmptyValue { get; } public bool AllowReserved { get; } - public System.Collections.Generic.Dictionary? Content { get; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; } public bool Deprecated { get; } public string? Description { get; set; } public System.Text.Json.Nodes.JsonNode? Example { get; } - public System.Collections.Generic.Dictionary? Examples { get; } + public Microsoft.OpenApi.OrderedDictionary? Examples { get; } public bool Explode { get; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } public string? Name { get; } public bool Required { get; } @@ -1303,8 +1349,8 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiPathItemReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } - public System.Collections.Generic.Dictionary? Operations { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Operations { get; } public System.Collections.Generic.List? Parameters { get; } public System.Collections.Generic.List? Servers { get; } public string? Summary { get; set; } @@ -1315,9 +1361,9 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiRequestBodyReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiRequestBody { public OpenApiRequestBodyReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.Dictionary? Content { get; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public bool Required { get; } public Microsoft.OpenApi.Models.Interfaces.IOpenApiParameter? ConvertToBodyParameter(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public System.Collections.Generic.IEnumerable? ConvertToFormDataParameters(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1328,11 +1374,11 @@ namespace Microsoft.OpenApi.Models.References public class OpenApiResponseReference : Microsoft.OpenApi.Models.References.BaseOpenApiReferenceHolder, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiReadOnlyExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable, Microsoft.OpenApi.Interfaces.IShallowCopyable, Microsoft.OpenApi.Models.Interfaces.IOpenApiDescribedElement, Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse { public OpenApiResponseReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } - public System.Collections.Generic.Dictionary? Content { get; } + public Microsoft.OpenApi.OrderedDictionary? Content { get; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } - public System.Collections.Generic.Dictionary? Headers { get; } - public System.Collections.Generic.Dictionary? Links { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Headers { get; } + public Microsoft.OpenApi.OrderedDictionary? Links { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse source) { } public Microsoft.OpenApi.Models.Interfaces.IOpenApiResponse CreateShallowCopy() { } } @@ -1346,8 +1392,8 @@ namespace Microsoft.OpenApi.Models.References public string? Comment { get; } public string? Const { get; } public System.Text.Json.Nodes.JsonNode? Default { get; } - public System.Collections.Generic.Dictionary? Definitions { get; } - public System.Collections.Generic.Dictionary>? DependentRequired { get; } + public Microsoft.OpenApi.OrderedDictionary? Definitions { get; } + public Microsoft.OpenApi.OrderedDictionary>? DependentRequired { get; } public bool Deprecated { get; } public string? Description { get; set; } public Microsoft.OpenApi.Models.OpenApiDiscriminator? Discriminator { get; } @@ -1358,7 +1404,7 @@ namespace Microsoft.OpenApi.Models.References public System.Collections.Generic.List? Examples { get; } public string? ExclusiveMaximum { get; } public string? ExclusiveMinimum { get; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } public string? Format { get; } public string? Id { get; } @@ -1375,17 +1421,17 @@ namespace Microsoft.OpenApi.Models.References public Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema? Not { get; } public System.Collections.Generic.List? OneOf { get; } public string? Pattern { get; } - public System.Collections.Generic.Dictionary? PatternProperties { get; } - public System.Collections.Generic.Dictionary? Properties { get; } + public Microsoft.OpenApi.OrderedDictionary? PatternProperties { get; } + public Microsoft.OpenApi.OrderedDictionary? Properties { get; } public bool ReadOnly { get; } - public System.Collections.Generic.HashSet? Required { get; } + public Microsoft.OpenApi.HashSet? Required { get; } public System.Uri? Schema { get; } public string? Title { get; } public Microsoft.OpenApi.Models.JsonSchemaType? Type { get; } public bool UnevaluatedProperties { get; } public bool? UniqueItems { get; } - public System.Collections.Generic.Dictionary? UnrecognizedKeywords { get; } - public System.Collections.Generic.Dictionary? Vocabulary { get; } + public Microsoft.OpenApi.OrderedDictionary? UnrecognizedKeywords { get; } + public Microsoft.OpenApi.OrderedDictionary? Vocabulary { get; } public bool WriteOnly { get; } public Microsoft.OpenApi.Models.OpenApiXml? Xml { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema CopyReferenceAsTargetElementWithOverrides(Microsoft.OpenApi.Models.Interfaces.IOpenApiSchema source) { } @@ -1399,7 +1445,7 @@ namespace Microsoft.OpenApi.Models.References public OpenApiSecuritySchemeReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? BearerFormat { get; } public string? Description { get; set; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiOAuthFlows? Flows { get; } public Microsoft.OpenApi.Models.ParameterLocation? In { get; } public string? Name { get; } @@ -1413,7 +1459,7 @@ namespace Microsoft.OpenApi.Models.References { public OpenApiTagReference(string referenceId, Microsoft.OpenApi.Models.OpenApiDocument? hostDocument = null, string? externalResource = null) { } public string? Description { get; } - public System.Collections.Generic.Dictionary? Extensions { get; } + public Microsoft.OpenApi.OrderedDictionary? Extensions { get; } public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; } public string? Name { get; } public override Microsoft.OpenApi.Models.Interfaces.IOpenApiTag? Target { get; } @@ -1463,7 +1509,7 @@ namespace Microsoft.OpenApi.Reader public System.Uri? BaseUrl { get; set; } public Microsoft.OpenApi.Interfaces.IStreamLoader? CustomExternalLoader { get; set; } public System.Collections.Generic.List? DefaultContentType { get; set; } - public System.Collections.Generic.Dictionary>? ExtensionParsers { get; set; } + public Microsoft.OpenApi.OrderedDictionary>? ExtensionParsers { get; set; } public System.Net.Http.HttpClient HttpClient { init; } public bool LeaveStreamOpen { get; set; } public bool LoadExternalRefs { get; set; } @@ -1485,7 +1531,7 @@ namespace Microsoft.OpenApi.Reader public System.Uri? BaseUrl { get; set; } public System.Collections.Generic.List? DefaultContentType { get; set; } public Microsoft.OpenApi.Reader.OpenApiDiagnostic Diagnostic { get; } - public System.Collections.Generic.Dictionary>? ExtensionParsers { get; set; } + public Microsoft.OpenApi.OrderedDictionary>? ExtensionParsers { get; set; } public void EndObject() { } public T? GetFromTempStorage(string key, object? scope = null) { } public string GetLocation() { } @@ -1553,8 +1599,8 @@ namespace Microsoft.OpenApi.Services public static class OpenApiFilterService { public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } - public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary sources) { } - public static System.Func CreatePredicate(string? operationIds = null, string? tags = null, System.Collections.Generic.Dictionary>? requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument? source = null) { } + public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Microsoft.OpenApi.OrderedDictionary sources) { } + public static System.Func CreatePredicate(string? operationIds = null, string? tags = null, Microsoft.OpenApi.OrderedDictionary>? requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument? source = null) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { @@ -1565,13 +1611,13 @@ namespace Microsoft.OpenApi.Services public class OpenApiUrlTreeNode { public static readonly System.Collections.Generic.IReadOnlyDictionary MermaidNodeStyles; - public System.Collections.Generic.Dictionary> AdditionalData { get; set; } - public System.Collections.Generic.Dictionary Children { get; } + public Microsoft.OpenApi.OrderedDictionary> AdditionalData { get; set; } + public Microsoft.OpenApi.OrderedDictionary Children { get; } public bool IsParameter { get; } public string Path { get; set; } - public System.Collections.Generic.Dictionary PathItems { get; } + public Microsoft.OpenApi.OrderedDictionary PathItems { get; } public string Segment { get; } - public void AddAdditionalData(System.Collections.Generic.Dictionary> additionalData) { } + public void AddAdditionalData(Microsoft.OpenApi.OrderedDictionary> additionalData) { } public void Attach(Microsoft.OpenApi.Models.OpenApiDocument doc, string label) { } public Microsoft.OpenApi.Services.OpenApiUrlTreeNode Attach(string path, Microsoft.OpenApi.Models.Interfaces.IOpenApiPathItem pathItem, string label) { } public bool HasOperations(string label) { } @@ -1586,6 +1632,8 @@ namespace Microsoft.OpenApi.Services public string PathString { get; } public virtual void Enter(string segment) { } public virtual void Exit() { } + public virtual void Visit(Microsoft.OpenApi.HashSet openApiTags) { } + public virtual void Visit(Microsoft.OpenApi.HashSet openApiTags) { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtensible openApiExtensible) { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtension openApiExtension) { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiReferenceHolder referenceHolder) { } @@ -1616,17 +1664,15 @@ namespace Microsoft.OpenApi.Services public virtual void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public virtual void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } public virtual void Visit(Microsoft.OpenApi.Models.References.OpenApiTagReference tag) { } - public virtual void Visit(System.Collections.Generic.Dictionary operations) { } - public virtual void Visit(System.Collections.Generic.Dictionary callbacks) { } - public virtual void Visit(System.Collections.Generic.Dictionary examples) { } - public virtual void Visit(System.Collections.Generic.Dictionary headers) { } - public virtual void Visit(System.Collections.Generic.Dictionary links) { } - public virtual void Visit(System.Collections.Generic.Dictionary webhooks) { } - public virtual void Visit(System.Collections.Generic.Dictionary encodings) { } - public virtual void Visit(System.Collections.Generic.Dictionary content) { } - public virtual void Visit(System.Collections.Generic.Dictionary serverVariables) { } - public virtual void Visit(System.Collections.Generic.HashSet openApiTags) { } - public virtual void Visit(System.Collections.Generic.HashSet openApiTags) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary operations) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary callbacks) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary examples) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary headers) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary links) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary webhooks) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary encodings) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary content) { } + public virtual void Visit(Microsoft.OpenApi.OrderedDictionary serverVariables) { } public virtual void Visit(System.Collections.Generic.List example) { } public virtual void Visit(System.Collections.Generic.List parameters) { } public virtual void Visit(System.Collections.Generic.List openApiSecurityRequirements) { } @@ -1712,14 +1758,14 @@ namespace Microsoft.OpenApi.Validations public override void Visit(Microsoft.OpenApi.Models.OpenApiServer server) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiTag tag) { } - public override void Visit(System.Collections.Generic.Dictionary operations) { } - public override void Visit(System.Collections.Generic.Dictionary callbacks) { } - public override void Visit(System.Collections.Generic.Dictionary examples) { } - public override void Visit(System.Collections.Generic.Dictionary headers) { } - public override void Visit(System.Collections.Generic.Dictionary links) { } - public override void Visit(System.Collections.Generic.Dictionary encodings) { } - public override void Visit(System.Collections.Generic.Dictionary content) { } - public override void Visit(System.Collections.Generic.Dictionary serverVariables) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary operations) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary callbacks) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary examples) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary headers) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary links) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary encodings) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary content) { } + public override void Visit(Microsoft.OpenApi.OrderedDictionary serverVariables) { } public override void Visit(System.Collections.Generic.List example) { } } public class OpenApiValidatorError : Microsoft.OpenApi.Models.OpenApiError @@ -1744,8 +1790,8 @@ namespace Microsoft.OpenApi.Validations public sealed class ValidationRuleSet { public ValidationRuleSet() { } + public ValidationRuleSet(Microsoft.OpenApi.OrderedDictionary> rules) { } public ValidationRuleSet(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } - public ValidationRuleSet(System.Collections.Generic.Dictionary> rules) { } public int Count { get; } public System.Collections.Generic.List Rules { get; } public void Add(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } @@ -1761,7 +1807,7 @@ namespace Microsoft.OpenApi.Validations public bool Remove(System.Type key, Microsoft.OpenApi.Validations.ValidationRule rule) { } public bool TryGetValue(System.Type key, out System.Collections.Generic.List? rules) { } public bool Update(System.Type key, Microsoft.OpenApi.Validations.ValidationRule newRule, Microsoft.OpenApi.Validations.ValidationRule oldRule) { } - public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, System.Collections.Generic.Dictionary> rules) { } + public static void AddValidationRules(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet, Microsoft.OpenApi.OrderedDictionary> rules) { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetDefaultRuleSet() { } public static Microsoft.OpenApi.Validations.ValidationRuleSet GetEmptyRuleSet() { } } @@ -1914,7 +1960,7 @@ namespace Microsoft.OpenApi.Writers public static class OpenApiWriterAnyExtensions { public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Text.Json.Nodes.JsonNode? node) { } - public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, System.Collections.Generic.Dictionary? extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } + public static void WriteExtensions(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OrderedDictionary? extensions, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } public abstract class OpenApiWriterBase : Microsoft.OpenApi.Writers.IOpenApiWriter { @@ -1961,13 +2007,13 @@ namespace Microsoft.OpenApi.Writers { public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary>? elements, System.Action> action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary>? elements, System.Action> action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) { } + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) + public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteOptionalObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } public static void WriteProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } @@ -1979,8 +2025,8 @@ namespace Microsoft.OpenApi.Writers where T : struct { } public static void WriteRequiredCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) { } - public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.Dictionary? elements, System.Action action) + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) { } + public static void WriteRequiredMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, Microsoft.OpenApi.OrderedDictionary? elements, System.Action action) where T : Microsoft.OpenApi.Interfaces.IOpenApiElement { } public static void WriteRequiredObject(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, T? value, System.Action action) { } public static void WriteRequiredProperty(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, string? value) { } diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs index 702b4ed12..f9dbdc856 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiUrlTreeNodeTests.cs @@ -354,7 +354,7 @@ public void AdditionalDataWorks() var label = "personal"; var rootNode = OpenApiUrlTreeNode.Create(doc, label); - var additionalData1 = new Dictionary> + var additionalData1 = new OrderedDictionary> { {"DatePurchased", new List { "21st April 2021" } }, {"Location", new List { "Seattle, WA" } }, @@ -363,13 +363,13 @@ public void AdditionalDataWorks() }; rootNode.AddAdditionalData(additionalData1); - var additionalData2 = new Dictionary> + var additionalData2 = new OrderedDictionary> { {"Bedrooms", new List { "Five" } } }; rootNode.Children["houses"].AddAdditionalData(additionalData2); - var additionalData3 = new Dictionary> + var additionalData3 = new OrderedDictionary> { {"Categories", new List { "Coupe", "Sedan", "Convertible" } } }; diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs index 1de888cd3..c3967ccc4 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiValidatorTests.cs @@ -37,7 +37,7 @@ public void ResponseMustHaveADescription() "/test", new OpenApiPathItem() { - Operations = new Dictionary + Operations = new OrderedDictionary { [HttpMethod.Get] = new() { @@ -131,7 +131,7 @@ public void ValidateCustomExtension() var extensionNode = JsonSerializer.Serialize(fooExtension); var jsonNode = JsonNode.Parse(extensionNode); - openApiDocument.Info.Extensions = new Dictionary + openApiDocument.Info.Extensions = new OrderedDictionary { { "x-foo", new OpenApiAny(jsonNode) } }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs index de83299fc..ad421c430 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiComponentsValidationTests.cs @@ -22,7 +22,7 @@ public void ValidateKeyMustMatchRegularExpressionInComponents() var components = new OpenApiComponents { - Responses = new Dictionary + Responses = new OrderedDictionary { { key, new OpenApiResponse { Description = "any" } } } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index b70eea7bc..4affcca40 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -57,7 +57,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer } }, - Examples = new Dictionary + Examples = new OrderedDictionary { ["example0"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index 17d3bdd54..1bf2a8e9e 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -56,7 +56,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer, } }, - Examples = new Dictionary + Examples = new OrderedDictionary { ["example0"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 6142bd082..cb417fd54 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -107,7 +107,7 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() Type = JsonSchemaType.Integer, } }, - Examples = new Dictionary + Examples = new OrderedDictionary { ["example0"] = new OpenApiExample() { diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs index 0fb23578b..c71e66761 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiReferenceValidationTests.cs @@ -62,7 +62,7 @@ public void ReferencedSchemaShouldOnlyBeValidatedOnce() }; // Act - var rules = new Dictionary>() + var rules = new OrderedDictionary>() { { typeof(IOpenApiSchema), new List() { new AlwaysFailRule() } @@ -116,7 +116,7 @@ public void UnresolvedSchemaReferencedShouldNotBeValidated() }; // Act - var rules = new Dictionary>() + var rules = new OrderedDictionary>() { { typeof(OpenApiSchema), new List() { new AlwaysFailRule() } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index f0c772473..fcffea1d9 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -115,7 +115,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() var schema = new OpenApiSchema { Type = JsonSchemaType.Object, - Properties = new Dictionary + Properties = new OrderedDictionary { ["property1"] = new OpenApiSchema() { @@ -187,7 +187,7 @@ public void ValidateSchemaRequiredFieldListMustContainThePropertySpecifiedInTheD { var components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new OrderedDictionary { { "schema1", @@ -220,7 +220,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim // Arrange var components = new OpenApiComponents { - Schemas = new Dictionary + Schemas = new OrderedDictionary { { "Person", @@ -235,7 +235,7 @@ public void ValidateOneOfSchemaPropertyNameContainsPropertySpecifiedInTheDiscrim [ new OpenApiSchema() { - Properties = new Dictionary + Properties = new OrderedDictionary { { "type", diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs index 9824b17f6..4a3e0adef 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiTagValidationTests.cs @@ -42,7 +42,7 @@ public void ValidateExtensionNameStartsWithXDashInTag() { Name = "tag" }; - tag.Extensions = new Dictionary + tag.Extensions = new OrderedDictionary { { "tagExt", new OpenApiAny("value") } }; diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index 48ac1f105..22fd9bfda 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -22,11 +22,11 @@ public class ValidationRuleSetTests private readonly ValidationRule _parameterValidationRule = new ValidationRule(nameof(_parameterValidationRule), (context, item) => { }); - private readonly Dictionary> _rulesDictionary; + private readonly OrderedDictionary> _rulesDictionary; public ValidationRuleSetTests() { - _rulesDictionary = new Dictionary>() + _rulesDictionary = new OrderedDictionary>() { {typeof(OpenApiContact), [_contactValidationRule] }, {typeof(OpenApiHeader), [_headerValidationRule] }, @@ -121,7 +121,7 @@ public void AddNewValidationRuleWorks() // Act ruleSet.Add(typeof(OpenApiResponse), [responseValidationRule]); ruleSet.Add(typeof(OpenApiTag), [tagValidationRule]); - var rulesDictionary = new Dictionary>() + var rulesDictionary = new OrderedDictionary>() { {typeof(OpenApiPaths), [pathsValidationRule] } }; @@ -175,7 +175,7 @@ public void ClearAllRulesWorks() var ruleSet = new ValidationRuleSet(); var tagValidationRule = new ValidationRule("ValidateTags", (context, item) => { }); var pathsValidationRule = new ValidationRule("ValidatePaths", (context, item) => { }); - var rulesDictionary = new Dictionary>() + var rulesDictionary = new OrderedDictionary>() { {typeof(OpenApiPaths), [pathsValidationRule] }, {typeof(OpenApiTag), [tagValidationRule] } diff --git a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs index 030e60581..c7e79da2e 100644 --- a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs @@ -29,23 +29,23 @@ public void ExpectedVirtualsInvolved() visitor.Visit(default(OpenApiPaths)); visitor.Visit(default(IOpenApiPathItem)); visitor.Visit(default(OpenApiServerVariable)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(OpenApiOperation)); visitor.Visit(default(List)); visitor.Visit(default(IOpenApiParameter)); visitor.Visit(default(IOpenApiRequestBody)); - visitor.Visit(default(Dictionary)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(IOpenApiResponse)); visitor.Visit(default(OpenApiResponses)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(OpenApiMediaType)); visitor.Visit(default(OpenApiEncoding)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(OpenApiComponents)); visitor.Visit(default(OpenApiExternalDocs)); visitor.Visit(default(IOpenApiSchema)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(IOpenApiLink)); visitor.Visit(default(IOpenApiCallback)); visitor.Visit(default(OpenApiTag)); @@ -59,8 +59,8 @@ public void ExpectedVirtualsInvolved() visitor.Visit(default(IOpenApiExtensible)); visitor.Visit(default(IOpenApiExtension)); visitor.Visit(default(List)); - visitor.Visit(default(Dictionary)); - visitor.Visit(default(Dictionary)); + visitor.Visit(default(OrderedDictionary)); + visitor.Visit(default(OrderedDictionary)); visitor.Visit(default(IOpenApiReferenceHolder)); visitor.Exit(); Assert.True(42 < ((TestVisitor)visitor).CallStack.Count); @@ -143,7 +143,7 @@ public override void Visit(OpenApiServerVariable serverVariable) base.Visit(serverVariable); } - public override void Visit(Dictionary operations) + public override void Visit(OrderedDictionary operations) { EncodeCall(); base.Visit(operations); @@ -173,13 +173,13 @@ public override void Visit(IOpenApiRequestBody requestBody) base.Visit(requestBody); } - public override void Visit(Dictionary headers) + public override void Visit(OrderedDictionary headers) { EncodeCall(); base.Visit(headers); } - public override void Visit(Dictionary callbacks) + public override void Visit(OrderedDictionary callbacks) { EncodeCall(); base.Visit(callbacks); @@ -197,7 +197,7 @@ public override void Visit(OpenApiResponses response) base.Visit(response); } - public override void Visit(Dictionary content) + public override void Visit(OrderedDictionary content) { EncodeCall(); base.Visit(content); @@ -215,7 +215,7 @@ public override void Visit(OpenApiEncoding encoding) base.Visit(encoding); } - public override void Visit(Dictionary examples) + public override void Visit(OrderedDictionary examples) { EncodeCall(); base.Visit(examples); @@ -239,7 +239,7 @@ public override void Visit(IOpenApiSchema schema) base.Visit(schema); } - public override void Visit(Dictionary links) + public override void Visit(OrderedDictionary links) { EncodeCall(); base.Visit(links); @@ -323,13 +323,13 @@ public override void Visit(List example) base.Visit(example); } - public override void Visit(Dictionary serverVariables) + public override void Visit(OrderedDictionary serverVariables) { EncodeCall(); base.Visit(serverVariables); } - public override void Visit(Dictionary encodings) + public override void Visit(OrderedDictionary encodings) { EncodeCall(); base.Visit(encodings); diff --git a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs index 01f3c223b..07881acda 100644 --- a/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs @@ -192,7 +192,7 @@ public void LocateReferences() Schema = new OpenApiSchemaReference("derived") } }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["test-header"] = testHeaderReference } @@ -209,11 +209,11 @@ public void LocateReferences() ["derived"] = derivedSchema, ["base"] = baseSchema, }, - Headers = new Dictionary + Headers = new OrderedDictionary { ["test-header"] = testHeader }, - SecuritySchemes = new Dictionary + SecuritySchemes = new OrderedDictionary { ["test-secScheme"] = new OpenApiSecuritySchemeReference("reference-to-scheme") } @@ -285,7 +285,7 @@ public override void Visit(IOpenApiReferenceHolder referenceable) { Locations.Add("referenceAt: " + this.PathString); } - public override void Visit(Dictionary content) + public override void Visit(OrderedDictionary content) { Locations.Add(this.PathString); } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs index 17dab923b..13486bd7e 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiReferencableTests.cs @@ -21,7 +21,7 @@ public class OpenApiReferencableTests private static readonly OpenApiHeader _headerFragment = new() { Schema = new OpenApiSchema(), - Examples = new Dictionary + Examples = new OrderedDictionary { { "example1", new OpenApiExample() } } @@ -29,7 +29,7 @@ public class OpenApiReferencableTests private static readonly OpenApiParameter _parameterFragment = new() { Schema = new OpenApiSchema(), - Examples = new Dictionary + Examples = new OrderedDictionary { { "example1", new OpenApiExample() } } @@ -37,11 +37,11 @@ public class OpenApiReferencableTests private static readonly OpenApiRequestBody _requestBodyFragment = new(); private static readonly OpenApiResponse _responseFragment = new() { - Headers = new Dictionary + Headers = new OrderedDictionary { { "header1", new OpenApiHeader() } }, - Links = new Dictionary + Links = new OrderedDictionary { { "link1", new OpenApiLink() } } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index ba66aeedf..c11c3cc98 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -110,7 +110,7 @@ public void OpenApiWorkspacesCanResolveReferencesToDocumentFragmentsWithJsonPoin var workspace = new OpenApiWorkspace(); var responseFragment = new OpenApiResponse { - Headers = new Dictionary + Headers = new OrderedDictionary { { "header1", new OpenApiHeader() } } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index fb149b5ec..63ee9e5e4 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -75,7 +75,7 @@ public async Task WriteStringListAsJsonShouldMatchExpected(string[] stringValues public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesSimple() { return - from input in new Dictionary[] { + from input in new OrderedDictionary[] { // Simple map new() { ["property1"] = "value1", @@ -99,14 +99,14 @@ from shouldBeTerse in shouldProduceTerseOutputValues public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesComplex() { return - from input in new Dictionary[] { + from input in new OrderedDictionary[] { // Empty map and empty list new() { - ["property1"] = new Dictionary(), + ["property1"] = new OrderedDictionary(), ["property2"] = new List(), ["property3"] = new List { - new Dictionary(), + new OrderedDictionary(), }, ["property4"] = "value4" }, @@ -135,12 +135,12 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesCo // Nested map new() { - ["property1"] = new Dictionary + ["property1"] = new OrderedDictionary { ["innerProperty1"] = "innerValue1" }, ["property2"] = "value2", - ["property3"] = new Dictionary + ["property3"] = new OrderedDictionary { ["innerProperty3"] = "innerValue3" }, @@ -149,13 +149,13 @@ public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesCo // Nested map and list new() { - ["property1"] = new Dictionary(), + ["property1"] = new OrderedDictionary(), ["property2"] = new List(), ["property3"] = new List { - new Dictionary(), + new OrderedDictionary(), "string1", - new Dictionary + new OrderedDictionary { ["innerProperty1"] = new List(), ["innerProperty2"] = "string2", @@ -187,8 +187,8 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) writer.WriteValue(value); } else if (value.GetType().IsGenericType && - (typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || - typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) + (typeof(OrderedDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || + typeof(OrderedDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) { writer.WriteStartObject(); foreach (var elementValue in (dynamic)(value)) @@ -214,7 +214,7 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) [Theory] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesSimple))] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesComplex))] - public void WriteMapAsJsonShouldMatchExpected(Dictionary inputMap, bool produceTerseOutput) + public void WriteMapAsJsonShouldMatchExpected(OrderedDictionary inputMap, bool produceTerseOutput) { // Arrange using var outputString = new StringWriter(CultureInfo.InvariantCulture); @@ -333,7 +333,7 @@ public void OpenApiJsonWriterOutputsValidJsonValueWhenSchemaHasNanOrInfinityValu var jsonString = schemaBuilder.ToString(); // Assert - var exception = Record.Exception(() => System.Text.Json.JsonSerializer.Deserialize>(jsonString)); + var exception = Record.Exception(() => System.Text.Json.JsonSerializer.Deserialize>(jsonString)); Assert.Null(exception); } } diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index dd5608f53..98c81d0fe 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -91,7 +91,7 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesSi // Simple map yield return new object[] { - new Dictionary + new OrderedDictionary { ["property1"] = "value1", ["property2"] = "value2", @@ -109,7 +109,7 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesSi // Simple map with duplicate value yield return new object[] { - new Dictionary + new OrderedDictionary { ["property1"] = "value1", ["property2"] = "value1", @@ -130,13 +130,13 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo // Empty map and empty list yield return new object[] { - new Dictionary + new OrderedDictionary { - ["property1"] = new Dictionary(), + ["property1"] = new OrderedDictionary(), ["property2"] = new List(), ["property3"] = new List { - new Dictionary(), + new OrderedDictionary(), }, ["property4"] = "value4" }, @@ -152,7 +152,7 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo // Number, boolean, and null handling yield return new object[] { - new Dictionary + new OrderedDictionary { ["property1"] = "10.0", ["property2"] = "10", @@ -184,7 +184,7 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo // DateTime yield return new object[] { - new Dictionary + new OrderedDictionary { ["property1"] = new DateTime(1970, 01, 01), ["property2"] = new DateTimeOffset(new DateTime(1970, 01, 01), TimeSpan.FromHours(3)), @@ -200,14 +200,14 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo // Nested map yield return new object[] { - new Dictionary + new OrderedDictionary { - ["property1"] = new Dictionary + ["property1"] = new OrderedDictionary { ["innerProperty1"] = "innerValue1" }, ["property2"] = "value2", - ["property3"] = new Dictionary + ["property3"] = new OrderedDictionary { ["innerProperty3"] = "innerValue3" }, @@ -226,15 +226,15 @@ public static IEnumerable WriteMapAsYamlShouldMatchExpectedTestCasesCo // Nested map and list yield return new object[] { - new Dictionary + new OrderedDictionary { - ["property1"] = new Dictionary(), + ["property1"] = new OrderedDictionary(), ["property2"] = new List(), ["property3"] = new List { - new Dictionary(), + new OrderedDictionary(), "string1", - new Dictionary + new OrderedDictionary { ["innerProperty1"] = new List(), ["innerProperty2"] = "string2", @@ -277,8 +277,8 @@ private void WriteValueRecursive(OpenApiYamlWriter writer, object value) writer.WriteValue(value); } else if (value.GetType().IsGenericType && - (typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || - typeof(Dictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) + (typeof(OrderedDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()) || + typeof(OrderedDictionary<,>).IsAssignableFrom(value.GetType().GetGenericTypeDefinition()))) { writer.WriteStartObject(); foreach (var elementValue in (dynamic)(value)) @@ -304,7 +304,7 @@ private void WriteValueRecursive(OpenApiYamlWriter writer, object value) [Theory] [MemberData(nameof(WriteMapAsYamlShouldMatchExpectedTestCasesSimple))] [MemberData(nameof(WriteMapAsYamlShouldMatchExpectedTestCasesComplex))] - public void WriteMapAsYamlShouldMatchExpected(Dictionary inputMap, string expectedYaml) + public void WriteMapAsYamlShouldMatchExpected(OrderedDictionary inputMap, string expectedYaml) { // Arrange var outputString = new StringWriter(CultureInfo.InvariantCulture);