forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
@@ -12,6 +12,218 @@ import RxSwift
|
||||
|
||||
|
||||
open class FakeAPI: APIBase {
|
||||
/**
|
||||
|
||||
- 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: ErrorResponse?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: Observable<OuterBoolean>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: OuterBoolean? = nil) -> Observable<OuterBoolean> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
fakeOuterBooleanSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
observer.on(.error(error as Error))
|
||||
} else {
|
||||
observer.on(.next(data!))
|
||||
}
|
||||
observer.on(.completed)
|
||||
}
|
||||
return NopDisposable.instance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- 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 = body?.encodeToJSON() as? [String:AnyObject]
|
||||
|
||||
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: ErrorResponse?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- returns: Observable<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil) -> Observable<OuterComposite> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
fakeOuterCompositeSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
observer.on(.error(error as Error))
|
||||
} else {
|
||||
observer.on(.next(data!))
|
||||
}
|
||||
observer.on(.completed)
|
||||
}
|
||||
return NopDisposable.instance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- 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 = body?.encodeToJSON() as? [String:AnyObject]
|
||||
|
||||
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: ErrorResponse?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: Observable<OuterNumber>
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: OuterNumber? = nil) -> Observable<OuterNumber> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
fakeOuterNumberSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
observer.on(.error(error as Error))
|
||||
} else {
|
||||
observer.on(.next(data!))
|
||||
}
|
||||
observer.on(.completed)
|
||||
}
|
||||
return NopDisposable.instance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- 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 = body?.encodeToJSON() as? [String:AnyObject]
|
||||
|
||||
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: ErrorResponse?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: Observable<OuterString>
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: OuterString? = nil) -> Observable<OuterString> {
|
||||
return Observable.create { observer -> Disposable in
|
||||
fakeOuterStringSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
observer.on(.error(error as Error))
|
||||
} else {
|
||||
observer.on(.next(data!))
|
||||
}
|
||||
observer.on(.completed)
|
||||
}
|
||||
return NopDisposable.instance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- 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 = body?.encodeToJSON() as? [String:AnyObject]
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1004,6 +1004,51 @@ class Decoders {
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [OuterBoolean]
|
||||
return Decoders.decode(clazz: [OuterBoolean].self, source: source, instance: instance)
|
||||
}
|
||||
// Decoder for OuterBoolean
|
||||
Decoders.addDecoder(clazz: OuterBoolean.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterBoolean> in
|
||||
if let source = source as? Bool {
|
||||
return .success(source)
|
||||
} else {
|
||||
return .failure(.typeMismatch(expected: "Typealias OuterBoolean", actual: "\(source)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [OuterComposite]
|
||||
return Decoders.decode(clazz: [OuterComposite].self, source: source, instance: instance)
|
||||
}
|
||||
// Decoder for OuterComposite
|
||||
Decoders.addDecoder(clazz: OuterComposite.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterComposite> in
|
||||
if let sourceDictionary = source as? [AnyHashable: Any] {
|
||||
let result = instance == nil ? OuterComposite() : instance as! OuterComposite
|
||||
switch Decoders.decodeOptional(clazz: OuterNumber.self, source: sourceDictionary["my_number"] as AnyObject?) {
|
||||
|
||||
case let .success(value): result.myNumber = value
|
||||
case let .failure(error): return .failure(error)
|
||||
|
||||
}
|
||||
switch Decoders.decodeOptional(clazz: OuterString.self, source: sourceDictionary["my_string"] as AnyObject?) {
|
||||
|
||||
case let .success(value): result.myString = value
|
||||
case let .failure(error): return .failure(error)
|
||||
|
||||
}
|
||||
switch Decoders.decodeOptional(clazz: OuterBoolean.self, source: sourceDictionary["my_boolean"] as AnyObject?) {
|
||||
|
||||
case let .success(value): result.myBoolean = value
|
||||
case let .failure(error): return .failure(error)
|
||||
|
||||
}
|
||||
return .success(result)
|
||||
} else {
|
||||
return .failure(.typeMismatch(expected: "OuterComposite", actual: "\(source)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [OuterEnum]
|
||||
return Decoders.decode(clazz: [OuterEnum].self, source: source, instance: instance)
|
||||
}
|
||||
@@ -1014,6 +1059,32 @@ class Decoders {
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [OuterNumber]
|
||||
return Decoders.decode(clazz: [OuterNumber].self, source: source, instance: instance)
|
||||
}
|
||||
// Decoder for OuterNumber
|
||||
Decoders.addDecoder(clazz: OuterNumber.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterNumber> in
|
||||
if let source = source as? Double {
|
||||
return .success(source)
|
||||
} else {
|
||||
return .failure(.typeMismatch(expected: "Typealias OuterNumber", actual: "\(source)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [OuterString]
|
||||
return Decoders.decode(clazz: [OuterString].self, source: source, instance: instance)
|
||||
}
|
||||
// Decoder for OuterString
|
||||
Decoders.addDecoder(clazz: OuterString.self) { (source: AnyObject, instance: AnyObject?) -> Decoded<OuterString> in
|
||||
if let source = source as? String {
|
||||
return .success(source)
|
||||
} else {
|
||||
return .failure(.typeMismatch(expected: "Typealias OuterString", actual: "\(source)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Decoder for [Pet]
|
||||
return Decoders.decode(clazz: [Pet].self, source: source, instance: instance)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// OuterBoolean.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public typealias OuterBoolean = Bool
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// OuterComposite.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
open class OuterComposite: JSONEncodable {
|
||||
|
||||
public var myNumber: OuterNumber?
|
||||
public var myString: OuterString?
|
||||
public var myBoolean: OuterBoolean?
|
||||
|
||||
public init() {}
|
||||
|
||||
// MARK: JSONEncodable
|
||||
open func encodeToJSON() -> Any {
|
||||
var nillableDictionary = [String:Any?]()
|
||||
nillableDictionary["my_number"] = self.myNumber?.encodeToJSON()
|
||||
nillableDictionary["my_string"] = self.myString?.encodeToJSON()
|
||||
nillableDictionary["my_boolean"] = self.myBoolean?.encodeToJSON()
|
||||
|
||||
let dictionary: [String:Any] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||
return dictionary
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// OuterNumber.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public typealias OuterNumber = Double
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// OuterString.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public typealias OuterString = String
|
||||
Reference in New Issue
Block a user