@@ -28,10 +28,7 @@ const basepath = "http://petstore.swagger.io/v2"
2828template constructResult [T](response: Response ): untyped =
2929 if response.code in {Http200 , Http201 , Http202 , Http204 , Http206 }:
3030 try :
31- when name (stripGenericParams (T.typedesc ).typedesc ) == name (Table ):
32- (some (json.to (parseJson (response.body), T.typedesc )), response)
33- else :
34- (some (marshal.to [T](response.body)), response)
31+ (some (to (parseJson (response.body), T)), response)
3532 except JsonParsingError :
3633 # The server returned a malformed response though the response code is 2XX
3734 # TODO : need better error handling
@@ -58,19 +55,19 @@ proc deletePet*(httpClient: HttpClient, petId: int64, apiKey: string): Response
5855
5956proc findPetsByStatus * (httpClient: HttpClient , status: seq [Status ]): (Option [seq [Pet ]], Response ) =
6057 # # Finds Pets by status
61- let url_encoded_query_params = encodeQuery ([
62- ( " status" , $ status.join (" ," )), # Status values that need to be considered for filter
63- ] )
58+ var query_params_list: seq [( string , string )] = @ []
59+ query_params_list. add (( " status" , $ status.join (" ," )))
60+ let url_encoded_query_params = encodeQuery (query_params_list )
6461
6562 let response = httpClient.get (basepath & " /pet/findByStatus" & " ?" & url_encoded_query_params)
6663 constructResult [seq [Pet ]](response)
6764
6865
6966proc findPetsByTags * (httpClient: HttpClient , tags: seq [string ]): (Option [seq [Pet ]], Response ) {.deprecated .} =
7067 # # Finds Pets by tags
71- let url_encoded_query_params = encodeQuery ([
72- ( " tags" , $ tags.join (" ," )), # Tags to filter by
73- ] )
68+ var query_params_list: seq [( string , string )] = @ []
69+ query_params_list. add (( " tags" , $ tags.join (" ," )))
70+ let url_encoded_query_params = encodeQuery (query_params_list )
7471
7572 let response = httpClient.get (basepath & " /pet/findByTags" & " ?" & url_encoded_query_params)
7673 constructResult [seq [Pet ]](response)
0 commit comments