Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 2.29 KB

File metadata and controls

77 lines (61 loc) · 2.29 KB

java-spring-boot-rest-api

This project serves as a demonstration of building a RESTful API using Java Spring Boot. REST, or Representational State Transfer, is an architectural style for designing APIs (Application Programming Interfaces) that enable different software systems to communicate and interact with each other over the internet. It emphasizes using standard HTTP methods (like GET, POST, PUT, DELETE) to perform actions on resources (such as data) in a clear and consistent manner. RESTful APIs allow clients (applications or devices) to request and manipulate data by following a set of conventions, making it a widely used approach for building web services and APIs.

Requirements

Docker

Technologies

Java 17 (openjdk), Maven, Spring Boot

sh folder

The sh folder allows you to quickly launch docker commands to perform tasks

Build project

On the root folder

sh sh/build

Run the project

sh sh/deploy

The service is deployed at http://localhost:8085

Swagger

Swagger UI, the interactive documentation tool for your API, is accessible at the URL http://localhost:8085/swagger-ui/index.html, providing a user-friendly interface to explore and test your APIs. Additionally, the raw Swagger JSON representation of your API documentation can be accessed at http://localhost:8085/v3/api-docs, serving as a machine-readable document describing your API endpoints and schemas.

Query

Get all personnes :

curl -X 'GET' \
  'http://localhost:8085/api/personnes' \
  -H 'accept: */*'

Create personne :

curl -X 'POST' \
  'http://localhost:8085/api/personnes' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "firstName": "toto",
  "lastName": "tata"
}'

Get a personne :

curl -X 'GET' \
  'http://localhost:8085/api/personnes/1' \
  -H 'accept: */*'

Update personne :

curl -X 'PUT' \
  'http://localhost:8085/api/personnes/1' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "firstName": "new-first-name",
  "lastName": "new-last-name"
}'

Delete personne

curl -X 'DELETE' \
  'http://localhost:8085/api/personnes/1' \
  -H 'accept: */*'