@@ -185,6 +185,59 @@ public void Writes_Get_With_Route()
185185 . And . NotContain ( "url.searchParams.append(" ) ;
186186 }
187187
188+ [ Fact ]
189+ public void Handles_Get_With_Route_And_Query_Parameters ( )
190+ {
191+ // Arrange
192+ var apiClient = new ApiClient ( "TestClient" , "TestController" , "test" , null ) ;
193+ apiClient . AddEndpoint ( new ApiClientEndpoint ( "getLatestId" , "latest/{year}" , EndpointMethod . GET , null , typeof ( Guid ) , false ,
194+ [ new EndpointParameter ( "year" , typeof ( int ) , null , false , false , true , false , false , false , false , false ) ,
195+ new EndpointParameter ( "reverse" , typeof ( bool ? ) , null , false , false , false , true , false , false , false , true ) ] , null ) ) ;
196+
197+ // Act
198+ var result = Sut . Write ( apiClient , [ ] , _converter , true , _templateFn , Casing . Pascal ) ;
199+
200+ // Assert
201+ var file = File . ReadAllText ( result ) . Trim ( ) ;
202+ file . Should ( )
203+ . NotBeEmpty ( )
204+ . And . Contain ( "import { z } from 'zod';" )
205+ . And . Contain ( "export class TestClient {" )
206+ . And . Contain ( "public async getLatestId(year: number, reverse: boolean | undefined, cancellationToken: AbortSignal = null): Promise<string> {" )
207+ . And . Contain ( "const url = new URL(`test/latest/${year}`, window.location.origin);" )
208+ . And . Contain ( "if (!!reverse)" )
209+ . And . Contain ( "url.searchParams.append('reverse', reverse.toString());" ) ;
210+ }
211+
212+ [ Fact ]
213+ public void Handles_Enum_As_Query_Parameter ( )
214+ {
215+ // Arrange
216+ var outputTypes = new List < OutputType >
217+ {
218+ _converter . Convert ( typeof ( ReportType ) )
219+ } ;
220+
221+ var apiClient = new ApiClient ( "TestClient" , "TestController" , "test" , null ) ;
222+ apiClient . AddEndpoint ( new ApiClientEndpoint ( "getLatestId" , "latest/{year}" , EndpointMethod . GET , null , typeof ( Guid ) , false ,
223+ [ new EndpointParameter ( "year" , typeof ( int ) , null , false , false , true , false , false , false , false , false ) ,
224+ new EndpointParameter ( "reportType" , typeof ( ReportType ) , null , false , false , false , true , false , false , false , false ) ] , null ) ) ;
225+
226+ // Act
227+ var result = Sut . Write ( apiClient , outputTypes , _converter , true , _templateFn , Casing . Pascal ) ;
228+
229+ // Assert
230+ var file = File . ReadAllText ( result ) . Trim ( ) ;
231+ file . Should ( )
232+ . NotBeEmpty ( )
233+ . And . Contain ( "import { z } from 'zod';" )
234+ . And . Contain ( "export class TestClient {" )
235+ . And . Contain ( "public async getLatestId(year: number, reportType: ReportType, cancellationToken: AbortSignal = null): Promise<string> {" )
236+ . And . Contain ( "const url = new URL(`test/latest/${year}`, window.location.origin);" )
237+ . And . NotContain ( "if (!!reportType)" )
238+ . And . Contain ( "url.searchParams.append('reportType', reportType.toString());" ) ;
239+ }
240+
188241 [ Fact ]
189242 public void Unpacks_Complex_Object_To_Query ( )
190243 {
@@ -290,6 +343,12 @@ private class PaginatedRequest
290343 public int PageSize { get ; set ; }
291344 }
292345
346+ private enum ReportType
347+ {
348+ Summary = 0 ,
349+ Detailed = 1 ,
350+ }
351+
293352 private MetadataLoadContext BuildMetadataLoadContext ( )
294353 {
295354 // Get the array of runtime assemblies.
0 commit comments