DTO compile issues using ServiceStack Swift (Add Reference feature)

Theres an identifier/property named “extension” on some of our DTOs: Phone, Fax and MyProfileBase64PhotoUpdateRequest classes for example. This generates an issue at compile time as “extension” is a Swift keyword.

I’m also getting the following errors:

/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:9786:22: error: declarations in extensions cannot override yet
public class var typeName:String { return "MyProfileUpdateRequest" }
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:5132:22: note: overridden declaration is here
public class var typeName:String { return "UpdateableProfile" }
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:9784:1: error: type 'MyProfileUpdateRequest' does not conform to protocol 'Convertible'
extension MyProfileUpdateRequest : JsonSerializable
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/JsonServiceClient.swift:1057:16: note: multiple matching properties named 'typeName' with type 'String'
static var typeName:String { get }
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:9786:22: note: candidate exactly matches
public class var typeName:String { return "MyProfileUpdateRequest" }
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:5132:22: note: candidate exactly matches
public class var typeName:String { return "UpdateableProfile" }
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:9819:23: error: declarations in extensions cannot override yet
public class func fromObject(any:AnyObject) -> MyProfileUpdateRequest? {
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:5165:23: note: overridden declaration is here
public class func fromObject(any:AnyObject) -> UpdateableProfile? {
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/JsonServiceClient.swift:1058:17: note: multiple matching functions named 'fromObject' with type '(AnyObject) -> MyProfileUpdateRequest.T?'
static func fromObject(any:AnyObject) -> T?
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:9819:23: note: candidate exactly matches [with T = MyProfileUpdateRequest]
public class func fromObject(any:AnyObject) -> MyProfileUpdateRequest? {
^
/Users/mjc/Documents/projects/aao-nfmobi-ios/src/memberapp/memberapp/AAOTestingApi.dtos.swift:5165:23: note: candidate exactly matches [with T = UpdateableProfile]
public class func fromObject(any:AnyObject) -> UpdateableProfile? {

We can’t really change our API, as it’s used in production right now, supporting some mobile apps and other applications. Any recommendations to get around these issues?

You can access the generated DTO here: http://nf.aaoinfo.org/nfaaotest/mapi/api/types/swift

I noticed this is only using v4.0.38, can you upgrade and send a link to an example that uses the latest v4.0.42.

Also please make sure you follow the Swift Type Limitations and make sure each base class is abstract.

Ok, the api at that url is updated to 4.0.42, i also removed some extra classes and interfaces, there’s still one abstract class called BaseNoCacheRequest which I can refactor out if needed, but need to do that later if that’s required.
The request DTOs do use the IReturn<> paradigm still

We’re now adding and escaping the full list of Swift keywords in this commit.

This change is now available from v4.0.43+ that’s now available on MyGet.

Also Services should ideally return Response DTO’s but they can also return raw references types like string or byte[] but they shouldn’t return ValueTypes like MyProfileChangePasswordRequest does by returning bool.

You’ll need to change this by either returning a string, e.g “true” or wrapping the result in a DTO, e.g:

class MyProfileChangePasswordResponse {
    public bool Result { get; set; }
}
1 Like

Sweet, compiles … Thanks for the quick action on this, keeps our momentum going, next up: JsonServiceClient.swift goodness :smile:

1 Like