forked from loafle/openapi-generator-original
Update samples using latest codegen and templates (#7071)
This commit is contained in:
parent
80cc90c7c1
commit
d2a2292d20
48
bin/swift4-all.sh
Executable file
48
bin/swift4-all.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT="$0"
|
||||||
|
|
||||||
|
while [ -h "$SCRIPT" ] ; do
|
||||||
|
ls=`ls -ld "$SCRIPT"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
SCRIPT="$link"
|
||||||
|
else
|
||||||
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "${APP_DIR}" ]; then
|
||||||
|
APP_DIR=`dirname "$SCRIPT"`/..
|
||||||
|
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||||
|
|
||||||
|
if [ ! -f "$executable" ]
|
||||||
|
then
|
||||||
|
mvn clean package
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore.json -o samples/client/petstore/swift4/default"
|
||||||
|
|
||||||
|
echo "#### Petstore Swift API client (default) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-promisekit.json -o samples/client/petstore/swift4/promisekit"
|
||||||
|
echo "#### Petstore Swift API client (promisekit) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift"
|
||||||
|
echo "#### Petstore Swift API client (rxswift) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-objcCompatible.json -o samples/client/petstore/swift4/objcCompatible"
|
||||||
|
echo "#### Petstore Swift API client (objcCompatible) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/swift4Test.json -l swift4 -c ./bin/swift4-test.json -o samples/client/test/swift4/default"
|
||||||
|
echo "#### Swift4Test Swift API client (default) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -38,3 +38,7 @@ java $JAVA_OPTS -jar $executable $ags
|
|||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-rxswift.json -o samples/client/petstore/swift4/rxswift"
|
||||||
echo "#### Petstore Swift API client (rxswift) ####"
|
echo "#### Petstore Swift API client (rxswift) ####"
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|
||||||
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift4 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift4 -c ./bin/swift4-petstore-objcCompatible.json -o samples/client/petstore/swift4/objcCompatible"
|
||||||
|
echo "#### Petstore Swift API client (objcCompatible) ####"
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -1 +1 @@
|
|||||||
unset
|
2.3.0-SNAPSHOT
|
@ -2,6 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
s.name = 'PetstoreClient'
|
s.name = 'PetstoreClient'
|
||||||
s.ios.deployment_target = '9.0'
|
s.ios.deployment_target = '9.0'
|
||||||
s.osx.deployment_target = '10.11'
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
s.version = '0.0.1'
|
s.version = '0.0.1'
|
||||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
s.authors = ''
|
s.authors = ''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// AnotherFakeAPI.swift
|
// AnotherfakeAPI.swift
|
||||||
//
|
//
|
||||||
// Generated by swagger-codegen
|
// Generated by swagger-codegen
|
||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
@ -10,7 +10,7 @@ import Alamofire
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
open class AnotherFakeAPI {
|
open class AnotherfakeAPI {
|
||||||
/**
|
/**
|
||||||
To test special tags
|
To test special tags
|
||||||
|
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// Fake_classname_tags123API.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Fake_classname_tags123API {
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- PATCH /fake_classname_test
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key_query (QUERY)
|
||||||
|
- name: api_key_query
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake_classname_test"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
samples/client/petstore/swift4/objcCompatible/.gitignore
vendored
Normal file
63
samples/client/petstore/swift4/objcCompatible/.gitignore
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||||
|
|
||||||
|
## Build generated
|
||||||
|
build/
|
||||||
|
DerivedData
|
||||||
|
|
||||||
|
## Various settings
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
xcuserdata
|
||||||
|
|
||||||
|
## Other
|
||||||
|
*.xccheckout
|
||||||
|
*.moved-aside
|
||||||
|
*.xcuserstate
|
||||||
|
*.xcscmblueprint
|
||||||
|
|
||||||
|
## Obj-C/Swift specific
|
||||||
|
*.hmap
|
||||||
|
*.ipa
|
||||||
|
|
||||||
|
## Playgrounds
|
||||||
|
timeline.xctimeline
|
||||||
|
playground.xcworkspace
|
||||||
|
|
||||||
|
# Swift Package Manager
|
||||||
|
#
|
||||||
|
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||||
|
# Packages/
|
||||||
|
.build/
|
||||||
|
|
||||||
|
# CocoaPods
|
||||||
|
#
|
||||||
|
# We recommend against adding the Pods directory to your .gitignore. However
|
||||||
|
# you should judge for yourself, the pros and cons are mentioned at:
|
||||||
|
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||||
|
#
|
||||||
|
# Pods/
|
||||||
|
|
||||||
|
# Carthage
|
||||||
|
#
|
||||||
|
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||||
|
# Carthage/Checkouts
|
||||||
|
|
||||||
|
Carthage/Build
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
#
|
||||||
|
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||||
|
# screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
|
||||||
|
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/screenshots
|
@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1 @@
|
|||||||
|
2.3.0-SNAPSHOT
|
1
samples/client/petstore/swift4/objcCompatible/Cartfile
Normal file
1
samples/client/petstore/swift4/objcCompatible/Cartfile
Normal file
@ -0,0 +1 @@
|
|||||||
|
github "Alamofire/Alamofire" ~> 4.5.0
|
@ -0,0 +1,14 @@
|
|||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'PetstoreClient'
|
||||||
|
s.ios.deployment_target = '9.0'
|
||||||
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
|
s.version = '0.0.1'
|
||||||
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
|
s.authors = ''
|
||||||
|
s.license = 'Proprietary'
|
||||||
|
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
|
||||||
|
s.summary = 'PetstoreClient'
|
||||||
|
s.source_files = 'PetstoreClient/Classes/**/*.swift'
|
||||||
|
s.dependency 'Alamofire', '~> 4.5.0'
|
||||||
|
end
|
@ -0,0 +1,65 @@
|
|||||||
|
// APIHelper.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class APIHelper {
|
||||||
|
static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||||
|
var destination = [String:Any]()
|
||||||
|
for (key, nillableValue) in source {
|
||||||
|
if let value: Any = nillableValue {
|
||||||
|
destination[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if destination.isEmpty {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||||
|
var destination = [String:String]()
|
||||||
|
for (key, nillableValue) in source {
|
||||||
|
if let value: Any = nillableValue {
|
||||||
|
destination[key] = "\(value)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||||
|
guard let source = source else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var destination = [String:Any]()
|
||||||
|
let theTrue = NSNumber(value: true as Bool)
|
||||||
|
let theFalse = NSNumber(value: false as Bool)
|
||||||
|
for (key, value) in source {
|
||||||
|
switch value {
|
||||||
|
case let x where x as? NSNumber === theTrue || x as? NSNumber === theFalse:
|
||||||
|
destination[key] = "\(value as! Bool)" as Any?
|
||||||
|
default:
|
||||||
|
destination[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destination
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
|
let returnValues = values
|
||||||
|
.filter { $0.1 != nil }
|
||||||
|
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
||||||
|
URLQueryItem(name: item._key, value:"\(item._value!)")
|
||||||
|
}
|
||||||
|
if returnValues.count == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return returnValues
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
// APIs.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
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 requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class RequestBuilder<T> {
|
||||||
|
var credential: URLCredential?
|
||||||
|
var headers: [String:String]
|
||||||
|
let parameters: [String:Any]?
|
||||||
|
let isBody: Bool
|
||||||
|
let method: String
|
||||||
|
let URLString: String
|
||||||
|
|
||||||
|
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||||
|
public var onProgressReady: ((Progress) -> ())?
|
||||||
|
|
||||||
|
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||||
|
self.method = method
|
||||||
|
self.URLString = URLString
|
||||||
|
self.parameters = parameters
|
||||||
|
self.isBody = isBody
|
||||||
|
self.headers = headers
|
||||||
|
|
||||||
|
addHeaders(PetstoreClientAPI.customHeaders)
|
||||||
|
}
|
||||||
|
|
||||||
|
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) { }
|
||||||
|
|
||||||
|
public func addHeader(name: String, value: String) -> Self {
|
||||||
|
if !value.isEmpty {
|
||||||
|
headers[name] = value
|
||||||
|
}
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
open func addCredential() -> Self {
|
||||||
|
self.credential = PetstoreClientAPI.credential
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol RequestBuilderFactory {
|
||||||
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
|
||||||
|
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// AnotherfakeAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class AnotherfakeAPI {
|
||||||
|
/**
|
||||||
|
To test special tags
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testSpecialTags(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testSpecialTagsWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test special tags
|
||||||
|
- PATCH /another-fake/dummy
|
||||||
|
- To test special tags
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testSpecialTagsWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/another-fake/dummy"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,485 @@
|
|||||||
|
//
|
||||||
|
// FakeAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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: OuterBoolean? = nil, completion: @escaping ((_ data: OuterBoolean?,_ 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
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
|
||||||
|
- parameter body: (body) Input boolean as post body (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<OuterBoolean>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: OuterBoolean? = nil) -> RequestBuilder<OuterBoolean> {
|
||||||
|
let path = "/fake/outer/boolean"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterBoolean>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
- parameter body: (body) Input composite as post body (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
|
||||||
|
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
- POST /fake/outer/composite
|
||||||
|
- Test serialization of object with outer number type
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"my_string" : { },
|
||||||
|
"my_number" : { },
|
||||||
|
"my_boolean" : { }
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) Input composite as post body (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<OuterComposite>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||||
|
let path = "/fake/outer/composite"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
- 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: OuterNumber? = nil, completion: @escaping ((_ data: OuterNumber?,_ 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
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
|
||||||
|
- parameter body: (body) Input number as post body (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<OuterNumber>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterNumberSerializeWithRequestBuilder(body: OuterNumber? = nil) -> RequestBuilder<OuterNumber> {
|
||||||
|
let path = "/fake/outer/number"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterNumber>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
- 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: OuterString? = nil, completion: @escaping ((_ data: OuterString?,_ 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
|
||||||
|
- examples: [{contentType=application/json, example={ }}]
|
||||||
|
|
||||||
|
- parameter body: (body) Input string as post body (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<OuterString>
|
||||||
|
*/
|
||||||
|
open class func fakeOuterStringSerializeWithRequestBuilder(body: OuterString? = nil) -> RequestBuilder<OuterString> {
|
||||||
|
let path = "/fake/outer/string"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<OuterString>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test \"client\" model
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testClientModelWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test \"client\" model
|
||||||
|
- PATCH /fake
|
||||||
|
- To test \"client\" model
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClientModelWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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)
|
||||||
|
- parameter float: (form) None (optional)
|
||||||
|
- parameter string: (form) None (optional)
|
||||||
|
- parameter binary: (form) None (optional)
|
||||||
|
- parameter date: (form) None (optional)
|
||||||
|
- parameter dateTime: (form) None (optional)
|
||||||
|
- parameter password: (form) None (optional)
|
||||||
|
- 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: Data? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ 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
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
- POST /fake
|
||||||
|
- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
- BASIC:
|
||||||
|
- type: basic
|
||||||
|
- 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)
|
||||||
|
- parameter float: (form) None (optional)
|
||||||
|
- parameter string: (form) None (optional)
|
||||||
|
- parameter binary: (form) None (optional)
|
||||||
|
- parameter date: (form) None (optional)
|
||||||
|
- parameter dateTime: (form) None (optional)
|
||||||
|
- parameter password: (form) None (optional)
|
||||||
|
- parameter callback: (form) None (optional)
|
||||||
|
|
||||||
|
- 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: Data? = 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?] = [
|
||||||
|
"integer": integer?.encodeToJSON(),
|
||||||
|
"int32": int32?.encodeToJSON(),
|
||||||
|
"int64": int64?.encodeToJSON(),
|
||||||
|
"number": number,
|
||||||
|
"float": float,
|
||||||
|
"double": double,
|
||||||
|
"string": string,
|
||||||
|
"pattern_without_delimiter": patternWithoutDelimiter,
|
||||||
|
"byte": byte,
|
||||||
|
"binary": binary,
|
||||||
|
"date": date?.encodeToJSON(),
|
||||||
|
"dateTime": dateTime?.encodeToJSON(),
|
||||||
|
"password": password,
|
||||||
|
"callback": callback
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumFormStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumFormStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumFormString
|
||||||
|
*/
|
||||||
|
public enum EnumFormString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumHeaderStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumHeaderStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumHeaderString
|
||||||
|
*/
|
||||||
|
public enum EnumHeaderString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryStringArray
|
||||||
|
*/
|
||||||
|
public enum EnumQueryStringArray_testEnumParameters: String {
|
||||||
|
case greaterThan = ">"
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryString
|
||||||
|
*/
|
||||||
|
public enum EnumQueryString_testEnumParameters: String {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryInteger
|
||||||
|
*/
|
||||||
|
public enum EnumQueryInteger_testEnumParameters: Int {
|
||||||
|
case _1 = 1
|
||||||
|
case number2 = -2
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter enumQueryDouble
|
||||||
|
*/
|
||||||
|
public enum EnumQueryDouble_testEnumParameters: Double {
|
||||||
|
case _11 = 1.1
|
||||||
|
case number12 = -1.2
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test enum parameters
|
||||||
|
|
||||||
|
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional)
|
||||||
|
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||||
|
- 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 enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||||
|
- parameter enumQueryDouble: (form) Query parameter enum test (double) (optional)
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testEnumParameters(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
testEnumParametersWithRequestBuilder(enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test enum parameters
|
||||||
|
- GET /fake
|
||||||
|
- To test enum parameters
|
||||||
|
|
||||||
|
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional)
|
||||||
|
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to -efg)
|
||||||
|
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||||
|
- 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 enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||||
|
- parameter enumQueryDouble: (form) Query parameter enum test (double) (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func testEnumParametersWithRequestBuilder(enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||||
|
let path = "/fake"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"enum_form_string_array": enumFormStringArray,
|
||||||
|
"enum_form_string": enumFormString?.rawValue,
|
||||||
|
"enum_query_double": enumQueryDouble?.rawValue
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"enum_query_string_array": enumQueryStringArray,
|
||||||
|
"enum_query_string": enumQueryString?.rawValue,
|
||||||
|
"enum_query_integer": enumQueryInteger?.rawValue
|
||||||
|
])
|
||||||
|
|
||||||
|
let nillableHeaders: [String: Any?] = [
|
||||||
|
"enum_header_string_array": enumHeaderStringArray,
|
||||||
|
"enum_header_string": enumHeaderString?.rawValue
|
||||||
|
]
|
||||||
|
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
test inline additionalProperties
|
||||||
|
|
||||||
|
- parameter param: (body) request body
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testInlineAdditionalProperties(param: Any, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
test inline additionalProperties
|
||||||
|
- POST /fake/inline-additionalProperties
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter param: (body) request body
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: Any) -> RequestBuilder<Void> {
|
||||||
|
let path = "/fake/inline-additionalProperties"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
test json serialization of form data
|
||||||
|
|
||||||
|
- 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 ((_ error: Error?) -> Void)) {
|
||||||
|
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
test json serialization of form data
|
||||||
|
- GET /fake/jsonFormData
|
||||||
|
-
|
||||||
|
|
||||||
|
- 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?] = [
|
||||||
|
"param": param,
|
||||||
|
"param2": param2
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// Fake_classname_tags123API.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Fake_classname_tags123API {
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- PATCH /fake_classname_test
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key_query (QUERY)
|
||||||
|
- name: api_key_query
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake_classname_test"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,588 @@
|
|||||||
|
//
|
||||||
|
// PetAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class PetAPI {
|
||||||
|
/**
|
||||||
|
Add a new pet to the store
|
||||||
|
|
||||||
|
- parameter body: (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(body: Pet, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add a new pet to the store
|
||||||
|
- POST /pet
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func addPetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||||
|
let path = "/pet"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes a pet
|
||||||
|
|
||||||
|
- 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 ((_ error: Error?) -> Void)) {
|
||||||
|
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes a pet
|
||||||
|
- DELETE /pet/{petId}
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
|
||||||
|
- parameter petId: (path) Pet id to delete
|
||||||
|
- parameter apiKey: (header) (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
let nillableHeaders: [String: Any?] = [
|
||||||
|
"api_key": apiKey
|
||||||
|
]
|
||||||
|
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum for parameter status
|
||||||
|
*/
|
||||||
|
public enum Status_findPetsByStatus: String {
|
||||||
|
case available = "available"
|
||||||
|
case pending = "pending"
|
||||||
|
case sold = "sold"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by status
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}, {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}, {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
|
||||||
|
- 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 url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"status": status
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Finds Pets by tags
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}, {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example=[ {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}, {
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
} ]}]
|
||||||
|
|
||||||
|
- 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 url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"tags": tags
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find pet by ID
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example={
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Pet>
|
||||||
|
<id>123456789</id>
|
||||||
|
<name>doggie</name>
|
||||||
|
<photoUrls>
|
||||||
|
<photoUrls>aeiou</photoUrls>
|
||||||
|
</photoUrls>
|
||||||
|
<tags>
|
||||||
|
</tags>
|
||||||
|
<status>aeiou</status>
|
||||||
|
</Pet>}, {contentType=application/json, example={
|
||||||
|
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||||
|
"name" : "doggie",
|
||||||
|
"id" : 0,
|
||||||
|
"category" : {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 6
|
||||||
|
},
|
||||||
|
"tags" : [ {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
}, {
|
||||||
|
"name" : "name",
|
||||||
|
"id" : 1
|
||||||
|
} ],
|
||||||
|
"status" : "available"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter petId: (path) ID of pet to return
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Pet>
|
||||||
|
*/
|
||||||
|
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update an existing pet
|
||||||
|
|
||||||
|
- parameter body: (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(body: Pet, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update an existing pet
|
||||||
|
- PUT /pet
|
||||||
|
-
|
||||||
|
- OAuth:
|
||||||
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
|
||||||
|
- parameter body: (body) Pet object that needs to be added to the store
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updatePetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||||
|
let path = "/pet"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates a pet in the store with form data
|
||||||
|
|
||||||
|
- 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 ((_ error: Error?) -> Void)) {
|
||||||
|
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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
|
||||||
|
- parameter name: (form) Updated name of the pet (optional)
|
||||||
|
- parameter status: (form) Updated status of the pet (optional)
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
|
||||||
|
var path = "/pet/{petId}"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"name": name,
|
||||||
|
"status": status
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
uploads an image
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"code" : 0,
|
||||||
|
"type" : "type",
|
||||||
|
"message" : "message"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- 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>
|
||||||
|
*/
|
||||||
|
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||||
|
var path = "/pet/{petId}/uploadImage"
|
||||||
|
path = path.replacingOccurrences(of: "{petId}", with: "\(petId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let formParams: [String:Any?] = [
|
||||||
|
"additionalMetadata": additionalMetadata,
|
||||||
|
"file": file
|
||||||
|
]
|
||||||
|
|
||||||
|
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||||
|
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,219 @@
|
|||||||
|
//
|
||||||
|
// StoreAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class StoreAPI {
|
||||||
|
/**
|
||||||
|
Delete purchase order by ID
|
||||||
|
|
||||||
|
- 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 ((_ error: Error?) -> Void)) {
|
||||||
|
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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>
|
||||||
|
*/
|
||||||
|
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
|
||||||
|
var path = "/store/order/{order_id}"
|
||||||
|
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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)) {
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"key" : 0
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- returns: 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 url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
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 completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- 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}"
|
||||||
|
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Place an order for a pet
|
||||||
|
|
||||||
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||||
|
placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Place an order for a pet
|
||||||
|
- POST /store/order
|
||||||
|
-
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<Order>
|
||||||
|
<id>123456789</id>
|
||||||
|
<petId>123456789</petId>
|
||||||
|
<quantity>123</quantity>
|
||||||
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
|
<status>aeiou</status>
|
||||||
|
<complete>true</complete>
|
||||||
|
</Order>}, {contentType=application/json, example={
|
||||||
|
"petId" : 6,
|
||||||
|
"quantity" : 1,
|
||||||
|
"id" : 0,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : false,
|
||||||
|
"status" : "placed"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Order>
|
||||||
|
*/
|
||||||
|
open class func placeOrderWithRequestBuilder(body: Order) -> RequestBuilder<Order> {
|
||||||
|
let path = "/store/order"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,344 @@
|
|||||||
|
//
|
||||||
|
// UserAPI.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class UserAPI {
|
||||||
|
/**
|
||||||
|
Create user
|
||||||
|
|
||||||
|
- parameter body: (body) Created user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUser(body: User, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create user
|
||||||
|
- POST /user
|
||||||
|
- This can only be done by the logged in user.
|
||||||
|
|
||||||
|
- parameter body: (body) Created user object
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUserWithRequestBuilder(body: User) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUsersWithArrayInput(body: [User], completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- POST /user/createWithArray
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUsersWithArrayInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/createWithArray"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func createUsersWithListInput(body: [User], completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates list of users with given input array
|
||||||
|
- POST /user/createWithList
|
||||||
|
-
|
||||||
|
|
||||||
|
- parameter body: (body) List of user object
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func createUsersWithListInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/createWithList"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Delete user
|
||||||
|
|
||||||
|
- 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 ((_ error: Error?) -> Void)) {
|
||||||
|
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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>
|
||||||
|
*/
|
||||||
|
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
|
||||||
|
var path = "/user/{username}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get user by user name
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get user by user name
|
||||||
|
- GET /user/{username}
|
||||||
|
-
|
||||||
|
- examples: [{contentType=application/xml, example=<User>
|
||||||
|
<id>123456789</id>
|
||||||
|
<username>aeiou</username>
|
||||||
|
<firstName>aeiou</firstName>
|
||||||
|
<lastName>aeiou</lastName>
|
||||||
|
<email>aeiou</email>
|
||||||
|
<password>aeiou</password>
|
||||||
|
<phone>aeiou</phone>
|
||||||
|
<userStatus>123</userStatus>
|
||||||
|
</User>}, {contentType=application/json, example={
|
||||||
|
"firstName" : "firstName",
|
||||||
|
"lastName" : "lastName",
|
||||||
|
"password" : "password",
|
||||||
|
"userStatus" : 6,
|
||||||
|
"phone" : "phone",
|
||||||
|
"id" : 0,
|
||||||
|
"email" : "email",
|
||||||
|
"username" : "username"
|
||||||
|
}}]
|
||||||
|
- examples: [{contentType=application/xml, example=<User>
|
||||||
|
<id>123456789</id>
|
||||||
|
<username>aeiou</username>
|
||||||
|
<firstName>aeiou</firstName>
|
||||||
|
<lastName>aeiou</lastName>
|
||||||
|
<email>aeiou</email>
|
||||||
|
<password>aeiou</password>
|
||||||
|
<phone>aeiou</phone>
|
||||||
|
<userStatus>123</userStatus>
|
||||||
|
</User>}, {contentType=application/json, example={
|
||||||
|
"firstName" : "firstName",
|
||||||
|
"lastName" : "lastName",
|
||||||
|
"password" : "password",
|
||||||
|
"userStatus" : 6,
|
||||||
|
"phone" : "phone",
|
||||||
|
"id" : 0,
|
||||||
|
"email" : "email",
|
||||||
|
"username" : "username"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- 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}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs user into the system
|
||||||
|
|
||||||
|
- 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)) {
|
||||||
|
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)]
|
||||||
|
- responseHeaders: [X-Rate-Limit(Int), X-Expires-After(Date)]
|
||||||
|
- examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example=""}]
|
||||||
|
- examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example=""}]
|
||||||
|
|
||||||
|
- 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 url = NSURLComponents(string: URLString)
|
||||||
|
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||||
|
"username": username,
|
||||||
|
"password": password
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 ((_ error: Error?) -> Void)) {
|
||||||
|
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs out current logged in user session
|
||||||
|
- GET /user/logout
|
||||||
|
-
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||||
|
let path = "/user/logout"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters: [String:Any]? = nil
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updated user
|
||||||
|
|
||||||
|
- parameter username: (path) name that need to be deleted
|
||||||
|
- parameter body: (body) Updated user object
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func updateUser(username: String, body: User, completion: @escaping ((_ error: Error?) -> Void)) {
|
||||||
|
updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in
|
||||||
|
completion(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 body: (body) Updated user object
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Void>
|
||||||
|
*/
|
||||||
|
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
|
||||||
|
var path = "/user/{username}"
|
||||||
|
path = path.replacingOccurrences(of: "{username}", with: "\(username)", options: .literal, range: nil)
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,413 @@
|
|||||||
|
// AlamofireImplementations.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||||
|
return AlamofireRequestBuilder<T>.self
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type {
|
||||||
|
return AlamofireDecodableRequestBuilder<T>.self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store manager to retain its reference
|
||||||
|
private var managerStore: [String: Alamofire.SessionManager] = [:]
|
||||||
|
|
||||||
|
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
|
required public 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
May be overridden by a subclass if you want to control the session
|
||||||
|
configuration.
|
||||||
|
*/
|
||||||
|
open func createSessionManager() -> Alamofire.SessionManager {
|
||||||
|
let configuration = URLSessionConfiguration.default
|
||||||
|
configuration.httpAdditionalHeaders = buildHeaders()
|
||||||
|
return Alamofire.SessionManager(configuration: configuration)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
May be overridden by a subclass if you want to control the Content-Type
|
||||||
|
that is given to an uploaded form part.
|
||||||
|
|
||||||
|
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? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 {
|
||||||
|
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
|
||||||
|
// 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 xMethod = Alamofire.HTTPMethod(rawValue: method)
|
||||||
|
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
|
||||||
|
.map { $0.0 }
|
||||||
|
|
||||||
|
if fileKeys.count > 0 {
|
||||||
|
manager.upload(multipartFormData: { mpForm in
|
||||||
|
for (k, v) in self.parameters! {
|
||||||
|
switch v {
|
||||||
|
case let fileURL as URL:
|
||||||
|
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
|
||||||
|
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mpForm.append(fileURL, withName: k)
|
||||||
|
}
|
||||||
|
case let string as String:
|
||||||
|
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
|
||||||
|
case let number as NSNumber:
|
||||||
|
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
|
||||||
|
default:
|
||||||
|
fatalError("Unprocessable value \(v) with key \(k)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 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):
|
||||||
|
completion(nil, ErrorResponse.error(415, nil, encodingError))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
let request = makeRequest(manager: manager, method: xMethod!, encoding: encoding, headers: headers)
|
||||||
|
if let onProgressReady = self.onProgressReady {
|
||||||
|
onProgressReady(request.progress)
|
||||||
|
}
|
||||||
|
processRequest(request: request, managerId, completion)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||||
|
if let credential = self.credential {
|
||||||
|
request.authenticate(usingCredential: credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
let cleanupRequest = {
|
||||||
|
_ = managerStore.removeValue(forKey: managerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
let validatedRequest = request.validate()
|
||||||
|
|
||||||
|
switch T.self {
|
||||||
|
case is String.Type:
|
||||||
|
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if stringResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: stringResponse.response!,
|
||||||
|
body: ((stringResponse.result.value ?? "") as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case is URL.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
guard !dataResponse.result.isFailure else {
|
||||||
|
throw DownloadException.responseFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let data = dataResponse.data else {
|
||||||
|
throw DownloadException.responseDataMissing
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let request = request.request else {
|
||||||
|
throw DownloadException.requestMissing
|
||||||
|
}
|
||||||
|
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
let urlRequest = try request.asURLRequest()
|
||||||
|
let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||||
|
let requestURL = try self.getURL(from: urlRequest)
|
||||||
|
|
||||||
|
var requestPath = try self.getPath(from: requestURL)
|
||||||
|
|
||||||
|
if let headerFileName = self.getFileName(fromContentDisposition: dataResponse.response?.allHeaderFields["Content-Disposition"] as? String) {
|
||||||
|
requestPath = requestPath.appending("/\(headerFileName)")
|
||||||
|
}
|
||||||
|
|
||||||
|
let filePath = documentsDirectory.appendingPathComponent(requestPath)
|
||||||
|
let directoryPath = filePath.deletingLastPathComponent().path
|
||||||
|
|
||||||
|
try fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true, attributes: nil)
|
||||||
|
try data.write(to: filePath, options: .atomic)
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: dataResponse.response!,
|
||||||
|
body: (filePath as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
|
||||||
|
} catch let requestParserError as DownloadException {
|
||||||
|
completion(nil, ErrorResponse.error(400, dataResponse.data, requestParserError))
|
||||||
|
} catch let error {
|
||||||
|
completion(nil, ErrorResponse.error(400, dataResponse.data, error))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
})
|
||||||
|
case is Void.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if voidResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: voidResponse.response!,
|
||||||
|
body: nil),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if dataResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: dataResponse.response!,
|
||||||
|
body: (dataResponse.data as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open func buildHeaders() -> [String: String] {
|
||||||
|
var httpHeaders = SessionManager.defaultHTTPHeaders
|
||||||
|
for (key, value) in self.headers {
|
||||||
|
httpHeaders[key] = value
|
||||||
|
}
|
||||||
|
return httpHeaders
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? {
|
||||||
|
|
||||||
|
guard let contentDisposition = contentDisposition else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let items = contentDisposition.components(separatedBy: ";")
|
||||||
|
|
||||||
|
var filename : String? = nil
|
||||||
|
|
||||||
|
for contentItem in items {
|
||||||
|
|
||||||
|
let filenameKey = "filename="
|
||||||
|
guard let range = contentItem.range(of: filenameKey) else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = contentItem
|
||||||
|
return filename?
|
||||||
|
.replacingCharacters(in: range, with:"")
|
||||||
|
.replacingOccurrences(of: "\"", with: "")
|
||||||
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate func getPath(from url : URL) throws -> String {
|
||||||
|
|
||||||
|
guard var path = NSURLComponents(url: url, resolvingAgainstBaseURL: true)?.path else {
|
||||||
|
throw DownloadException.requestMissingPath
|
||||||
|
}
|
||||||
|
|
||||||
|
if path.hasPrefix("/") {
|
||||||
|
path.remove(at: path.startIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate func getURL(from urlRequest : URLRequest) throws -> URL {
|
||||||
|
|
||||||
|
guard let url = urlRequest.url else {
|
||||||
|
throw DownloadException.requestMissingURL
|
||||||
|
}
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fileprivate enum DownloadException : Error {
|
||||||
|
case responseDataMissing
|
||||||
|
case responseFailed
|
||||||
|
case requestMissing
|
||||||
|
case requestMissingPath
|
||||||
|
case requestMissingURL
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AlamofireDecodableRequestBuilderError: Error {
|
||||||
|
case emptyDataResponse
|
||||||
|
case nilHTTPResponse
|
||||||
|
case jsonDecoding(DecodingError)
|
||||||
|
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) {
|
||||||
|
if let credential = self.credential {
|
||||||
|
request.authenticate(usingCredential: credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
let cleanupRequest = {
|
||||||
|
_ = managerStore.removeValue(forKey: managerId)
|
||||||
|
}
|
||||||
|
|
||||||
|
let validatedRequest = request.validate()
|
||||||
|
|
||||||
|
switch T.self {
|
||||||
|
case is String.Type:
|
||||||
|
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if stringResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: stringResponse.response!,
|
||||||
|
body: ((stringResponse.result.value ?? "") as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case is Void.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if voidResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: voidResponse.response!,
|
||||||
|
body: nil),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
case is Data.Type:
|
||||||
|
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
if dataResponse.result.isFailure {
|
||||||
|
completion(
|
||||||
|
nil,
|
||||||
|
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(
|
||||||
|
Response(
|
||||||
|
response: dataResponse.response!,
|
||||||
|
body: (dataResponse.data as! T)
|
||||||
|
),
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
validatedRequest.responseData(completionHandler: { (dataResponse: DataResponse<Data>) in
|
||||||
|
cleanupRequest()
|
||||||
|
|
||||||
|
guard dataResponse.result.isSuccess else {
|
||||||
|
completion(nil, ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let data = dataResponse.data, !data.isEmpty else {
|
||||||
|
completion(nil, ErrorResponse.error(-1, nil, AlamofireDecodableRequestBuilderError.emptyDataResponse))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let httpResponse = dataResponse.response else {
|
||||||
|
completion(nil, ErrorResponse.error(-2, nil, AlamofireDecodableRequestBuilderError.nilHTTPResponse))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var responseObj: Response<T>? = nil
|
||||||
|
|
||||||
|
let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data)
|
||||||
|
if decodeResult.error == nil {
|
||||||
|
responseObj = Response(response: httpResponse, body: decodeResult.decodableObj)
|
||||||
|
}
|
||||||
|
|
||||||
|
completion(responseObj, decodeResult.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
//
|
||||||
|
// CodableHelper.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
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 {
|
||||||
|
var returnedDecodable: T? = nil
|
||||||
|
var returnedError: Error? = nil
|
||||||
|
|
||||||
|
let decoder = JSONDecoder()
|
||||||
|
if let df = self.dateformatter {
|
||||||
|
decoder.dateDecodingStrategy = .formatted(df)
|
||||||
|
} else {
|
||||||
|
decoder.dataDecodingStrategy = .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"
|
||||||
|
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
returnedDecodable = try decoder.decode(type, from: data)
|
||||||
|
} catch {
|
||||||
|
returnedError = error
|
||||||
|
}
|
||||||
|
|
||||||
|
return (returnedDecodable, returnedError)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable {
|
||||||
|
var returnedData: Data?
|
||||||
|
var returnedError: Error? = nil
|
||||||
|
|
||||||
|
let encoder = JSONEncoder()
|
||||||
|
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)
|
||||||
|
|
||||||
|
do {
|
||||||
|
returnedData = try encoder.encode(value)
|
||||||
|
} catch {
|
||||||
|
returnedError = error
|
||||||
|
}
|
||||||
|
|
||||||
|
return (returnedData, returnedError)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
// Configuration.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
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.
|
||||||
|
open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,173 @@
|
|||||||
|
// Extensions.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
extension Bool: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int32: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return NSNumber(value: self as Int32) }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int64: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return NSNumber(value: self as Int64) }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any { return self as Any }
|
||||||
|
}
|
||||||
|
|
||||||
|
private func encodeIfPossible<T>(_ object: T) -> Any {
|
||||||
|
if let encodableObject = object as? JSONEncodable {
|
||||||
|
return encodableObject.encodeToJSON()
|
||||||
|
} else {
|
||||||
|
return object as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.map(encodeIfPossible)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Dictionary: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
var dictionary = [AnyHashable: Any]()
|
||||||
|
for (key, value) in self {
|
||||||
|
dictionary[key] = encodeIfPossible(value)
|
||||||
|
}
|
||||||
|
return dictionary as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Data: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let dateFormatter: DateFormatter = {
|
||||||
|
let fmt = DateFormatter()
|
||||||
|
fmt.dateFormat = Configuration.dateFormat
|
||||||
|
fmt.locale = Locale(identifier: "en_US_POSIX")
|
||||||
|
return fmt
|
||||||
|
}()
|
||||||
|
|
||||||
|
extension Date: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return dateFormatter.string(from: self) as Any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UUID: JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any {
|
||||||
|
return self.uuidString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String: CodingKey {
|
||||||
|
|
||||||
|
public var stringValue: String {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public init?(stringValue: String) {
|
||||||
|
self.init(stringLiteral: stringValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var intValue: Int? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public init?(intValue: Int) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension KeyedEncodingContainerProtocol {
|
||||||
|
|
||||||
|
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 {
|
||||||
|
if let values = values {
|
||||||
|
try encodeArray(values, forKey: key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
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 {
|
||||||
|
var tmpArray = [T]()
|
||||||
|
|
||||||
|
var nestedContainer = try nestedUnkeyedContainer(forKey: key)
|
||||||
|
while !nestedContainer.isAtEnd {
|
||||||
|
let arrayValue = try nestedContainer.decode(T.self)
|
||||||
|
tmpArray.append(arrayValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmpArray
|
||||||
|
}
|
||||||
|
|
||||||
|
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable {
|
||||||
|
var tmpArray: [T]? = nil
|
||||||
|
|
||||||
|
if contains(key) {
|
||||||
|
tmpArray = try decodeArray(T.self, forKey: key)
|
||||||
|
}
|
||||||
|
|
||||||
|
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] = [:]
|
||||||
|
|
||||||
|
for key in allKeys {
|
||||||
|
if !excludedKeys.contains(key) {
|
||||||
|
let value = try decode(T.self, forKey: key)
|
||||||
|
map[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// JSONDataEncoding.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
public struct JSONDataEncoding: ParameterEncoding {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
private static let jsonDataKey = "jsonData"
|
||||||
|
|
||||||
|
// MARK: Encoding
|
||||||
|
|
||||||
|
/// Creates a URL request by encoding parameters and applying them onto an existing request.
|
||||||
|
///
|
||||||
|
/// - parameter urlRequest: The request to have parameters applied.
|
||||||
|
/// - parameter parameters: The parameters to apply. This should have a single key/value
|
||||||
|
/// pair with "jsonData" as the key and a Data object as the value.
|
||||||
|
///
|
||||||
|
/// - throws: An `Error` if the encoding process encounters an error.
|
||||||
|
///
|
||||||
|
/// - returns: The encoded request.
|
||||||
|
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
|
||||||
|
var urlRequest = try urlRequest.asURLRequest()
|
||||||
|
|
||||||
|
guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else {
|
||||||
|
return urlRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
|
||||||
|
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||||
|
}
|
||||||
|
|
||||||
|
urlRequest.httpBody = jsonData
|
||||||
|
|
||||||
|
return urlRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func encodingParameters(jsonData: Data?) -> Parameters? {
|
||||||
|
var returnedParams: Parameters? = nil
|
||||||
|
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||||
|
var params = Parameters()
|
||||||
|
params[jsonDataKey] = jsonData
|
||||||
|
returnedParams = params
|
||||||
|
}
|
||||||
|
return returnedParams
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// JSONEncodingHelper.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
open class JSONEncodingHelper {
|
||||||
|
|
||||||
|
open class func encodingParameters<T:Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
|
||||||
|
var params: Parameters? = nil
|
||||||
|
|
||||||
|
// Encode the Encodable object
|
||||||
|
if let encodableObj = encodableObj {
|
||||||
|
let encodeResult = CodableHelper.encode(encodableObj, prettyPrint: true)
|
||||||
|
if encodeResult.error == nil {
|
||||||
|
params = JSONDataEncoding.encodingParameters(jsonData: encodeResult.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
// Models.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol JSONEncodable {
|
||||||
|
func encodeToJSON() -> Any
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ErrorResponse : Error {
|
||||||
|
case error(Int, Data?, Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Response<T> {
|
||||||
|
open let statusCode: Int
|
||||||
|
open let header: [String: String]
|
||||||
|
open let body: T?
|
||||||
|
|
||||||
|
public init(statusCode: Int, header: [String: String], body: T?) {
|
||||||
|
self.statusCode = statusCode
|
||||||
|
self.header = header
|
||||||
|
self.body = body
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init(response: HTTPURLResponse, body: T?) {
|
||||||
|
let rawHeader = response.allHeaderFields
|
||||||
|
var header = [String:String]()
|
||||||
|
for case let (key, value) as (String, String) in rawHeader {
|
||||||
|
header[key] = value
|
||||||
|
}
|
||||||
|
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// AdditionalPropertiesClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class AdditionalPropertiesClass: Codable {
|
||||||
|
|
||||||
|
public var mapProperty: [String:String]?
|
||||||
|
public var mapOfMapProperty: [String:[String:String]]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
|
||||||
|
self.mapProperty = mapProperty
|
||||||
|
self.mapOfMapProperty = mapOfMapProperty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(mapProperty, forKey: "map_property")
|
||||||
|
try container.encodeIfPresent(mapOfMapProperty, forKey: "map_of_map_property")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
mapProperty = try container.decodeIfPresent([String:String].self, forKey: "map_property")
|
||||||
|
mapOfMapProperty = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_of_map_property")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Animal.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Animal: Codable {
|
||||||
|
|
||||||
|
public var className: String
|
||||||
|
public var color: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(className: String, color: String?) {
|
||||||
|
self.className = className
|
||||||
|
self.color = color
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encode(className, forKey: "className")
|
||||||
|
try container.encodeIfPresent(color, forKey: "color")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
className = try container.decode(String.self, forKey: "className")
|
||||||
|
color = try container.decodeIfPresent(String.self, forKey: "color")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// AnimalFarm.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public typealias AnimalFarm = [Animal]
|
@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// ApiResponse.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class ApiResponse: Codable {
|
||||||
|
|
||||||
|
public var code: Int?
|
||||||
|
public var codeNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return code.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var type: String?
|
||||||
|
public var message: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(code: Int?, type: String?, message: String?) {
|
||||||
|
self.code = code
|
||||||
|
self.type = type
|
||||||
|
self.message = message
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(code, forKey: "code")
|
||||||
|
try container.encodeIfPresent(type, forKey: "type")
|
||||||
|
try container.encodeIfPresent(message, forKey: "message")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
||||||
|
type = try container.decodeIfPresent(String.self, forKey: "type")
|
||||||
|
message = try container.decodeIfPresent(String.self, forKey: "message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// ArrayOfArrayOfNumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayOfArrayOfNumberOnly: Codable {
|
||||||
|
|
||||||
|
public var arrayArrayNumber: [[Double]]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayArrayNumber: [[Double]]?) {
|
||||||
|
self.arrayArrayNumber = arrayArrayNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(arrayArrayNumber, forKey: "ArrayArrayNumber")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
arrayArrayNumber = try container.decodeIfPresent([[Double]].self, forKey: "ArrayArrayNumber")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// ArrayOfNumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayOfNumberOnly: Codable {
|
||||||
|
|
||||||
|
public var arrayNumber: [Double]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayNumber: [Double]?) {
|
||||||
|
self.arrayNumber = arrayNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(arrayNumber, forKey: "ArrayNumber")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
arrayNumber = try container.decodeIfPresent([Double].self, forKey: "ArrayNumber")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// ArrayTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class ArrayTest: Codable {
|
||||||
|
|
||||||
|
public var arrayOfString: [String]?
|
||||||
|
public var arrayArrayOfInteger: [[Int64]]?
|
||||||
|
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
|
||||||
|
self.arrayOfString = arrayOfString
|
||||||
|
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||||
|
self.arrayArrayOfModel = arrayArrayOfModel
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(arrayOfString, forKey: "array_of_string")
|
||||||
|
try container.encodeIfPresent(arrayArrayOfInteger, forKey: "array_array_of_integer")
|
||||||
|
try container.encodeIfPresent(arrayArrayOfModel, forKey: "array_array_of_model")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
arrayOfString = try container.decodeIfPresent([String].self, forKey: "array_of_string")
|
||||||
|
arrayArrayOfInteger = try container.decodeIfPresent([[Int64]].self, forKey: "array_array_of_integer")
|
||||||
|
arrayArrayOfModel = try container.decodeIfPresent([[ReadOnlyFirst]].self, forKey: "array_array_of_model")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// Capitalization.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Capitalization: Codable {
|
||||||
|
|
||||||
|
public var smallCamel: String?
|
||||||
|
public var capitalCamel: String?
|
||||||
|
public var smallSnake: String?
|
||||||
|
public var capitalSnake: String?
|
||||||
|
public var sCAETHFlowPoints: String?
|
||||||
|
/** Name of the pet */
|
||||||
|
public var ATT_NAME: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
|
||||||
|
self.smallCamel = smallCamel
|
||||||
|
self.capitalCamel = capitalCamel
|
||||||
|
self.smallSnake = smallSnake
|
||||||
|
self.capitalSnake = capitalSnake
|
||||||
|
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||||
|
self.ATT_NAME = ATT_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(smallCamel, forKey: "smallCamel")
|
||||||
|
try container.encodeIfPresent(capitalCamel, forKey: "CapitalCamel")
|
||||||
|
try container.encodeIfPresent(smallSnake, forKey: "small_Snake")
|
||||||
|
try container.encodeIfPresent(capitalSnake, forKey: "Capital_Snake")
|
||||||
|
try container.encodeIfPresent(sCAETHFlowPoints, forKey: "SCA_ETH_Flow_Points")
|
||||||
|
try container.encodeIfPresent(ATT_NAME, forKey: "ATT_NAME")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
smallCamel = try container.decodeIfPresent(String.self, forKey: "smallCamel")
|
||||||
|
capitalCamel = try container.decodeIfPresent(String.self, forKey: "CapitalCamel")
|
||||||
|
smallSnake = try container.decodeIfPresent(String.self, forKey: "small_Snake")
|
||||||
|
capitalSnake = try container.decodeIfPresent(String.self, forKey: "Capital_Snake")
|
||||||
|
sCAETHFlowPoints = try container.decodeIfPresent(String.self, forKey: "SCA_ETH_Flow_Points")
|
||||||
|
ATT_NAME = try container.decodeIfPresent(String.self, forKey: "ATT_NAME")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// Cat.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Cat: Animal {
|
||||||
|
|
||||||
|
public var declawed: Bool?
|
||||||
|
public var declawedNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return declawed.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(declawed, forKey: "declawed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
declawed = try container.decodeIfPresent(Bool.self, forKey: "declawed")
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// Category.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Category: Codable {
|
||||||
|
|
||||||
|
public var id: Int64?
|
||||||
|
public var idNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return id.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var name: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?, name: String?) {
|
||||||
|
self.id = id
|
||||||
|
self.name = name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(id, forKey: "id")
|
||||||
|
try container.encodeIfPresent(name, forKey: "name")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||||
|
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// ClassModel.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model with \"_class\" property */
|
||||||
|
|
||||||
|
open class ClassModel: Codable {
|
||||||
|
|
||||||
|
public var _class: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(_class: String?) {
|
||||||
|
self._class = _class
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(_class, forKey: "_class")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
_class = try container.decodeIfPresent(String.self, forKey: "_class")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// Client.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Client: Codable {
|
||||||
|
|
||||||
|
public var client: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(client: String?) {
|
||||||
|
self.client = client
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(client, forKey: "client")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
client = try container.decodeIfPresent(String.self, forKey: "client")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// Dog.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Dog: Animal {
|
||||||
|
|
||||||
|
public var breed: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(breed, forKey: "breed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
breed = try container.decodeIfPresent(String.self, forKey: "breed")
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// EnumArrays.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class EnumArrays: Codable {
|
||||||
|
|
||||||
|
public enum JustSymbol: String, Codable {
|
||||||
|
case greaterThanOrEqualTo = ">="
|
||||||
|
case dollar = "$"
|
||||||
|
}
|
||||||
|
public enum ArrayEnum: String, Codable {
|
||||||
|
case fish = "fish"
|
||||||
|
case crab = "crab"
|
||||||
|
}
|
||||||
|
public var justSymbol: JustSymbol?
|
||||||
|
public var arrayEnum: [ArrayEnum]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
|
||||||
|
self.justSymbol = justSymbol
|
||||||
|
self.arrayEnum = arrayEnum
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(justSymbol, forKey: "just_symbol")
|
||||||
|
try container.encodeIfPresent(arrayEnum, forKey: "array_enum")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
justSymbol = try container.decodeIfPresent(JustSymbol.self, forKey: "just_symbol")
|
||||||
|
arrayEnum = try container.decodeIfPresent([ArrayEnum].self, forKey: "array_enum")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// EnumClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public enum EnumClass: String, Codable {
|
||||||
|
case abc = "_abc"
|
||||||
|
case efg = "-efg"
|
||||||
|
case xyz = "(xyz)"
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
//
|
||||||
|
// EnumTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class EnumTest: Codable {
|
||||||
|
|
||||||
|
public enum EnumString: String, Codable {
|
||||||
|
case upper = "UPPER"
|
||||||
|
case lower = "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 enumInteger: EnumInteger?
|
||||||
|
public var enumNumber: EnumNumber?
|
||||||
|
public var outerEnum: OuterEnum?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(enumString: EnumString?, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
|
||||||
|
self.enumString = enumString
|
||||||
|
self.enumInteger = enumInteger
|
||||||
|
self.enumNumber = enumNumber
|
||||||
|
self.outerEnum = outerEnum
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(enumString, forKey: "enum_string")
|
||||||
|
try container.encodeIfPresent(enumInteger, forKey: "enum_integer")
|
||||||
|
try container.encodeIfPresent(enumNumber, forKey: "enum_number")
|
||||||
|
try container.encodeIfPresent(outerEnum, forKey: "outerEnum")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
enumString = try container.decodeIfPresent(EnumString.self, forKey: "enum_string")
|
||||||
|
enumInteger = try container.decodeIfPresent(EnumInteger.self, forKey: "enum_integer")
|
||||||
|
enumNumber = try container.decodeIfPresent(EnumNumber.self, forKey: "enum_number")
|
||||||
|
outerEnum = try container.decodeIfPresent(OuterEnum.self, forKey: "outerEnum")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,118 @@
|
|||||||
|
//
|
||||||
|
// FormatTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class FormatTest: Codable {
|
||||||
|
|
||||||
|
public var integer: Int?
|
||||||
|
public var integerNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return integer.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var int32: Int?
|
||||||
|
public var int32Num: NSNumber? {
|
||||||
|
get {
|
||||||
|
return int32.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var int64: Int64?
|
||||||
|
public var int64Num: NSNumber? {
|
||||||
|
get {
|
||||||
|
return int64.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var number: Double
|
||||||
|
public var numberNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return number.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var float: Float?
|
||||||
|
public var floatNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return float.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var double: Double?
|
||||||
|
public var doubleNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return double.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var string: String?
|
||||||
|
public var byte: Data
|
||||||
|
public var binary: Data?
|
||||||
|
public var date: Date
|
||||||
|
public var dateTime: Date?
|
||||||
|
public var uuid: UUID?
|
||||||
|
public var password: String
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: Data?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
|
||||||
|
self.integer = integer
|
||||||
|
self.int32 = int32
|
||||||
|
self.int64 = int64
|
||||||
|
self.number = number
|
||||||
|
self.float = float
|
||||||
|
self.double = double
|
||||||
|
self.string = string
|
||||||
|
self.byte = byte
|
||||||
|
self.binary = binary
|
||||||
|
self.date = date
|
||||||
|
self.dateTime = dateTime
|
||||||
|
self.uuid = uuid
|
||||||
|
self.password = password
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(integer, forKey: "integer")
|
||||||
|
try container.encodeIfPresent(int32, forKey: "int32")
|
||||||
|
try container.encodeIfPresent(int64, forKey: "int64")
|
||||||
|
try container.encode(number, forKey: "number")
|
||||||
|
try container.encodeIfPresent(float, forKey: "float")
|
||||||
|
try container.encodeIfPresent(double, forKey: "double")
|
||||||
|
try container.encodeIfPresent(string, forKey: "string")
|
||||||
|
try container.encode(byte, forKey: "byte")
|
||||||
|
try container.encodeIfPresent(binary, forKey: "binary")
|
||||||
|
try container.encode(date, forKey: "date")
|
||||||
|
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||||
|
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||||
|
try container.encode(password, forKey: "password")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
integer = try container.decodeIfPresent(Int.self, forKey: "integer")
|
||||||
|
int32 = try container.decodeIfPresent(Int.self, forKey: "int32")
|
||||||
|
int64 = try container.decodeIfPresent(Int64.self, forKey: "int64")
|
||||||
|
number = try container.decode(Double.self, forKey: "number")
|
||||||
|
float = try container.decodeIfPresent(Float.self, forKey: "float")
|
||||||
|
double = try container.decodeIfPresent(Double.self, forKey: "double")
|
||||||
|
string = try container.decodeIfPresent(String.self, forKey: "string")
|
||||||
|
byte = try container.decode(Data.self, forKey: "byte")
|
||||||
|
binary = try container.decodeIfPresent(Data.self, forKey: "binary")
|
||||||
|
date = try container.decode(Date.self, forKey: "date")
|
||||||
|
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||||
|
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||||
|
password = try container.decode(String.self, forKey: "password")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// HasOnlyReadOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class HasOnlyReadOnly: Codable {
|
||||||
|
|
||||||
|
public var bar: String?
|
||||||
|
public var foo: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(bar: String?, foo: String?) {
|
||||||
|
self.bar = bar
|
||||||
|
self.foo = foo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(bar, forKey: "bar")
|
||||||
|
try container.encodeIfPresent(foo, forKey: "foo")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||||
|
foo = try container.decodeIfPresent(String.self, forKey: "foo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// List.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class List: Codable {
|
||||||
|
|
||||||
|
public var _123List: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(_123List: String?) {
|
||||||
|
self._123List = _123List
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(_123List, forKey: "123-list")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
_123List = try container.decodeIfPresent(String.self, forKey: "123-list")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// MapTest.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class MapTest: Codable {
|
||||||
|
|
||||||
|
public enum MapOfEnumString: String, Codable {
|
||||||
|
case upper = "UPPER"
|
||||||
|
case lower = "lower"
|
||||||
|
}
|
||||||
|
public var mapMapOfString: [String:[String:String]]?
|
||||||
|
public var mapOfEnumString: [String:String]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
|
||||||
|
self.mapMapOfString = mapMapOfString
|
||||||
|
self.mapOfEnumString = mapOfEnumString
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(mapMapOfString, forKey: "map_map_of_string")
|
||||||
|
try container.encodeIfPresent(mapOfEnumString, forKey: "map_of_enum_string")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
mapMapOfString = try container.decodeIfPresent([String:[String:String]].self, forKey: "map_map_of_string")
|
||||||
|
mapOfEnumString = try container.decodeIfPresent([String:String].self, forKey: "map_of_enum_string")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// MixedPropertiesAndAdditionalPropertiesClass.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||||
|
|
||||||
|
public var uuid: UUID?
|
||||||
|
public var dateTime: Date?
|
||||||
|
public var map: [String:Animal]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||||
|
self.uuid = uuid
|
||||||
|
self.dateTime = dateTime
|
||||||
|
self.map = map
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(uuid, forKey: "uuid")
|
||||||
|
try container.encodeIfPresent(dateTime, forKey: "dateTime")
|
||||||
|
try container.encodeIfPresent(map, forKey: "map")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
uuid = try container.decodeIfPresent(UUID.self, forKey: "uuid")
|
||||||
|
dateTime = try container.decodeIfPresent(Date.self, forKey: "dateTime")
|
||||||
|
map = try container.decodeIfPresent([String:Animal].self, forKey: "map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// Model200Response.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model name starting with number */
|
||||||
|
|
||||||
|
open class Model200Response: Codable {
|
||||||
|
|
||||||
|
public var name: Int?
|
||||||
|
public var nameNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return name.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var _class: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(name: Int?, _class: String?) {
|
||||||
|
self.name = name
|
||||||
|
self._class = _class
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(name, forKey: "name")
|
||||||
|
try container.encodeIfPresent(_class, forKey: "class")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
name = try container.decodeIfPresent(Int.self, forKey: "name")
|
||||||
|
_class = try container.decodeIfPresent(String.self, forKey: "class")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
|||||||
|
//
|
||||||
|
// Name.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing model name same as property name */
|
||||||
|
|
||||||
|
open class Name: Codable {
|
||||||
|
|
||||||
|
public var name: Int
|
||||||
|
public var nameNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return name.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var snakeCase: Int?
|
||||||
|
public var snakeCaseNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return snakeCase.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var property: String?
|
||||||
|
public var _123Number: Int?
|
||||||
|
public var _123NumberNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return _123Number.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(name: Int, snakeCase: Int?, property: String?, _123Number: Int?) {
|
||||||
|
self.name = name
|
||||||
|
self.snakeCase = snakeCase
|
||||||
|
self.property = property
|
||||||
|
self._123Number = _123Number
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encode(name, forKey: "name")
|
||||||
|
try container.encodeIfPresent(snakeCase, forKey: "snake_case")
|
||||||
|
try container.encodeIfPresent(property, forKey: "property")
|
||||||
|
try container.encodeIfPresent(_123Number, forKey: "123Number")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
name = try container.decode(Int.self, forKey: "name")
|
||||||
|
snakeCase = try container.decodeIfPresent(Int.self, forKey: "snake_case")
|
||||||
|
property = try container.decodeIfPresent(String.self, forKey: "property")
|
||||||
|
_123Number = try container.decodeIfPresent(Int.self, forKey: "123Number")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// NumberOnly.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class NumberOnly: Codable {
|
||||||
|
|
||||||
|
public var justNumber: Double?
|
||||||
|
public var justNumberNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return justNumber.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(justNumber: Double?) {
|
||||||
|
self.justNumber = justNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(justNumber, forKey: "JustNumber")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
justNumber = try container.decodeIfPresent(Double.self, forKey: "JustNumber")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
|||||||
|
//
|
||||||
|
// Order.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Order: Codable {
|
||||||
|
|
||||||
|
public enum Status: String, Codable {
|
||||||
|
case placed = "placed"
|
||||||
|
case approved = "approved"
|
||||||
|
case delivered = "delivered"
|
||||||
|
}
|
||||||
|
public var id: Int64?
|
||||||
|
public var idNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return id.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var petId: Int64?
|
||||||
|
public var petIdNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return petId.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var quantity: Int?
|
||||||
|
public var quantityNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return quantity.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var shipDate: Date?
|
||||||
|
/** Order Status */
|
||||||
|
public var status: Status?
|
||||||
|
public var complete: Bool?
|
||||||
|
public var completeNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return complete.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
|
||||||
|
self.id = id
|
||||||
|
self.petId = petId
|
||||||
|
self.quantity = quantity
|
||||||
|
self.shipDate = shipDate
|
||||||
|
self.status = status
|
||||||
|
self.complete = complete
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(id, forKey: "id")
|
||||||
|
try container.encodeIfPresent(petId, forKey: "petId")
|
||||||
|
try container.encodeIfPresent(quantity, forKey: "quantity")
|
||||||
|
try container.encodeIfPresent(shipDate, forKey: "shipDate")
|
||||||
|
try container.encodeIfPresent(status, forKey: "status")
|
||||||
|
try container.encodeIfPresent(complete, forKey: "complete")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||||
|
petId = try container.decodeIfPresent(Int64.self, forKey: "petId")
|
||||||
|
quantity = try container.decodeIfPresent(Int.self, forKey: "quantity")
|
||||||
|
shipDate = try container.decodeIfPresent(Date.self, forKey: "shipDate")
|
||||||
|
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||||
|
complete = try container.decodeIfPresent(Bool.self, forKey: "complete")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// OuterBoolean.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class OuterBoolean: Codable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// OuterComposite.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class OuterComposite: Codable {
|
||||||
|
|
||||||
|
public var myNumber: OuterNumber?
|
||||||
|
public var myString: OuterString?
|
||||||
|
public var myBoolean: OuterBoolean?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(myNumber: OuterNumber?, myString: OuterString?, myBoolean: OuterBoolean?) {
|
||||||
|
self.myNumber = myNumber
|
||||||
|
self.myString = myString
|
||||||
|
self.myBoolean = myBoolean
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(myNumber, forKey: "my_number")
|
||||||
|
try container.encodeIfPresent(myString, forKey: "my_string")
|
||||||
|
try container.encodeIfPresent(myBoolean, forKey: "my_boolean")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
myNumber = try container.decodeIfPresent(OuterNumber.self, forKey: "my_number")
|
||||||
|
myString = try container.decodeIfPresent(OuterString.self, forKey: "my_string")
|
||||||
|
myBoolean = try container.decodeIfPresent(OuterBoolean.self, forKey: "my_boolean")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// OuterEnum.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public enum OuterEnum: String, Codable {
|
||||||
|
case placed = "placed"
|
||||||
|
case approved = "approved"
|
||||||
|
case delivered = "delivered"
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// OuterNumber.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class OuterNumber: Codable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// OuterString.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class OuterString: Codable {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// Pet.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Pet: Codable {
|
||||||
|
|
||||||
|
public enum Status: String, Codable {
|
||||||
|
case available = "available"
|
||||||
|
case pending = "pending"
|
||||||
|
case sold = "sold"
|
||||||
|
}
|
||||||
|
public var id: Int64?
|
||||||
|
public var idNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return id.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var category: Category?
|
||||||
|
public var name: String
|
||||||
|
public var photoUrls: [String]
|
||||||
|
public var tags: [Tag]?
|
||||||
|
/** pet status in the store */
|
||||||
|
public var status: Status?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
|
||||||
|
self.id = id
|
||||||
|
self.category = category
|
||||||
|
self.name = name
|
||||||
|
self.photoUrls = photoUrls
|
||||||
|
self.tags = tags
|
||||||
|
self.status = status
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(id, forKey: "id")
|
||||||
|
try container.encodeIfPresent(category, forKey: "category")
|
||||||
|
try container.encode(name, forKey: "name")
|
||||||
|
try container.encode(photoUrls, forKey: "photoUrls")
|
||||||
|
try container.encodeIfPresent(tags, forKey: "tags")
|
||||||
|
try container.encodeIfPresent(status, forKey: "status")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||||
|
category = try container.decodeIfPresent(Category.self, forKey: "category")
|
||||||
|
name = try container.decode(String.self, forKey: "name")
|
||||||
|
photoUrls = try container.decode([String].self, forKey: "photoUrls")
|
||||||
|
tags = try container.decodeIfPresent([Tag].self, forKey: "tags")
|
||||||
|
status = try container.decodeIfPresent(Status.self, forKey: "status")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// ReadOnlyFirst.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class ReadOnlyFirst: Codable {
|
||||||
|
|
||||||
|
public var bar: String?
|
||||||
|
public var baz: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(bar: String?, baz: String?) {
|
||||||
|
self.bar = bar
|
||||||
|
self.baz = baz
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(bar, forKey: "bar")
|
||||||
|
try container.encodeIfPresent(baz, forKey: "baz")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
bar = try container.decodeIfPresent(String.self, forKey: "bar")
|
||||||
|
baz = try container.decodeIfPresent(String.self, forKey: "baz")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// Return.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/** Model for testing reserved words */
|
||||||
|
|
||||||
|
open class Return: Codable {
|
||||||
|
|
||||||
|
public var _return: Int?
|
||||||
|
public var _returnNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return _return.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(_return: Int?) {
|
||||||
|
self._return = _return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(_return, forKey: "return")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
_return = try container.decodeIfPresent(Int.self, forKey: "return")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// SpecialModelName.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class SpecialModelName: Codable {
|
||||||
|
|
||||||
|
public var specialPropertyName: Int64?
|
||||||
|
public var specialPropertyNameNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return specialPropertyName.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(specialPropertyName: Int64?) {
|
||||||
|
self.specialPropertyName = specialPropertyName
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(specialPropertyName, forKey: "$special[property.name]")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
specialPropertyName = try container.decodeIfPresent(Int64.self, forKey: "$special[property.name]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// Tag.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Tag: Codable {
|
||||||
|
|
||||||
|
public var id: Int64?
|
||||||
|
public var idNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return id.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var name: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?, name: String?) {
|
||||||
|
self.id = id
|
||||||
|
self.name = name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(id, forKey: "id")
|
||||||
|
try container.encodeIfPresent(name, forKey: "name")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||||
|
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
|||||||
|
//
|
||||||
|
// User.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class User: Codable {
|
||||||
|
|
||||||
|
public var id: Int64?
|
||||||
|
public var idNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return id.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var username: String?
|
||||||
|
public var firstName: String?
|
||||||
|
public var lastName: String?
|
||||||
|
public var email: String?
|
||||||
|
public var password: String?
|
||||||
|
public var phone: String?
|
||||||
|
/** User Status */
|
||||||
|
public var userStatus: Int?
|
||||||
|
public var userStatusNum: NSNumber? {
|
||||||
|
get {
|
||||||
|
return userStatus.map({ return NSNumber(value: $0) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public init(id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
|
||||||
|
self.id = id
|
||||||
|
self.username = username
|
||||||
|
self.firstName = firstName
|
||||||
|
self.lastName = lastName
|
||||||
|
self.email = email
|
||||||
|
self.password = password
|
||||||
|
self.phone = phone
|
||||||
|
self.userStatus = userStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Encodable protocol methods
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
try container.encodeIfPresent(id, forKey: "id")
|
||||||
|
try container.encodeIfPresent(username, forKey: "username")
|
||||||
|
try container.encodeIfPresent(firstName, forKey: "firstName")
|
||||||
|
try container.encodeIfPresent(lastName, forKey: "lastName")
|
||||||
|
try container.encodeIfPresent(email, forKey: "email")
|
||||||
|
try container.encodeIfPresent(password, forKey: "password")
|
||||||
|
try container.encodeIfPresent(phone, forKey: "phone")
|
||||||
|
try container.encodeIfPresent(userStatus, forKey: "userStatus")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decodable protocol methods
|
||||||
|
|
||||||
|
public required init(from decoder: Decoder) throws {
|
||||||
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
|
id = try container.decodeIfPresent(Int64.self, forKey: "id")
|
||||||
|
username = try container.decodeIfPresent(String.self, forKey: "username")
|
||||||
|
firstName = try container.decodeIfPresent(String.self, forKey: "firstName")
|
||||||
|
lastName = try container.decodeIfPresent(String.self, forKey: "lastName")
|
||||||
|
email = try container.decodeIfPresent(String.self, forKey: "email")
|
||||||
|
password = try container.decodeIfPresent(String.self, forKey: "password")
|
||||||
|
phone = try container.decodeIfPresent(String.self, forKey: "phone")
|
||||||
|
userStatus = try container.decodeIfPresent(Int.self, forKey: "userStatus")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
52
samples/client/petstore/swift4/objcCompatible/git_push.sh
Normal file
52
samples/client/petstore/swift4/objcCompatible/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
@ -1 +1 @@
|
|||||||
unset
|
2.3.0-SNAPSHOT
|
@ -2,6 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
s.name = 'PetstoreClient'
|
s.name = 'PetstoreClient'
|
||||||
s.ios.deployment_target = '9.0'
|
s.ios.deployment_target = '9.0'
|
||||||
s.osx.deployment_target = '10.11'
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
s.version = '0.0.1'
|
s.version = '0.0.1'
|
||||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
s.authors = ''
|
s.authors = ''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// AnotherFakeAPI.swift
|
// AnotherfakeAPI.swift
|
||||||
//
|
//
|
||||||
// Generated by swagger-codegen
|
// Generated by swagger-codegen
|
||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
@ -11,7 +11,7 @@ import PromiseKit
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
open class AnotherFakeAPI {
|
open class AnotherfakeAPI {
|
||||||
/**
|
/**
|
||||||
To test special tags
|
To test special tags
|
||||||
|
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// Fake_classname_tags123API.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
import PromiseKit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Fake_classname_tags123API {
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- returns: Promise<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassname( body: Client) -> Promise<Client> {
|
||||||
|
let deferred = Promise<Client>.pending()
|
||||||
|
testClassname(body: body) { data, error in
|
||||||
|
if let error = error {
|
||||||
|
deferred.reject(error)
|
||||||
|
} else {
|
||||||
|
deferred.fulfill(data!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deferred.promise
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- PATCH /fake_classname_test
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key_query (QUERY)
|
||||||
|
- name: api_key_query
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake_classname_test"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
unset
|
2.3.0-SNAPSHOT
|
@ -2,6 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
s.name = 'PetstoreClient'
|
s.name = 'PetstoreClient'
|
||||||
s.ios.deployment_target = '9.0'
|
s.ios.deployment_target = '9.0'
|
||||||
s.osx.deployment_target = '10.11'
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
s.version = '0.0.1'
|
s.version = '0.0.1'
|
||||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
s.authors = ''
|
s.authors = ''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// AnotherFakeAPI.swift
|
// AnotherfakeAPI.swift
|
||||||
//
|
//
|
||||||
// Generated by swagger-codegen
|
// Generated by swagger-codegen
|
||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
@ -11,7 +11,7 @@ import RxSwift
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
open class AnotherFakeAPI {
|
open class AnotherfakeAPI {
|
||||||
/**
|
/**
|
||||||
To test special tags
|
To test special tags
|
||||||
|
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
//
|
||||||
|
// Fake_classname_tags123API.swift
|
||||||
|
//
|
||||||
|
// Generated by swagger-codegen
|
||||||
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Alamofire
|
||||||
|
import RxSwift
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
open class Fake_classname_tags123API {
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- parameter completion: completion handler to receive the data and the error objects
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||||
|
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||||
|
completion(response?.body, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
- returns: Observable<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassname(body: Client) -> Observable<Client> {
|
||||||
|
return Observable.create { observer -> Disposable in
|
||||||
|
testClassname(body: body) { data, error in
|
||||||
|
if let error = error {
|
||||||
|
observer.on(.error(error))
|
||||||
|
} else {
|
||||||
|
observer.on(.next(data!))
|
||||||
|
}
|
||||||
|
observer.on(.completed)
|
||||||
|
}
|
||||||
|
return Disposables.create()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
To test class name in snake case
|
||||||
|
- PATCH /fake_classname_test
|
||||||
|
- API Key:
|
||||||
|
- type: apiKey api_key_query (QUERY)
|
||||||
|
- name: api_key_query
|
||||||
|
- examples: [{contentType=application/json, example={
|
||||||
|
"client" : "client"
|
||||||
|
}}]
|
||||||
|
|
||||||
|
- parameter body: (body) client model
|
||||||
|
|
||||||
|
- returns: RequestBuilder<Client>
|
||||||
|
*/
|
||||||
|
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||||
|
let path = "/fake_classname_test"
|
||||||
|
let URLString = PetstoreClientAPI.basePath + path
|
||||||
|
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||||
|
|
||||||
|
let url = NSURLComponents(string: URLString)
|
||||||
|
|
||||||
|
|
||||||
|
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||||
|
|
||||||
|
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
github "Alamofire/Alamofire" >= 3.1.0
|
github "Alamofire/Alamofire" ~> 4.5.0
|
||||||
|
@ -2,6 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
s.name = 'TestClient'
|
s.name = 'TestClient'
|
||||||
s.ios.deployment_target = '9.0'
|
s.ios.deployment_target = '9.0'
|
||||||
s.osx.deployment_target = '10.11'
|
s.osx.deployment_target = '10.11'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
s.version = '0.0.1'
|
s.version = '0.0.1'
|
||||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||||
s.authors = ''
|
s.authors = ''
|
||||||
|
@ -11,14 +11,23 @@ public typealias EncodeResult = (data: Data?, error: Error?)
|
|||||||
|
|
||||||
open class CodableHelper {
|
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 returnedDecodable: T? = nil
|
||||||
var returnedError: Error? = nil
|
var returnedError: Error? = nil
|
||||||
|
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
decoder.dataDecodingStrategy = .base64
|
if let df = self.dateformatter {
|
||||||
if #available(iOS 10.0, *) {
|
decoder.dateDecodingStrategy = .formatted(df)
|
||||||
decoder.dateDecodingStrategy = .iso8601
|
} else {
|
||||||
|
decoder.dataDecodingStrategy = .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"
|
||||||
|
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -39,9 +48,12 @@ open class CodableHelper {
|
|||||||
encoder.outputFormatting = .prettyPrinted
|
encoder.outputFormatting = .prettyPrinted
|
||||||
}
|
}
|
||||||
encoder.dataEncodingStrategy = .base64
|
encoder.dataEncodingStrategy = .base64
|
||||||
if #available(iOS 10.0, *) {
|
let formatter = DateFormatter()
|
||||||
encoder.dateEncodingStrategy = .iso8601
|
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 {
|
do {
|
||||||
returnedData = try encoder.encode(value)
|
returnedData = try encoder.encode(value)
|
||||||
|
@ -44,7 +44,8 @@ open class AllPrimitives: Codable {
|
|||||||
public var myInlineStringEnum: MyInlineStringEnum?
|
public var myInlineStringEnum: MyInlineStringEnum?
|
||||||
|
|
||||||
|
|
||||||
public init(myInteger: Int?, myIntegerArray: [Int]?, myLong: Int64?, myLongArray: [Int64]?, myFloat: Float?, myFloatArray: [Float]?, myDouble: Double?, myDoubleArray: [Double]?, myString: String?, myStringArray: [String]?, myBytes: Data?, myBytesArray: [Data]?, myBoolean: Bool?, myBooleanArray: [Bool]?, myDate: Date?, myDateArray: [Date]?, myDateTime: Date?, myDateTimeArray: [Date]?, myFile: URL?, myFileArray: [URL]?, myUUID: UUID?, myUUIDArray: [UUID]?, myStringEnum: StringEnum?, myStringEnumArray: [StringEnum]?) {
|
|
||||||
|
public init(myInteger: Int?, myIntegerArray: [Int]?, myLong: Int64?, myLongArray: [Int64]?, myFloat: Float?, myFloatArray: [Float]?, myDouble: Double?, myDoubleArray: [Double]?, myString: String?, myStringArray: [String]?, myBytes: Data?, myBytesArray: [Data]?, myBoolean: Bool?, myBooleanArray: [Bool]?, myDate: Date?, myDateArray: [Date]?, myDateTime: Date?, myDateTimeArray: [Date]?, myFile: URL?, myFileArray: [URL]?, myUUID: UUID?, myUUIDArray: [UUID]?, myStringEnum: StringEnum?, myStringEnumArray: [StringEnum]?, myInlineStringEnum: MyInlineStringEnum?) {
|
||||||
self.myInteger = myInteger
|
self.myInteger = myInteger
|
||||||
self.myIntegerArray = myIntegerArray
|
self.myIntegerArray = myIntegerArray
|
||||||
self.myLong = myLong
|
self.myLong = myLong
|
||||||
@ -69,8 +70,10 @@ open class AllPrimitives: Codable {
|
|||||||
self.myUUIDArray = myUUIDArray
|
self.myUUIDArray = myUUIDArray
|
||||||
self.myStringEnum = myStringEnum
|
self.myStringEnum = myStringEnum
|
||||||
self.myStringEnumArray = myStringEnumArray
|
self.myStringEnumArray = myStringEnumArray
|
||||||
|
self.myInlineStringEnum = myInlineStringEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -78,29 +81,29 @@ open class AllPrimitives: Codable {
|
|||||||
var container = encoder.container(keyedBy: String.self)
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
try container.encodeIfPresent(myInteger, forKey: "myInteger")
|
try container.encodeIfPresent(myInteger, forKey: "myInteger")
|
||||||
try container.encodeArrayIfPresent(myIntegerArray, forKey: "myIntegerArray")
|
try container.encodeIfPresent(myIntegerArray, forKey: "myIntegerArray")
|
||||||
try container.encodeIfPresent(myLong, forKey: "myLong")
|
try container.encodeIfPresent(myLong, forKey: "myLong")
|
||||||
try container.encodeArrayIfPresent(myLongArray, forKey: "myLongArray")
|
try container.encodeIfPresent(myLongArray, forKey: "myLongArray")
|
||||||
try container.encodeIfPresent(myFloat, forKey: "myFloat")
|
try container.encodeIfPresent(myFloat, forKey: "myFloat")
|
||||||
try container.encodeArrayIfPresent(myFloatArray, forKey: "myFloatArray")
|
try container.encodeIfPresent(myFloatArray, forKey: "myFloatArray")
|
||||||
try container.encodeIfPresent(myDouble, forKey: "myDouble")
|
try container.encodeIfPresent(myDouble, forKey: "myDouble")
|
||||||
try container.encodeArrayIfPresent(myDoubleArray, forKey: "myDoubleArray")
|
try container.encodeIfPresent(myDoubleArray, forKey: "myDoubleArray")
|
||||||
try container.encodeIfPresent(myString, forKey: "myString")
|
try container.encodeIfPresent(myString, forKey: "myString")
|
||||||
try container.encodeArrayIfPresent(myStringArray, forKey: "myStringArray")
|
try container.encodeIfPresent(myStringArray, forKey: "myStringArray")
|
||||||
try container.encodeIfPresent(myBytes, forKey: "myBytes")
|
try container.encodeIfPresent(myBytes, forKey: "myBytes")
|
||||||
try container.encodeArrayIfPresent(myBytesArray, forKey: "myBytesArray")
|
try container.encodeIfPresent(myBytesArray, forKey: "myBytesArray")
|
||||||
try container.encodeIfPresent(myBoolean, forKey: "myBoolean")
|
try container.encodeIfPresent(myBoolean, forKey: "myBoolean")
|
||||||
try container.encodeArrayIfPresent(myBooleanArray, forKey: "myBooleanArray")
|
try container.encodeIfPresent(myBooleanArray, forKey: "myBooleanArray")
|
||||||
try container.encodeIfPresent(myDate, forKey: "myDate")
|
try container.encodeIfPresent(myDate, forKey: "myDate")
|
||||||
try container.encodeArrayIfPresent(myDateArray, forKey: "myDateArray")
|
try container.encodeIfPresent(myDateArray, forKey: "myDateArray")
|
||||||
try container.encodeIfPresent(myDateTime, forKey: "myDateTime")
|
try container.encodeIfPresent(myDateTime, forKey: "myDateTime")
|
||||||
try container.encodeArrayIfPresent(myDateTimeArray, forKey: "myDateTimeArray")
|
try container.encodeIfPresent(myDateTimeArray, forKey: "myDateTimeArray")
|
||||||
try container.encodeIfPresent(myFile, forKey: "myFile")
|
try container.encodeIfPresent(myFile, forKey: "myFile")
|
||||||
try container.encodeArrayIfPresent(myFileArray, forKey: "myFileArray")
|
try container.encodeIfPresent(myFileArray, forKey: "myFileArray")
|
||||||
try container.encodeIfPresent(myUUID, forKey: "myUUID")
|
try container.encodeIfPresent(myUUID, forKey: "myUUID")
|
||||||
try container.encodeArrayIfPresent(myUUIDArray, forKey: "myUUIDArray")
|
try container.encodeIfPresent(myUUIDArray, forKey: "myUUIDArray")
|
||||||
try container.encodeIfPresent(myStringEnum, forKey: "myStringEnum")
|
try container.encodeIfPresent(myStringEnum, forKey: "myStringEnum")
|
||||||
try container.encodeArrayIfPresent(myStringEnumArray, forKey: "myStringEnumArray")
|
try container.encodeIfPresent(myStringEnumArray, forKey: "myStringEnumArray")
|
||||||
try container.encodeIfPresent(myInlineStringEnum, forKey: "myInlineStringEnum")
|
try container.encodeIfPresent(myInlineStringEnum, forKey: "myInlineStringEnum")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,29 +113,29 @@ open class AllPrimitives: Codable {
|
|||||||
let container = try decoder.container(keyedBy: String.self)
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
myInteger = try container.decodeIfPresent(Int.self, forKey: "myInteger")
|
myInteger = try container.decodeIfPresent(Int.self, forKey: "myInteger")
|
||||||
myIntegerArray = try container.decodeArrayIfPresent(Int.self, forKey: "myIntegerArray")
|
myIntegerArray = try container.decodeIfPresent([Int].self, forKey: "myIntegerArray")
|
||||||
myLong = try container.decodeIfPresent(Int64.self, forKey: "myLong")
|
myLong = try container.decodeIfPresent(Int64.self, forKey: "myLong")
|
||||||
myLongArray = try container.decodeArrayIfPresent(Int64.self, forKey: "myLongArray")
|
myLongArray = try container.decodeIfPresent([Int64].self, forKey: "myLongArray")
|
||||||
myFloat = try container.decodeIfPresent(Float.self, forKey: "myFloat")
|
myFloat = try container.decodeIfPresent(Float.self, forKey: "myFloat")
|
||||||
myFloatArray = try container.decodeArrayIfPresent(Float.self, forKey: "myFloatArray")
|
myFloatArray = try container.decodeIfPresent([Float].self, forKey: "myFloatArray")
|
||||||
myDouble = try container.decodeIfPresent(Double.self, forKey: "myDouble")
|
myDouble = try container.decodeIfPresent(Double.self, forKey: "myDouble")
|
||||||
myDoubleArray = try container.decodeArrayIfPresent(Double.self, forKey: "myDoubleArray")
|
myDoubleArray = try container.decodeIfPresent([Double].self, forKey: "myDoubleArray")
|
||||||
myString = try container.decodeIfPresent(String.self, forKey: "myString")
|
myString = try container.decodeIfPresent(String.self, forKey: "myString")
|
||||||
myStringArray = try container.decodeArrayIfPresent(String.self, forKey: "myStringArray")
|
myStringArray = try container.decodeIfPresent([String].self, forKey: "myStringArray")
|
||||||
myBytes = try container.decodeIfPresent(Data.self, forKey: "myBytes")
|
myBytes = try container.decodeIfPresent(Data.self, forKey: "myBytes")
|
||||||
myBytesArray = try container.decodeArrayIfPresent(Data.self, forKey: "myBytesArray")
|
myBytesArray = try container.decodeIfPresent([Data].self, forKey: "myBytesArray")
|
||||||
myBoolean = try container.decodeIfPresent(Bool.self, forKey: "myBoolean")
|
myBoolean = try container.decodeIfPresent(Bool.self, forKey: "myBoolean")
|
||||||
myBooleanArray = try container.decodeArrayIfPresent(Bool.self, forKey: "myBooleanArray")
|
myBooleanArray = try container.decodeIfPresent([Bool].self, forKey: "myBooleanArray")
|
||||||
myDate = try container.decodeIfPresent(Date.self, forKey: "myDate")
|
myDate = try container.decodeIfPresent(Date.self, forKey: "myDate")
|
||||||
myDateArray = try container.decodeArrayIfPresent(Date.self, forKey: "myDateArray")
|
myDateArray = try container.decodeIfPresent([Date].self, forKey: "myDateArray")
|
||||||
myDateTime = try container.decodeIfPresent(Date.self, forKey: "myDateTime")
|
myDateTime = try container.decodeIfPresent(Date.self, forKey: "myDateTime")
|
||||||
myDateTimeArray = try container.decodeArrayIfPresent(Date.self, forKey: "myDateTimeArray")
|
myDateTimeArray = try container.decodeIfPresent([Date].self, forKey: "myDateTimeArray")
|
||||||
myFile = try container.decodeIfPresent(URL.self, forKey: "myFile")
|
myFile = try container.decodeIfPresent(URL.self, forKey: "myFile")
|
||||||
myFileArray = try container.decodeArrayIfPresent(URL.self, forKey: "myFileArray")
|
myFileArray = try container.decodeIfPresent([URL].self, forKey: "myFileArray")
|
||||||
myUUID = try container.decodeIfPresent(UUID.self, forKey: "myUUID")
|
myUUID = try container.decodeIfPresent(UUID.self, forKey: "myUUID")
|
||||||
myUUIDArray = try container.decodeArrayIfPresent(UUID.self, forKey: "myUUIDArray")
|
myUUIDArray = try container.decodeIfPresent([UUID].self, forKey: "myUUIDArray")
|
||||||
myStringEnum = try container.decodeIfPresent(StringEnum.self, forKey: "myStringEnum")
|
myStringEnum = try container.decodeIfPresent(StringEnum.self, forKey: "myStringEnum")
|
||||||
myStringEnumArray = try container.decodeArrayIfPresent(StringEnum.self, forKey: "myStringEnumArray")
|
myStringEnumArray = try container.decodeIfPresent([StringEnum].self, forKey: "myStringEnumArray")
|
||||||
myInlineStringEnum = try container.decodeIfPresent(MyInlineStringEnum.self, forKey: "myInlineStringEnum")
|
myInlineStringEnum = try container.decodeIfPresent(MyInlineStringEnum.self, forKey: "myInlineStringEnum")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,14 @@ open class ErrorInfo: Codable {
|
|||||||
public var details: [String]?
|
public var details: [String]?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public init(code: Int?, message: String?, details: [String]?) {
|
public init(code: Int?, message: String?, details: [String]?) {
|
||||||
self.code = code
|
self.code = code
|
||||||
self.message = message
|
self.message = message
|
||||||
self.details = details
|
self.details = details
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -31,7 +33,7 @@ open class ErrorInfo: Codable {
|
|||||||
|
|
||||||
try container.encodeIfPresent(code, forKey: "code")
|
try container.encodeIfPresent(code, forKey: "code")
|
||||||
try container.encodeIfPresent(message, forKey: "message")
|
try container.encodeIfPresent(message, forKey: "message")
|
||||||
try container.encodeArrayIfPresent(details, forKey: "details")
|
try container.encodeIfPresent(details, forKey: "details")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decodable protocol methods
|
// Decodable protocol methods
|
||||||
@ -41,7 +43,7 @@ open class ErrorInfo: Codable {
|
|||||||
|
|
||||||
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
code = try container.decodeIfPresent(Int.self, forKey: "code")
|
||||||
message = try container.decodeIfPresent(String.self, forKey: "message")
|
message = try container.decodeIfPresent(String.self, forKey: "message")
|
||||||
details = try container.decodeArrayIfPresent(String.self, forKey: "details")
|
details = try container.decodeIfPresent([String].self, forKey: "details")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,19 +17,21 @@ open class GetAllModelsResult: Codable {
|
|||||||
public var myVariableNameTest: VariableNameTest?
|
public var myVariableNameTest: VariableNameTest?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public init(myPrimitiveArray: [AllPrimitives]?, myPrimitive: AllPrimitives?, myVariableNameTest: VariableNameTest?) {
|
public init(myPrimitiveArray: [AllPrimitives]?, myPrimitive: AllPrimitives?, myVariableNameTest: VariableNameTest?) {
|
||||||
self.myPrimitiveArray = myPrimitiveArray
|
self.myPrimitiveArray = myPrimitiveArray
|
||||||
self.myPrimitive = myPrimitive
|
self.myPrimitive = myPrimitive
|
||||||
self.myVariableNameTest = myVariableNameTest
|
self.myVariableNameTest = myVariableNameTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
||||||
var container = encoder.container(keyedBy: String.self)
|
var container = encoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
try container.encodeArrayIfPresent(myPrimitiveArray, forKey: "myPrimitiveArray")
|
try container.encodeIfPresent(myPrimitiveArray, forKey: "myPrimitiveArray")
|
||||||
try container.encodeIfPresent(myPrimitive, forKey: "myPrimitive")
|
try container.encodeIfPresent(myPrimitive, forKey: "myPrimitive")
|
||||||
try container.encodeIfPresent(myVariableNameTest, forKey: "myVariableNameTest")
|
try container.encodeIfPresent(myVariableNameTest, forKey: "myVariableNameTest")
|
||||||
}
|
}
|
||||||
@ -39,7 +41,7 @@ open class GetAllModelsResult: Codable {
|
|||||||
public required init(from decoder: Decoder) throws {
|
public required init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: String.self)
|
let container = try decoder.container(keyedBy: String.self)
|
||||||
|
|
||||||
myPrimitiveArray = try container.decodeArrayIfPresent(AllPrimitives.self, forKey: "myPrimitiveArray")
|
myPrimitiveArray = try container.decodeIfPresent([AllPrimitives].self, forKey: "myPrimitiveArray")
|
||||||
myPrimitive = try container.decodeIfPresent(AllPrimitives.self, forKey: "myPrimitive")
|
myPrimitive = try container.decodeIfPresent(AllPrimitives.self, forKey: "myPrimitive")
|
||||||
myVariableNameTest = try container.decodeIfPresent(VariableNameTest.self, forKey: "myVariableNameTest")
|
myVariableNameTest = try container.decodeIfPresent(VariableNameTest.self, forKey: "myVariableNameTest")
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ open class ModelWithIntAdditionalPropertiesOnly: Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
@ -36,6 +36,7 @@ open class ModelWithPropertiesAndAdditionalProperties: Codable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public init(myIntegerReq: Int, myIntegerOpt: Int?, myPrimitiveReq: AllPrimitives, myPrimitiveOpt: AllPrimitives?, myStringArrayReq: [String], myStringArrayOpt: [String]?, myPrimitiveArrayReq: [AllPrimitives], myPrimitiveArrayOpt: [AllPrimitives]?) {
|
public init(myIntegerReq: Int, myIntegerOpt: Int?, myPrimitiveReq: AllPrimitives, myPrimitiveOpt: AllPrimitives?, myStringArrayReq: [String], myStringArrayOpt: [String]?, myPrimitiveArrayReq: [AllPrimitives], myPrimitiveArrayOpt: [AllPrimitives]?) {
|
||||||
self.myIntegerReq = myIntegerReq
|
self.myIntegerReq = myIntegerReq
|
||||||
self.myIntegerOpt = myIntegerOpt
|
self.myIntegerOpt = myIntegerOpt
|
||||||
@ -47,6 +48,7 @@ open class ModelWithPropertiesAndAdditionalProperties: Codable {
|
|||||||
self.myPrimitiveArrayOpt = myPrimitiveArrayOpt
|
self.myPrimitiveArrayOpt = myPrimitiveArrayOpt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -57,10 +59,10 @@ open class ModelWithPropertiesAndAdditionalProperties: Codable {
|
|||||||
try container.encodeIfPresent(myIntegerOpt, forKey: "myIntegerOpt")
|
try container.encodeIfPresent(myIntegerOpt, forKey: "myIntegerOpt")
|
||||||
try container.encode(myPrimitiveReq, forKey: "myPrimitiveReq")
|
try container.encode(myPrimitiveReq, forKey: "myPrimitiveReq")
|
||||||
try container.encodeIfPresent(myPrimitiveOpt, forKey: "myPrimitiveOpt")
|
try container.encodeIfPresent(myPrimitiveOpt, forKey: "myPrimitiveOpt")
|
||||||
try container.encodeArray(myStringArrayReq, forKey: "myStringArrayReq")
|
try container.encode(myStringArrayReq, forKey: "myStringArrayReq")
|
||||||
try container.encodeArrayIfPresent(myStringArrayOpt, forKey: "myStringArrayOpt")
|
try container.encodeIfPresent(myStringArrayOpt, forKey: "myStringArrayOpt")
|
||||||
try container.encodeArray(myPrimitiveArrayReq, forKey: "myPrimitiveArrayReq")
|
try container.encode(myPrimitiveArrayReq, forKey: "myPrimitiveArrayReq")
|
||||||
try container.encodeArrayIfPresent(myPrimitiveArrayOpt, forKey: "myPrimitiveArrayOpt")
|
try container.encodeIfPresent(myPrimitiveArrayOpt, forKey: "myPrimitiveArrayOpt")
|
||||||
try container.encodeMap(additionalProperties)
|
try container.encodeMap(additionalProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,10 +75,10 @@ open class ModelWithPropertiesAndAdditionalProperties: Codable {
|
|||||||
myIntegerOpt = try container.decodeIfPresent(Int.self, forKey: "myIntegerOpt")
|
myIntegerOpt = try container.decodeIfPresent(Int.self, forKey: "myIntegerOpt")
|
||||||
myPrimitiveReq = try container.decode(AllPrimitives.self, forKey: "myPrimitiveReq")
|
myPrimitiveReq = try container.decode(AllPrimitives.self, forKey: "myPrimitiveReq")
|
||||||
myPrimitiveOpt = try container.decodeIfPresent(AllPrimitives.self, forKey: "myPrimitiveOpt")
|
myPrimitiveOpt = try container.decodeIfPresent(AllPrimitives.self, forKey: "myPrimitiveOpt")
|
||||||
myStringArrayReq = try container.decodeArray(String.self, forKey: "myStringArrayReq")
|
myStringArrayReq = try container.decode([String].self, forKey: "myStringArrayReq")
|
||||||
myStringArrayOpt = try container.decodeArrayIfPresent(String.self, forKey: "myStringArrayOpt")
|
myStringArrayOpt = try container.decodeIfPresent([String].self, forKey: "myStringArrayOpt")
|
||||||
myPrimitiveArrayReq = try container.decodeArray(AllPrimitives.self, forKey: "myPrimitiveArrayReq")
|
myPrimitiveArrayReq = try container.decode([AllPrimitives].self, forKey: "myPrimitiveArrayReq")
|
||||||
myPrimitiveArrayOpt = try container.decodeArrayIfPresent(AllPrimitives.self, forKey: "myPrimitiveArrayOpt")
|
myPrimitiveArrayOpt = try container.decodeIfPresent([AllPrimitives].self, forKey: "myPrimitiveArrayOpt")
|
||||||
var nonAdditionalPropertyKeys = Set<String>()
|
var nonAdditionalPropertyKeys = Set<String>()
|
||||||
nonAdditionalPropertyKeys.insert("myIntegerReq")
|
nonAdditionalPropertyKeys.insert("myIntegerReq")
|
||||||
nonAdditionalPropertyKeys.insert("myIntegerOpt")
|
nonAdditionalPropertyKeys.insert("myIntegerOpt")
|
||||||
|
@ -29,6 +29,7 @@ open class ModelWithStringAdditionalPropertiesOnly: Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
@ -18,11 +18,13 @@ open class VariableNameTest: Codable {
|
|||||||
public var _for: String?
|
public var _for: String?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public init(exampleName: String?, _for: String?) {
|
public init(exampleName: String?, _for: String?) {
|
||||||
self.exampleName = exampleName
|
self.exampleName = exampleName
|
||||||
self._for = _for
|
self._for = _for
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Encodable protocol methods
|
// Encodable protocol methods
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
@ -36,7 +36,7 @@ git_remote=`git remote`
|
|||||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
if [ "$GIT_TOKEN" = "" ]; then
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
else
|
else
|
||||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
Loading…
x
Reference in New Issue
Block a user