@@ -53,7 +53,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l
53
53
if ( options . Output == null )
54
54
{
55
55
var inputExtension = GetInputPathExtension ( options . OpenApi , options . Csdl ) ;
56
- options . Output = new FileInfo ( $ "./output{ inputExtension } ") ;
56
+ options . Output = new ( $ "./output{ inputExtension } ") ;
57
57
} ;
58
58
59
59
if ( options . CleanOutput && options . Output . Exists )
@@ -66,8 +66,8 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l
66
66
}
67
67
68
68
// Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion
69
- OpenApiFormat openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiFormat . Yaml ) ;
70
- OpenApiSpecVersion openApiVersion = options . Version != null ? TryParseOpenApiSpecVersion ( options . Version ) : OpenApiSpecVersion . OpenApi3_0 ;
69
+ var openApiFormat = options . OpenApiFormat ?? ( ! string . IsNullOrEmpty ( options . OpenApi ) ? GetOpenApiFormat ( options . OpenApi , logger ) : OpenApiFormat . Yaml ) ;
70
+ var openApiVersion = options . Version != null ? TryParseOpenApiSpecVersion ( options . Version ) : OpenApiSpecVersion . OpenApi3_0 ;
71
71
72
72
// If ApiManifest is provided, set the referenced OpenAPI document
73
73
var apiDependency = await FindApiDependency ( options . FilterOptions . FilterByApiManifest , logger , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -85,7 +85,7 @@ public static async Task TransformOpenApiDocument(HidiOptions options, ILogger l
85
85
}
86
86
87
87
// Load OpenAPI document
88
- OpenApiDocument document = await GetOpenApi ( options , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
88
+ var document = await GetOpenApi ( options , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
89
89
90
90
if ( options . FilterOptions != null )
91
91
{
@@ -194,7 +194,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma
194
194
195
195
IOpenApiWriter writer = openApiFormat switch
196
196
{
197
- OpenApiFormat . Json => options . TerseOutput ? new OpenApiJsonWriter ( textWriter , settings , options . TerseOutput ) : new OpenApiJsonWriter ( textWriter , settings , false ) ,
197
+ OpenApiFormat . Json => options . TerseOutput ? new ( textWriter , settings , options . TerseOutput ) : new OpenApiJsonWriter ( textWriter , settings , false ) ,
198
198
OpenApiFormat . Yaml => new OpenApiYamlWriter ( textWriter , settings ) ,
199
199
_ => throw new ArgumentException ( "Unknown format" ) ,
200
200
} ;
@@ -227,7 +227,7 @@ private static async Task<OpenApiDocument> GetOpenApi(HidiOptions options, ILogg
227
227
Stream ? filteredStream = null ;
228
228
if ( ! string . IsNullOrEmpty ( options . CsdlFilter ) )
229
229
{
230
- XslCompiledTransform transform = GetFilterTransform ( ) ;
230
+ var transform = GetFilterTransform ( ) ;
231
231
filteredStream = ApplyFilterToCsdl ( stream , options . CsdlFilter , transform ) ;
232
232
filteredStream . Position = 0 ;
233
233
await stream . DisposeAsync ( ) . ConfigureAwait ( false ) ;
@@ -299,7 +299,7 @@ private static Dictionary<string, List<string>> GetRequestUrlsFromManifest(ApiDe
299
299
private static XslCompiledTransform GetFilterTransform ( )
300
300
{
301
301
XslCompiledTransform transform = new ( ) ;
302
- Assembly assembly = typeof ( OpenApiService ) . GetTypeInfo ( ) . Assembly ;
302
+ var assembly = typeof ( OpenApiService ) . GetTypeInfo ( ) . Assembly ;
303
303
using var xslt = assembly . GetManifestResourceStream ( "Microsoft.OpenApi.Hidi.CsdlFilter.xslt" ) ?? throw new InvalidOperationException ( "Could not find the Microsoft.OpenApi.Hidi.CsdlFilter.xslt file in the assembly. Check build configuration." ) ;
304
304
using var streamReader = new StreamReader ( xslt ) ;
305
305
using var textReader = new XmlTextReader ( streamReader ) ;
@@ -310,7 +310,7 @@ private static XslCompiledTransform GetFilterTransform()
310
310
private static Stream ApplyFilterToCsdl ( Stream csdlStream , string entitySetOrSingleton , XslCompiledTransform transform )
311
311
{
312
312
using StreamReader inputReader = new ( csdlStream , leaveOpen : true ) ;
313
- using XmlReader inputXmlReader = XmlReader . Create ( inputReader ) ;
313
+ using var inputXmlReader = XmlReader . Create ( inputReader ) ;
314
314
MemoryStream filteredStream = new ( ) ;
315
315
using StreamWriter writer = new ( filteredStream , leaveOpen : true ) ;
316
316
XsltArgumentList args = new ( ) ;
@@ -363,16 +363,16 @@ public static async Task ValidateOpenApiDocument(
363
363
private static async Task < ReadResult > ParseOpenApi ( string openApiFile , bool inlineExternal , ILogger logger , Stream stream , CancellationToken cancellationToken = default )
364
364
{
365
365
ReadResult result ;
366
- Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
366
+ var stopwatch = Stopwatch . StartNew ( ) ;
367
367
using ( logger . BeginScope ( "Parsing OpenAPI: {OpenApiFile}" , openApiFile ) )
368
368
{
369
369
stopwatch . Start ( ) ;
370
370
371
- result = await new OpenApiStreamReader ( new OpenApiReaderSettings
372
- {
371
+ result = await new OpenApiStreamReader ( new ( )
372
+ {
373
373
LoadExternalRefs = inlineExternal ,
374
374
BaseUrl = openApiFile . StartsWith ( "http" , StringComparison . OrdinalIgnoreCase ) ?
375
- new Uri ( openApiFile ) :
375
+ new ( openApiFile ) :
376
376
new Uri ( "file://" + new FileInfo ( openApiFile ) . DirectoryName + Path . DirectorySeparatorChar )
377
377
}
378
378
) . ReadAsync ( stream , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -398,7 +398,7 @@ public static async Task<OpenApiDocument> ConvertCsdlToOpenApi(Stream csdl, stri
398
398
var edmModel = CsdlReader . Parse ( XElement . Parse ( csdlText ) . CreateReader ( ) ) ;
399
399
settings ??= SettingsUtilities . GetConfiguration ( ) ;
400
400
401
- OpenApiDocument document = edmModel . ConvertToOpenApi ( SettingsUtilities . GetOpenApiConvertSettings ( settings , metadataVersion ) ) ;
401
+ var document = edmModel . ConvertToOpenApi ( SettingsUtilities . GetOpenApiConvertSettings ( settings , metadataVersion ) ) ;
402
402
document = FixReferences ( document ) ;
403
403
404
404
return document ;
@@ -459,7 +459,7 @@ private static Dictionary<string, List<string>> EnumerateJsonDocument(JsonElemen
459
459
}
460
460
else
461
461
{
462
- paths . Add ( path , new List < string > { method } ) ;
462
+ paths . Add ( path , new ( ) { method } ) ;
463
463
}
464
464
}
465
465
else
@@ -725,7 +725,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C
725
725
}
726
726
727
727
// Load OpenAPI document
728
- OpenApiDocument document = await GetOpenApi ( options , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
728
+ var document = await GetOpenApi ( options , logger , options . MetadataVersion , cancellationToken ) . ConfigureAwait ( false ) ;
729
729
730
730
cancellationToken . ThrowIfCancellationRequested ( ) ;
731
731
@@ -741,7 +741,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C
741
741
outputFolder . Create ( ) ;
742
742
}
743
743
// Write OpenAPI to Output folder
744
- options . Output = new FileInfo ( Path . Combine ( options . OutputFolder , "openapi.json" ) ) ;
744
+ options . Output = new ( Path . Combine ( options . OutputFolder , "openapi.json" ) ) ;
745
745
options . TerseOutput = true ;
746
746
WriteOpenApi ( options , OpenApiFormat . Json , OpenApiSpecVersion . OpenApi3_0 , document , logger ) ;
747
747
@@ -762,7 +762,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C
762
762
// Write OpenAIPluginManifest to Output folder
763
763
var manifestFile = new FileInfo ( Path . Combine ( options . OutputFolder , "ai-plugin.json" ) ) ;
764
764
using var file = new FileStream ( manifestFile . FullName , FileMode . Create ) ;
765
- using var jsonWriter = new Utf8JsonWriter ( file , new JsonWriterOptions { Indented = true } ) ;
765
+ using var jsonWriter = new Utf8JsonWriter ( file , new ( ) { Indented = true } ) ;
766
766
manifest . Write ( jsonWriter ) ;
767
767
await jsonWriter . FlushAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
768
768
}
0 commit comments