I am creating android client for my WordPress website . Is there a way to generate retrofit 2 client library from wp rest client using swagger or is there any other tool to generate the same .
3 Answers
Citing from here, yes it is part of the existing codegen module of swagger:
The latest Java API client supports different HTTP client including Retrofit. To use Retrofit, please create a config.json file as follows:
{ "library": "retrofit" }
and pass config.json via -c in the command line
You can run java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l java for more information on customizing the Java API client.

- 563
- 3
- 13
-
I know that swagger support retrofit but where Do I get API specification from or do I need to write by myself . Or is there any other way – Rahul Apr 28 '16 at 13:16
-
You need to provide the API specification (OpenAPI/Swagger) in order to generate the Retrofit2 client. – William Cheng Apr 29 '16 at 00:28
-
@wing328 That is what i don't want to do. Wp-api provide client lib for javascript , angularjs and for some other languages too. I just want to is there any already written client side library . – Rahul Apr 29 '16 at 03:24
As per discussion with wp-api team they are not providing any HTTP client library for android and also they are not planning to provide the same .
Please follow below link for the issue created in wp-api

- 367
- 2
- 6
- 27
If you have a swagger 2.0 you better try Swagger Gradle Codegen, Generates Kotlin code and Retrofit interfaces, with RxJava2 for async calls, Moshi for serialization and ThreeTenABP for Data management

- 3,310
- 3
- 25
- 41