Java ecosystem has many mature libraries enabling us to write REST APIs with little or no code for wiring the various aspects, and only focus on core business logic. A few of such libraries are Spring WebMVC, Dropwizard, Jersey, RESTEasy etc.
This page is a comprehensive guide for building and testing the REST APIs in Java. It aims to cover the most important aspects of REST constraints and how to integrate those constraints into our API source code.
We will start with REST basics and REST Clients and gradually move towards advanced topics such as API security and API monitoring.
1. REST API Basics
- Comparing SOAP vs REST APIs
- Bootstrapping a REST API with Spring Boot
- Difference Between @Controller and @RestController
- Internationalization with Spring Boot REST
- REST API Request Validation with Spring Boot
- Spring REST Request Body and Parameter Validation
- Error Handling with Spring REST
- Adding Custom Headers to Spring Boot REST APIs
- Spring Boot REST – Consume and Produce JSON
- Writing REST Controller with Spring WebMVC
- Create Jersey REST APIs with Spring Boot
2. HATEOAS
- Intro to HATEOAS with Spring
- Building HATEOAS Links with Spring Boot REST
- Building Pagination Links with Spring HATEOAS
- Building HATEOAS Links with JAX-RS
- Building HATEOAS Links with RESTEasy and JAX-RS
3. REST Clients
3.1. Retrofit 2
- Getting Started with Retrofit 2
- Guide to Retrofit.Builder API
- Logging in Retrofit 2
- Retrofit 2 Handle Connection Timeout Exception
- Retrofit 2 Synchronous and Asynchronous Calls
- Retrofit 2 Service Generator
3.2. RestTemplate
- Intro to Spring RestTemplate
- Intro to Spring RestTemplateBuilder
- Configuring Spring RestTemplate with HttpClient
- Configuring Timeouts with Spring RestTemplate
- Spring Boot RestTemplate GET Example
- Spring Boot RestTemplate POST Example
- Logging Request and Response with Spring RestTemplate
3.3. Misc
- Generate REST Client with Swagger Codegen
- Getting Started with Jersey Client
- Consuming REST APIs with RESTEasy Client
- Consuming REST APIs with HttpClient
- Writing a Native Java REST Client
4. Testing
- Testing in Spring Boot 2
- Testing REST Controllers with Spring Boot @RestClientTest
- Testing a Spring Boot REST Controller with Junit 5 and Mockito
- Spring – @WebFluxTest with WebTestClient
- Testing POST with Headers using Spring Boot TestRestTemplate
5. Aync
- Spring WebClient vs RestTemplate
- Building Async REST APIs with Spring WebFlux
- Building WebSocket with Spring Boot WebFlux
- Building @Async REST APIs with Spring @EnableAsync
- Spring Boot Async Controller with Callable Interface
- Spring Boot Async Controller with SseEmitter
- Spring Boot Async Controller with ResponseBodyEmitter
- Consuming Async REST APIs with Spring WebClient
- Setting Timeout with Spring WebClient
- Testing Async REST APIs with @WebFluxTest and WebTestClient
- Testing Spring Async Rest Controller with MockMvc
6. Security
- REST API Security Guide
- Securing Spring Boot REST API with Basic Auth
- Adding Role-Based Security with Spring Boot REST APIs
- Spring REST Custom Token Authentication
- Securing REST APIs with RESTEasy Filter
7. Documentation, Monitoring and Advance Topics
- Generate REST API Docs with Swagger
- Spring Boot Actuator
- Spring Boot Dev Tools Tutorial
- Spring Boot REST – Internationalization
- Spring Boot REST – Response Gzip Compression
- Spring REST Multiple Uploads