@@ -149,7 +149,7 @@ static void SortSchema(IOpenApiSchema schema)
149
149
{
150
150
if ( concrete . Required is { Count : > 1 } required )
151
151
{
152
- concrete . Required = new SortedSet < string > ( required ) ;
152
+ concrete . Required = [ .. new SortedSet < string > ( required ) ] ;
153
153
}
154
154
155
155
if ( concrete . AllOf is { Count : > 0 } allOf )
@@ -241,7 +241,7 @@ private async Task<OpenApiPaths> GeneratePathsAsync(
241
241
OpenApiDocument document ,
242
242
IEnumerable < ApiDescription > apiDescriptions ,
243
243
SchemaRepository schemaRepository ,
244
- Func < OpenApiDocument , IGrouping < string , ApiDescription > , SchemaRepository , Task < Dictionary < OperationType , OpenApiOperation > > > operationsGenerator )
244
+ Func < OpenApiDocument , IGrouping < string , ApiDescription > , SchemaRepository , Task < Dictionary < HttpMethod , OpenApiOperation > > > operationsGenerator )
245
245
{
246
246
var apiDescriptionsByPath = apiDescriptions
247
247
. OrderBy ( _options . SortKeySelector )
@@ -285,7 +285,7 @@ private async Task<OpenApiPaths> GeneratePathsAsync(
285
285
GenerateOperationsAsync ) ;
286
286
}
287
287
288
- private IEnumerable < ( OperationType , ApiDescription ) > GetOperationsGroupedByMethod (
288
+ private IEnumerable < ( HttpMethod , ApiDescription ) > GetOperationsGroupedByMethod (
289
289
IEnumerable < ApiDescription > apiDescriptions )
290
290
{
291
291
return apiDescriptions
@@ -294,13 +294,13 @@ private async Task<OpenApiPaths> GeneratePathsAsync(
294
294
. Select ( PrepareGenerateOperation ) ;
295
295
}
296
296
297
- private Dictionary < OperationType , OpenApiOperation > GenerateOperations (
297
+ private Dictionary < HttpMethod , OpenApiOperation > GenerateOperations (
298
298
OpenApiDocument document ,
299
299
IEnumerable < ApiDescription > apiDescriptions ,
300
300
SchemaRepository schemaRepository )
301
301
{
302
302
var apiDescriptionsByMethod = GetOperationsGroupedByMethod ( apiDescriptions ) ;
303
- var operations = new Dictionary < OperationType , OpenApiOperation > ( ) ;
303
+ var operations = new Dictionary < HttpMethod , OpenApiOperation > ( ) ;
304
304
305
305
foreach ( ( var operationType , var description ) in apiDescriptionsByMethod )
306
306
{
@@ -310,13 +310,13 @@ private Dictionary<OperationType, OpenApiOperation> GenerateOperations(
310
310
return operations ;
311
311
}
312
312
313
- private async Task < Dictionary < OperationType , OpenApiOperation > > GenerateOperationsAsync (
313
+ private async Task < Dictionary < HttpMethod , OpenApiOperation > > GenerateOperationsAsync (
314
314
OpenApiDocument document ,
315
315
IEnumerable < ApiDescription > apiDescriptions ,
316
316
SchemaRepository schemaRepository )
317
317
{
318
318
var apiDescriptionsByMethod = GetOperationsGroupedByMethod ( apiDescriptions ) ;
319
- var operations = new Dictionary < OperationType , OpenApiOperation > ( ) ;
319
+ var operations = new Dictionary < HttpMethod , OpenApiOperation > ( ) ;
320
320
321
321
foreach ( ( var operationType , var description ) in apiDescriptionsByMethod )
322
322
{
@@ -326,7 +326,7 @@ private async Task<Dictionary<OperationType, OpenApiOperation>> GenerateOperatio
326
326
return operations ;
327
327
}
328
328
329
- private ( OperationType OperationType , ApiDescription ApiDescription ) PrepareGenerateOperation ( IGrouping < string , ApiDescription > group )
329
+ private ( HttpMethod OperationType , ApiDescription ApiDescription ) PrepareGenerateOperation ( IGrouping < string , ApiDescription > group )
330
330
{
331
331
var httpMethod = group . Key ?? throw new SwaggerGeneratorException ( string . Format (
332
332
"Ambiguous HTTP method for action - {0}. " +
@@ -583,7 +583,7 @@ private HashSet<OpenApiTagReference> GenerateOperationTags(OpenApiDocument docum
583
583
584
584
if ( names . Length > 0 )
585
585
{
586
- document . Tags ??= new HashSet < OpenApiTag > ( ) ;
586
+ document . Tags ??= [ ] ;
587
587
foreach ( var name in names )
588
588
{
589
589
document . Tags . Add ( new OpenApiTag { Name = name } ) ;
@@ -1025,7 +1025,7 @@ static OpenApiSchema GenerateSchemaForProperties(Dictionary<string, IOpenApiSche
1025
1025
{
1026
1026
Type = JsonSchemaTypes . Object ,
1027
1027
Properties = properties ,
1028
- Required = new SortedSet < string > ( requiredPropertyNames )
1028
+ Required = [ .. new SortedSet < string > ( requiredPropertyNames ) ] ,
1029
1029
} ;
1030
1030
}
1031
1031
@@ -1108,16 +1108,18 @@ private static bool IsFromFormAttributeUsedWithIFormFile(ApiParameterDescription
1108
1108
return fromFormAttribute != null && parameterInfo ? . ParameterType == typeof ( IFormFile ) ;
1109
1109
}
1110
1110
1111
- private static readonly Dictionary < string , OperationType > OperationTypeMap = new ( StringComparer . OrdinalIgnoreCase )
1111
+ private static readonly Dictionary < string , HttpMethod > OperationTypeMap = new ( StringComparer . OrdinalIgnoreCase )
1112
1112
{
1113
- [ "GET" ] = OperationType . Get ,
1114
- [ "PUT" ] = OperationType . Put ,
1115
- [ "POST" ] = OperationType . Post ,
1116
- [ "DELETE" ] = OperationType . Delete ,
1117
- [ "OPTIONS" ] = OperationType . Options ,
1118
- [ "HEAD" ] = OperationType . Head ,
1119
- [ "PATCH" ] = OperationType . Patch ,
1120
- [ "TRACE" ] = OperationType . Trace ,
1113
+ [ "GET" ] = HttpMethod . Get ,
1114
+ [ "PUT" ] = HttpMethod . Put ,
1115
+ [ "POST" ] = HttpMethod . Post ,
1116
+ [ "DELETE" ] = HttpMethod . Delete ,
1117
+ [ "OPTIONS" ] = HttpMethod . Options ,
1118
+ [ "HEAD" ] = HttpMethod . Head ,
1119
+ #if NET
1120
+ [ "PATCH" ] = HttpMethod . Patch ,
1121
+ #endif
1122
+ [ "TRACE" ] = HttpMethod . Trace ,
1121
1123
} ;
1122
1124
1123
1125
private static readonly Dictionary < BindingSource , ParameterLocation > ParameterLocationMap = new ( )
0 commit comments