forked from loafle/openapi-generator-original
use basename for swift model property
This commit is contained in:
@@ -177,7 +177,7 @@ class Decoders {
|
||||
Decoders.addDecoder(clazz: ModelReturn.self) { (source: AnyObject) -> ModelReturn in
|
||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||
let instance = ModelReturn()
|
||||
instance._return = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["_return"])
|
||||
instance._return = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["return"])
|
||||
return instance
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ class Decoders {
|
||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||
let instance = Name()
|
||||
instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"])
|
||||
instance.snakeCase = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["snake_case"])
|
||||
return instance
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@ class Decoders {
|
||||
Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in
|
||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||
let instance = SpecialModelName()
|
||||
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["specialPropertyName"])
|
||||
instance.specialPropertyName = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["$special[property.name]"])
|
||||
return instance
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ModelReturn: JSONEncodable {
|
||||
// MARK: JSONEncodable
|
||||
func encodeToJSON() -> AnyObject {
|
||||
var nillableDictionary = [String:AnyObject?]()
|
||||
nillableDictionary["_return"] = self._return
|
||||
nillableDictionary["return"] = self._return
|
||||
let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||
return dictionary
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import Foundation
|
||||
public class Name: JSONEncodable {
|
||||
|
||||
public var name: Int?
|
||||
public var snakeCase: Int?
|
||||
|
||||
|
||||
public init() {}
|
||||
@@ -19,6 +20,7 @@ public class Name: JSONEncodable {
|
||||
func encodeToJSON() -> AnyObject {
|
||||
var nillableDictionary = [String:AnyObject?]()
|
||||
nillableDictionary["name"] = self.name
|
||||
nillableDictionary["snake_case"] = self.snakeCase
|
||||
let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||
return dictionary
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SpecialModelName: JSONEncodable {
|
||||
// MARK: JSONEncodable
|
||||
func encodeToJSON() -> AnyObject {
|
||||
var nillableDictionary = [String:AnyObject?]()
|
||||
nillableDictionary["specialPropertyName"] = self.specialPropertyName
|
||||
nillableDictionary["$special[property.name]"] = self.specialPropertyName
|
||||
let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:]
|
||||
return dictionary
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user