Generating Kotlin/Retrofit networking code from Sw...
# feed
g
Generating Kotlin/Retrofit networking code from Swagger Specs: https://github.com/yelp/swagger-gradle-codegen Feedbacks/Issues/PRs are welcome šŸ’Ŗ
šŸ‘ 10
o
Do you have examples of generated code?
g
We should probably add an example in the repo where the folder is not `.gitignore`d
t
How does this differ to the other gradle swagger plugins?
g
This is more ā€œopinionatedā€, it generates Moshi/RxJava2/Retrofit code.
Moreover it creates a
generateSwagger
gradle task that you can plug in your pipeline. E.g. you can make it run locally before your builds, or you can setup a CI job to create an Android/Java artifact and upload it somewhere to use it.
Our usecase is mostly the latter: whenever there is a new change in the swagger spec, a new Android archive will be published on our internal nexus. Developers just have to bump the library to get the latest Retrofit interfaces/Data classes.
t
I’m not criticizing, I’ve just done something similar interally - it’s just the existing gradle plugin can do that for you with you just providing templates
g
Great šŸ˜„ Which plugin are you talking to btw? https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin <- This?
m
This one is WAY better. The team developing this used to work on the swagger one until SmartBear took over, and they had differing opinions. The OpenAPI support V2 and V3 of Swagger/OpenApi specs from the same codebase. The plugin provides generate tasks etc. There are a number of good templates, and instructions to create your own. I suspect this will speed up your development. https://github.com/OpenAPITools/openapi-generator
t
@gammax this is the one I was talking about -> https://github.com/int128/gradle-swagger-generator-plugin
m
I've used both of the other ones and have moved to open api one. It supports v2 and v3 out of the box, many templates already, actively developed. Highly recommend it over the other 2 suggestions. But obviously you need to decide which fulfils your needs best.
g
@Olivier To answer your question: samples are forthcoming https://github.com/Yelp/swagger-gradle-codegen/pull/12
@tddmonkey And the answer to your question is here: https://github.com/Yelp/swagger-gradle-codegen/issues/8#issuecomment-461514382
t
Thanks!
Like I said - we run a customised one on our projects too, so I can see the need
425 Views