@@ -55,7 +55,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
5555 if ( options . Output == null )
5656 {
5757#pragma warning disable CA1308 // Normalize strings to uppercase
58- var extension = options . OpenApiFormat ? . GetDisplayName ( ) . ToLowerInvariant ( ) ;
58+ var extension = options . OpenApiFormat ? . ToLowerInvariant ( ) ;
5959 var inputExtension = ! string . IsNullOrEmpty ( extension ) ? string . Concat ( "." , extension )
6060 : GetInputPathExtension ( options . OpenApi , options . Csdl ) ;
6161
@@ -73,7 +73,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
7373 }
7474
7575 // Default to yaml and OpenApiVersion 3_1 during csdl to OpenApi conversion
76- var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiFormat . Yaml ) ;
76+ var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiConstants . Yaml ) ;
7777 var openApiVersion = options . Version != null ? TryParseOpenApiSpecVersion ( options . Version ) : OpenApiSpecVersion . OpenApi3_1 ;
7878
7979 // If ApiManifest is provided, set the referenced OpenAPI document
@@ -92,7 +92,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
9292 }
9393
9494 // Load OpenAPI document
95- var document = await GetOpenApiAsync ( options , openApiFormat . GetDisplayName ( ) , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
95+ var document = await GetOpenApiAsync ( options , openApiFormat , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
9696
9797 if ( options . FilterOptions != null && document is not null )
9898 {
@@ -189,7 +189,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger,
189189 return document ;
190190 }
191191
192- private static async Task WriteOpenApiAsync ( HidiOptions options , OpenApiFormat openApiFormat , OpenApiSpecVersion openApiVersion , OpenApiDocument document , ILogger logger , CancellationToken cancellationToken )
192+ private static async Task WriteOpenApiAsync ( HidiOptions options , string openApiFormat , OpenApiSpecVersion openApiVersion , OpenApiDocument document , ILogger logger , CancellationToken cancellationToken )
193193 {
194194 using ( logger . BeginScope ( "Output" ) )
195195 {
@@ -205,8 +205,8 @@ private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat o
205205
206206 IOpenApiWriter writer = openApiFormat switch
207207 {
208- OpenApiFormat . Json => options . TerseOutput ? new ( textWriter , settings , options . TerseOutput ) : new OpenApiJsonWriter ( textWriter , settings , false ) ,
209- OpenApiFormat . Yaml => new OpenApiYamlWriter ( textWriter , settings ) ,
208+ OpenApiConstants . Json => options . TerseOutput ? new ( textWriter , settings , options . TerseOutput ) : new OpenApiJsonWriter ( textWriter , settings , false ) ,
209+ OpenApiConstants . Yaml => new OpenApiYamlWriter ( textWriter , settings ) ,
210210 _ => throw new ArgumentException ( "Unknown format" ) ,
211211 } ;
212212
@@ -560,10 +560,10 @@ SecurityException or
560560 /// <param name="input"></param>
561561 /// <param name="logger"></param>
562562 /// <returns></returns>
563- private static OpenApiFormat GetOpenApiFormat ( string input , ILogger logger )
563+ private static string GetOpenApiFormat ( string input , ILogger logger )
564564 {
565565 logger . LogTrace ( "Getting the OpenApi format" ) ;
566- return ! input . StartsWith ( "http" , StringComparison . OrdinalIgnoreCase ) && Path . GetExtension ( input ) == ".json" ? OpenApiFormat . Json : OpenApiFormat . Yaml ;
566+ return ! input . StartsWith ( "http" , StringComparison . OrdinalIgnoreCase ) && Path . GetExtension ( input ) == ".json" ? OpenApiConstants . Json : OpenApiConstants . Yaml ;
567567 }
568568
569569 private static string GetInputPathExtension ( string ? openapi = null , string ? csdl = null )
@@ -590,8 +590,8 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl
590590 throw new ArgumentException ( "Please input a file path or URL" ) ;
591591 }
592592
593- var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiFormat . Yaml ) ;
594- var document = await GetOpenApiAsync ( options , openApiFormat . GetDisplayName ( ) , logger , null , cancellationToken ) . ConfigureAwait ( false ) ;
593+ var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiConstants . Yaml ) ;
594+ var document = await GetOpenApiAsync ( options , openApiFormat , logger , null , cancellationToken ) . ConfigureAwait ( false ) ;
595595 if ( document is not null )
596596 {
597597 using ( logger . BeginScope ( "Creating diagram" ) )
@@ -754,10 +754,10 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
754754 }
755755
756756 var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi )
757- ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiFormat . Yaml ) ;
757+ ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiConstants . Yaml ) ;
758758
759759 // Load OpenAPI document
760- var document = await GetOpenApiAsync ( options , openApiFormat . GetDisplayName ( ) , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
760+ var document = await GetOpenApiAsync ( options , openApiFormat , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
761761
762762 cancellationToken . ThrowIfCancellationRequested ( ) ;
763763
@@ -777,7 +777,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
777777 options . TerseOutput = true ;
778778 if ( document is not null )
779779 {
780- await WriteOpenApiAsync ( options , OpenApiFormat . Json , OpenApiSpecVersion . OpenApi3_1 , document , logger , cancellationToken ) . ConfigureAwait ( false ) ;
780+ await WriteOpenApiAsync ( options , OpenApiConstants . Json , OpenApiSpecVersion . OpenApi3_1 , document , logger , cancellationToken ) . ConfigureAwait ( false ) ;
781781
782782 // Create OpenAIPluginManifest from ApiDependency and OpenAPI document
783783 var manifest = new OpenAIPluginManifest ( document . Info . Title ?? "Title" ,
0 commit comments