Skip to content

Commit 7fc0c4d

Browse files
committed
Add call to encodeToQueryString only once per request
1 parent bd2fbee commit 7fc0c4d

36 files changed

Lines changed: 536 additions & 536 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"{{baseName}}": {{#isQueryParam}}(wrappedValue: {{/isQueryParam}}{{paramName}}{{^required}}?{{/required}}.encodeToQueryString(codableHelper: apiConfiguration.codableHelper){{#isQueryParam}}, isExplode: {{isExplode}}){{/isQueryParam}}
1+
"{{baseName}}": {{#isQueryParam}}(wrappedValue: {{/isQueryParam}}{{paramName}}{{#isQueryParam}}, isExplode: {{isExplode}}){{/isQueryParam}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ extension {{projectName}}API {
301301
{{/formParams}}
302302
]
303303

304-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
304+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
305305
{{/hasFormParams}}
306306
{{^hasFormParams}}
307307
let localVariableParameters: [String: any Sendable]? = nil

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/APIs/FakeAPI.swift

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ open class FakeAPI {
257257

258258
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
259259
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
260-
"query": (wrappedValue: query.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
260+
"query": (wrappedValue: query, isExplode: false),
261261
])
262262

263263
let localVariableNillableHeaders: [String: (any Sendable)?] = [
@@ -376,23 +376,23 @@ open class FakeAPI {
376376
let localVariablePath = "/fake"
377377
let localVariableURLString = apiConfiguration.basePath + localVariablePath
378378
let localVariableFormParams: [String: (any Sendable)?] = [
379-
"integer": integer?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
380-
"int32": int32?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
381-
"int64": int64?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
382-
"number": number.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
383-
"float": float?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
384-
"double": double.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
385-
"string": string?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
386-
"pattern_without_delimiter": patternWithoutDelimiter.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
387-
"byte": byte.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
388-
"binary": binary?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
389-
"date": date?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
390-
"dateTime": dateTime?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
391-
"password": password?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
392-
"callback": callback?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
379+
"integer": integer,
380+
"int32": int32,
381+
"int64": int64,
382+
"number": number,
383+
"float": float,
384+
"double": double,
385+
"string": string,
386+
"pattern_without_delimiter": patternWithoutDelimiter,
387+
"byte": byte,
388+
"binary": binary,
389+
"date": date,
390+
"dateTime": dateTime,
391+
"password": password,
392+
"callback": callback,
393393
]
394394

395-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
395+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
396396

397397
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
398398

@@ -519,24 +519,24 @@ open class FakeAPI {
519519
let localVariablePath = "/fake"
520520
let localVariableURLString = apiConfiguration.basePath + localVariablePath
521521
let localVariableFormParams: [String: (any Sendable)?] = [
522-
"enum_form_string_array": enumFormStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
523-
"enum_form_string": enumFormString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
522+
"enum_form_string_array": enumFormStringArray,
523+
"enum_form_string": enumFormString,
524524
]
525525

526-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
526+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
527527

528528
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
529529
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
530-
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
531-
"enum_query_string": (wrappedValue: enumQueryString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
532-
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
533-
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
530+
"enum_query_string_array": (wrappedValue: enumQueryStringArray, isExplode: false),
531+
"enum_query_string": (wrappedValue: enumQueryString, isExplode: false),
532+
"enum_query_integer": (wrappedValue: enumQueryInteger, isExplode: false),
533+
"enum_query_double": (wrappedValue: enumQueryDouble, isExplode: false),
534534
])
535535

536536
let localVariableNillableHeaders: [String: (any Sendable)?] = [
537537
"Content-Type": "application/x-www-form-urlencoded",
538-
"enum_header_string_array": enumHeaderStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
539-
"enum_header_string": enumHeaderString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
538+
"enum_header_string_array": enumHeaderStringArray,
539+
"enum_header_string": enumHeaderString,
540540
]
541541

542542
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
@@ -590,15 +590,15 @@ open class FakeAPI {
590590

591591
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
592592
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
593-
"required_string_group": (wrappedValue: requiredStringGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
594-
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
595-
"string_group": (wrappedValue: stringGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
596-
"int64_group": (wrappedValue: int64Group?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
593+
"required_string_group": (wrappedValue: requiredStringGroup, isExplode: false),
594+
"required_int64_group": (wrappedValue: requiredInt64Group, isExplode: false),
595+
"string_group": (wrappedValue: stringGroup, isExplode: false),
596+
"int64_group": (wrappedValue: int64Group, isExplode: false),
597597
])
598598

599599
let localVariableNillableHeaders: [String: (any Sendable)?] = [
600-
"required_boolean_group": requiredBooleanGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
601-
"boolean_group": booleanGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
600+
"required_boolean_group": requiredBooleanGroup,
601+
"boolean_group": booleanGroup,
602602
]
603603

604604
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
@@ -684,11 +684,11 @@ open class FakeAPI {
684684
let localVariablePath = "/fake/jsonFormData"
685685
let localVariableURLString = apiConfiguration.basePath + localVariablePath
686686
let localVariableFormParams: [String: (any Sendable)?] = [
687-
"param": param.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
688-
"param2": param2.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
687+
"param": param,
688+
"param2": param2,
689689
]
690690

691-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
691+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
692692

693693
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
694694

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/APIs/PetAPI.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ open class PetAPI {
101101
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
102102

103103
let localVariableNillableHeaders: [String: (any Sendable)?] = [
104-
"api_key": apiKey?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
104+
"api_key": apiKey,
105105
]
106106

107107
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
@@ -157,7 +157,7 @@ open class PetAPI {
157157

158158
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
159159
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
160-
"status": (wrappedValue: status.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
160+
"status": (wrappedValue: status, isExplode: false),
161161
])
162162

163163
let localVariableNillableHeaders: [String: (any Sendable)?] = [
@@ -210,7 +210,7 @@ open class PetAPI {
210210

211211
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
212212
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
213-
"tags": (wrappedValue: tags.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
213+
"tags": (wrappedValue: tags, isExplode: false),
214214
])
215215

216216
let localVariableNillableHeaders: [String: (any Sendable)?] = [
@@ -362,11 +362,11 @@ open class PetAPI {
362362
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
363363
let localVariableURLString = apiConfiguration.basePath + localVariablePath
364364
let localVariableFormParams: [String: (any Sendable)?] = [
365-
"name": name?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
366-
"status": status?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
365+
"name": name,
366+
"status": status,
367367
]
368368

369-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
369+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
370370

371371
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
372372

@@ -421,11 +421,11 @@ open class PetAPI {
421421
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
422422
let localVariableURLString = apiConfiguration.basePath + localVariablePath
423423
let localVariableFormParams: [String: (any Sendable)?] = [
424-
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
425-
"file": file?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
424+
"additionalMetadata": additionalMetadata,
425+
"file": file,
426426
]
427427

428-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
428+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
429429

430430
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
431431

@@ -480,11 +480,11 @@ open class PetAPI {
480480
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
481481
let localVariableURLString = apiConfiguration.basePath + localVariablePath
482482
let localVariableFormParams: [String: (any Sendable)?] = [
483-
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
484-
"requiredFile": requiredFile.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
483+
"additionalMetadata": additionalMetadata,
484+
"requiredFile": requiredFile,
485485
]
486486

487-
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)
487+
let localVariableParameters = APIHelper.rejectNil(localVariableFormParams)?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper)
488488

489489
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
490490

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/APIs/UserAPI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ open class UserAPI {
273273

274274
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
275275
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
276-
"username": (wrappedValue: username.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
277-
"password": (wrappedValue: password.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
276+
"username": (wrappedValue: username, isExplode: false),
277+
"password": (wrappedValue: password, isExplode: false),
278278
])
279279

280280
let localVariableNillableHeaders: [String: (any Sendable)?] = [

0 commit comments

Comments
 (0)