Ref: Android Assessment
The following is an assessment of using Swagger when developing iOS apps.
Observations
- Generates Swift3 code which is nice
- Model classes are not as overly verbose as Android, come with JSON encoding methods
- Uses Alamofire which is the most popular networking library on iOS and already used in many of our projects
- Documentation for every api path showing example use
- Code seems very complex, might be harder for some devs to pickup quickly which might be a big problem on this project as people will come and go relatively quickly
- Handles deserialising JSON into model objects which is a lot of boilerplate on it’s own so that saves a lot of time
- Code seems robust (includes things like callbacks for progress updates)
- Some code seems weird, like a
convertBoolToStringmethod. I’m sure it’s useful but it’s not readily apparent whyMarking properties of Model classes as “required” doesn’t stop them from being generated as Optionals
Conclusion
The codegen is pretty robust but this comes at the cost of complexity. It would definitely speed up dev time initially but might hinder progress later in the project as new devs come and go.
Jason had a good point in thinking of the codegen not as our code but an external lib, a black box where we just make api calls in which case the complexity of the code doesn’t matter. One thing he did suggest was using the networking code and using another tool to generate the model classes from JSON, one which will actually respect the Optionals and create code in the conventional way
It’s a balancing act of saving time at the cost of reliability/maintainability/conventions. I think it’s more viable on iOS than it is on Android, whether it’s worth having it used on one platform and not the other is another question altogether.