100% found this document useful (2 votes)
206 views3 pages

REST API Design for Java Developers

The document outlines requirements for building a REST API using Spring to manage orders and items. It specifies using Derby DB with JPA, returning JSON payloads from API endpoints, and creating endpoints to create a new order, get an order by ID, and get all orders. The table structure defines an Order with order details and a collection of related Items.

Uploaded by

Muthyala Akhil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
206 views3 pages

REST API Design for Java Developers

The document outlines requirements for building a REST API using Spring to manage orders and items. It specifies using Derby DB with JPA, returning JSON payloads from API endpoints, and creating endpoints to create a new order, get an order by ID, and get all orders. The table structure defines an Order with order details and a collection of related Items.

Uploaded by

Muthyala Akhil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Build REST API using Spring

You can use Derby for DB and you must use JPA to map objects to DB
API endpoints should accept json payload and return json payload and return proper
HTTP status. Try to use proper annotation and minimum code.
Project should be a build in maven and do send instruction file containing steps to
execute your code.

Following should be the Table Structure.


Order
orderId(PK)
orderDate
orderStatus
collection of Items

Item
itemId(PK)
orderId(FK)
itemName
itemUnitPrice
itemQuantity

Create following API endpoints.


1. Create New Orders

POST - order/create
[
{
"orderDate" : "",
"items" :[
{ "itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
},
{
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
}
]
},
{
"orderDate" : "",
"items" :[
{
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
},
{
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
}
]
}
]

2. Get Order by ID
GET - order/{order_id}
{
"orderId" : "",
"orderDate" : "",
"orderStatus" : "New",
"items" :[
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
},
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
}
]
}

3. Get all orders

GET - orders
[
{
"orderId" : "",
"orderDate" : "",
"orderStatus" : "New",
"items" :[
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
},
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
}
]
},
{
"orderId" : "",
"orderDate" : "",
"orderStatus" : "New",
"items" :[
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
},
{
"itemId" : "",
"itemName" :"",
"itemUnitPrice" : "",
"itemQuantity" : 4
}
]
}
]

You might also like