Skip to content

Commit f125e10

Browse files
authored
[crystal-lang] Various fixes for Crystal client (#22465)
* [crystal] implement "multi" params See: https://github.com/mamantoha/crest?tab=readme-ov-file#crestnestedparamsencoder * [crystal] remove useless templates (imported from ruby)
1 parent 9a6f14a commit f125e10

File tree

13 files changed

+28
-150
lines changed

13 files changed

+28
-150
lines changed

modules/openapi-generator/src/main/resources/crystal/Gemfile.mustache

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/crystal/Rakefile.mustache

Lines changed: 0 additions & 10 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/crystal/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module {{moduleName}}
131131
cookie_params = Hash(String, String).new
132132

133133
# query parameters
134-
query_params = Hash(String, String).new
134+
query_params = Hash(String, String | Array(String)).new
135135
{{#queryParams}}
136136
query_params["{{{baseName}}}"] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}) unless {{{paramName}}}.nil?{{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.to_s unless {{{paramName}}}.nil?{{/collectionFormat}}
137137
{{/queryParams}}

modules/openapi-generator/src/main/resources/crystal/api_client.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ module {{moduleName}}
109109
when :pipes
110110
param.join("|")
111111
when :multi
112-
# TODO: Need to fix this
113-
raise "multi is not supported yet"
112+
param
114113
else
115114
raise "unknown collection format: #{collection_format.inspect}"
116115
end
@@ -147,7 +146,8 @@ module {{moduleName}}
147146
cookies: cookie_params,
148147
form: form_or_body,
149148
logging: @config.debugging,
150-
handle_errors: false
149+
handle_errors: false,
150+
params_encoder: Crest::NestedParamsEncoder
151151
)
152152

153153
response = request.execute

modules/openapi-generator/src/main/resources/crystal/configuration_spec.mustache

Lines changed: 0 additions & 35 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/crystal/configuration_tls_faraday_partial.mustache

Lines changed: 0 additions & 29 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/crystal/configuration_tls_typhoeus_partial.mustache

Lines changed: 0 additions & 34 deletions
This file was deleted.

modules/openapi-generator/src/main/resources/crystal/version.mustache

Lines changed: 0 additions & 5 deletions
This file was deleted.

samples/client/petstore/crystal/src/petstore/api/fake_api.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module Petstore
6767
cookie_params = Hash(String, String).new
6868

6969
# query parameters
70-
query_params = Hash(String, String).new
70+
query_params = Hash(String, String | Array(String)).new
7171
query_params["type"] = _type.to_s unless _type.nil?
7272
query_params["http_debug_option"] = http_debug_option.to_s unless http_debug_option.nil?
7373

samples/client/petstore/crystal/src/petstore/api/pet_api.cr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module Petstore
4545
cookie_params = Hash(String, String).new
4646

4747
# query parameters
48-
query_params = Hash(String, String).new
48+
query_params = Hash(String, String | Array(String)).new
4949

5050
# header parameters
5151
header_params = Hash(String, String).new
@@ -110,7 +110,7 @@ module Petstore
110110
cookie_params = Hash(String, String).new
111111

112112
# query parameters
113-
query_params = Hash(String, String).new
113+
query_params = Hash(String, String | Array(String)).new
114114

115115
# header parameters
116116
header_params = Hash(String, String).new
@@ -172,7 +172,7 @@ module Petstore
172172
cookie_params = Hash(String, String).new
173173

174174
# query parameters
175-
query_params = Hash(String, String).new
175+
query_params = Hash(String, String | Array(String)).new
176176
query_params["status"] = @api_client.build_collection_param(status, :csv) unless status.nil?
177177

178178
# header parameters
@@ -236,7 +236,7 @@ module Petstore
236236
cookie_params = Hash(String, String).new
237237

238238
# query parameters
239-
query_params = Hash(String, String).new
239+
query_params = Hash(String, String | Array(String)).new
240240
query_params["tags"] = @api_client.build_collection_param(tags, :csv) unless tags.nil?
241241

242242
# header parameters
@@ -300,7 +300,7 @@ module Petstore
300300
cookie_params = Hash(String, String).new
301301

302302
# query parameters
303-
query_params = Hash(String, String).new
303+
query_params = Hash(String, String | Array(String)).new
304304

305305
# header parameters
306306
header_params = Hash(String, String).new
@@ -363,7 +363,7 @@ module Petstore
363363
cookie_params = Hash(String, String).new
364364

365365
# query parameters
366-
query_params = Hash(String, String).new
366+
query_params = Hash(String, String | Array(String)).new
367367

368368
# header parameters
369369
header_params = Hash(String, String).new
@@ -428,7 +428,7 @@ module Petstore
428428
cookie_params = Hash(String, String).new
429429

430430
# query parameters
431-
query_params = Hash(String, String).new
431+
query_params = Hash(String, String | Array(String)).new
432432

433433
# header parameters
434434
header_params = Hash(String, String).new
@@ -493,7 +493,7 @@ module Petstore
493493
cookie_params = Hash(String, String).new
494494

495495
# query parameters
496-
query_params = Hash(String, String).new
496+
query_params = Hash(String, String | Array(String)).new
497497

498498
# header parameters
499499
header_params = Hash(String, String).new

0 commit comments

Comments
 (0)