Rest Client Generator

Java annotation processor for the implementation of rest calls.

License

License

Categories

Categories

Spring Boot Container Microservices CLI User Interface Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

io.github.raphasil.rest-client-generator
ArtifactId

ArtifactId

webclient-generator-spring-boot-autoconfigure
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Rest Client Generator
Java annotation processor for the implementation of rest calls.
Project URL

Project URL

https://raphasil.github.io/rest-client-generator
Source Code Management

Source Code Management

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

Download webclient-generator-spring-boot-autoconfigure

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
io.github.raphasil.rest-client-generator : api jar 0.0.1
org.springframework.boot : spring-boot-starter-webflux jar

runtime (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-validation jar
org.springframework.boot : spring-boot-autoconfigure jar

Project Modules

There are no modules declared in this project.

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);

}

Versions

Version
0.0.1