forked from loafle/openapi-generator-original
[swift][client] make QueryStringEncodable return any Sendable (#21142)
* [swift][client] make QueryStringEncodable return any Sendable * [swift][client] rename QueryStringEncodable to ParameterConvertible * [swift][client] update migration docs * Revert "[swift][client] update migration docs" This reverts commit 00a490536df393c4075e3e739b2e33446f614988. * [swift][client] rename QueryStringEncodable to ParameterConvertible
This commit is contained in:
parent
44c342bddd
commit
f950ac97e8
@ -56,7 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|useBacktickEscapes|Escape reserved words using backticks (default: false)| |false|
|
|useBacktickEscapes|Escape reserved words using backticks (default: false)| |false|
|
||||||
|useClasses|Use final classes for models instead of structs (default: false)| |false|
|
|useClasses|Use final classes for models instead of structs (default: false)| |false|
|
||||||
|useCustomDateWithoutTime|Uses a custom type to decode and encode dates without time information to support OpenAPIs date format (default: false)| |false|
|
|useCustomDateWithoutTime|Uses a custom type to decode and encode dates without time information to support OpenAPIs date format (default: false)| |false|
|
||||||
|useJsonEncodable|Make models conform to JSONEncodable protocol (default: true)| |true|
|
|useParameterConvertible|Make models conform to ParameterConvertible protocol (default: true)| |true|
|
||||||
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: true).| |null|
|
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: true).| |null|
|
||||||
|validatable|Make validation rules and validator for model properties (default: true)| |true|
|
|validatable|Make validation rules and validator for model properties (default: true)| |true|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES = "generateModelAdditionalProperties";
|
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES = "generateModelAdditionalProperties";
|
||||||
public static final String HASHABLE_MODELS = "hashableModels";
|
public static final String HASHABLE_MODELS = "hashableModels";
|
||||||
public static final String IDENTIFIABLE_MODELS = "identifiableModels";
|
public static final String IDENTIFIABLE_MODELS = "identifiableModels";
|
||||||
public static final String USE_JSON_ENCODABLE = "useJsonEncodable";
|
public static final String USE_PARAMETER_CONVERTIBLE = "useParameterConvertible";
|
||||||
public static final String MAP_FILE_BINARY_TO_DATA = "mapFileBinaryToData";
|
public static final String MAP_FILE_BINARY_TO_DATA = "mapFileBinaryToData";
|
||||||
public static final String USE_CUSTOM_DATE_WITHOUT_TIME = "useCustomDateWithoutTime";
|
public static final String USE_CUSTOM_DATE_WITHOUT_TIME = "useCustomDateWithoutTime";
|
||||||
public static final String VALIDATABLE = "validatable";
|
public static final String VALIDATABLE = "validatable";
|
||||||
@ -115,7 +115,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
@Setter
|
@Setter
|
||||||
protected boolean identifiableModels = true;
|
protected boolean identifiableModels = true;
|
||||||
@Setter
|
@Setter
|
||||||
protected boolean useJsonEncodable = true;
|
protected boolean useParameterConvertible = true;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
protected boolean mapFileBinaryToData = false;
|
protected boolean mapFileBinaryToData = false;
|
||||||
@ -335,8 +335,8 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
"Make models conform to Identifiable when an id is present (default: true)")
|
"Make models conform to Identifiable when an id is present (default: true)")
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
|
|
||||||
cliOptions.add(new CliOption(USE_JSON_ENCODABLE,
|
cliOptions.add(new CliOption(USE_PARAMETER_CONVERTIBLE,
|
||||||
"Make models conform to JSONEncodable protocol (default: true)")
|
"Make models conform to ParameterConvertible protocol (default: true)")
|
||||||
.defaultValue(Boolean.TRUE.toString()));
|
.defaultValue(Boolean.TRUE.toString()));
|
||||||
|
|
||||||
cliOptions.add(new CliOption(MAP_FILE_BINARY_TO_DATA,
|
cliOptions.add(new CliOption(MAP_FILE_BINARY_TO_DATA,
|
||||||
@ -560,10 +560,10 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
additionalProperties.put(IDENTIFIABLE_MODELS, identifiableModels);
|
additionalProperties.put(IDENTIFIABLE_MODELS, identifiableModels);
|
||||||
|
|
||||||
if (additionalProperties.containsKey(USE_JSON_ENCODABLE)) {
|
if (additionalProperties.containsKey(USE_PARAMETER_CONVERTIBLE)) {
|
||||||
setUseJsonEncodable(convertPropertyToBooleanAndWriteBack(USE_JSON_ENCODABLE));
|
setUseParameterConvertible(convertPropertyToBooleanAndWriteBack(USE_PARAMETER_CONVERTIBLE));
|
||||||
}
|
}
|
||||||
additionalProperties.put(USE_JSON_ENCODABLE, useJsonEncodable);
|
additionalProperties.put(USE_PARAMETER_CONVERTIBLE, useParameterConvertible);
|
||||||
|
|
||||||
if (additionalProperties.containsKey(MAP_FILE_BINARY_TO_DATA)) {
|
if (additionalProperties.containsKey(MAP_FILE_BINARY_TO_DATA)) {
|
||||||
setMapFileBinaryToData(convertPropertyToBooleanAndWriteBack(MAP_FILE_BINARY_TO_DATA));
|
setMapFileBinaryToData(convertPropertyToBooleanAndWriteBack(MAP_FILE_BINARY_TO_DATA));
|
||||||
|
@ -11,78 +11,73 @@ import FoundationNetworking
|
|||||||
@preconcurrency import PromiseKit{{/usePromiseKit}}{{#useVapor}}
|
@preconcurrency import PromiseKit{{/usePromiseKit}}{{#useVapor}}
|
||||||
import Vapor{{/useVapor}}{{^useVapor}}
|
import Vapor{{/useVapor}}{{^useVapor}}
|
||||||
|
|
||||||
extension QueryStringEncodable {
|
extension Bool: ParameterConvertible {
|
||||||
@_disfavoredOverload
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Bool: QueryStringEncodable {
|
extension Float: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Float: QueryStringEncodable {
|
extension Int: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int: QueryStringEncodable {
|
extension Int32: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int32: QueryStringEncodable {
|
extension Int64: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int64: QueryStringEncodable {
|
extension Double: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Double: QueryStringEncodable {
|
extension Decimal: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Decimal: QueryStringEncodable {
|
extension String: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String: QueryStringEncodable {
|
extension URL: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension URL: QueryStringEncodable {
|
extension UUID: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UUID: QueryStringEncodable {
|
extension RawRepresentable where RawValue: ParameterConvertible, RawValue: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { return self.rawValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RawRepresentable where RawValue: QueryStringEncodable {
|
private func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
|
if let encodableObject = object as? ParameterConvertible {
|
||||||
}
|
return encodableObject.asParameter(codableHelper: codableHelper)
|
||||||
|
|
||||||
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
|
|
||||||
if let encodableObject = object as? QueryStringEncodable {
|
|
||||||
return encodableObject.encodeToQueryString(codableHelper: codableHelper)
|
|
||||||
} else {
|
} else {
|
||||||
return String(describing: object)
|
return object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Array {
|
extension Array where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Set {
|
extension Set where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return Array(self).encodeToQueryString(codableHelper: codableHelper)
|
return Array(self).asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Dictionary {
|
extension Dictionary where Key: Sendable, Value: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [Key: String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
var dictionary = [Key: String]()
|
var dictionary = [Key: any Sendable]()
|
||||||
for (key, value) in self {
|
for (key, value) in self {
|
||||||
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
@ -90,24 +85,24 @@ extension Dictionary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Data: QueryStringEncodable {
|
extension Data: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Date: QueryStringEncodable {
|
extension Date: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return codableHelper.dateFormatter.string(from: self)
|
return codableHelper.dateFormatter.string(from: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension QueryStringEncodable where Self: Encodable {
|
extension ParameterConvertible where Self: Encodable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
||||||
fatalError("Could not encode to json: \(self)")
|
fatalError("Could not encode to json: \(self)")
|
||||||
}
|
}
|
||||||
return data.encodeToQueryString(codableHelper: codableHelper)
|
return data.asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}{{/useVapor}}{{#generateModelAdditionalProperties}}
|
}{{/useVapor}}{{#generateModelAdditionalProperties}}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ import FoundationNetworking
|
|||||||
#endif{{#useAlamofire}}
|
#endif{{#useAlamofire}}
|
||||||
import Alamofire{{/useAlamofire}}
|
import Alamofire{{/useAlamofire}}
|
||||||
|
|
||||||
protocol QueryStringEncodable {
|
protocol ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String
|
func asParameter(codableHelper: CodableHelper) -> any Sendable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enum where the last case value can be used as a default catch-all.
|
/// An enum where the last case value can be used as a default catch-all.
|
||||||
|
@ -76,8 +76,8 @@ import Foundation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension OpenAPIDateWithoutTime: QueryStringEncodable {
|
extension OpenAPIDateWithoutTime: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate())
|
return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
"{{baseName}}": {{#isQueryParam}}(wrappedValue: {{/isQueryParam}}{{paramName}}{{^required}}?{{/required}}.encodeToQueryString(codableHelper: apiConfiguration.codableHelper){{#isQueryParam}}, isExplode: {{isExplode}}){{/isQueryParam}}
|
"{{baseName}}": {{#isQueryParam}}(wrappedValue: {{/isQueryParam}}{{paramName}}{{^required}}?{{/required}}.asParameter(codableHelper: apiConfiguration.codableHelper){{#isQueryParam}}, isExplode: {{isExplode}}){{/isQueryParam}}
|
@ -1,4 +1,4 @@
|
|||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{dataType}}, Sendable, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{^isString}}{{^isInteger}}{{^isFloat}}{{^isDouble}}{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{/isDouble}}{{/isFloat}}{{/isInteger}}{{/isString}}{{/useVapor}}, CaseIterable{{#enumUnknownDefaultCase}}{{#isInteger}}, CaseIterableDefaultsLast{{/isInteger}}{{#isFloat}}, CaseIterableDefaultsLast{{/isFloat}}{{#isDouble}}, CaseIterableDefaultsLast{{/isDouble}}{{#isString}}, CaseIterableDefaultsLast{{/isString}}{{/enumUnknownDefaultCase}} {
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{dataType}}, Sendable, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{^isString}}{{^isInteger}}{{^isFloat}}{{^isDouble}}{{#useParameterConvertible}}, ParameterConvertible{{/useParameterConvertible}}{{/isDouble}}{{/isFloat}}{{/isInteger}}{{/isString}}{{/useVapor}}, CaseIterable{{#enumUnknownDefaultCase}}{{#isInteger}}, CaseIterableDefaultsLast{{/isInteger}}{{#isFloat}}, CaseIterableDefaultsLast{{/isFloat}}{{#isDouble}}, CaseIterableDefaultsLast{{/isDouble}}{{#isString}}, CaseIterableDefaultsLast{{/isString}}{{/enumUnknownDefaultCase}} {
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
case {{{name}}} = {{{value}}}
|
case {{{name}}} = {{{value}}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, Sendable, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{^isContainer}}{{^isString}}{{^isInteger}}{{^isFloat}}{{^isDouble}}{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{/isDouble}}{{/isFloat}}{{/isInteger}}{{/isString}}{{/isContainer}}{{/useVapor}}, CaseIterable{{#enumUnknownDefaultCase}}{{#isInteger}}, CaseIterableDefaultsLast{{/isInteger}}{{#isFloat}}, CaseIterableDefaultsLast{{/isFloat}}{{#isDouble}}, CaseIterableDefaultsLast{{/isDouble}}{{#isString}}, CaseIterableDefaultsLast{{/isString}}{{#isContainer}}, CaseIterableDefaultsLast{{/isContainer}}{{/enumUnknownDefaultCase}} {
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{enumName}}: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}String{{/isContainer}}, Sendable, {{#useVapor}}Content, Hashable{{/useVapor}}{{^useVapor}}Codable{{^isContainer}}{{^isString}}{{^isInteger}}{{^isFloat}}{{^isDouble}}{{#useParameterConvertible}}, ParameterConvertible{{/useParameterConvertible}}{{/isDouble}}{{/isFloat}}{{/isInteger}}{{/isString}}{{/isContainer}}{{/useVapor}}, CaseIterable{{#enumUnknownDefaultCase}}{{#isInteger}}, CaseIterableDefaultsLast{{/isInteger}}{{#isFloat}}, CaseIterableDefaultsLast{{/isFloat}}{{#isDouble}}, CaseIterableDefaultsLast{{/isDouble}}{{#isString}}, CaseIterableDefaultsLast{{/isString}}{{#isContainer}}, CaseIterableDefaultsLast{{/isContainer}}{{/enumUnknownDefaultCase}} {
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
case {{{name}}} = {{{value}}}
|
case {{{name}}} = {{{value}}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}@unchecked Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
|
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}@unchecked Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useParameterConvertible}}, ParameterConvertible{{/useParameterConvertible}}{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
|
||||||
{{/objcCompatible}}{{#objcCompatible}}@objcMembers {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}} {
|
{{/objcCompatible}}{{#objcCompatible}}@objcMembers {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable{{#useParameterConvertible}}, ParameterConvertible{{/useParameterConvertible}} {
|
||||||
{{/objcCompatible}}
|
{{/objcCompatible}}
|
||||||
|
|
||||||
{{#allVars}}
|
{{#allVars}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}}{{/useVapor}} {
|
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useParameterConvertible}}, ParameterConvertible{{/useParameterConvertible}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}}{{/useVapor}} {
|
||||||
{{#oneOf}}
|
{{#oneOf}}
|
||||||
case type{{#transformArrayType}}{{.}}{{/transformArrayType}}({{.}})
|
case type{{#transformArrayType}}{{.}}{{/transformArrayType}}({{.}})
|
||||||
{{/oneOf}}
|
{{/oneOf}}
|
||||||
|
@ -48,7 +48,7 @@ public class Swift6ClientCodegenOptionsProvider implements OptionsProvider {
|
|||||||
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE = "true";
|
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE = "true";
|
||||||
public static final String HASHABLE_MODELS_VALUE = "true";
|
public static final String HASHABLE_MODELS_VALUE = "true";
|
||||||
public static final String IDENTIFIABLE_MODELS_VALUE = "true";
|
public static final String IDENTIFIABLE_MODELS_VALUE = "true";
|
||||||
public static final String USE_JSON_ENCODABLE_VALUE = "true";
|
public static final String USE_PARAMETER_CONVERTIBLE_VALUE = "true";
|
||||||
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
|
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
|
||||||
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
|
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
|
||||||
public static final String LIBRARY_VALUE = "alamofire";
|
public static final String LIBRARY_VALUE = "alamofire";
|
||||||
@ -99,7 +99,7 @@ public class Swift6ClientCodegenOptionsProvider implements OptionsProvider {
|
|||||||
GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE)
|
GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE)
|
||||||
.put(Swift6ClientCodegen.HASHABLE_MODELS, HASHABLE_MODELS_VALUE)
|
.put(Swift6ClientCodegen.HASHABLE_MODELS, HASHABLE_MODELS_VALUE)
|
||||||
.put(Swift6ClientCodegen.IDENTIFIABLE_MODELS, IDENTIFIABLE_MODELS_VALUE)
|
.put(Swift6ClientCodegen.IDENTIFIABLE_MODELS, IDENTIFIABLE_MODELS_VALUE)
|
||||||
.put(Swift6ClientCodegen.USE_JSON_ENCODABLE, USE_JSON_ENCODABLE_VALUE)
|
.put(Swift6ClientCodegen.USE_PARAMETER_CONVERTIBLE, USE_PARAMETER_CONVERTIBLE_VALUE)
|
||||||
.put(Swift6ClientCodegen.MAP_FILE_BINARY_TO_DATA, "false")
|
.put(Swift6ClientCodegen.MAP_FILE_BINARY_TO_DATA, "false")
|
||||||
.put(Swift6ClientCodegen.USE_CUSTOM_DATE_WITHOUT_TIME, "false")
|
.put(Swift6ClientCodegen.USE_CUSTOM_DATE_WITHOUT_TIME, "false")
|
||||||
.put(Swift6ClientCodegen.VALIDATABLE, "true")
|
.put(Swift6ClientCodegen.VALIDATABLE, "true")
|
||||||
|
@ -257,7 +257,7 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"query": (wrappedValue: query.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"query": (wrappedValue: query.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -376,20 +376,20 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"integer": integer?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"integer": integer?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int32": int32?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int32": int32?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int64": int64?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int64": int64?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"number": number.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"number": number.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"float": float?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"float": float?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"double": double.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"double": double.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"string": string?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"string": string?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"pattern_without_delimiter": patternWithoutDelimiter.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"byte": byte.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"byte": byte.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"binary": binary?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"binary": binary?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"date": date?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"date": date?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"dateTime": dateTime?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"dateTime": dateTime?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"password": password?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"password": password?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"callback": callback?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"callback": callback?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -520,8 +520,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"enum_form_string_array": enumFormStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string_array": enumFormStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_form_string": enumFormString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string": enumFormString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -529,16 +529,16 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_string": (wrappedValue: enumQueryString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string": (wrappedValue: enumQueryString?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_integer": (wrappedValue: enumQueryInteger?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_double": (wrappedValue: enumQueryDouble?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"enum_header_string_array": enumHeaderStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string_array": enumHeaderStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_header_string": enumHeaderString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string": enumHeaderString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -592,15 +592,15 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"required_string_group": (wrappedValue: requiredStringGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_string_group": (wrappedValue: requiredStringGroup.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_int64_group": (wrappedValue: requiredInt64Group.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"string_group": (wrappedValue: stringGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"string_group": (wrappedValue: stringGroup?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"int64_group": (wrappedValue: int64Group?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"int64_group": (wrappedValue: int64Group?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"required_boolean_group": requiredBooleanGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"required_boolean_group": requiredBooleanGroup.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"boolean_group": booleanGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"boolean_group": booleanGroup?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -686,8 +686,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake/jsonFormData"
|
let localVariablePath = "/fake/jsonFormData"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"param": param.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param": param.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"param2": param2.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param2": param2.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -101,7 +101,7 @@ open class PetAPI {
|
|||||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"api_key": apiKey?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"api_key": apiKey?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -157,7 +157,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"status": (wrappedValue: status.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"status": (wrappedValue: status.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -210,7 +210,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"tags": (wrappedValue: tags.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"tags": (wrappedValue: tags.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -362,8 +362,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"name": name?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"name": name?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"status": status?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"status": status?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -422,8 +422,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"file": file?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"file": file?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -482,8 +482,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"requiredFile": requiredFile.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"requiredFile": requiredFile.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -273,8 +273,8 @@ open class UserAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"username": (wrappedValue: username.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"username": (wrappedValue: username.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"password": (wrappedValue: password.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"password": (wrappedValue: password.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
|
@ -9,78 +9,73 @@ import Foundation
|
|||||||
import FoundationNetworking
|
import FoundationNetworking
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension QueryStringEncodable {
|
extension Bool: ParameterConvertible {
|
||||||
@_disfavoredOverload
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Bool: QueryStringEncodable {
|
extension Float: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Float: QueryStringEncodable {
|
extension Int: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int: QueryStringEncodable {
|
extension Int32: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int32: QueryStringEncodable {
|
extension Int64: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int64: QueryStringEncodable {
|
extension Double: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Double: QueryStringEncodable {
|
extension Decimal: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Decimal: QueryStringEncodable {
|
extension String: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String: QueryStringEncodable {
|
extension URL: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension URL: QueryStringEncodable {
|
extension UUID: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UUID: QueryStringEncodable {
|
extension RawRepresentable where RawValue: ParameterConvertible, RawValue: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { return self.rawValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RawRepresentable where RawValue: QueryStringEncodable {
|
private func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
|
if let encodableObject = object as? ParameterConvertible {
|
||||||
}
|
return encodableObject.asParameter(codableHelper: codableHelper)
|
||||||
|
|
||||||
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
|
|
||||||
if let encodableObject = object as? QueryStringEncodable {
|
|
||||||
return encodableObject.encodeToQueryString(codableHelper: codableHelper)
|
|
||||||
} else {
|
} else {
|
||||||
return String(describing: object)
|
return object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Array {
|
extension Array where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Set {
|
extension Set where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return Array(self).encodeToQueryString(codableHelper: codableHelper)
|
return Array(self).asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Dictionary {
|
extension Dictionary where Key: Sendable, Value: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [Key: String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
var dictionary = [Key: String]()
|
var dictionary = [Key: any Sendable]()
|
||||||
for (key, value) in self {
|
for (key, value) in self {
|
||||||
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
@ -88,24 +83,24 @@ extension Dictionary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Data: QueryStringEncodable {
|
extension Data: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Date: QueryStringEncodable {
|
extension Date: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return codableHelper.dateFormatter.string(from: self)
|
return codableHelper.dateFormatter.string(from: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension QueryStringEncodable where Self: Encodable {
|
extension ParameterConvertible where Self: Encodable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
||||||
fatalError("Could not encode to json: \(self)")
|
fatalError("Could not encode to json: \(self)")
|
||||||
}
|
}
|
||||||
return data.encodeToQueryString(codableHelper: codableHelper)
|
return data.asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ import FoundationNetworking
|
|||||||
#endif
|
#endif
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
protocol QueryStringEncodable {
|
protocol ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String
|
func asParameter(codableHelper: CodableHelper) -> any Sendable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enum where the last case value can be used as a default catch-all.
|
/// An enum where the last case value can be used as a default catch-all.
|
||||||
|
@ -76,8 +76,8 @@ public struct OpenAPIDateWithoutTime: Sendable, Codable, Hashable, Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension OpenAPIDateWithoutTime: QueryStringEncodable {
|
extension OpenAPIDateWithoutTime: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate())
|
return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct AdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct AdditionalPropertiesClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var mapString: [String: String]?
|
public var mapString: [String: String]?
|
||||||
public var mapMapString: [String: [String: String]]?
|
public var mapMapString: [String: [String: String]]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Animal: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Animal: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ApiResponse: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ApiResponse: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var code: Int?
|
public var code: Int?
|
||||||
public var type: String?
|
public var type: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayArrayNumber: [[Double]]?
|
public var arrayArrayNumber: [[Double]]?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayOfNumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayNumber: [Double]?
|
public var arrayNumber: [Double]?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayOfString: [String]?
|
public var arrayOfString: [String]?
|
||||||
public var arrayArrayOfInteger: [[Int64]]?
|
public var arrayArrayOfInteger: [[Int64]]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Capitalization: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Capitalization: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var smallCamel: String?
|
public var smallCamel: String?
|
||||||
public var capitalCamel: String?
|
public var capitalCamel: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Cat: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Cat: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Category: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Category: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var name: String? = "default-name"
|
public var name: String? = "default-name"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model with \"_class\" property */
|
/** Model for testing model with \"_class\" property */
|
||||||
public struct ClassModel: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ClassModel: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _class: String?
|
public var _class: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Client: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Client: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var client: String?
|
public var client: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Dog: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Dog: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct EnumArrays: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct EnumArrays: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum JustSymbol: String, Sendable, Codable, CaseIterable {
|
public enum JustSymbol: String, Sendable, Codable, CaseIterable {
|
||||||
case greaterThanOrEqualTo = ">="
|
case greaterThanOrEqualTo = ">="
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct EnumTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct EnumTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum EnumString: String, Sendable, Codable, CaseIterable {
|
public enum EnumString: String, Sendable, Codable, CaseIterable {
|
||||||
case upper = "UPPER"
|
case upper = "UPPER"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Must be named `File` for test. */
|
/** Must be named `File` for test. */
|
||||||
public struct File: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct File: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
/** Test capitalization */
|
/** Test capitalization */
|
||||||
public var sourceURI: String?
|
public var sourceURI: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct FileSchemaTestClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct FileSchemaTestClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var file: File?
|
public var file: File?
|
||||||
public var files: [File]?
|
public var files: [File]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct FormatTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct FormatTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public static let integerRule = NumericRule<Int>(minimum: 10, exclusiveMinimum: false, maximum: 100, exclusiveMaximum: false, multipleOf: nil)
|
public static let integerRule = NumericRule<Int>(minimum: 10, exclusiveMinimum: false, maximum: 100, exclusiveMaximum: false, multipleOf: nil)
|
||||||
public static let int32Rule = NumericRule<Int>(minimum: 20, exclusiveMinimum: false, maximum: 200, exclusiveMaximum: false, multipleOf: nil)
|
public static let int32Rule = NumericRule<Int>(minimum: 20, exclusiveMinimum: false, maximum: 200, exclusiveMaximum: false, multipleOf: nil)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct HasOnlyReadOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct HasOnlyReadOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var bar: String?
|
public var bar: String?
|
||||||
public var foo: String?
|
public var foo: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct List: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct List: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _123list: String?
|
public var _123list: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct MapTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct MapTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum MapOfEnumString: String, Sendable, Codable, CaseIterable {
|
public enum MapOfEnumString: String, Sendable, Codable, CaseIterable {
|
||||||
case upper = "UPPER"
|
case upper = "UPPER"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var uuid: UUID?
|
public var uuid: UUID?
|
||||||
public var dateTime: Date?
|
public var dateTime: Date?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model name starting with number */
|
/** Model for testing model name starting with number */
|
||||||
public struct Model200Response: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Model200Response: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var name: Int?
|
public var name: Int?
|
||||||
public var _class: String?
|
public var _class: String?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model name same as property name */
|
/** Model for testing model name same as property name */
|
||||||
public struct Name: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Name: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var name: Int
|
public var name: Int
|
||||||
public var snakeCase: NullEncodable<Int> = .encodeValue(11033)
|
public var snakeCase: NullEncodable<Int> = .encodeValue(11033)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct NumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct NumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var justNumber: Double?
|
public var justNumber: Double?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Order: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Order: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum Status: String, Sendable, Codable, CaseIterable {
|
public enum Status: String, Sendable, Codable, CaseIterable {
|
||||||
case placed = "placed"
|
case placed = "placed"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct OuterComposite: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct OuterComposite: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var myNumber: Double?
|
public var myNumber: Double?
|
||||||
public var myString: String?
|
public var myString: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Pet: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Pet: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum Status: String, Sendable, Codable, CaseIterable {
|
public enum Status: String, Sendable, Codable, CaseIterable {
|
||||||
case available = "available"
|
case available = "available"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ReadOnlyFirst: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ReadOnlyFirst: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var bar: String?
|
public var bar: String?
|
||||||
public var baz: String?
|
public var baz: String?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing reserved words */
|
/** Model for testing reserved words */
|
||||||
public struct Return: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Return: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _return: Int?
|
public var _return: Int?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct SpecialModelName: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct SpecialModelName: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var specialPropertyName: Int64?
|
public var specialPropertyName: Int64?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct StringBooleanMap: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct StringBooleanMap: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
|
|
||||||
public enum CodingKeys: CodingKey, CaseIterable {
|
public enum CodingKeys: CodingKey, CaseIterable {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Tag: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Tag: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var name: String?
|
public var name: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct TypeHolderDefault: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct TypeHolderDefault: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var stringItem: String = "what"
|
public var stringItem: String = "what"
|
||||||
public var numberItem: Double
|
public var numberItem: Double
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct TypeHolderExample: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct TypeHolderExample: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var stringItem: String
|
public var stringItem: String
|
||||||
public var numberItem: Double
|
public var numberItem: Double
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct User: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct User: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var username: String?
|
public var username: String?
|
||||||
|
@ -27,7 +27,7 @@ class DateFormatTests: XCTestCase {
|
|||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
func testencodeToQueryStringAlwaysResultsInUTCEncodedDate() {
|
func testAsParameterAlwaysResultsInUTCEncodedDate() {
|
||||||
var dateComponents = DateComponents()
|
var dateComponents = DateComponents()
|
||||||
dateComponents.calendar = Calendar(identifier: .gregorian)
|
dateComponents.calendar = Calendar(identifier: .gregorian)
|
||||||
dateComponents.year = 2018
|
dateComponents.year = 2018
|
||||||
@ -47,7 +47,7 @@ class DateFormatTests: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var encodedDate = utcDate.encodeToQueryString(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
var encodedDate = utcDate.asParameter(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
||||||
XCTAssert(encodedDate.hasSuffix("Z"))
|
XCTAssert(encodedDate.hasSuffix("Z"))
|
||||||
|
|
||||||
// test with a positive timzone offset from UTC
|
// test with a positive timzone offset from UTC
|
||||||
@ -59,7 +59,7 @@ class DateFormatTests: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedDate = nonUTCDate1.encodeToQueryString(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
encodedDate = nonUTCDate1.asParameter(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
||||||
XCTAssert(encodedDate.hasSuffix("Z"))
|
XCTAssert(encodedDate.hasSuffix("Z"))
|
||||||
|
|
||||||
// test with a negative timzone offset from UTC
|
// test with a negative timzone offset from UTC
|
||||||
@ -71,7 +71,7 @@ class DateFormatTests: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedDate = nonUTCDate2.encodeToQueryString(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
encodedDate = nonUTCDate2.asParameter(codableHelper: PetstoreClientAPIConfiguration.shared.codableHelper) as! String
|
||||||
XCTAssert(encodedDate.hasSuffix("Z"))
|
XCTAssert(encodedDate.hasSuffix("Z"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"query": (wrappedValue: query.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"query": (wrappedValue: query.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -1233,20 +1233,20 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"integer": integer?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"integer": integer?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int32": int32?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int32": int32?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int64": int64?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int64": int64?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"number": number.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"number": number.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"float": float?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"float": float?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"double": double.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"double": double.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"string": string?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"string": string?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"pattern_without_delimiter": patternWithoutDelimiter.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"byte": byte.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"byte": byte.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"binary": binary?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"binary": binary?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"date": date?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"date": date?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"dateTime": dateTime?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"dateTime": dateTime?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"password": password?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"password": password?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"callback": callback?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"callback": callback?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -1513,8 +1513,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"enum_form_string_array": enumFormStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string_array": enumFormStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_form_string": enumFormString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string": enumFormString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -1522,16 +1522,16 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_string": (wrappedValue: enumQueryString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string": (wrappedValue: enumQueryString?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_integer": (wrappedValue: enumQueryInteger?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_double": (wrappedValue: enumQueryDouble?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"enum_header_string_array": enumHeaderStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string_array": enumHeaderStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_header_string": enumHeaderString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string": enumHeaderString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -1711,15 +1711,15 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"required_string_group": (wrappedValue: requiredStringGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_string_group": (wrappedValue: requiredStringGroup.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_int64_group": (wrappedValue: requiredInt64Group.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"string_group": (wrappedValue: stringGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"string_group": (wrappedValue: stringGroup?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"int64_group": (wrappedValue: int64Group?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"int64_group": (wrappedValue: int64Group?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"required_boolean_group": requiredBooleanGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"required_boolean_group": requiredBooleanGroup.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"boolean_group": booleanGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"boolean_group": booleanGroup?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -2012,8 +2012,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake/jsonFormData"
|
let localVariablePath = "/fake/jsonFormData"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"param": param.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param": param.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"param2": param2.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param2": param2.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -317,7 +317,7 @@ open class PetAPI {
|
|||||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"api_key": apiKey?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"api_key": apiKey?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -474,7 +474,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"status": (wrappedValue: status.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"status": (wrappedValue: status.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -633,7 +633,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"tags": (wrappedValue: tags.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"tags": (wrappedValue: tags.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -1098,8 +1098,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"name": name?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"name": name?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"status": status?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"status": status?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -1269,8 +1269,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"file": file?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"file": file?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -1440,8 +1440,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"requiredFile": requiredFile.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"requiredFile": requiredFile.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -893,8 +893,8 @@ open class UserAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"username": (wrappedValue: username.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"username": (wrappedValue: username.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"password": (wrappedValue: password.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"password": (wrappedValue: password.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
|
@ -10,78 +10,73 @@ import FoundationNetworking
|
|||||||
#endif
|
#endif
|
||||||
@preconcurrency import PromiseKit
|
@preconcurrency import PromiseKit
|
||||||
|
|
||||||
extension QueryStringEncodable {
|
extension Bool: ParameterConvertible {
|
||||||
@_disfavoredOverload
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Bool: QueryStringEncodable {
|
extension Float: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Float: QueryStringEncodable {
|
extension Int: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int: QueryStringEncodable {
|
extension Int32: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int32: QueryStringEncodable {
|
extension Int64: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int64: QueryStringEncodable {
|
extension Double: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Double: QueryStringEncodable {
|
extension Decimal: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Decimal: QueryStringEncodable {
|
extension String: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String: QueryStringEncodable {
|
extension URL: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension URL: QueryStringEncodable {
|
extension UUID: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UUID: QueryStringEncodable {
|
extension RawRepresentable where RawValue: ParameterConvertible, RawValue: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { return self.rawValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RawRepresentable where RawValue: QueryStringEncodable {
|
private func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
|
if let encodableObject = object as? ParameterConvertible {
|
||||||
}
|
return encodableObject.asParameter(codableHelper: codableHelper)
|
||||||
|
|
||||||
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
|
|
||||||
if let encodableObject = object as? QueryStringEncodable {
|
|
||||||
return encodableObject.encodeToQueryString(codableHelper: codableHelper)
|
|
||||||
} else {
|
} else {
|
||||||
return String(describing: object)
|
return object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Array {
|
extension Array where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Set {
|
extension Set where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return Array(self).encodeToQueryString(codableHelper: codableHelper)
|
return Array(self).asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Dictionary {
|
extension Dictionary where Key: Sendable, Value: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [Key: String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
var dictionary = [Key: String]()
|
var dictionary = [Key: any Sendable]()
|
||||||
for (key, value) in self {
|
for (key, value) in self {
|
||||||
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
@ -89,24 +84,24 @@ extension Dictionary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Data: QueryStringEncodable {
|
extension Data: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Date: QueryStringEncodable {
|
extension Date: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return codableHelper.dateFormatter.string(from: self)
|
return codableHelper.dateFormatter.string(from: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension QueryStringEncodable where Self: Encodable {
|
extension ParameterConvertible where Self: Encodable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
||||||
fatalError("Could not encode to json: \(self)")
|
fatalError("Could not encode to json: \(self)")
|
||||||
}
|
}
|
||||||
return data.encodeToQueryString(codableHelper: codableHelper)
|
return data.asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ import FoundationNetworking
|
|||||||
#endif
|
#endif
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
protocol QueryStringEncodable {
|
protocol ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String
|
func asParameter(codableHelper: CodableHelper) -> any Sendable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enum where the last case value can be used as a default catch-all.
|
/// An enum where the last case value can be used as a default catch-all.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct AdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct AdditionalPropertiesClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var mapString: [String: String]?
|
public var mapString: [String: String]?
|
||||||
public var mapMapString: [String: [String: String]]?
|
public var mapMapString: [String: [String: String]]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Animal: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Animal: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ApiResponse: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ApiResponse: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var code: Int?
|
public var code: Int?
|
||||||
public var type: String?
|
public var type: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayArrayNumber: [[Double]]?
|
public var arrayArrayNumber: [[Double]]?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayOfNumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayNumber: [Double]?
|
public var arrayNumber: [Double]?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ArrayTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ArrayTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var arrayOfString: [String]?
|
public var arrayOfString: [String]?
|
||||||
public var arrayArrayOfInteger: [[Int64]]?
|
public var arrayArrayOfInteger: [[Int64]]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Capitalization: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Capitalization: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var smallCamel: String?
|
public var smallCamel: String?
|
||||||
public var capitalCamel: String?
|
public var capitalCamel: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Cat: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Cat: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Category: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Category: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var name: String? = "default-name"
|
public var name: String? = "default-name"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model with \"_class\" property */
|
/** Model for testing model with \"_class\" property */
|
||||||
public struct ClassModel: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ClassModel: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _class: String?
|
public var _class: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Client: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Client: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var client: String?
|
public var client: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Dog: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Dog: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct EnumArrays: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct EnumArrays: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum JustSymbol: String, Sendable, Codable, CaseIterable {
|
public enum JustSymbol: String, Sendable, Codable, CaseIterable {
|
||||||
case greaterThanOrEqualTo = ">="
|
case greaterThanOrEqualTo = ">="
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct EnumTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct EnumTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum EnumString: String, Sendable, Codable, CaseIterable {
|
public enum EnumString: String, Sendable, Codable, CaseIterable {
|
||||||
case upper = "UPPER"
|
case upper = "UPPER"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Must be named `File` for test. */
|
/** Must be named `File` for test. */
|
||||||
public struct File: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct File: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
/** Test capitalization */
|
/** Test capitalization */
|
||||||
public var sourceURI: String?
|
public var sourceURI: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct FileSchemaTestClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct FileSchemaTestClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var file: File?
|
public var file: File?
|
||||||
public var files: [File]?
|
public var files: [File]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct FormatTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct FormatTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public static let integerRule = NumericRule<Int>(minimum: 10, exclusiveMinimum: false, maximum: 100, exclusiveMaximum: false, multipleOf: nil)
|
public static let integerRule = NumericRule<Int>(minimum: 10, exclusiveMinimum: false, maximum: 100, exclusiveMaximum: false, multipleOf: nil)
|
||||||
public static let int32Rule = NumericRule<Int>(minimum: 20, exclusiveMinimum: false, maximum: 200, exclusiveMaximum: false, multipleOf: nil)
|
public static let int32Rule = NumericRule<Int>(minimum: 20, exclusiveMinimum: false, maximum: 200, exclusiveMaximum: false, multipleOf: nil)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct HasOnlyReadOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct HasOnlyReadOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var bar: String?
|
public var bar: String?
|
||||||
public var foo: String?
|
public var foo: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct List: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct List: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _123list: String?
|
public var _123list: String?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct MapTest: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct MapTest: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum MapOfEnumString: String, Sendable, Codable, CaseIterable {
|
public enum MapOfEnumString: String, Sendable, Codable, CaseIterable {
|
||||||
case upper = "UPPER"
|
case upper = "UPPER"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var uuid: UUID?
|
public var uuid: UUID?
|
||||||
public var dateTime: Date?
|
public var dateTime: Date?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model name starting with number */
|
/** Model for testing model name starting with number */
|
||||||
public struct Model200Response: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Model200Response: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var name: Int?
|
public var name: Int?
|
||||||
public var _class: String?
|
public var _class: String?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing model name same as property name */
|
/** Model for testing model name same as property name */
|
||||||
public struct Name: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Name: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var name: Int
|
public var name: Int
|
||||||
public var snakeCase: NullEncodable<Int> = .encodeValue(11033)
|
public var snakeCase: NullEncodable<Int> = .encodeValue(11033)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct NumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct NumberOnly: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var justNumber: Double?
|
public var justNumber: Double?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Order: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Order: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum Status: String, Sendable, Codable, CaseIterable {
|
public enum Status: String, Sendable, Codable, CaseIterable {
|
||||||
case placed = "placed"
|
case placed = "placed"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct OuterComposite: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct OuterComposite: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var myNumber: Double?
|
public var myNumber: Double?
|
||||||
public var myString: String?
|
public var myString: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Pet: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Pet: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public enum Status: String, Sendable, Codable, CaseIterable {
|
public enum Status: String, Sendable, Codable, CaseIterable {
|
||||||
case available = "available"
|
case available = "available"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ReadOnlyFirst: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ReadOnlyFirst: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var bar: String?
|
public var bar: String?
|
||||||
public var baz: String?
|
public var baz: String?
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/** Model for testing reserved words */
|
/** Model for testing reserved words */
|
||||||
public struct Return: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Return: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var _return: Int?
|
public var _return: Int?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct SpecialModelName: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct SpecialModelName: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var specialPropertyName: Int64?
|
public var specialPropertyName: Int64?
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Tag: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Tag: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var name: String?
|
public var name: String?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct TypeHolderDefault: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct TypeHolderDefault: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var stringItem: String = "what"
|
public var stringItem: String = "what"
|
||||||
public var numberItem: Double
|
public var numberItem: Double
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct TypeHolderExample: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct TypeHolderExample: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var stringItem: String
|
public var stringItem: String
|
||||||
public var numberItem: Double
|
public var numberItem: Double
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct User: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct User: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var username: String?
|
public var username: String?
|
||||||
|
@ -215,7 +215,7 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"query": (wrappedValue: query.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"query": (wrappedValue: query.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -320,20 +320,20 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"integer": integer?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"integer": integer?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int32": int32?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int32": int32?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"int64": int64?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"int64": int64?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"number": number.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"number": number.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"float": float?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"float": float?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"double": double.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"double": double.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"string": string?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"string": string?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"pattern_without_delimiter": patternWithoutDelimiter.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"byte": byte.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"byte": byte.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"binary": binary?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"binary": binary?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"date": date?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"date": date?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"dateTime": dateTime?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"dateTime": dateTime?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"password": password?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"password": password?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"callback": callback?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"callback": callback?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -457,8 +457,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake"
|
let localVariablePath = "/fake"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"enum_form_string_array": enumFormStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string_array": enumFormStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_form_string": enumFormString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_form_string": enumFormString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -466,16 +466,16 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string_array": (wrappedValue: enumQueryStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_string": (wrappedValue: enumQueryString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_string": (wrappedValue: enumQueryString?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_integer": (wrappedValue: enumQueryInteger?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_integer": (wrappedValue: enumQueryInteger?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"enum_query_double": (wrappedValue: enumQueryDouble?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"enum_query_double": (wrappedValue: enumQueryDouble?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"enum_header_string_array": enumHeaderStringArray?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string_array": enumHeaderStringArray?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"enum_header_string": enumHeaderString?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"enum_header_string": enumHeaderString?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -522,15 +522,15 @@ open class FakeAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"required_string_group": (wrappedValue: requiredStringGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_string_group": (wrappedValue: requiredStringGroup.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"required_int64_group": (wrappedValue: requiredInt64Group.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"required_int64_group": (wrappedValue: requiredInt64Group.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"string_group": (wrappedValue: stringGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"string_group": (wrappedValue: stringGroup?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"int64_group": (wrappedValue: int64Group?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"int64_group": (wrappedValue: int64Group?.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"required_boolean_group": requiredBooleanGroup.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"required_boolean_group": requiredBooleanGroup.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"boolean_group": booleanGroup?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"boolean_group": booleanGroup?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -602,8 +602,8 @@ open class FakeAPI {
|
|||||||
let localVariablePath = "/fake/jsonFormData"
|
let localVariablePath = "/fake/jsonFormData"
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"param": param.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param": param.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"param2": param2.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"param2": param2.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -87,7 +87,7 @@ open class PetAPI {
|
|||||||
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
let localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
"api_key": apiKey?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"api_key": apiKey?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders)
|
||||||
@ -136,7 +136,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"status": (wrappedValue: status.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"status": (wrappedValue: status.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -182,7 +182,7 @@ open class PetAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"tags": (wrappedValue: tags.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"tags": (wrappedValue: tags.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
@ -313,8 +313,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"name": name?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"name": name?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"status": status?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"status": status?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -366,8 +366,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"file": file?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"file": file?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
@ -419,8 +419,8 @@ open class PetAPI {
|
|||||||
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
localVariablePath = localVariablePath.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||||
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
let localVariableURLString = apiConfiguration.basePath + localVariablePath
|
||||||
let localVariableFormParams: [String: (any Sendable)?] = [
|
let localVariableFormParams: [String: (any Sendable)?] = [
|
||||||
"additionalMetadata": additionalMetadata?.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"additionalMetadata": additionalMetadata?.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
"requiredFile": requiredFile.encodeToQueryString(codableHelper: apiConfiguration.codableHelper),
|
"requiredFile": requiredFile.asParameter(codableHelper: apiConfiguration.codableHelper),
|
||||||
]
|
]
|
||||||
|
|
||||||
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
let localVariableNonNullParameters = APIHelper.rejectNil(localVariableFormParams)
|
||||||
|
@ -231,8 +231,8 @@ open class UserAPI {
|
|||||||
|
|
||||||
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
var localVariableUrlComponents = URLComponents(string: localVariableURLString)
|
||||||
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
localVariableUrlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||||
"username": (wrappedValue: username.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"username": (wrappedValue: username.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
"password": (wrappedValue: password.encodeToQueryString(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
"password": (wrappedValue: password.asParameter(codableHelper: apiConfiguration.codableHelper), isExplode: false),
|
||||||
])
|
])
|
||||||
|
|
||||||
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
let localVariableNillableHeaders: [String: (any Sendable)?] = [
|
||||||
|
@ -9,78 +9,73 @@ import Foundation
|
|||||||
import FoundationNetworking
|
import FoundationNetworking
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension QueryStringEncodable {
|
extension Bool: ParameterConvertible {
|
||||||
@_disfavoredOverload
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Bool: QueryStringEncodable {
|
extension Float: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Float: QueryStringEncodable {
|
extension Int: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int: QueryStringEncodable {
|
extension Int32: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int32: QueryStringEncodable {
|
extension Int64: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Int64: QueryStringEncodable {
|
extension Double: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Double: QueryStringEncodable {
|
extension Decimal: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Decimal: QueryStringEncodable {
|
extension String: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String: QueryStringEncodable {
|
extension URL: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension URL: QueryStringEncodable {
|
extension UUID: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UUID: QueryStringEncodable {
|
extension RawRepresentable where RawValue: ParameterConvertible, RawValue: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
|
func asParameter(codableHelper: CodableHelper) -> any Sendable { return self.rawValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RawRepresentable where RawValue: QueryStringEncodable {
|
private func encodeIfPossible<T: Sendable>(_ object: T, codableHelper: CodableHelper) -> any Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
|
if let encodableObject = object as? ParameterConvertible {
|
||||||
}
|
return encodableObject.asParameter(codableHelper: codableHelper)
|
||||||
|
|
||||||
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
|
|
||||||
if let encodableObject = object as? QueryStringEncodable {
|
|
||||||
return encodableObject.encodeToQueryString(codableHelper: codableHelper)
|
|
||||||
} else {
|
} else {
|
||||||
return String(describing: object)
|
return object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Array {
|
extension Array where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
return self.map { encodeIfPossible($0, codableHelper: codableHelper) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Set {
|
extension Set where Element: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return Array(self).encodeToQueryString(codableHelper: codableHelper)
|
return Array(self).asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Dictionary {
|
extension Dictionary where Key: Sendable, Value: Sendable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> [Key: String] {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
var dictionary = [Key: String]()
|
var dictionary = [Key: any Sendable]()
|
||||||
for (key, value) in self {
|
for (key, value) in self {
|
||||||
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
dictionary[key] = encodeIfPossible(value, codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
@ -88,24 +83,24 @@ extension Dictionary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Data: QueryStringEncodable {
|
extension Data: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Date: QueryStringEncodable {
|
extension Date: ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
return codableHelper.dateFormatter.string(from: self)
|
return codableHelper.dateFormatter.string(from: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension QueryStringEncodable where Self: Encodable {
|
extension ParameterConvertible where Self: Encodable {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String {
|
func asParameter(codableHelper: CodableHelper) -> any Sendable {
|
||||||
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
|
||||||
fatalError("Could not encode to json: \(self)")
|
fatalError("Could not encode to json: \(self)")
|
||||||
}
|
}
|
||||||
return data.encodeToQueryString(codableHelper: codableHelper)
|
return data.asParameter(codableHelper: codableHelper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ import Foundation
|
|||||||
import FoundationNetworking
|
import FoundationNetworking
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protocol QueryStringEncodable {
|
protocol ParameterConvertible {
|
||||||
func encodeToQueryString(codableHelper: CodableHelper) -> String
|
func asParameter(codableHelper: CodableHelper) -> any Sendable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enum where the last case value can be used as a default catch-all.
|
/// An enum where the last case value can be used as a default catch-all.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct AdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct AdditionalPropertiesClass: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var mapString: [String: String]?
|
public var mapString: [String: String]?
|
||||||
public var mapMapString: [String: [String: String]]?
|
public var mapMapString: [String: [String: String]]?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Animal: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct Animal: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var className: String
|
public var className: String
|
||||||
public var color: String? = "red"
|
public var color: String? = "red"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct ApiResponse: Sendable, Codable, QueryStringEncodable, Hashable {
|
public struct ApiResponse: Sendable, Codable, ParameterConvertible, Hashable {
|
||||||
|
|
||||||
public var code: Int?
|
public var code: Int?
|
||||||
public var type: String?
|
public var type: String?
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user