Add file post-processing to Swift 3.x, 4.x generators (#1069)

* update all swift samples

* format swift code with swiftformat

* minor format fix

* rename environment variable
This commit is contained in:
William Cheng 2018-09-20 19:29:25 +08:00 committed by Daiki Matsudate
parent ca9a4a2ff3
commit 340466066c
73 changed files with 596 additions and 787 deletions

View File

@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
@ -242,6 +243,10 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("SWIFT_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable SWIFT_POST_PROCESS_FILE not defined so the Swift code may not be properly formatted. To define it, try 'export SWIFT_POST_PROCESS_FILE=/usr/local/bin/swiftformat' (Linux/Mac)");
}
// Setup project name
if (additionalProperties.containsKey(PROJECT_NAME)) {
setProjectName((String) additionalProperties.get(PROJECT_NAME));
@ -681,4 +686,31 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String swiftPostProcessFile = System.getenv("SWIFT_POST_PROCESS_FILE");
if (StringUtils.isEmpty(swiftPostProcessFile)) {
return; // skip if SWIFT_POST_PROCESS_FILE env variable is not defined
}
// only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
String command = swiftPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
}
}
}

View File

@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
@ -26,6 +27,7 @@ import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.io.FilenameUtils;
import java.io.File;
import java.util.*;
@ -296,6 +298,10 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("SWIFT_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable SWIFT_POST_PROCESS_FILE not defined so the Swift code may not be properly formatted. To define it, try 'export SWIFT_POST_PROCESS_FILE=/usr/local/bin/swiftformat' (Linux/Mac)");
}
// Setup project name
if (additionalProperties.containsKey(PROJECT_NAME)) {
setProjectName((String) additionalProperties.get(PROJECT_NAME));
@ -836,4 +842,30 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String swiftPostProcessFile = System.getenv("SWIFT_POST_PROCESS_FILE");
if (StringUtils.isEmpty(swiftPostProcessFile)) {
return; // skip if SWIFT_POST_PROCESS_FILE env variable is not defined
}
// only process files with swift extension
if ("swift".equals(FilenameUtils.getExtension(file.toString()))) {
String command = swiftPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
}
}
}

View File

