Rest Client Generator

Java annotation processor for the implementation of rest calls.

Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

io.github.raphasil.rest-client-generator
Идентификатор

Идентификатор

core
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Rest Client Generator
Java annotation processor for the implementation of rest calls.
Ссылка на сайт

Ссылка на сайт

https://raphasil.github.io/rest-client-generator
Система контроля версий

Система контроля версий

https://github.com/raphasil/rest-client-generator

Скачать core

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.raphasil.rest-client-generator/core/ -->
<dependency>
    <groupId>io.github.raphasil.rest-client-generator</groupId>
    <artifactId>core</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.raphasil.rest-client-generator/core/
implementation 'io.github.raphasil.rest-client-generator:core:0.0.1'
// https://jarcasting.com/artifacts/io.github.raphasil.rest-client-generator/core/
implementation ("io.github.raphasil.rest-client-generator:core:0.0.1")
'io.github.raphasil.rest-client-generator:core:jar:0.0.1'
<dependency org="io.github.raphasil.rest-client-generator" name="core" rev="0.0.1">
  <artifact name="core" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.raphasil.rest-client-generator', module='core', version='0.0.1')
)
libraryDependencies += "io.github.raphasil.rest-client-generator" % "core" % "0.0.1"
[io.github.raphasil.rest-client-generator/core "0.0.1"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.github.raphasil.rest-client-generator : api jar 0.0.1

runtime (2)

Идентификатор библиотеки Тип Версия
com.squareup : javapoet jar
com.google.auto : auto-common jar

test (3)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter jar
org.mockito : mockito-core jar
org.assertj : assertj-core jar

Модули Проекта

Данный проект не имеет модулей.

Rest Client Generator

Maven Central License

Build Status codecov Code Quality: Java Total Alerts

Introduction

RestClientGenerator is a Java annotation processor for the implementation of rest calls

Getting Started

Take a look here.

API Declaration

Annotations on the interface methods and its parameters indicate how a request will be handled.

Request Method

Every method must have an HTTP annotation that provides the request method and relative path. There are eight built-in annotations: HTTP, GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD. The relative path of the resource can be defined in the annotation.

@RestClient("client-one")
interface UserService {
    @GET("api/v1/users")
    List getUsers();
}

URL Manipulation

A request URL can be updated dynamically using replacement blocks and parameters on the method. A replacement block is an alphanumeric string surrounded by { and }. A corresponding parameter must be annotated with @Path using the same string or variable name.

@RestClient(value = "client-one", path = "api/v1/users")
interface UserService {
    
    @GET("{id}")
    User getUserById(@Path UUID id);
    
    @GET("api/v1/users/{id}/profiles/{profile-id}")
    User getUserProfile(@Path UUID id, @Path("profile-id") String profileId);

}

A query parameter can also be added:

@RestClient("client-one")
interface UserService {
    
    // result: api/v1/users?sort=""&nickname=""
    @GET("api/v1/users")
    List<User> getAll(@Query String sort, @Query("nickname") String name);

}

Request Body

An object can be specified for use as an HTTP request body with the @Body annotation.

@RestClient("client-one")
interface UserService {
        
    @POST("api/v1/users")
    User create(@Body User user);

}

Header Manipulation

You can set static headers for a method using the @Headers annotation.

@RestClient("client-one")
interface UserService {
    
    @Headers("x-ping: pong")    
    @POST("api/v1/users")
    User create(@Body User user);
    
    @Headers({
                 "Accept: application/txt",
                 "x-api-key: secret"
             })    
    @PUT("api/v1/users")
    User create(@Body User user);
    
    @GET("api/v1/users")
    User getUser(@Header("Authorization") String admin);

}

Версии библиотеки

Версия
0.0.1