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 .
Retrofit is a REST Client for Java and Android allowing to retrieve and upload JSON (or other structured data) via a REST based You can configure which converters are used for the data serialization, example GSON for JSON.
Retrofit is type-safe REST client for Android and Java which aims to make it easier to consume RESTful web services.
Retrofit is a type-safe REST client for Android, Java and Kotlin developed by Square. The library provides a powerful framework for authenticating and interacting with APIs and sending network requests with OkHttp. See this guide to understand how OkHttp works.
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.
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
https://github.com/WP-API/WP-API/issues/2473
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With