| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
An API for product management. This project is built with Java, Spring Boot, and Spring Framework. The API main URL /products.
This API provides HTTP endpoint's and tools for the following:
To test the application import src/main/resources/insomnia_collection.json file on Insomnia App
POST/products
This end-point is called to add a new Product.
Body:
{
"name": "Product name",
"description": "Product description",
"price": 99.5
}Where:
name - product name (required)
description - product description (required)
price – product price(parsable as a BigDecimal (required)
Return: Returns all info about the added product including the generated id:
{
"id": "2018795b-3537-4ddc-a22f-69e90116c6c4",
"name": "Product name",
"description": "Product description",
"price": 99.5
}PUT/products/{id}
This end-point is called to update a existing Product.
Path param:
id - product id to update (required)
Body:
{
"name": "Product name",
"description": "Product description",
"price": 99.5
}Where:
name - product name (required)
description - product description (required)
price – product price(parsable as a BigDecimal (required)
Return: Returns all info about the updated product including the generated id:
{
"id": "2018795b-3537-4ddc-a22f-69e90116c6c4",
"name": "Product name",
"description": "Product description",
"price": 99.5
}DELETE/products/{id}
This end-point is called to delete a existing Product.
Path param:
id - product id to delete (required)
Return: Returns the http status code to operation:
GET/products/{id}
This end-point is called to find a unique product Product.
Path param:
id - product id to find (required)
Return: Returns all about the product:
{
"id": "2018795b-3537-4ddc-a22f-69e90116c6c4",
"name": "Product name",
"description": "Product description",
"price": 99.5
}GET/products
This end-point is called to find all Products.
Return: Returns the list of products:
[
{
"id": "2018795b-3537-4ddc-a22f-69e90116c6c4",
"name": "Product name",
"description": "Product description",
"price": 99.5
},
{
"id": "2018795b-3537-4ddc-a22f-69e901163364",
"name": "Product name 2",
"description": "Product description 2",
"price": 10.5
},
]GET/products/search?q={expression}&min_price={min_price}&max_price={max_price}
This end-point is called to find products by some cryteria.
Query params:
q - product name or description
min_price - Minimum product price
max_price - Maximum product price
Return: Returns the list of products:
[
{
"id": "2018795b-3537-4ddc-a22f-69e90116c6c4",
"name": "Product name",
"description": "Product description",
"price": 99.5
},
{
"id": "2018795b-3537-4ddc-a22f-69e901163364",
"name": "Product name 2",
"description": "Product description 2",
"price": 10.5
},
]This project was developed with:
The API also was developed to run with an jar. In order to generate this jar, you should run:
mvn packageThis command will clean, compile and generate a jar at target directory, e.g. products-java-api-1.0.0-SNAPSHOT.jar
This project uses H2 database. This database run in memory!. On run the project automatically will create a database, table and populate with 5 products!.
mvn testIn order to run the API, run the jar as following:
java -jar products-java-api-1.0.0-SNAPSHOT.jar --spring.profiles.active=devor
mvn spring-boot:run -Dspring.profiles.active=devBy default, the API will be available at http://localhost:9999
| Back | FazBrowse Home | New Git URL |