Java client and swagger

There’s no support for v3, but the way ServiceStack is designed you just need to generate Java DTO’s which you can use with the generic Java Service Client so you should still be able to leverage a lot of the Java Add Service Reference support in v4 to at least generate the Java DTO’s, which you can do by creating an empty v4 project that just has all the Service Models with empty services stub, e.g:

public class Request1 : IReturn<Request1Response> { ... }
public class Request2 : IReturn<Request2Response> { ... }

public class StubServices : Service
{
    public object Any(Request1 request) { return request; }
    public object Any(Request2 request) { return request; }
}

Once you have all the DTO’s and an empty Service you can get the Java DTO’s from the /types/java language types path which will return all the Java DTO’s in a single static class, e.g: http://techstacks.io/types/java

These Java DTO’s can be used with the AndroidServiceClient in the Android Java Package for Android Clients or the JsonServiceClient in the Java 1.7 package for pure Java clients.

The JSON Serialization hasn’t changed too much since v3 but there’s going to be some functionality that’s missing so not everything will work smoothly. You may need to customize the Gson configuration if you’re using some of the unsupported types if you’re lucky, otherwise you may need to modify the source code of the Java Clients required to support v3.

1 Like