This API as been design to be used to test Swift Kitura framework 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
Generate Jazzy docs under macOS :
run jazzy
and .jazzy.yaml
will do the rest
you can also pass some options see the official documentation Jazzy
access online docs : Docs
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
Run a docker container that contains a postgres database. With environnement variable you can specify the name of db, a username and a password
$ docker run --name *name* -e POSTGRES_PASSWORD=*pwd* -e POSTGRES_USER=*userName* -e POSTGRES_DB=*dbName* -d postgres
Then lauch this command inside the project folder. If you want to set it :
```shell
$ docker build -t *name* .
if your working behind a proxy you need to set proxy with '--build-arg' :
$ docker build --build-arg http_proxy=*yourproxy* --build-arg https-proxy=*yourhttpsproxy* -t *name* .
please be careful about http_proxy and HTTP_PROXY you can have some issues if your not using it correctly. For example apt-get works fine with http_proxy but not with HTTP_PROXY
name correspond au nom que vous voulez donner à l'image
$ docker run -it --rm --link *databaseContainerName*:database -p 8080:8080 -v `pwd`:`pwd` -w `pwd` *name*
if your application recover database settings through environnement variable please use -e options with run commands :
$ docker run -it --rm --link *databaseContainerName*:database -e DATABASE_USER=USER -p 8080:8080 -v `pwd`:`pwd` -w `pwd` *name*
you can also modify the 'Dockerfile' and add some lines to provide directly the ENV variables (NOT RECOMMENDED) :
# this is an example you have to make it match your application and database settings
ENV DATABASE_USER=USER
ENV DATABASE_DB=storeDB
ENV DATABASE_HOST=...
Coming
- Database connection
- Stores routes
- Products routes
- Stock routes
- Docker
- Linux compatibility
- API docs
- Unit tests
- CI
- Code Cov