Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate Retrofit client library from wp rest api using swagger

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 .

like image 206
Rahul Avatar asked Apr 26 '16 11:04

Rahul


People also ask

Is retrofit a REST client?

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.

What is retrofit REST API?

Retrofit is type-safe REST client for Android and Java which aims to make it easier to consume RESTful web services.

What is retrofit HTTP client?

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.


2 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.

like image 170
J. Dow Avatar answered Oct 28 '22 21:10

J. Dow


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

like image 36
Rahul Avatar answered Oct 28 '22 19:10

Rahul