Author: Jordy Hamwijk
Created: 2024-04-05
Last updated: 2024-05-17</br>
A CRUD REST API allows clients to perform basic operations on resources via HTTP requests. These operations include creating new resources, reading existing ones, updating resource data, and deleting resources. It adheres to the principles of REST, ensuring a predictable and uniform interface for communication between clients and servers.</br>
CRUD stands for Create, Read, Update, and Delete. </br>
It represents the four fundamental operations used to interact with database applications.
These operations allow developers to manipulate data within a collection or database.
Here’s what each function does:
Spring Boot simplifies building RESTful APIs by providing a framework for handling HTTP requests and integrating with databases.</br>
Go to Spring and create a new Spring Boot project.

Add additional dependencies:
<!-- https://springdoc.org/ -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.openapi-ui}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-api</artifactId>
<version>${springdoc-openapi-starter-webflux-api}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc-openapi-starter-webmvc-ui}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>${springdoc.openapi.starter.webmvc.api}</version>
</dependency>
<!-- https://modelmapper.org/getting-started/ -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
</dependency>
//User is the parent class of Profile
@Tag(name = "USER", description = "User applicatie Endpoints")
@RequestMapping(RequestPath.V1 + RequestPath.USER)
public interface UserApi {
@GetMapping("/{code}")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
@Operation(summary = "User weergeven op basis van code.")
UserDTO getUserByCode(@PathVariable(value = "code")
@Parameter(example = "ABCD", description = "test") String code);
}
@Tag(name = "USER", description = "User applicatie Endpoints")
@RequestMapping(RequestPath.V1 + RequestPath.USER)
public interface UserApi {
@GetMapping()
@Operation(summary = "Lijst weergeven met alle users als paging.")
@Parameter(name = "page", schema = @Schema(type = "integer", defaultValue = "0"), in = ParameterIn.QUERY)
@Parameter(name = "size", schema = @Schema(type = "integer", defaultValue = "20"), in = ParameterIn.QUERY)
PagedModel<?> getAllUsersPageable(@ParameterObject @Parameter(hidden = true) Pageable pageable);
}
@Tag(name = "USER", description = "User applicatie Endpoints")
@RequestMapping(RequestPath.V1 + RequestPath.USER)
public interface UserApi {
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
//@PreAuthorize("hasAuthority('admin:READ)")
@Operation(summary = "Nieuwe user aanmaken.")
@ResponseBody
UserDTO createUser(@Valid @RequestBody UserDTO userDTO);
}
Feedback is always welcome. If you have any questions, comments, or suggestions, please do not hesitate to reach out.
Star the repository to show your support.
Follow me for more interesting repositories!