https://github.com/sawicki-rafal/city-list-app-client
Open a command line (or terminal) and navigate to the folder where you have the project files. One can build and run the application by issuing the following command:
MacOS/Linux
./mvnw spring-boot:run
Windows
mvnw spring-boot:run
There are two users in app:
username | password | roles |
---|---|---|
reader | reader | ROLE_ALLOW_READ |
editor | editor | ROLE_ALLOW_READ, ROLE_ALLOW_EDIT |
Authorization is done using basic authentication.
Server on default runs on http://localhost:8081/. Therefore, API is available on http://localhost:8081/api. Available endpoints:
- /cities
- description: Get list of cities in pagable format.
- method: GET
- params:
- page - the offset to be taken according to the underlying page and size.
- size - the number of items to be returned.
- example request:
- example response:
{
"content": [
{
"id": 1,
"name": "Tokyo",
"photoUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Skyscrapers_of_Shinjuku_2009_January.jpg/500px-Skyscrapers_of_Shinjuku_2009_January.jpg"
},
{
"id": 2,
"name": "Jakarta",
"photoUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Jakarta_Pictures-1.jpg/327px-Jakarta_Pictures-1.jpg"
}
],
"pageable": {
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"offset": 0,
"pageSize": 2,
"pageNumber": 0,
"unpaged": false,
"paged": true
},
"last": false,
"totalElements": 1000,
"totalPages": 500,
"size": 2,
"number": 0,
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"first": true,
"numberOfElements": 2,
"empty": false
}
-
/cities/{name}
- description: Get list of cities that starts with prefix name in a pagable format..
- method: GET
- example request:
- response: see GET /cities
-
/cities/{id}
- description: Edit city.
- id - id of the requested city
- method: PUT
- body: DTO in JSON format, ex.
{
"name": "put new name here",
"photoUrl": "put new photo url here"
}
-
- response: DTO in JSON format, ex.
{
"id": 32,
"name": "London",
"photoUrl": "https://new.url.com"
}