Last active
March 9, 2021 06:22
-
-
Save gistlyn/0b983a810eafa602177592a2df8aafc6 to your computer and use it in GitHub Desktop.
swift-alltypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swift-tools-version:5.3 | |
import PackageDescription | |
let package = Package( | |
name: "MyApp", | |
dependencies: [ | |
.package(name: "ServiceStack", url: "https://github.com/ServiceStack/ServiceStack.Swift.git", | |
Version(5,0,0)..<Version(6,0,0)) | |
], | |
targets: [ | |
.target( | |
name: "MyApp", | |
dependencies: ["ServiceStack"]), | |
] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Options: | |
Date: 2021-03-09 07:20:56 | |
SwiftVersion: 5.0 | |
Version: 5.105 | |
Tip: To override a DTO option, remove "//" prefix before updating | |
BaseUrl: https://test.servicestack.net | |
//BaseClass: | |
//AddModelExtensions: True | |
//AddServiceStackTypes: True | |
IncludeTypes: AllTypes.* | |
//ExcludeTypes: | |
//ExcludeGenericBaseTypes: False | |
//AddResponseStatus: False | |
//AddImplicitVersion: | |
//AddDescriptionAsComments: True | |
//InitializeCollections: True | |
//TreatTypesAsStrings: | |
//DefaultImports: Foundation,ServiceStack | |
*/ | |
import Foundation | |
import ServiceStack | |
public class AllTypes : IReturn, Codable | |
{ | |
public typealias Return = AllTypes | |
public var id:Int? | |
public var nullableId:Int? | |
public var byte:Int8? | |
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<String, String>? | |
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(){} | |
} | |
public class KeyValuePair<TKey : Codable, TValue : Codable> : 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(){} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(FoundationNetworking) | |
import FoundationNetworking | |
#endif | |
import Foundation | |
import ServiceStack | |
let client = JsonServiceClient(baseUrl: "https://test.servicestack.net") | |
let request = AllTypes() | |
request.id = 1 | |
request.nullableId = 2 | |
request.byte = 3 | |
request.short = 4 | |
request.int = 5 | |
request.long = 6 | |
request.uShort = 7 | |
request.uInt = 8 | |
request.uLong = 9 | |
request.float = 10.0 | |
request.double = 11.0 | |
request.decimal = 12.0 | |
request.string = "String" | |
request.dateTime = DateTime.parse("2021-12-31T04:59:00Z") | |
request.timeSpan = TimeSpan.parse("PT1H2M3S") | |
request.guid = "bc525c18-ac21-4a60-a2be-6187c9af2716" | |
request.char = "c" | |
let response = client.send(request) | |
Inspect.printDump(response) | |
Inspect.vars(["response":response]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment