/* Options: Date: 2025-05-12 17:42:41 SwiftVersion: 6.0 Version: 8.53 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://test.servicestack.net //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True //MakePropertiesOptional: True IncludeTypes: HelloSubAllTypes.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: False //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack public class HelloSubAllTypes : AllTypesBase, IReturn { public typealias Return = SubAllTypes public var hierarchy:Int? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case hierarchy } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) hierarchy = try container.decodeIfPresent(Int.self, forKey: .hierarchy) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if hierarchy != nil { try container.encode(hierarchy, forKey: .hierarchy) } } } public class SubAllTypes : AllTypesBase { public var hierarchy:Int? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case hierarchy } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) hierarchy = try container.decodeIfPresent(Int.self, forKey: .hierarchy) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if hierarchy != nil { try container.encode(hierarchy, forKey: .hierarchy) } } } public class KeyValuePair : Codable { public var key:TKey? public var value:TValue? required public init(){} } public class SubType : Codable { public var id:Int? public var name:String? required public init(){} } public class AllTypesBase : Codable { public var id:Int? public var nullableId:Int? public var byte:UInt8? public var short:Int16? public var int:Int? public var long:Int? public var uShort:UInt16? public var uInt:UInt32? public var uLong:UInt64? public var float:Float? public var double:Double? public var decimal:Double? public var string:String? public var dateTime:Date? @TimeSpan public var timeSpan:TimeInterval? public var dateTimeOffset:Date? public var guid:String? public var char:String? public var keyValuePair:KeyValuePair? public var nullableDateTime:Date? @TimeSpan public var nullableTimeSpan:TimeInterval? public var stringList:[String] = [] public var stringArray:[String] = [] public var stringMap:[String:String] = [:] public var intStringMap:[Int:String] = [:] public var subType:SubType? required public init(){} private enum CodingKeys : String, CodingKey { case id case nullableId case byte case short case int case long case uShort case uInt case uLong case float case double case decimal case string case dateTime case timeSpan case dateTimeOffset case guid case char case keyValuePair case nullableDateTime case nullableTimeSpan case stringList case stringArray case stringMap case intStringMap case subType } required public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(Int.self, forKey: .id) nullableId = try container.decodeIfPresent(Int.self, forKey: .nullableId) byte = try container.decodeIfPresent(UInt8.self, forKey: .byte) short = try container.decodeIfPresent(Int16.self, forKey: .short) int = try container.decodeIfPresent(Int.self, forKey: .int) long = try container.decodeIfPresent(Int.self, forKey: .long) uShort = try container.decodeIfPresent(UInt16.self, forKey: .uShort) uInt = try container.decodeIfPresent(UInt32.self, forKey: .uInt) uLong = try container.decodeIfPresent(UInt64.self, forKey: .uLong) float = try container.decodeIfPresent(Float.self, forKey: .float) double = try container.decodeIfPresent(Double.self, forKey: .double) decimal = try container.decodeIfPresent(Double.self, forKey: .decimal) string = try container.decodeIfPresent(String.self, forKey: .string) dateTime = try container.decodeIfPresent(Date.self, forKey: .dateTime) timeSpan = try container.convertIfPresent(TimeInterval.self, forKey: .timeSpan) dateTimeOffset = try container.decodeIfPresent(Date.self, forKey: .dateTimeOffset) guid = try container.decodeIfPresent(String.self, forKey: .guid) char = try container.decodeIfPresent(String.self, forKey: .char) keyValuePair = try container.decodeIfPresent(KeyValuePair.self, forKey: .keyValuePair) nullableDateTime = try container.decodeIfPresent(Date.self, forKey: .nullableDateTime) nullableTimeSpan = try container.convertIfPresent(TimeInterval.self, forKey: .nullableTimeSpan) stringList = try container.decodeIfPresent([String].self, forKey: .stringList) ?? [] stringArray = try container.decodeIfPresent([String].self, forKey: .stringArray) ?? [] stringMap = try container.decodeIfPresent([String:String].self, forKey: .stringMap) ?? [:] intStringMap = try container.decodeIfPresent([Int:String].self, forKey: .intStringMap) ?? [:] subType = try container.decodeIfPresent(SubType.self, forKey: .subType) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) if id != nil { try container.encode(id, forKey: .id) } if nullableId != nil { try container.encode(nullableId, forKey: .nullableId) } if byte != nil { try container.encode(byte, forKey: .byte) } if short != nil { try container.encode(short, forKey: .short) } if int != nil { try container.encode(int, forKey: .int) } if long != nil { try container.encode(long, forKey: .long) } if uShort != nil { try container.encode(uShort, forKey: .uShort) } if uInt != nil { try container.encode(uInt, forKey: .uInt) } if uLong != nil { try container.encode(uLong, forKey: .uLong) } if float != nil { try container.encode(float, forKey: .float) } if double != nil { try container.encode(double, forKey: .double) } if decimal != nil { try container.encode(decimal, forKey: .decimal) } if string != nil { try container.encode(string, forKey: .string) } if dateTime != nil { try container.encode(dateTime, forKey: .dateTime) } if timeSpan != nil { try container.encode(timeSpan, forKey: .timeSpan) } if dateTimeOffset != nil { try container.encode(dateTimeOffset, forKey: .dateTimeOffset) } if guid != nil { try container.encode(guid, forKey: .guid) } if char != nil { try container.encode(char, forKey: .char) } if keyValuePair != nil { try container.encode(keyValuePair, forKey: .keyValuePair) } if nullableDateTime != nil { try container.encode(nullableDateTime, forKey: .nullableDateTime) } if nullableTimeSpan != nil { try container.encode(nullableTimeSpan, forKey: .nullableTimeSpan) } if stringList.count > 0 { try container.encode(stringList, forKey: .stringList) } if stringArray.count > 0 { try container.encode(stringArray, forKey: .stringArray) } if stringMap.count > 0 { try container.encode(stringMap, forKey: .stringMap) } if intStringMap.count > 0 { try container.encode(intStringMap, forKey: .intStringMap) } if subType != nil { try container.encode(subType, forKey: .subType) } } }