Skip to content

A REST API that creates brands and adds products to those brands.

Notifications You must be signed in to change notification settings

Jenkins1128/REST-API-Showroom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

REST API - Showroom

The Showroom REST API creates brands and adds products to those brands.

Isaiah Jenkins

Technologies

  • Java (Server-side language)
  • Hibernate (ORM)
  • MySQL (Server)
  • MySQL Workbench (visual database design tool for MySQL database)
  • Jersey (JAX-RS)
  • Tomcat (Web server)
  • Postman (REST Client)
  • Maven (Dependency Injection)
  • Eclispe (IDE, Jave EE version 2020-12)

Download Eclispe IDE, MySQL tools, and Postman

  1. Eclispe (IDE, Java EE version 2020-12)
  2. MySQL Community Server
  3. MySQL Workbench
  4. Postman

Set up schema and tables on MySQL Workbench

Note: Make sure to start your MySQL server on your computer.

Schema - showroom

Screen Shot 2021-03-10 at 1 57 38 PM

Tables - brands, products

Screen Shot 2021-03-10 at 2 01 21 PM

Screen Shot 2021-03-10 at 2 02 17 PM

In the products table, set up a foreign key for brand id referenced to the brands table in showroom schema. Each product is tagged to a brand with the brand's id.

Screen Shot 2021-03-10 at 2 10 10 PM

How to run the project

  1. Open Eclipse.
  2. Right-click on "restapi" project folder.
  3. Click Run As -> Run on Server.
  4. Make sure the web server is the latest Tomcat for v9.x.x.
  5. Hit Finish.

Use Postman to test application

Important: Make sure the Content-type header is set to application/json for the requests except for DELETE operation.

Create a brand

Ex:

POST http://localhost:8080/restapp/showroom/brands 

In BODY, send raw JSON object like below

{
    "brandName": "my brand"
}

Get all brands

Ex: 

GET http://localhost:8080/restapp/showroom/brands

No body

Get brand by brand id

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4

No body

Get products by brand id

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4/products

No body

Get products by brand id and category

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4/products?category=clothing

No body

Update brand name by brand id

Ex: 

PUT http://localhost:8080/restapp/showroom/brands/16

In BODY, send raw JSON object like below

{
    "brandId": 16,
    "brandName": "brand18"
}

Delete brand by id

Ex: 

DELETE http://localhost:8080/restapp/showroom/brands/16

No body

Releases

No releases published

Packages

No packages published

Languages