//
// Generated by SwagGen
// https://github.com/yonaskolb/SwagGen
//

import Foundation

public class ModelWithInlineSpec: Codable, Equatable {

    /** an inline model */
    public var myModel: MyModel?

    public class MyModel: Codable, Equatable {

        /** name of the model */
        public var name: String?

        public init(name: String? = nil) {
            self.name = name
        }

        private enum CodingKeys: String, CodingKey {
            case name
        }

        public required init(from decoder: Decoder) throws {
            let container = try decoder.container(keyedBy: CodingKeys.self)

            name = try container.decodeIfPresent(.name)
        }

        public func encode(to encoder: Encoder) throws {
            var container = encoder.container(keyedBy: CodingKeys.self)

            try container.encodeIfPresent(name, forKey: .name)
        }

        public func isEqual(to object: Any?) -> Bool {
          guard let object = object as? MyModel else { return false }
          guard self.name == object.name else { return false }
          return true
        }

        public static func == (lhs: MyModel, rhs: MyModel) -> Bool {
            return lhs.isEqual(to: rhs)
        }
    }

    public init(myModel: MyModel? = nil) {
        self.myModel = myModel
    }

    private enum CodingKeys: String, CodingKey {
        case myModel
    }

    public required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)

        myModel = try container.decodeIfPresent(.myModel)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)

        try container.encodeIfPresent(myModel, forKey: .myModel)
    }

    public func isEqual(to object: Any?) -> Bool {
      guard let object = object as? ModelWithInlineSpec else { return false }
      guard self.myModel == object.myModel else { return false }
      return true
    }

    public static func == (lhs: ModelWithInlineSpec, rhs: ModelWithInlineSpec) -> Bool {
        return lhs.isEqual(to: rhs)
    }
}
