@@ -245,6 +245,16 @@ private List<MemberDeclarationSyntax> CreateMethods(string className)
245
245
{
246
246
methodDeclaration = CreateTypeRequestObjectResult ( className , httpStatusCode . ToNormalizedString ( ) , schema . GetDataType ( ) , "response" , isList , isPagination ) ;
247
247
}
248
+ else if ( schema != null && string . Equals ( schema . Type , OpenApiDataTypeConstants . Array , StringComparison . Ordinal ) )
249
+ {
250
+ methodDeclaration = CreateTypeRequestObjectResult (
251
+ className ,
252
+ httpStatusCode . ToNormalizedString ( ) ,
253
+ schema . Items . GetDataType ( ) ,
254
+ "response" ,
255
+ isList ,
256
+ isPagination ) ;
257
+ }
248
258
else
249
259
{
250
260
methodDeclaration = CreateTypeRequestWithMessageAllowNull ( className , httpStatusCode , nameof ( OkObjectResult ) ) ;
@@ -558,9 +568,13 @@ private static MethodDeclarationSyntax CreateTypeRequestObjectResult(
558
568
bool asGenericPagination = false )
559
569
{
560
570
string ? genericListTypeName = null ;
571
+ string objectResultParameter = asGenericList
572
+ ? parameterName + $ " ?? Enumerable.Empty<{ parameterTypeName } >()"
573
+ : parameterName ;
574
+
561
575
if ( asGenericList )
562
576
{
563
- genericListTypeName = Microsoft . OpenApi . Models . NameConstants . List ;
577
+ genericListTypeName = NameConstants . AbstractCollectionTypeName ;
564
578
}
565
579
else if ( asGenericPagination )
566
580
{
@@ -585,7 +599,7 @@ private static MethodDeclarationSyntax CreateTypeRequestObjectResult(
585
599
SyntaxFactory . SingletonSeparatedList (
586
600
SyntaxFactory . Argument (
587
601
SyntaxObjectCreationExpressionFactory . Create ( methodName + nameof ( ObjectResult ) )
588
- . WithArgumentList ( SyntaxArgumentListFactory . CreateWithOneItem ( parameterName ) ) ) ) ) ) ) )
602
+ . WithArgumentList ( SyntaxArgumentListFactory . CreateWithOneItem ( objectResultParameter ) ) ) ) ) ) ) )
589
603
. WithSemicolonToken ( SyntaxTokenFactory . Semicolon ( ) ) ;
590
604
}
591
605
@@ -669,10 +683,10 @@ private static ConversionOperatorDeclarationSyntax CreateImplicitOperator(
669
683
SyntaxFactory . IdentifierName ( SyntaxFactory . Identifier ( className ) ) )
670
684
. WithModifiers ( SyntaxTokenListFactory . PublicStaticKeyword ( true ) )
671
685
. WithOperatorKeyword ( SyntaxTokenFactory . OperatorKeyword ( ) )
672
- . AddParameterListParameters ( SyntaxParameterFactory . Create ( typeName , "x " , genericListTypeName ) )
686
+ . AddParameterListParameters ( SyntaxParameterFactory . Create ( typeName , "response " , genericListTypeName ) )
673
687
. WithExpressionBody ( SyntaxFactory . ArrowExpressionClause (
674
688
SyntaxFactory . InvocationExpression ( SyntaxFactory . IdentifierName ( SyntaxFactory . Identifier ( httpStatus ) ) )
675
- . AddArgumentListArguments ( SyntaxArgumentFactory . Create ( "x " ) ) )
689
+ . AddArgumentListArguments ( SyntaxArgumentFactory . Create ( "response " ) ) )
676
690
. WithArrowToken ( SyntaxTokenFactory . EqualsGreaterThan ( ) ) )
677
691
. WithSemicolonToken ( SyntaxTokenFactory . Semicolon ( ) ) ;
678
692
}
0 commit comments