Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active March 9, 2021 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/204e73d5cfd8b964591246d16b2d3e30 to your computer and use it in GitHub Desktop.
Save gistlyn/204e73d5cfd8b964591246d16b2d3e30 to your computer and use it in GitHub Desktop.
swift-allcollections
// 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"]),
]
)
/* Options:
Date: 2021-03-09 07:28:40
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: AllCollectionTypes.*
//ExcludeTypes:
//ExcludeGenericBaseTypes: False
//AddResponseStatus: False
//AddImplicitVersion:
//AddDescriptionAsComments: True
//InitializeCollections: True
//TreatTypesAsStrings:
//DefaultImports: Foundation,ServiceStack
*/
import Foundation
import ServiceStack
public class AllCollectionTypes : IReturn, Codable
{
public typealias Return = AllCollectionTypes
public var intArray:[Int] = []
public var intList:[Int] = []
public var stringArray:[String] = []
public var stringList:[String] = []
public var floatArray:[Float] = []
public var doubleList:[Double] = []
public var byteArray:[Int8] = []
public var charArray:[String] = []
public var decimalList:[Double] = []
public var pocoArray:[Poco] = []
public var pocoList:[Poco] = []
public var pocoLookup:[String:[Poco]] = [:]
public var pocoLookupMap:[String:[[String:Poco]]] = [:]
required public init(){}
}
public class Poco : Codable
{
public var name:String?
required public init(){}
}
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import Foundation
import ServiceStack
let client = JsonServiceClient(baseUrl: "https://test.servicestack.net")
let request = AllCollectionTypes()
request.intArray = [1, 2, 3]
request.intList = [4, 5, 6]
request.stringArray = ["AB", " C", " DEF"]
request.stringList = ["AB", " C", " DEF"]
request.floatArray = [1.0, 2.2, 3.3]
request.doubleList = [1.0, 2.2, 3.3]
request.byteArray = [65,66,67]
request.charArray = ["a", "b", "c"]
request.decimalList = [1.0, 2.2, 3.3]
let response = try 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