This API as been design to be used to test Vapor framework (Swift) performances.
This API is build to work with a PostgreSQL database and provide a way to interact with stores and products through an relational model.
Stores | Products | Stock | Errors
URL : api/v1/stores
| api/v1/stores/:id
Method : GET
,POST
| DELETE
, PATCH
GET
URL Params : none | id: required
Parameters : Limit
and Offet
with GET | None
Request body Structure :
// Store obj
{
"refStore": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"vat":Double, // optional
"currency":String, // optional
"merchantkey":String // optional
}
Code
Content:
// Store obj
{
"refStore": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"vat":Double, // optional
"currency":String, // optional
"merchantkey":String // optional
}
OR
[
{
"refStore": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"vat":Double, // optional
"currency":String, // optional
"merchantkey":String // optional
},{
"refStore": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"vat":Double, // optional
"currency":String, // optional
"merchantkey":String // optional
}
,...
]
Content:
// Store obj
{
"refStore": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"vat":Double, // optional
"currency":String, // optional
"merchantkey":String // optional
}
URL : api/v1/products
| api/v1/products/:id
Method : GET
,POST
| DELETE
, PATCH
GET
URL Params : none | id: required
Parameters : Limit
and Offet
with GET | None
Request body Structure :
// Product obj
{
"refproduct": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"creationdate":Date // Auto generated do not modify
}
Code
Content:
// Product obj
{
"refproduct": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"creationdate":Date // Auto generated do not modify
}
OR
[
// Product obj
{
"refproduct": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"creationdate":Date // Auto generated do not modify
},{
"refproduct": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"creationdate":Date // Auto generated do not modify
}
,...
]
Content:
// Product obj
{
"refproduct": String // Auto generated do not modify
"name": String, // required
"picture":String, // optional
"creationdate":Date // Auto generated do not modify
}
URL : api/v1/stores/:storeId/products
| api/v1/stores/:storeId/products/:productId
Method : GET
,POST
| DELETE
, PATCH
GET
URL Params : storeId: required | storeId: required, productId: required
Parameters : Limit
and Offet
with GET | None
Request body Structure :
// Stock obj
{
"product_refproduct": String // Auto generated do not modify
"product_name": String, // required
"product_picture":String, // optional
"product_creationdate":Date, // Auto generated do not modify
"refproduct":String,
"refstore":String,
"quantity":Int,
"vat":Double,
"priceht":Double,
"status":String,
"creationdate":Date,
"lastupdate":Date
}
Code
Content:
// Stock obj
{
"product_refproduct": String // Auto generated do not modify
"product_name": String, // required
"product_picture":String, // optional
"product_creationdate":Date, // Auto generated do not modify
"refproduct":String,
"refstore":String,
"quantity":Int,
"vat":Double,
"priceht":Double,
"status":String,
"creationdate":Date,
"lastupdate":Date
}
OR
[
// Product obj
// Stock obj
{
"product_refproduct": String // Auto generated do not modify
"product_name": String, // required
"product_picture":String, // optional
"product_creationdate":Date, // Auto generated do not modify
"refproduct":String,
"refstore":String,
"quantity":Int,
"vat":Double,
"priceht":Double,
"status":String,
"creationdate":Date,
"lastupdate":Date
} ,{
"product_refproduct": String // Auto generated do not modify
"product_name": String, // required
"product_picture":String, // optional
"product_creationdate":Date, // Auto generated do not modify
"refproduct":String,
"refstore":String,
"quantity":Int,
"vat":Double,
"priceht":Double,
"status":String,
"creationdate":Date,
"lastupdate":Date
}
,...
]
Content:
// Stock obj
{
"product_refproduct": String // Auto generated do not modify
"product_name": String, // required
"product_picture":String, // optional
"product_creationdate":Date, // Auto generated do not modify
"refproduct":String,
"refstore":String,
"quantity":Int,
"vat":Double,
"priceht":Double,
"status":String,
"creationdate":Date,
"lastupdate":Date
}
Example :
-
Empty JSON Body for POST or PATCH
-
Missing required properties POST
-
Wrong limit or offset ( < 0 )
Example : Id not found in database
$ docker pull postgres
$ docker pull swift
$ docker run --name *containerName* -e POSTGRES_PASSWORD=*pwd* -e POSTGRES_USER=*userName* -e POSTGRES_DB=*dbName* -d postgres
$ docker build -t *name* .
$ docker run -it --rm --link *databaseContainerName*:database -p 8080:8080 -v `pwd`:`pwd` -w `pwd` *perfectImageName*
You should update value in Config file postgresql.json to match your database information
Coming Soon
- Database connection
- Stores routes
- Products routes
- Stock routes
- Docker
- Linux compatibility
- API docs
- Unit tests
- CI
- Code Cov