@@ -155,7 +155,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
155155
156156 private static OpenApiDocument ApplyFilters ( HidiOptions options , ILogger logger , ApiDependency ? apiDependency , JsonDocument ? postmanCollection , OpenApiDocument document )
157157 {
158- Dictionary < string , List < string > > requestUrls ;
158+ OrderedDictionary < string , List < string > > requestUrls ;
159159 if ( apiDependency != null )
160160 {
161161 requestUrls = GetRequestUrlsFromManifest ( apiDependency ) ;
@@ -262,7 +262,7 @@ private static async Task WriteOpenApiAsync(HidiOptions options, string openApiF
262262 return document ;
263263 }
264264
265- private static Func < string , HttpMethod , OpenApiOperation , bool > ? FilterOpenApiDocument ( string ? filterByOperationIds , string ? filterByTags , Dictionary < string , List < string > > requestUrls , OpenApiDocument document , ILogger logger )
265+ private static Func < string , HttpMethod , OpenApiOperation , bool > ? FilterOpenApiDocument ( string ? filterByOperationIds , string ? filterByTags , OrderedDictionary < string , List < string > > requestUrls , OpenApiDocument document , ILogger logger )
266266 {
267267 Func < string , HttpMethod , OpenApiOperation , bool > ? predicate = null ;
268268
@@ -295,18 +295,18 @@ private static async Task WriteOpenApiAsync(HidiOptions options, string openApiF
295295 return predicate ;
296296 }
297297
298- private static Dictionary < string , List < string > > GetRequestUrlsFromManifest ( ApiDependency apiDependency )
298+ private static OrderedDictionary < string , List < string > > GetRequestUrlsFromManifest ( ApiDependency apiDependency )
299299 {
300300 // Get the request URLs from the API Dependencies in the API manifest
301301 var requests = apiDependency
302302 . Requests . Where ( static r => ! r . Exclude && ! string . IsNullOrEmpty ( r . UriTemplate ) && ! string . IsNullOrEmpty ( r . Method ) )
303303 . Select ( static r => new { UriTemplate = r . UriTemplate ! , Method = r . Method ! } )
304304 . GroupBy ( static r => r . UriTemplate )
305- . ToDictionary ( static g => g . Key , static g => g . Select ( static r => r . Method ) . ToList ( ) ) ;
305+ . ToOrderedDictionary ( static g => g . Key , static g => g . Select ( static r => r . Method ) . ToList ( ) ) ;
306306 // This makes the assumption that the UriTemplate in the ApiManifest matches exactly the UriTemplate in the OpenAPI document
307307 // This does not need to be the case. The URI template in the API manifest could map to a set of OpenAPI paths.
308308 // Additional logic will be required to handle this scenario. I suggest we build this into the OpenAPI.Net library at some point.
309- return requests ;
309+ return new OrderedDictionary < string , List < string > > ( requests ) ;
310310 }
311311
312312 private static XslCompiledTransform GetFilterTransform ( )
@@ -451,10 +451,10 @@ private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool
451451 /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods
452452 /// </summary>
453453 /// <param name="stream"> A file stream.</param>
454- /// <returns> A dictionary of request urls and http methods from a collection.</returns>
455- public static Dictionary < string , List < string > > ParseJsonCollectionFile ( Stream stream , ILogger logger )
454+ /// <returns> A OrderedDictionary of request urls and http methods from a collection.</returns>
455+ public static OrderedDictionary < string , List < string > > ParseJsonCollectionFile ( Stream stream , ILogger logger )
456456 {
457- var requestUrls = new Dictionary < string , List < string > > ( ) ;
457+ var requestUrls = new OrderedDictionary < string , List < string > > ( ) ;
458458
459459 logger . LogTrace ( "Parsing the json collection file into a JsonDocument" ) ;
460460 using var document = JsonDocument . Parse ( stream ) ;
@@ -466,7 +466,7 @@ public static Dictionary<string, List<string>> ParseJsonCollectionFile(Stream st
466466 return requestUrls ;
467467 }
468468
469- private static Dictionary < string , List < string > > EnumerateJsonDocument ( JsonElement itemElement , Dictionary < string , List < string > > paths )
469+ private static OrderedDictionary < string , List < string > > EnumerateJsonDocument ( JsonElement itemElement , OrderedDictionary < string , List < string > > paths )
470470 {
471471 var itemsArray = itemElement . GetProperty ( "item" ) ;
472472
@@ -476,7 +476,7 @@ private static Dictionary<string, List<string>> EnumerateJsonDocument(JsonElemen
476476 {
477477 if ( item . TryGetProperty ( "request" , out var request ) )
478478 {
479- // Fetch list of methods and urls from collection, store them in a dictionary
479+ // Fetch list of methods and urls from collection, store them in a OrderedDictionary
480480 var path = request . GetProperty ( "url" ) . GetProperty ( "raw" ) . ToString ( ) ;
481481 var method = request . GetProperty ( "method" ) . ToString ( ) ;
482482 if ( paths . TryGetValue ( path , out var value ) )
0 commit comments