Skip to content

Latest commit

 

History

History
78 lines (55 loc) · 7.27 KB

README.md

File metadata and controls

78 lines (55 loc) · 7.27 KB

Automation Practice App

This is an Application Programming Interface (API) where you can perform actions with users, roles this user have, skills this users might have.

Content

  1. ERD Diagram
  2. Swagger documentation
  3. API definitions

1. ERD Diagram

This diagram gives the idea about the entities in the project and the entities in the database (In Postgres).

DB ERD

2. Swagger documentation

You can find a swagger documentation here: swagger-ui This one is not pretty accurate but gives the most important ideas about what this API can do. You can also use in this UI the open endpoint "role-test-controller" where you can perform actions (CRUD) for role entity.

3. API Definitions

This application uses authentication (Bearer token) so any action/request you want to make, need first to login. In case you don't pass a token or wrong one then you will get 401 Unauthorized status response. There is one open endpoint where you don't need token to use "role-test-controller". We recommend use a tool such as Postman to create the request and be able of send the Bearer token where need it. Also remember in case the system is down or have any internal issue, all endpoints might return 500 status code.

Endpoints/Controllers:

A. Auth

Here you can authenticate against the system and this will return a token to make the requests. Also you will be able to sign up if you want a personal account.

Method Endpoint Possible return values Description JSON Body Example
POST /login 200 OK, 401 Unauthorized You authenticate against the system and if the credentials are valid will give you a token with duration of one day {
 "username": "admin",
 "password": "admin"
}
POST /signup 201 Created, 400 Bad Request You can create an account in the system to login and get a token. You will be created with default role "user" {
 "username": "admin",
 "password": "admin",
 "email": "[email protected]"
}

B. Role

Method Endpoint Possible return values Description JSON Body Example
GET /roles 200 OK Get all the roles registered in the database Empty
POST /roles 201 Created, 400 Bad Request Create a new role in the database system. The name should be unique {
 "name": "MyRole"
}
GET /roles/{id} 200 OK, 404 Not Found Get an specific role by it's id Empty
PUT /roles/{id} 200 OK, 404 Not Found Update an specific role name by it's id {
 "username": "admin",
 "password": "admin"
}
DELETE /roles/{id} 204 No Content, 404 Not Found Delete from system's database a specific role Empty

C. Role Test (Open API - No token needed)

Method Endpoint Possible return values Description JSON Body Example
GET api/test/roles 200 OK Get all the roles registered in the database Empty
POST api/test/roles 201 Created, 400 Bad Request Create a new role in the database system. The name should be unique {
 "name": "unique name"
}
GET api/test/roles/{id} 200 OK, 404 Not Found Get an specific role by it's id Empty
PUT api/test/roles/{id} 200 OK, 404 Not Found Update an specific role name by it's id {
 "name": "name updated"
}
DELETE api/test/roles/{id} 204 No Content, 404 Not Found Delete from system's database a specific role Empty

D. Skill

Method Endpoint Possible return values Description JSON Body Example
GET /skills 200 OK Get all the skills registered in the database. This one works with pagination so you can pass as an url parameter page and/or offset the first one if there is more than 10 elemens and the second defines how many elements will retrieve Empty
POST /skills 201 Created, 400 Bad Request Create a new skill in the database system. The name should be unique {
 "name": "unique skill name"
}
GET /skills/{id} 200 OK, 404 Not Found Get an specific skill by it's id Empty
GET /skills/mine 200 OK Get the skills of the user who belongs the token
PUT /skills/{id} 200 OK, 404 Not Found Update an specific skill name by it's id {
 "name": "skill name updated"
}
DELETE /skills/{id} 204 No Content, 404 Not Found Delete from system's database a specific skill Empty

E. User

Method Endpoint Possible return values Description JSON Body Example
GET /users 200 OK Get all the users registered in the database Empty
POST /users 201 Created, 400 Bad Request Create a new user in the database system. You will be created with default role "moderator" {
 "username": "username_unique",
 "email": "[email protected]",
 "password": "uniqueadmin",
 "role": [
  "admin",
  "user"
 ]
}
GET /users/{username} 200 OK, 404 Not Found Get an specific user by it's username Empty
PUT /users/{username} 200 OK, 404 Not Found Update an specific user name by it's username {
 "username": "username_unique",
 "email": "[email protected]",
 "roles": [
  "admin",
  "mod"
 ]
}
DELETE /users/{username} 204 No Content, 404 Not Found Delete from system's database a specific user Empty