Commit 7b43d51e authored by Tomáš Biloš's avatar Tomáš Biloš
Browse files

Merge branch 'feat/curl' into 'main'

feat: Add sample curl API testing commands

Closes #43

See merge request !88
parents 7bb300ee 7550d886
......@@ -68,3 +68,115 @@ The diagrams were made in plantUML available at https://plantuml.com/.
### Usecase Diagram
[<img src="backend/docs/useCase.png">]()
## Testing the API
Here are some sample `curl` commands you can try to test out the REST API. Make sure you have `jq` installed if you want pretty outputs. If you want to test out `POST` and `DELETE`, simply swap them out for `PUT` and `GET`, respectively.
```bash
# Missions
curl -X 'GET' 'http://localhost:8080/pa165/missions' | jq
curl -X 'PUT' \
'http://localhost:8080/pa165/missions/3' \
-H 'Content-Type: application/json' \
-d '{
"id": "3",
"name": "Darude",
"start": "2011-08-29",
"durationInDays": 3,
"objective": "Blow up stuff, do some research on the rich politicians, run, ??, profit.",
"country": {
"id": "1",
"name": "Czechia"
},
"agentAssignments": [],
"resources": [
{
"id": "2",
"name": "Small bombs mainly to distract attention."
},
{
"id": "5",
"name": "Car Honda S2000"
},
{
"id": "7",
"name": "Humvee"
}
]
}' | jq
curl -X 'GET' 'http://localhost:8080/pa165/missions/3' | jq
# Agents
curl -X 'GET' 'http://localhost:8080/pa165/agents' | jq
curl -X 'PUT' \
'http://localhost:8080/pa165/agents/1020' \
-H 'Content-Type: application/json' \
-d '{
"id": "1020",
"name": "Felipe",
"agentRole": "REGULAR",
"training": "Specializes in trafficking and Spanish.",
"codeNames" :[
{
"id":"3",
"codeName": "Obej"
}
],
"skills": [
{
"id": "3020",
"name": "trafficking"
},
{
"id":"1050",
"name":"spanish"
}
]
}' | jq
curl -X 'GET' 'http://localhost:8080/pa165/agents/1020' | jq
# Countries
curl -X 'GET' 'http://localhost:8080/pa165/countries' | jq
curl -X 'PUT' \
'http://localhost:8080/pa165/countries/1' \
-H 'Content-Type: application/json' \
-d '{
"id": "1",
"code": "CZE",
"name": "Czechia",
"demographics": "There is Captain Demo, so yes.",
"geography": "almost perfectly central in Europe",
"communications": "great comms",
"government": "Mostly democratic western-style",
"economy": "high inflation, but quite balanced economy",
"military": "Not that bad",
"missionIds": null
}' | jq
curl -X 'GET' 'http://localhost:8080/pa165/countries/1' | jq
# Assignments
curl -X 'GET' 'http://localhost:8080/pa165/assignments/1' | jq
curl -X 'PUT' \
'http://localhost:8080/pa165/assignments/1' \
-H 'Content-Type: application/json' \
-d '{
"id": "1",
"start": "2016-08-10",
"durationInDays": 12,
"report": "Well done indeed!",
"mission": {
"id": "1",
"name": "Replenish"
},
"agent": {
"id": "1000",
"name": "Jonathan"
}
}' | jq
curl -X 'GET' 'http://localhost:8080/pa165/assignments/1' | jq
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment