Open aldan95 opened 4 years ago
The specific request this issue is about was probably addressed as of v4.4.0 and v4.6.0 (after some fixes). However there's still something broken, as reported here #295, not sure if that would affect you.
I've tested above samples with v.4.6.0. Dog from first spec:
public class Dog: Animal {
public var breed: String?
public init(className: String, color: String? = nil, breed: String? = nil) {
self.breed = breed
super.init(className: className, color: color)
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
breed = try container.decodeIfPresent("breed")
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringCodingKey.self)
try container.encodeIfPresent(breed, forKey: "breed")
try super.encode(to: encoder)
}
override public func isEqual(to object: Any?) -> Bool {
guard let object = object as? Dog else { return false }
guard self.breed == object.breed else { return false }
return super.isEqual(to: object)
}
}
and Dog from second spec:
public class Dog: APIModel {
public init() {
}
public required init(from decoder: Decoder) throws {
}
public func encode(to encoder: Encoder) throws {
}
public func isEqual(to object: Any?) -> Bool {
guard object is Dog else { return false }
return true
}
public static func == (lhs: Dog, rhs: Dog) -> Bool {
return lhs.isEqual(to: rhs)
}
}
Two valid specifications (verified by swagger.io online validator):
generates
public class Dog: Animal
, but same spec withtype: object
added toDog
generates
public class Dog: APIModel
without properties at allversion 4.3.1