@@ -537,4 +537,59 @@ await VerifyOpenApiDocument(builder, document =>
537537 Assert . Null ( operation . RequestBody . Content [ "application/json" ] . Schema . Type ) ;
538538 } ) ;
539539 }
540+
541+ [ Theory ]
542+ [ InlineData ( false ) ]
543+ [ InlineData ( true ) ]
544+ public async Task SupportsParameterWithEnumType ( bool useAction )
545+ {
546+ // Arrange
547+ if ( ! useAction )
548+ {
549+ var builder = CreateBuilder ( ) ;
550+ builder . MapGet ( "/api/with-enum" , ( ItemStatus status ) => status ) ;
551+ }
552+ else
553+ {
554+ var action = CreateActionDescriptor ( nameof ( GetItemStatus ) ) ;
555+ await VerifyOpenApiDocument ( action , AssertOpenApiDocument ) ;
556+ }
557+
558+ static void AssertOpenApiDocument ( OpenApiDocument document )
559+ {
560+ var operation = document . Paths [ "/api/with-enum" ] . Operations [ OperationType . Get ] ;
561+ var parameter = Assert . Single ( operation . Parameters ) ;
562+ var response = Assert . Single ( operation . Responses ) . Value . Content [ "application/json" ] . Schema ;
563+ Assert . NotNull ( parameter . Schema . Reference ) ;
564+ Assert . Equal ( parameter . Schema . Reference . Id , response . Reference . Id ) ;
565+ var schema = parameter . Schema . GetEffective ( document ) ;
566+ Assert . Collection ( schema . Enum ,
567+ value =>
568+ {
569+ var openApiString = Assert . IsType < OpenApiString > ( value ) ;
570+ Assert . Equal ( "Pending" , openApiString . Value ) ;
571+ } ,
572+ value =>
573+ {
574+ var openApiString = Assert . IsType < OpenApiString > ( value ) ;
575+ Assert . Equal ( "Approved" , openApiString . Value ) ;
576+ } ,
577+ value =>
578+ {
579+ var openApiString = Assert . IsType < OpenApiString > ( value ) ;
580+ Assert . Equal ( "Rejected" , openApiString . Value ) ;
581+ } ) ;
582+ }
583+ }
584+
585+ [ Route ( "/api/with-enum" ) ]
586+ private ItemStatus GetItemStatus ( [ FromQuery ] ItemStatus status ) => status ;
587+
588+ [ JsonConverter ( typeof ( JsonStringEnumConverter < ItemStatus > ) ) ]
589+ internal enum ItemStatus
590+ {
591+ Pending = 0 ,
592+ Approved = 1 ,
593+ Rejected = 2 ,
594+ }
540595}
0 commit comments