Swagger Codegen Android Assessment

By Alexander Scanlan

November 22, 2016 at 10:28

dev swagger android

Ref: iOS Assessment

The following is an assessment of using Swagger when developing Android apps.

General Observations

Model Classes

Request Classes

Util Class

Conclusion

The architecture of the app will need to be fundamentally different if using Swagger rather than our normal approach.

The time saved by codegen may be negated by dev learning the new approach and fixing issues but may also save time in the long run regardless of these issues.

The model class generation is the most agnostic feature of the codegen and may be helpful even without the rest of the generated code; the problem with it is that the classes may need slight alterations which will be overridden if the API is changed and new code is generated and as such would need to be modified again. The model class codegen is most useful when the API is already fully defined and won’t change much, in such a case it cuts down significant time writing boilerplate code but if the API is constantly changing this advantage MAY be overtaken by time needed to fix issues.

If Swagger is to be used to the fullest (all API calls, model classes, exceptions etc.) then the app will need to adopt the approach fully to get the most benefit (No retrofit, no/more lenient checkstyle, devs learning swaggers approach).

I believe the model class generation is the biggest benefit and may be useful regardless of the rest of the codegen.

Download the Android Swagger Client Example

2016-11-25 11:14 Update from Alex:

Swagger can generate Retrofit code which makes it a lot more lucrative than my first assessment, it even uses RxJava. We already have an internal library for this code though so i’m not sure if this changes much.

A lot of the remarks will be similar (general verbosity of the code, checkstyle errors [although iOS is not using checkstyle at the moment], requiring full dedication no half measures etc.)

Last updated: November 22, 2016 at 10:28