@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -7,8 +7,8 @@
import Foundation
public struct APIHelper {
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
let destination = source.reduce(into: [String: Any]()) { (result, item) in
public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? {
let destination = source.reduce(into: [String: Any]()) { result, item in
if let value = item.value {
result[item.key] = value
}
@ -20,22 +20,22 @@ public struct APIHelper {
return destination
}
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
return source.reduce(into: [String: String]()) { (result, item) in
public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] {
return source.reduce(into: [String: String]()) { result, item in
if let collection = item.value as? Array<Any?> {
result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",")
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
} else if let value: Any = item.value {
result[item.key] = "\(value)"
}
}
}
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? {
guard let source = source else {
return nil
}
return source.reduce(into: [String: Any](), { (result, item) in
return source.reduce(into: [String: Any](), { result, item in
switch item.value {
case let x as Bool:
result[item.key] = x.description
@ -45,11 +45,10 @@ public struct APIHelper {
})
}
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? {
let destination = source.filter({ $0.value != nil }).reduce(into: [URLQueryItem]()) { result, item in
if let collection = item.value as? Array<Any?> {
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
let value = collection.filter({ $0 != nil }).map({ "\($0!)" }).joined(separator: ",")
result.append(URLQueryItem(name: item.key, value: value))
} else if let value = item.value {
result.append(URLQueryItem(name: item.key, value: "\(value)"))
@ -62,4 +61,3 @@ public struct APIHelper {
return destination
}
}

View File

@ -9,22 +9,22 @@ import Foundation
open class PetstoreClientAPI {
open static var basePath = "http://petstore.swagger.io:80/v2"
open static var credential: URLCredential?
open static var customHeaders: [String:String] = [:]
open static var customHeaders: [String: String] = [:]
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
}
open class RequestBuilder<T> {
var credential: URLCredential?
var headers: [String:String]
public let parameters: [String:Any]?
var headers: [String: String]
public let parameters: [String: Any]?
public let isBody: Bool
public let method: String
public let URLString: String
/// Optional block to obtain a reference to the request's progress instance when available.
public var onProgressReady: ((Progress) -> ())?
public var onProgressReady: ((Progress) -> Void)?
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
public required init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
self.method = method
self.URLString = URLString
self.parameters = parameters
@ -34,13 +34,13 @@ open class RequestBuilder<T> {
addHeaders(PetstoreClientAPI.customHeaders)
}
open func addHeaders(_ aHeaders:[String:String]) {
open func addHeaders(_ aHeaders: [String: String]) {
for (header, value) in aHeaders {
headers[header] = value
}
}
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) { }
open func execute(_: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {}
public func addHeader(name: String, value: String) -> Self {
if !value.isEmpty {
@ -50,12 +50,12 @@ open class RequestBuilder<T> {
}
open func addCredential() -> Self {
self.credential = PetstoreClientAPI.credential
credential = PetstoreClientAPI.credential
return self
}
}
public protocol RequestBuilderFactory {
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type
}

View File

@ -5,31 +5,28 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class AnotherFakeAPI {
/**
To test special tags
- parameter client: (body) client model
- parameter client: (body) client model
- parameter completion: completion handler to receive the data and the error objects
*/
open class func call123testSpecialTags(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
open class func call123testSpecialTags(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
call123testSpecialTagsWithRequestBuilder(client: client).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
To test special tags
- PATCH /another-fake/dummy
- To test special tags and operation ID starting with number
- parameter client: (body) client model
- returns: RequestBuilder<Client>
- parameter client: (body) client model
- returns: RequestBuilder<Client>
*/
open class func call123testSpecialTagsWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
let path = "/another-fake/dummy"
@ -42,5 +39,4 @@ open class AnotherFakeAPI {
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
}
}

View File

@ -5,10 +5,8 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class FakeAPI {
/**
@ -16,18 +14,17 @@ open class FakeAPI {
- parameter body: (body) Input boolean as post body (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) {
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?, _ error: Error?) -> Void)) {
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
- POST /fake/outer/boolean
- Test serialization of outer boolean types
- parameter body: (body) Input boolean as post body (optional)
- returns: RequestBuilder<Bool>
- returns: RequestBuilder<Bool>
*/
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil) -> RequestBuilder<Bool> {
let path = "/fake/outer/boolean"
@ -46,18 +43,17 @@ open class FakeAPI {
- parameter outerComposite: (body) Input composite as post body (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: Error?) -> Void)) {
fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: outerComposite).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
- POST /fake/outer/composite
- Test serialization of object with outer number type
- parameter outerComposite: (body) Input composite as post body (optional)
- returns: RequestBuilder<OuterComposite>
- returns: RequestBuilder<OuterComposite>
*/
open class func fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
let path = "/fake/outer/composite"
@ -76,18 +72,17 @@ open class FakeAPI {
- parameter body: (body) Input number as post body (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) {
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?, _ error: Error?) -> Void)) {
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
- POST /fake/outer/number
- Test serialization of outer number types
- parameter body: (body) Input number as post body (optional)
- returns: RequestBuilder<Double>
- returns: RequestBuilder<Double>
*/
open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil) -> RequestBuilder<Double> {
let path = "/fake/outer/number"
@ -106,18 +101,17 @@ open class FakeAPI {
- parameter body: (body) Input string as post body (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
- POST /fake/outer/string
- Test serialization of outer string types
- parameter body: (body) Input string as post body (optional)
- returns: RequestBuilder<String>
- returns: RequestBuilder<String>
*/
open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil) -> RequestBuilder<String> {
let path = "/fake/outer/string"
@ -133,11 +127,11 @@ open class FakeAPI {
/**
- parameter fileSchemaTestClass: (body)
- parameter fileSchemaTestClass: (body)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: fileSchemaTestClass).execute { (response, error) -> Void in
open class func testBodyWithFileSchema(fileSchemaTestClass: FileSchemaTestClass, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: fileSchemaTestClass).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -146,12 +140,11 @@ open class FakeAPI {
}
}
/**
- PUT /fake/body-with-file-schema
- For this test, the body for this request much reference a schema named `File`.
- parameter fileSchemaTestClass: (body)
- returns: RequestBuilder<Void>
- parameter fileSchemaTestClass: (body)
- returns: RequestBuilder<Void>
*/
open class func testBodyWithFileSchemaWithRequestBuilder(fileSchemaTestClass: FileSchemaTestClass) -> RequestBuilder<Void> {
let path = "/fake/body-with-file-schema"
@ -167,12 +160,12 @@ open class FakeAPI {
/**
- parameter query: (query)
- parameter user: (body)
- parameter query: (query)
- parameter user: (body)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (response, error) -> Void in
open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -181,12 +174,11 @@ open class FakeAPI {
}
}
/**
- PUT /fake/body-with-query-params
- parameter query: (query)
- parameter user: (body)
- returns: RequestBuilder<Void>
- parameter query: (query)
- parameter user: (body)
- returns: RequestBuilder<Void>
*/
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, user: User) -> RequestBuilder<Void> {
let path = "/fake/body-with-query-params"
@ -195,7 +187,7 @@ open class FakeAPI {
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"query": query
"query": query,
])
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -205,23 +197,22 @@ open class FakeAPI {
/**
To test \"client\" model
- parameter client: (body) client model
- parameter client: (body) client model
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
testClientModelWithRequestBuilder(client: client).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
To test \"client\" model
- PATCH /fake
- To test \"client\" model
- parameter client: (body) client model
- returns: RequestBuilder<Client>
- parameter client: (body) client model
- returns: RequestBuilder<Client>
*/
open class func testClientModelWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
let path = "/fake"
@ -236,12 +227,12 @@ open class FakeAPI {
}
/**
Fake endpoint for testing various parameters
- parameter number: (form) None
- parameter double: (form) None
- parameter patternWithoutDelimiter: (form) None
- parameter byte: (form) None
Fake endpoint for testing various parameters
- parameter number: (form) None
- parameter double: (form) None
- parameter patternWithoutDelimiter: (form) None
- parameter byte: (form) None
- parameter integer: (form) None (optional)
- parameter int32: (form) None (optional)
- parameter int64: (form) None (optional)
@ -254,8 +245,8 @@ open class FakeAPI {
- parameter callback: (form) None (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -264,18 +255,17 @@ open class FakeAPI {
}
}
/**
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters
- POST /fake
- Fake endpoint for testing various parameters
- Fake endpoint for testing various parameters
- BASIC:
- type: http
- name: http_basic_test
- parameter number: (form) None
- parameter double: (form) None
- parameter patternWithoutDelimiter: (form) None
- parameter byte: (form) None
- type: http
- name: http_basic_test
- parameter number: (form) None
- parameter double: (form) None
- parameter patternWithoutDelimiter: (form) None
- parameter byte: (form) None
- parameter integer: (form) None (optional)
- parameter int32: (form) None (optional)
- parameter int64: (form) None (optional)
@ -286,12 +276,12 @@ open class FakeAPI {
- parameter dateTime: (form) None (optional)
- parameter password: (form) None (optional)
- parameter callback: (form) None (optional)
- returns: RequestBuilder<Void>
- returns: RequestBuilder<Void>
*/
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
let path = "/fake"
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"integer": integer?.encodeToJSON(),
"int32": int32?.encodeToJSON(),
"int64": int64?.encodeToJSON(),
@ -305,12 +295,12 @@ open class FakeAPI {
"date": date?.encodeToJSON(),
"dateTime": dateTime?.encodeToJSON(),
"password": password,
"callback": callback
"callback": callback,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -387,19 +377,19 @@ open class FakeAPI {
/**
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -408,42 +398,41 @@ open class FakeAPI {
}
}
/**
To test enum parameters
- GET /fake
- To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- returns: RequestBuilder<Void>
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: RequestBuilder<Void>
*/
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
let path = "/fake"
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"enum_form_string_array": enumFormStringArray,
"enum_form_string": enumFormString?.rawValue
"enum_form_string": enumFormString?.rawValue,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.rawValue,
"enum_query_double": enumQueryDouble?.rawValue
"enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.rawValue,
"enum_query_double": enumQueryDouble?.rawValue,
])
let nillableHeaders: [String: Any?] = [
"enum_header_string_array": enumHeaderStringArray,
"enum_header_string": enumHeaderString?.rawValue
"enum_header_string": enumHeaderString?.rawValue,
]
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
@ -454,12 +443,12 @@ open class FakeAPI {
/**
test inline additionalProperties
- parameter requestBody: (body) request body
- parameter requestBody: (body) request body
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testInlineAdditionalProperties(requestBody: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (response, error) -> Void in
open class func testInlineAdditionalProperties(requestBody: [String: String], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -468,14 +457,13 @@ open class FakeAPI {
}
}
/**
test inline additionalProperties
- POST /fake/inline-additionalProperties
- parameter requestBody: (body) request body
- returns: RequestBuilder<Void>
- parameter requestBody: (body) request body
- returns: RequestBuilder<Void>
*/
open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String:String]) -> RequestBuilder<Void> {
open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String: String]) -> RequestBuilder<Void> {
let path = "/fake/inline-additionalProperties"
let URLString = PetstoreClientAPI.basePath + path
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: requestBody)
@ -489,13 +477,13 @@ open class FakeAPI {
/**
test json serialization of form data
- parameter param: (form) field1
- parameter param2: (form) field2
- parameter param: (form) field1
- parameter param2: (form) field2
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -504,30 +492,28 @@ open class FakeAPI {
}
}
/**
test json serialization of form data
- GET /fake/jsonFormData
- parameter param: (form) field1
- parameter param2: (form) field2
- returns: RequestBuilder<Void>
- parameter param: (form) field1
- parameter param2: (form) field2
- returns: RequestBuilder<Void>
*/
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
let path = "/fake/jsonFormData"
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"param": param,
"param2": param2
"param2": param2,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
}

View File

@ -5,34 +5,31 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class FakeClassnameTags123API {
/**
To test class name in snake case
- parameter client: (body) client model
- parameter client: (body) client model
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testClassname(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
open class func testClassname(client: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
testClassnameWithRequestBuilder(client: client).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
To test class name in snake case
- PATCH /fake_classname_test
- To test class name in snake case
- API Key:
- type: apiKey api_key_query (QUERY)
- name: api_key_query
- parameter client: (body) client model
- returns: RequestBuilder<Client>
- type: apiKey api_key_query (QUERY)
- name: api_key_query
- parameter client: (body) client model
- returns: RequestBuilder<Client>
*/
open class func testClassnameWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
let path = "/fake_classname_test"
@ -45,5 +42,4 @@ open class FakeClassnameTags123API {
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
}
}

View File

@ -5,20 +5,18 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class PetAPI {
/**
Add a new pet to the store
- parameter pet: (body) Pet object that needs to be added to the store
- parameter pet: (body) Pet object that needs to be added to the store
- parameter completion: completion handler to receive the data and the error objects
*/
open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
addPetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
addPetWithRequestBuilder(pet: pet).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -27,15 +25,14 @@ open class PetAPI {
}
}
/**
Add a new pet to the store
- POST /pet
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter pet: (body) Pet object that needs to be added to the store
- returns: RequestBuilder<Void>
- type: oauth2
- name: petstore_auth
- parameter pet: (body) Pet object that needs to be added to the store
- returns: RequestBuilder<Void>
*/
open class func addPetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
let path = "/pet"
@ -51,13 +48,13 @@ open class PetAPI {
/**
Deletes a pet
- parameter petId: (path) Pet id to delete
- parameter petId: (path) Pet id to delete
- parameter apiKey: (header) (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -66,16 +63,15 @@ open class PetAPI {
}
}
/**
Deletes a pet
- DELETE /pet/{petId}
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter petId: (path) Pet id to delete
- type: oauth2
- name: petstore_auth
- parameter petId: (path) Pet id to delete
- parameter apiKey: (header) (optional)
- returns: RequestBuilder<Void>
- returns: RequestBuilder<Void>
*/
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
@ -83,11 +79,11 @@ open class PetAPI {
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let nillableHeaders: [String: Any?] = [
"api_key": apiKey
"api_key": apiKey,
]
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
@ -100,42 +96,41 @@ open class PetAPI {
* enum for parameter status
*/
public enum Status_findPetsByStatus: String {
case available = "available"
case pending = "pending"
case sold = "sold"
case available
case pending
case sold
}
/**
Finds Pets by status
- parameter status: (query) Status values that need to be considered for filter
- parameter status: (query) Status values that need to be considered for filter
- parameter completion: completion handler to receive the data and the error objects
*/
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Finds Pets by status
- GET /pet/findByStatus
- Multiple status values can be provided with comma separated strings
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter status: (query) Status values that need to be considered for filter
- returns: RequestBuilder<[Pet]>
- type: oauth2
- name: petstore_auth
- parameter status: (query) Status values that need to be considered for filter
- returns: RequestBuilder<[Pet]>
*/
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
let path = "/pet/findByStatus"
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"status": status
"status": status,
])
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -145,35 +140,34 @@ open class PetAPI {
/**
Finds Pets by tags
- parameter tags: (query) Tags to filter by
- parameter tags: (query) Tags to filter by
- parameter completion: completion handler to receive the data and the error objects
*/
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Finds Pets by tags
- GET /pet/findByTags
- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter tags: (query) Tags to filter by
- returns: RequestBuilder<[Pet]>
- type: oauth2
- name: petstore_auth
- parameter tags: (query) Tags to filter by
- returns: RequestBuilder<[Pet]>
*/
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
let path = "/pet/findByTags"
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"tags": tags
"tags": tags,
])
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -183,26 +177,25 @@ open class PetAPI {
/**
Find pet by ID
- parameter petId: (path) ID of pet to return
- parameter petId: (path) ID of pet to return
- parameter completion: completion handler to receive the data and the error objects
*/
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: Error?) -> Void)) {
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Find pet by ID
- GET /pet/{petId}
- Returns a single pet
- API Key:
- type: apiKey api_key
- name: api_key
- parameter petId: (path) ID of pet to return
- returns: RequestBuilder<Pet>
- type: apiKey api_key
- name: api_key
- parameter petId: (path) ID of pet to return
- returns: RequestBuilder<Pet>
*/
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
var path = "/pet/{petId}"
@ -210,8 +203,8 @@ open class PetAPI {
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -221,12 +214,12 @@ open class PetAPI {
/**
Update an existing pet
- parameter pet: (body) Pet object that needs to be added to the store
- parameter pet: (body) Pet object that needs to be added to the store
- parameter completion: completion handler to receive the data and the error objects
*/
open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
updatePetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
updatePetWithRequestBuilder(pet: pet).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -235,15 +228,14 @@ open class PetAPI {
}
}
/**
Update an existing pet
- PUT /pet
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter pet: (body) Pet object that needs to be added to the store
- returns: RequestBuilder<Void>
- type: oauth2
- name: petstore_auth
- parameter pet: (body) Pet object that needs to be added to the store
- returns: RequestBuilder<Void>
*/
open class func updatePetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
let path = "/pet"
@ -259,14 +251,14 @@ open class PetAPI {
/**
Updates a pet in the store with form data
- parameter petId: (path) ID of pet that needs to be updated
- parameter petId: (path) ID of pet that needs to be updated
- parameter name: (form) Updated name of the pet (optional)
- parameter status: (form) Updated status of the pet (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -275,17 +267,16 @@ open class PetAPI {
}
}
/**
Updates a pet in the store with form data
- POST /pet/{petId}
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet that needs to be updated
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet that needs to be updated
- parameter name: (form) Updated name of the pet (optional)
- parameter status: (form) Updated status of the pet (optional)
- returns: RequestBuilder<Void>
- returns: RequestBuilder<Void>
*/
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
var path = "/pet/{petId}"
@ -293,14 +284,14 @@ open class PetAPI {
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"name": name,
"status": status
"status": status,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -310,29 +301,28 @@ open class PetAPI {
/**
uploads an image
- parameter petId: (path) ID of pet to update
- parameter petId: (path) ID of pet to update
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
- parameter file: (form) file to upload (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
uploads an image
- POST /pet/{petId}/uploadImage
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet to update
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet to update
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
- parameter file: (form) file to upload (optional)
- returns: RequestBuilder<ApiResponse>
- returns: RequestBuilder<ApiResponse>
*/
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
var path = "/pet/{petId}/uploadImage"
@ -340,14 +330,14 @@ open class PetAPI {
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"additionalMetadata": additionalMetadata,
"file": file
"file": file,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -357,29 +347,28 @@ open class PetAPI {
/**
uploads an image (required)
- parameter petId: (path) ID of pet to update
- parameter requiredFile: (form) file to upload
- parameter petId: (path) ID of pet to update
- parameter requiredFile: (form) file to upload
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
uploads an image (required)
- POST /fake/{petId}/uploadImageWithRequiredFile
- OAuth:
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet to update
- parameter requiredFile: (form) file to upload
- type: oauth2
- name: petstore_auth
- parameter petId: (path) ID of pet to update
- parameter requiredFile: (form) file to upload
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
- returns: RequestBuilder<ApiResponse>
- returns: RequestBuilder<ApiResponse>
*/
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> RequestBuilder<ApiResponse> {
var path = "/fake/{petId}/uploadImageWithRequiredFile"
@ -387,19 +376,18 @@ open class PetAPI {
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let formParams: [String:Any?] = [
let formParams: [String: Any?] = [
"additionalMetadata": additionalMetadata,
"requiredFile": requiredFile
"requiredFile": requiredFile,
]
let nonNullParameters = APIHelper.rejectNil(formParams)
let parameters = APIHelper.convertBoolToString(nonNullParameters)
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
}

View File

@ -5,20 +5,18 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class StoreAPI {
/**
Delete purchase order by ID
- parameter orderId: (path) ID of the order that needs to be deleted
- parameter orderId: (path) ID of the order that needs to be deleted
- parameter completion: completion handler to receive the data and the error objects
*/
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
deleteOrderWithRequestBuilder(orderId: orderId).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -27,13 +25,12 @@ open class StoreAPI {
}
}
/**
Delete purchase order by ID
- DELETE /store/order/{order_id}
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- parameter orderId: (path) ID of the order that needs to be deleted
- returns: RequestBuilder<Void>
- parameter orderId: (path) ID of the order that needs to be deleted
- returns: RequestBuilder<Void>
*/
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{order_id}"
@ -41,8 +38,8 @@ open class StoreAPI {
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -52,56 +49,54 @@ open class StoreAPI {
/**
Returns pet inventories by status
- parameter completion: completion handler to receive the data and the error objects
*/
open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) {
open class func getInventory(completion: @escaping ((_ data: [String: Int]?, _ error: Error?) -> Void)) {
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Returns pet inventories by status
- GET /store/inventory
- Returns a map of status codes to quantities
- API Key:
- type: apiKey api_key
- name: api_key
- returns: RequestBuilder<[String:Int]>
- type: apiKey api_key
- name: api_key
- returns: RequestBuilder<[String:Int]>
*/
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String: Int]> {
let path = "/store/inventory"
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
let requestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
}
/**
Find purchase order by ID
- parameter orderId: (path) ID of pet that needs to be fetched
- parameter orderId: (path) ID of pet that needs to be fetched
- parameter completion: completion handler to receive the data and the error objects
*/
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Find purchase order by ID
- GET /store/order/{order_id}
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- parameter orderId: (path) ID of pet that needs to be fetched
- returns: RequestBuilder<Order>
- parameter orderId: (path) ID of pet that needs to be fetched
- returns: RequestBuilder<Order>
*/
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{order_id}"
@ -109,8 +104,8 @@ open class StoreAPI {
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -120,22 +115,21 @@ open class StoreAPI {
/**
Place an order for a pet
- parameter order: (body) order placed for purchasing the pet
- parameter order: (body) order placed for purchasing the pet
- parameter completion: completion handler to receive the data and the error objects
*/
open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
placeOrderWithRequestBuilder(order: order).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Place an order for a pet
- POST /store/order
- parameter order: (body) order placed for purchasing the pet
- returns: RequestBuilder<Order>
- parameter order: (body) order placed for purchasing the pet
- returns: RequestBuilder<Order>
*/
open class func placeOrderWithRequestBuilder(order: Order) -> RequestBuilder<Order> {
let path = "/store/order"
@ -148,5 +142,4 @@ open class StoreAPI {
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
}
}

View File

@ -5,20 +5,18 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class UserAPI {
/**
Create user
- parameter user: (body) Created user object
- parameter user: (body) Created user object
- parameter completion: completion handler to receive the data and the error objects
*/
open class func createUser(user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
createUserWithRequestBuilder(user: user).execute { (response, error) -> Void in
open class func createUser(user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
createUserWithRequestBuilder(user: user).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -27,13 +25,12 @@ open class UserAPI {
}
}
/**
Create user
- POST /user
- This can only be done by the logged in user.
- parameter user: (body) Created user object
- returns: RequestBuilder<Void>
- parameter user: (body) Created user object
- returns: RequestBuilder<Void>
*/
open class func createUserWithRequestBuilder(user: User) -> RequestBuilder<Void> {
let path = "/user"
@ -49,12 +46,12 @@ open class UserAPI {
/**
Creates list of users with given input array
- parameter user: (body) List of user object
- parameter user: (body) List of user object
- parameter completion: completion handler to receive the data and the error objects
*/
open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
createUsersWithArrayInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
createUsersWithArrayInputWithRequestBuilder(user: user).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -63,12 +60,11 @@ open class UserAPI {
}
}
/**
Creates list of users with given input array
- POST /user/createWithArray
- parameter user: (body) List of user object
- returns: RequestBuilder<Void>
- parameter user: (body) List of user object
- returns: RequestBuilder<Void>
*/
open class func createUsersWithArrayInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
let path = "/user/createWithArray"
@ -84,12 +80,12 @@ open class UserAPI {
/**
Creates list of users with given input array
- parameter user: (body) List of user object
- parameter user: (body) List of user object
- parameter completion: completion handler to receive the data and the error objects
*/
open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
createUsersWithListInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
createUsersWithListInputWithRequestBuilder(user: user).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -98,12 +94,11 @@ open class UserAPI {
}
}
/**
Creates list of users with given input array
- POST /user/createWithList
- parameter user: (body) List of user object
- returns: RequestBuilder<Void>
- parameter user: (body) List of user object
- returns: RequestBuilder<Void>
*/
open class func createUsersWithListInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
let path = "/user/createWithList"
@ -119,12 +114,12 @@ open class UserAPI {
/**
Delete user
- parameter username: (path) The name that needs to be deleted
- parameter username: (path) The name that needs to be deleted
- parameter completion: completion handler to receive the data and the error objects
*/
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
deleteUserWithRequestBuilder(username: username).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -133,13 +128,12 @@ open class UserAPI {
}
}
/**
Delete user
- DELETE /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) The name that needs to be deleted
- returns: RequestBuilder<Void>
- parameter username: (path) The name that needs to be deleted
- returns: RequestBuilder<Void>
*/
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
var path = "/user/{username}"
@ -147,8 +141,8 @@ open class UserAPI {
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -158,22 +152,21 @@ open class UserAPI {
/**
Get user by user name
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- parameter completion: completion handler to receive the data and the error objects
*/
open class func getUserByName(username: String, completion: @escaping ((_ data: User?,_ error: Error?) -> Void)) {
open class func getUserByName(username: String, completion: @escaping ((_ data: User?, _ error: Error?) -> Void)) {
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Get user by user name
- GET /user/{username}
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- returns: RequestBuilder<User>
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- returns: RequestBuilder<User>
*/
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
var path = "/user/{username}"
@ -181,8 +174,8 @@ open class UserAPI {
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -192,35 +185,34 @@ open class UserAPI {
/**
Logs user into the system
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- parameter completion: completion handler to receive the data and the error objects
*/
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
completion(response?.body, error)
}
}
/**
Logs user into the system
- GET /user/login
- responseHeaders: [X-Rate-Limit(Int), X-Expires-After(Date)]
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- returns: RequestBuilder<String>
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- returns: RequestBuilder<String>
*/
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
let path = "/user/login"
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
var url = URLComponents(string: URLString)
url?.queryItems = APIHelper.mapValuesToQueryItems([
"username": username,
"password": password
"username": username,
"password": password,
])
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
@ -230,11 +222,11 @@ open class UserAPI {
/**
Logs out current logged in user session
- parameter completion: completion handler to receive the data and the error objects
*/
open class func logoutUser(completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
open class func logoutUser(completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
logoutUserWithRequestBuilder().execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -243,17 +235,16 @@ open class UserAPI {
}
}
/**
Logs out current logged in user session
- GET /user/logout
- returns: RequestBuilder<Void>
- returns: RequestBuilder<Void>
*/
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
let path = "/user/logout"
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil
let parameters: [String: Any]? = nil
let url = URLComponents(string: URLString)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
@ -263,13 +254,13 @@ open class UserAPI {
/**
Updated user
- parameter username: (path) name that need to be deleted
- parameter user: (body) Updated user object
- parameter username: (path) name that need to be deleted
- parameter user: (body) Updated user object
- parameter completion: completion handler to receive the data and the error objects
*/
open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
updateUserWithRequestBuilder(username: username, user: user).execute { (response, error) -> Void in
open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
updateUserWithRequestBuilder(username: username, user: user).execute { (_, error) -> Void in
if error == nil {
completion((), error)
} else {
@ -278,14 +269,13 @@ open class UserAPI {
}
}
/**
Updated user
- PUT /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) name that need to be deleted
- parameter user: (body) Updated user object
- returns: RequestBuilder<Void>
- parameter username: (path) name that need to be deleted
- parameter user: (body) Updated user object
- returns: RequestBuilder<Void>
*/
open class func updateUserWithRequestBuilder(username: String, user: User) -> RequestBuilder<Void> {
var path = "/user/{username}"
@ -301,5 +291,4 @@ open class UserAPI {
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
}
}

View File

@ -4,53 +4,52 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
return AlamofireRequestBuilder<T>.self
}
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type {
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
return AlamofireDecodableRequestBuilder<T>.self
}
}
private struct SynchronizedDictionary<K: Hashable, V> {
private var dictionary = [K: V]()
private let queue = DispatchQueue(
label: "SynchronizedDictionary",
qos: DispatchQoS.userInitiated,
attributes: [DispatchQueue.Attributes.concurrent],
autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit,
target: nil
)
private var dictionary = [K: V]()
private let queue = DispatchQueue(
label: "SynchronizedDictionary",
qos: DispatchQoS.userInitiated,
attributes: [DispatchQueue.Attributes.concurrent],
autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit,
target: nil
)
public subscript(key: K) -> V? {
get {
var value: V?
public subscript(key: K) -> V? {
get {
var value: V?
queue.sync {
value = self.dictionary[key]
}
queue.sync {
value = self.dictionary[key]
}
return value
}
set {
queue.sync(flags: DispatchWorkItemFlags.barrier) {
self.dictionary[key] = newValue
}
}
}
}
return value
}
set {
queue.sync(flags: DispatchWorkItemFlags.barrier) {
self.dictionary[key] = newValue
}
}
}
}
// Store manager to retain its reference
private var managerStore = SynchronizedDictionary<String, Alamofire.SessionManager>()
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
public required init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
}
@ -71,7 +70,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
Return nil to use the default behavior (inferring the Content-Type from
the file extension). Return the desired Content-Type otherwise.
*/
open func contentTypeForFormPart(fileURL: URL) -> String? {
open func contentTypeForFormPart(fileURL _: URL) -> String? {
return nil
}
@ -79,21 +78,21 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
May be overridden by a subclass if you want to control the request
configuration (e.g. to override the cache policy).
*/
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest {
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) -> DataRequest {
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers)
}
override open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
let managerId:String = UUID().uuidString
open override func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
let managerId: String = UUID().uuidString
// Create a new manager for each request to customize its request header
let manager = createSessionManager()
managerStore[managerId] = manager
let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
let encoding: ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
let xMethod = Alamofire.HTTPMethod(rawValue: method)
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
.map { $0.0 }
.map { $0.0 }
if fileKeys.count > 0 {
manager.upload(multipartFormData: { mpForm in
@ -102,8 +101,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
case let fileURL as URL:
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
}
else {
} else {
mpForm.append(fileURL, withName: k)
}
case let string as String:
@ -114,14 +112,14 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
fatalError("Unprocessable value \(v) with key \(k)")
}
}
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
if let onProgressReady = self.onProgressReady {
onProgressReady(upload.uploadProgress)
}
self.processRequest(request: upload, managerId, completion)
case .failure(let encodingError):
case let .failure(encodingError):
completion(nil, ErrorResponse.error(415, nil, encodingError))
}
})
@ -132,7 +130,6 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
}
processRequest(request: request, managerId, completion)
}
}
fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
@ -148,7 +145,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
switch T.self {
case is String.Type:
validatedRequest.responseString(completionHandler: { (stringResponse) in
validatedRequest.responseString(completionHandler: { stringResponse in
cleanupRequest()
if stringResponse.result.isFailure {
@ -168,11 +165,10 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
)
})
case is URL.Type:
validatedRequest.responseData(completionHandler: { (dataResponse) in
validatedRequest.responseData(completionHandler: { dataResponse in
cleanupRequest()
do {
guard !dataResponse.result.isFailure else {
throw DownloadException.responseFailed
}
@ -218,7 +214,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
return
})
case is Void.Type:
validatedRequest.responseData(completionHandler: { (voidResponse) in
validatedRequest.responseData(completionHandler: { voidResponse in
cleanupRequest()
if voidResponse.result.isFailure {
@ -232,12 +228,13 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
completion(
Response(
response: voidResponse.response!,
body: nil),
body: nil
),
nil
)
})
default:
validatedRequest.responseData(completionHandler: { (dataResponse) in
validatedRequest.responseData(completionHandler: { dataResponse in
cleanupRequest()
if dataResponse.result.isFailure {
@ -261,24 +258,22 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
open func buildHeaders() -> [String: String] {
var httpHeaders = SessionManager.defaultHTTPHeaders
for (key, value) in self.headers {
for (key, value) in headers {
httpHeaders[key] = value
}
return httpHeaders
}
fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? {
fileprivate func getFileName(fromContentDisposition contentDisposition: String?) -> String? {
guard let contentDisposition = contentDisposition else {
return nil
}
let items = contentDisposition.components(separatedBy: ";")
var filename : String? = nil
var filename: String?
for contentItem in items {
let filenameKey = "filename="
guard let range = contentItem.range(of: filenameKey) else {
break
@ -286,17 +281,15 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
filename = contentItem
return filename?
.replacingCharacters(in: range, with:"")
.replacingCharacters(in: range, with: "")
.replacingOccurrences(of: "\"", with: "")
.trimmingCharacters(in: .whitespacesAndNewlines)
}
return filename
}
fileprivate func getPath(from url : URL) throws -> String {
fileprivate func getPath(from url: URL) throws -> String {
guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else {
throw DownloadException.requestMissingPath
}
@ -306,21 +299,18 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
}
return path
}
fileprivate func getURL(from urlRequest : URLRequest) throws -> URL {
fileprivate func getURL(from urlRequest: URLRequest) throws -> URL {
guard let url = urlRequest.url else {
throw DownloadException.requestMissingURL
}
return url
}
}
fileprivate enum DownloadException : Error {
fileprivate enum DownloadException: Error {
case responseDataMissing
case responseFailed
case requestMissing
@ -335,9 +325,8 @@ public enum AlamofireDecodableRequestBuilderError: Error {
case generalError(Error)
}
open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilder<T> {
override fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
open class AlamofireDecodableRequestBuilder<T: Decodable>: AlamofireRequestBuilder<T> {
fileprivate override func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
if let credential = self.credential {
request.authenticate(usingCredential: credential)
}
@ -350,7 +339,7 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
switch T.self {
case is String.Type:
validatedRequest.responseString(completionHandler: { (stringResponse) in
validatedRequest.responseString(completionHandler: { stringResponse in
cleanupRequest()
if stringResponse.result.isFailure {
@ -370,7 +359,7 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
)
})
case is Void.Type:
validatedRequest.responseData(completionHandler: { (voidResponse) in
validatedRequest.responseData(completionHandler: { voidResponse in
cleanupRequest()
if voidResponse.result.isFailure {
@ -384,12 +373,13 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
completion(
Response(
response: voidResponse.response!,
body: nil),
body: nil
),
nil
)
})
case is Data.Type:
validatedRequest.responseData(completionHandler: { (dataResponse) in
validatedRequest.responseData(completionHandler: { dataResponse in
cleanupRequest()
if dataResponse.result.isFailure {
@ -427,7 +417,7 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
return
}
var responseObj: Response<T>? = nil
var responseObj: Response<T>?
let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data)
if decodeResult.error == nil {
@ -438,5 +428,4 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
})
}
}
}

View File

@ -10,10 +10,9 @@ import Foundation
public typealias EncodeResult = (data: Data?, error: Error?)
open class CodableHelper {
open static var dateformatter: DateFormatter?
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T: Decodable {
var returnedDecodable: T? = nil
var returnedError: Error? = nil
@ -39,9 +38,9 @@ open class CodableHelper {
return (returnedDecodable, returnedError)
}
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable {
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T: Encodable {
var returnedData: Data?
var returnedError: Error? = nil
var returnedError: Error?
let encoder = JSONEncoder()
if prettyPrint {
@ -67,5 +66,4 @@ open class CodableHelper {
return (returnedData, returnedError)
}
}

View File

@ -7,9 +7,7 @@
import Foundation
open class Configuration {
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
// You must set it prior to encoding any dates, and it will only be read once.
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
// You must set it prior to encoding any dates, and it will only be read once.
open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
}
}

View File

@ -4,8 +4,8 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }
@ -45,7 +45,7 @@ private func encodeIfPossible<T>(_ object: T) -> Any {
extension Array: JSONEncodable {
func encodeToJSON() -> Any {
return self.map(encodeIfPossible)
return map(encodeIfPossible)
}
}
@ -61,7 +61,7 @@ extension Dictionary: JSONEncodable {
extension Data: JSONEncodable {
func encodeToJSON() -> Any {
return self.base64EncodedString(options: Data.Base64EncodingOptions())
return base64EncodedString(options: Data.Base64EncodingOptions())
}
}
@ -80,12 +80,11 @@ extension Date: JSONEncodable {
extension UUID: JSONEncodable {
func encodeToJSON() -> Any {
return self.uuidString
return uuidString
}
}
extension String: CodingKey {
public var stringValue: String {
return self
}
@ -98,42 +97,38 @@ extension String: CodingKey {
return nil
}
public init?(intValue: Int) {
public init?(intValue _: Int) {
return nil
}
}
extension KeyedEncodingContainerProtocol {
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T : Encodable {
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T: Encodable {
var arrayContainer = nestedUnkeyedContainer(forKey: key)
try arrayContainer.encode(contentsOf: values)
}
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T : Encodable {
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T: Encodable {
if let values = values {
try encodeArray(values, forKey: key)
}
}
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T : Encodable {
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T: Encodable {
for (key, value) in pairs {
try encode(value, forKey: key)
}
}
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T : Encodable {
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T: Encodable {
if let pairs = pairs {
try encodeMap(pairs)
}
}
}
extension KeyedDecodingContainerProtocol {
public func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T : Decodable {
public func decodeArray<T>(_: T.Type, forKey key: Self.Key) throws -> [T] where T: Decodable {
var tmpArray = [T]()
var nestedContainer = try nestedUnkeyedContainer(forKey: key)
@ -145,7 +140,7 @@ extension KeyedDecodingContainerProtocol {
return tmpArray
}
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable {
public func decodeArrayIfPresent<T>(_: T.Type, forKey key: Self.Key) throws -> [T]? where T: Decodable {
var tmpArray: [T]? = nil
if contains(key) {
@ -155,8 +150,8 @@ extension KeyedDecodingContainerProtocol {
return tmpArray
}
public func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T : Decodable {
var map: [Self.Key : T] = [:]
public func decodeMap<T>(_: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T: Decodable {
var map: [Self.Key: T] = [:]
for key in allKeys {
if !excludedKeys.contains(key) {
@ -167,7 +162,4 @@ extension KeyedDecodingContainerProtocol {
return map
}
}

View File

@ -5,11 +5,10 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
public struct JSONDataEncoding: ParameterEncoding {
// MARK: Properties
private static let jsonDataKey = "jsonData"
@ -42,7 +41,7 @@ public struct JSONDataEncoding: ParameterEncoding {
}
public static func encodingParameters(jsonData: Data?) -> Parameters? {
var returnedParams: Parameters? = nil
var returnedParams: Parameters?
if let jsonData = jsonData, !jsonData.isEmpty {
var params = Parameters()
params[jsonDataKey] = jsonData
@ -50,5 +49,4 @@ public struct JSONDataEncoding: ParameterEncoding {
}
return returnedParams
}
}

View File

@ -5,13 +5,12 @@
// https://openapi-generator.tech
//
import Foundation
import Alamofire
import Foundation
open class JSONEncodingHelper {
open class func encodingParameters<T:Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
var params: Parameters? = nil
open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
var params: Parameters?
// Encode the Encodable object
if let encodableObj = encodableObj {
@ -25,7 +24,7 @@ open class JSONEncodingHelper {
}
open class func encodingParameters(forEncodableObject encodableObj: Any?) -> Parameters? {
var params: Parameters? = nil
var params: Parameters?
if let encodableObj = encodableObj {
do {
@ -39,5 +38,4 @@ open class JSONEncodingHelper {
return params
}
}

View File

@ -10,7 +10,7 @@ protocol JSONEncodable {
func encodeToJSON() -> Any
}
public enum ErrorResponse : Error {
public enum ErrorResponse: Error {
case error(Int, Data?, Error)
}
@ -27,7 +27,7 @@ open class Response<T> {
public convenience init(response: HTTPURLResponse, body: T?) {
let rawHeader = response.allHeaderFields
var header = [String:String]()
var header = [String: String]()
for case let (key, value) as (String, String) in rawHeader {
header[key] = value
}

View File

@ -7,23 +7,17 @@
import Foundation
public struct AdditionalPropertiesClass: Codable {
public var mapProperty: [String: String]?
public var mapOfMapProperty: [String: [String: String]]?
public var mapProperty: [String:String]?
public var mapOfMapProperty: [String:[String:String]]?
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
public init(mapProperty: [String: String]?, mapOfMapProperty: [String: [String: String]]?) {
self.mapProperty = mapProperty
self.mapOfMapProperty = mapOfMapProperty
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case mapProperty = "map_property"
case mapOfMapProperty = "map_of_map_property"
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Animal: Codable {
public var className: String
public var color: String? = "red"
@ -18,7 +15,4 @@ public struct Animal: Codable {
self.className = className
self.color = color
}
}

View File

@ -7,5 +7,4 @@
import Foundation
public typealias AnimalFarm = [Animal]

View File

@ -7,10 +7,7 @@
import Foundation
public struct ApiResponse: Codable {
public var code: Int?
public var type: String?
public var message: String?
@ -20,7 +17,4 @@ public struct ApiResponse: Codable {
self.type = type
self.message = message
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct ArrayOfArrayOfNumberOnly: Codable {
public var arrayArrayNumber: [[Double]]?
public init(arrayArrayNumber: [[Double]]?) {
self.arrayArrayNumber = arrayArrayNumber
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case arrayArrayNumber = "ArrayArrayNumber"
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct ArrayOfNumberOnly: Codable {
public var arrayNumber: [Double]?
public init(arrayNumber: [Double]?) {
self.arrayNumber = arrayNumber
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case arrayNumber = "ArrayNumber"
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct ArrayTest: Codable {
public var arrayOfString: [String]?
public var arrayArrayOfInteger: [[Int64]]?
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
@ -21,12 +18,9 @@ public struct ArrayTest: Codable {
self.arrayArrayOfModel = arrayArrayOfModel
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case arrayOfString = "array_of_string"
case arrayArrayOfInteger = "array_array_of_integer"
case arrayArrayOfModel = "array_array_of_model"
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Capitalization: Codable {
public var smallCamel: String?
public var capitalCamel: String?
public var smallSnake: String?
@ -28,7 +25,7 @@ public struct Capitalization: Codable {
self.ATT_NAME = ATT_NAME
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case smallCamel
case capitalCamel = "CapitalCamel"
case smallSnake = "small_Snake"
@ -36,7 +33,4 @@ public struct Capitalization: Codable {
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
case ATT_NAME
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Cat: Codable {
public var className: String
public var color: String? = "red"
public var declawed: Bool?
@ -20,7 +17,4 @@ public struct Cat: Codable {
self.color = color
self.declawed = declawed
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Category: Codable {
public var _id: Int64?
public var name: String?
@ -19,11 +16,8 @@ public struct Category: Codable {
self.name = name
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _id = "id"
case name
}
}

View File

@ -7,17 +7,12 @@
import Foundation
/** Model for testing model with \&quot;_class\&quot; property */
public struct ClassModel: Codable {
public var _class: String?
public init(_class: String?) {
self._class = _class
}
}

View File

@ -7,16 +7,10 @@
import Foundation
public struct Client: Codable {
public var client: String?
public init(client: String?) {
self.client = client
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Dog: Codable {
public var className: String
public var color: String? = "red"
public var breed: String?
@ -20,7 +17,4 @@ public struct Dog: Codable {
self.color = color
self.breed = breed
}
}

View File

@ -7,18 +7,17 @@
import Foundation
public struct EnumArrays: Codable {
public enum JustSymbol: String, Codable {
case greaterThanOrEqualTo = ">="
case dollar = "$"
}
public enum ArrayEnum: String, Codable {
case fish = "fish"
case crab = "crab"
case fish
case crab
}
public var justSymbol: JustSymbol?
public var arrayEnum: [ArrayEnum]?
@ -27,11 +26,8 @@ public struct EnumArrays: Codable {
self.arrayEnum = arrayEnum
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case justSymbol = "just_symbol"
case arrayEnum = "array_enum"
}
}

View File

@ -7,7 +7,6 @@
import Foundation
public enum EnumClass: String, Codable {
case abc = "_abc"
case efg = "-efg"

View File

@ -7,28 +7,29 @@
import Foundation
public struct EnumTest: Codable {
public enum EnumString: String, Codable {
case upper = "UPPER"
case lower = "lower"
case lower
case empty = ""
}
public enum EnumStringRequired: String, Codable {
case upper = "UPPER"
case lower = "lower"
case lower
case empty = ""
}
public enum EnumInteger: Int, Codable {
case _1 = 1
case number1 = -1
}
public enum EnumNumber: Double, Codable {
case _11 = 1.1
case number12 = -1.2
}
public var enumString: EnumString?
public var enumStringRequired: EnumStringRequired
public var enumInteger: EnumInteger?
@ -43,14 +44,11 @@ public struct EnumTest: Codable {
self.outerEnum = outerEnum
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case enumString = "enum_string"
case enumStringRequired = "enum_string_required"
case enumInteger = "enum_integer"
case enumNumber = "enum_number"
case outerEnum
}
}

View File

@ -7,18 +7,13 @@
import Foundation
/** Must be named &#x60;File&#x60; for test. */
public struct File: Codable {
/** Test capitalization */
public var sourceURI: String?
public init(sourceURI: String?) {
self.sourceURI = sourceURI
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct FileSchemaTestClass: Codable {
public var file: File?
public var files: [File]?
@ -18,7 +15,4 @@ public struct FileSchemaTestClass: Codable {
self.file = file
self.files = files
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct FormatTest: Codable {
public var integer: Int?
public var int32: Int?
public var int64: Int64?
@ -40,7 +37,4 @@ public struct FormatTest: Codable {
self.uuid = uuid
self.password = password
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct HasOnlyReadOnly: Codable {
public var bar: String?
public var foo: String?
@ -18,7 +15,4 @@ public struct HasOnlyReadOnly: Codable {
self.bar = bar
self.foo = foo
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct List: Codable {
public var _123list: String?
public init(_123list: String?) {
self._123list = _123list
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _123list = "123-list"
}
}

View File

@ -7,33 +7,28 @@
import Foundation
public struct MapTest: Codable {
public enum MapOfEnumString: String, Codable {
case upper = "UPPER"
case lower = "lower"
case lower
}
public var mapMapOfString: [String:[String:String]]?
public var mapOfEnumString: [String:String]?
public var directMap: [String:Bool]?
public var mapMapOfString: [String: [String: String]]?
public var mapOfEnumString: [String: String]?
public var directMap: [String: Bool]?
public var indirectMap: StringBooleanMap?
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?, directMap: [String:Bool]?, indirectMap: StringBooleanMap?) {
public init(mapMapOfString: [String: [String: String]]?, mapOfEnumString: [String: String]?, directMap: [String: Bool]?, indirectMap: StringBooleanMap?) {
self.mapMapOfString = mapMapOfString
self.mapOfEnumString = mapOfEnumString
self.directMap = directMap
self.indirectMap = indirectMap
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case mapMapOfString = "map_map_of_string"
case mapOfEnumString = "map_of_enum_string"
case directMap = "direct_map"
case indirectMap = "indirect_map"
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
public var uuid: UUID?
public var dateTime: Date?
public var map: [String:Animal]?
public var map: [String: Animal]?
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
public init(uuid: UUID?, dateTime: Date?, map: [String: Animal]?) {
self.uuid = uuid
self.dateTime = dateTime
self.map = map
}
}

View File

@ -7,11 +7,9 @@
import Foundation
/** Model for testing model name starting with number */
public struct Model200Response: Codable {
public var name: Int?
public var _class: String?
@ -20,11 +18,8 @@ public struct Model200Response: Codable {
self._class = _class
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case name
case _class = "class"
}
}

View File

@ -7,11 +7,9 @@
import Foundation
/** Model for testing model name same as property name */
public struct Name: Codable {
public var name: Int
public var snakeCase: Int?
public var property: String?
@ -24,13 +22,10 @@ public struct Name: Codable {
self._123number = _123number
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case name
case snakeCase = "snake_case"
case property
case _123number = "123Number"
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct NumberOnly: Codable {
public var justNumber: Double?
public init(justNumber: Double?) {
self.justNumber = justNumber
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case justNumber = "JustNumber"
}
}

View File

@ -7,15 +7,13 @@
import Foundation
public struct Order: Codable {
public enum Status: String, Codable {
case placed = "placed"
case approved = "approved"
case delivered = "delivered"
case placed
case approved
case delivered
}
public var _id: Int64?
public var petId: Int64?
public var quantity: Int?
@ -33,7 +31,7 @@ public struct Order: Codable {
self.complete = complete
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _id = "id"
case petId
case quantity
@ -41,7 +39,4 @@ public struct Order: Codable {
case status
case complete
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct OuterComposite: Codable {
public var myNumber: Double?
public var myString: String?
public var myBoolean: Bool?
@ -21,12 +18,9 @@ public struct OuterComposite: Codable {
self.myBoolean = myBoolean
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case myNumber = "my_number"
case myString = "my_string"
case myBoolean = "my_boolean"
}
}

View File

@ -7,9 +7,8 @@
import Foundation
public enum OuterEnum: String, Codable {
case placed = "placed"
case approved = "approved"
case delivered = "delivered"
case placed
case approved
case delivered
}

View File

@ -7,15 +7,13 @@
import Foundation
public struct Pet: Codable {
public enum Status: String, Codable {
case available = "available"
case pending = "pending"
case sold = "sold"
case available
case pending
case sold
}
public var _id: Int64?
public var category: Category?
public var name: String
@ -33,7 +31,7 @@ public struct Pet: Codable {
self.status = status
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _id = "id"
case category
case name
@ -41,7 +39,4 @@ public struct Pet: Codable {
case tags
case status
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct ReadOnlyFirst: Codable {
public var bar: String?
public var baz: String?
@ -18,7 +15,4 @@ public struct ReadOnlyFirst: Codable {
self.bar = bar
self.baz = baz
}
}

View File

@ -7,21 +7,16 @@
import Foundation
/** Model for testing reserved words */
public struct Return: Codable {
public var _return: Int?
public init(_return: Int?) {
self._return = _return
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _return = "return"
}
}

View File

@ -7,20 +7,14 @@
import Foundation
public struct SpecialModelName: Codable {
public var specialPropertyName: Int64?
public init(specialPropertyName: Int64?) {
self.specialPropertyName = specialPropertyName
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case specialPropertyName = "$special[property.name]"
}
}

View File

@ -7,12 +7,8 @@
import Foundation
public struct StringBooleanMap: Codable {
public var additionalProperties: [String:Bool] = [:]
public var additionalProperties: [String: Bool] = [:]
public subscript(key: String) -> Bool? {
get {
@ -30,7 +26,6 @@ public struct StringBooleanMap: Codable {
// Encodable protocol methods
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: String.self)
try container.encodeMap(additionalProperties)
@ -44,8 +39,4 @@ public struct StringBooleanMap: Codable {
var nonAdditionalPropertyKeys = Set<String>()
additionalProperties = try container.decodeMap(Bool.self, excludedKeys: nonAdditionalPropertyKeys)
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct Tag: Codable {
public var _id: Int64?
public var name: String?
@ -19,11 +16,8 @@ public struct Tag: Codable {
self.name = name
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _id = "id"
case name
}
}

View File

@ -7,10 +7,7 @@
import Foundation
public struct User: Codable {
public var _id: Int64?
public var username: String?
public var firstName: String?
@ -32,7 +29,7 @@ public struct User: Codable {
self.userStatus = userStatus
}
public enum CodingKeys: String, CodingKey {
public enum CodingKeys: String, CodingKey {
case _id = "id"
case username
case firstName
@ -42,7 +39,4 @@ public struct User: Codable {
case phone
case userStatus
}
}

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -389,13 +389,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
@ -414,13 +414,13 @@ open class FakeAPI {
- GET /fake
- To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: RequestBuilder<Void>
*/
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {

View File

@ -47,13 +47,17 @@ open class CodableHelper {
if prettyPrint {
encoder.outputFormatting = .prettyPrinted
}
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
if let df = self.dateformatter {
encoder.dateEncodingStrategy = .formatted(df)
} else {
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
}
do {
returnedData = try encoder.encode(value)

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -534,13 +534,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
@ -557,13 +557,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: Promise<Void>
*/
open class func testEnumParameters( enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> Promise<Void> {
@ -583,13 +583,13 @@ open class FakeAPI {
- GET /fake
- To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: RequestBuilder<Void>
*/
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {

View File

@ -47,13 +47,17 @@ open class CodableHelper {
if prettyPrint {
encoder.outputFormatting = .prettyPrinted
}
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
if let df = self.dateformatter {
encoder.dateEncodingStrategy = .formatted(df)
} else {
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
}
do {
returnedData = try encoder.encode(value)

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -550,13 +550,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
@ -573,13 +573,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: Observable<Void>
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> Observable<Void> {
@ -601,13 +601,13 @@ open class FakeAPI {
- GET /fake
- To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: RequestBuilder<Void>
*/
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {

View File

@ -47,13 +47,17 @@ open class CodableHelper {
if prettyPrint {
encoder.outputFormatting = .prettyPrinted
}
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
if let df = self.dateformatter {
encoder.dateEncodingStrategy = .formatted(df)
} else {
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
}
do {
returnedData = try encoder.encode(value)

View File

@ -1 +1 @@
3.2.3-SNAPSHOT
3.3.0-SNAPSHOT

View File

@ -389,13 +389,13 @@ open class FakeAPI {
To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- parameter completion: completion handler to receive the data and the error objects
*/
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
@ -414,13 +414,13 @@ open class FakeAPI {
- GET /fake
- To test enum parameters
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to .-efg)
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to .$)
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
- returns: RequestBuilder<Void>
*/
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {

View File

@ -47,13 +47,17 @@ open class CodableHelper {
if prettyPrint {
encoder.outputFormatting = .prettyPrinted
}
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
if let df = self.dateformatter {
encoder.dateEncodingStrategy = .formatted(df)
} else {
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
}
do {
returnedData = try encoder.encode(value)