Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • s3206149/mod4-wp-2023-2024-pokemon
  • s3281744/mod4-wp-2023-2024-pokemon
  • s3128989/mod4-wp-2023-2024-pokemon
  • s3263797/m-4-pokemon
  • s3203255/mod4-wp-2023-2024-pokemon
  • s2854961/mod-4-wp-2023-2024-pokemons
  • s3192016/pokemon-practical-sessions
  • s3126080/mod4-wp-2023-2024-pokemon
  • s3165442/poke-mon
  • s3187152/mod4-wp-2023-2024-pokemon
  • s3209105/mod4-wp-2023-2024-pokemon
  • s3362779/mod4-wp-2023-2024-pokemon
  • s3173011/mod-4-wp-3-2023-2024-pokemon
  • s3174506/mod4-wp-2023-2024-pokemon
  • s3216926/mod-4-wp-2023-2024-pokemon-2nd
  • s3211770/mod4-wp-2023-2024-pokemon
  • s2936011/mod4-wp-2023-2024-pokemon
  • s3234312/mod4-wp-2023-2024-pokemon
  • s3362264/mod4-wp-2023-2024-pokemon
  • s3204766/mod4-wp-2023-2024-pokemon
  • s3363775/mod4-wp-2023-2024-pokemon
  • s3142906/mod4-wp-2023-2024-pokemon
  • s3298892/mod4-wp-2023-2024-pokemon
  • s3125866/mod-4-wp-2023-2024-pokemon-update
  • s2900556/mod-4-wp-2023-2024-pokemontut-3
  • s3196801/mod4-wp-2023-2024-pokemon
  • s2507919/mod4-wp-2023-2024-pokemon
  • Marius/mod-4-pokemon
  • s2948486/mod4-wp-2023-2024-pokemon
  • s3193748/mod4-wp-2023-2024-pokemon
  • s3199800/mod4-wp-2023-2024-pokemon
  • s3152340/mod4-wp-2023-2024-pokemon
  • s3194108/mod4-wp-2023-2024-pokemon
  • s3364518/mod4-wp-2023-2024-pokemon
  • s3200205/mod4-wp-2023-2024-pokemon
  • s3187667/pokemon-server
  • s3259633/mod4-wp-2023-2024-pokemon
  • s3137279/mod4-wp-2023-2024-pokemon
  • s3213552/mod4-wp-2023-2024-pokemon
  • s3200779/mod4-wp-2023-2024-pokemon
  • s3148157/mod4-wp-2023-2024-pokemon
  • s3196372/mod4-wp-2023-2024-pokemon
  • s3126714/mod4-wp-2023-2024-pokemon
  • s3286029/pracitcal-2
  • s3262499/mod4-wp-2023-2024-pokemon
  • s3290387/mod4-wp-2023-2024-pokemon
  • s3202798/mod4-wp-2023-2024-pokemon
  • s3210715/mod4-wp-2023-2024-pokemon
  • s3198308/mod4-wp-2023-2024-pokemon
  • s3211614/mod4-wp-2023-2024-pokemon
  • s3193691/mod4-wp-2023-2024-pokemon
  • s3273733/mod4-wp-2023-2024-pokemon
  • s3210898/mod4-wp-2023-2024-pokemon
  • s3133931/mod4-wp-2023-2024-pokemon
  • s3199479/mod4-wp-2023-2024-pokemon
  • s3190285/mod4-wp-2023-2024-pokemon
  • s3002896/mod4-wp-2023-2024-pokemon
  • s3166244/mod4-wp-2023-2024-pokemon
  • s3165582/mod4-wp-2023-2024-pokemon
  • s3147851/mod-4-wp-2023-2024-pokemon
  • web-programming-sessions/mod4-wp-2023-2024-pokemon
  • s3309630/mod4-wp-2023-2024-pokemon
  • s2914980/mod4-wp-2023-2024-pokemon
  • s3000885/mod4-wp-2023-2024-pokemon
  • s3209539/mod-4-pokemon-project
  • s3203573/kai-poke-mon
  • s3138127/mod-4-wp-2023-2024-pokemon-daniel
  • s3106586/mod4-wp-2023-2024-pokemon
  • s3183394/mod4-wp-2023-2024-pokemon
  • s3245748/mod4-wp-2023-2024-pokemon
  • s3252159/dm-mod-4-wp-2023-2024-pokemon
  • s2695154/mod4-wp-2023-2024-pokemon
  • s3171825/mod4-wp-2023-2024-pokemon
  • s3200183/mod4-wp-2023-2024-pokemon
  • s3000087/mod4-wp-2023-2024-pokemon
  • s3127168/mod4-wp-2023-2024-pokemon
  • s3137333/mod4-wp-2023-2024-pokemon
  • s3128830/mod4-wp-2023-2024-pokemon
  • s3102378/mod4-wp-2023-2024-pokemon
  • s3202224/mod4-wp-2023-2024-pokemon
  • s2590654/mod4-wp-2023-2024-pokemon
  • s3154882/mod4-wp-2023-2024-pokemon
  • s2958732/mod4-wp-2023-2024-pokemon
  • s3161293/mod4-wp-2023-2024-pokemon
  • s3133656/mod4-wp-2023-2024-pokemon
  • s3157385/mod-4-wp-2023-2024-pokemon-ali
  • s3192393/mod4-wp-2023-2024-pokemon
  • s3192016/mod4-wp-2023-2024-pokemon
  • s3211347/mod4-wp-2023-2024-pokemon
  • s3152790/mod4-wp-2023-2024-pokemon
  • s2959380/mod4-wp-2023-2024-pokemon
  • s3362906/mod4-wp-2023-2024-pokemon
  • s2964546/mod4-wp-2023-2024-pokemon
  • s3214915/mod4-wp-2023-2024-pokemon
  • s2219174/mod4-wp-2023-2024-pokemon
  • s3161595/mod4-wp-2023-2024-pokemon
  • s3207803/mod4-wp-2023-2024-pokemon
  • s3209334/mod4-wp-2023-2024-pokemon
  • s3191915/mod4-wp-2023-2024-pokemon
  • s3192253/mod4-wp-2023-2024-pokemon
  • s3137090/mod4-wp-2023-2024-pokemon
  • s3190536/mod4-wp-2023-2024-pokemon2
  • s3138585/mod4-wp-2023-2024-pokemon
  • s3186792/mod4-wp-2023-2024-pokemon
  • s2998491/mod4-wp-2023-2024-pokemon
  • s3145786/mod4-wp-2023-2024-pokemon
  • s3231046/mod4-wp-2023-2024-pokemon
  • s3125866/mod4-wp-2023-2024-pokemon
  • s3140458/mod4-wp-2023-2024-pokemon
  • s3133346/mod4-wp-2023-2024-pokemon
  • s3274519/mod4-wp-2023-2024-pokemon
  • s3216551/mod4-wp-2023-2024-pokemon
  • s3237478/mod4-wp-2023-2024-pokemon
  • s2985063/mod4-wp-2023-2024-pokemon
  • s3251942/mod4-wp-2023-2024-pokemon
  • s3305155/mod-4-wp-2023-2024-pokemon-david-sastre-madueno
  • s2675072/mod4-wp-2023-2024-pokemon
  • s3136027/mod4-wp-2023-2024-pokemon
  • s3186156/mod4-wp-2023-2024-pokemon
  • s3277305/mod4-wp-2023-2024-pokemon
  • s3242404/mod4-wp-2023-2024-pokemon
  • s3205967/mod4-wp-2023-2024-pokemon
  • s3173011/mod4-wp-2023-2024-pokemon
  • s3159736/mod4-wp-2023-2024-pokemon
  • s3207269/wplab-2
  • s3195945/mod4-wp-2023-2024-pokemon
  • s3151913/mod4-wp-2023-2024-pokemon
  • s3135136/mod4-wp-2023-2024-pokemon
  • s3216926/mod4-wp-2023-2024-pokemon
  • s3161218/mod4-wp-2023-2024-pokemon
  • s2921103/mod4-wp-2023-2024-pokemon
  • s3175561/mod4-wp-2023-2024-pokemon
  • SimeonNikolov/mod4-wp-2023-2024-pokemon
  • s3200329/mod4-wp-2023-2024-pokemon
  • s3148726/mod4-wp-2023-2024-pokemon
  • s2960796/mod4-wp-2023-2024-pokemon
  • s3098117/mod4-wp-2023-2024-pokemon
  • s3180794/mod4-wp-2023-2024-pokemon
  • s3179176/mod4-wp-2023-2024-pokemon
  • s3170268/mod4-wp-2023-2024-pokemon
  • s3126188/mod4-wp-2023-2024-pokemon
  • s3166449/pokemon-sarah-vonk
  • s3191567/mod4-wp-2023-2024-pokemon
  • s3271498/mod4-wp-2023-2024-pokemon
  • s3173089/mod4-wp-2023-2024-pokemon
  • s3172716/mod4-wp-2023-2024-pokemon
  • s3188981/mod4-wp-2023-2024-pokemon
  • s3184609/mod-4-lab-1-pokemon
  • s3144569/mod4-wp-2023-2024-pokemon
  • s3181340/poke-app-lab-06-05
  • s2900556/mod4-wp-2023-2024-pokemon
  • s3177858/mod4-wp-2023-2024-pokemon
  • s3209180/mod4-wp-2023-2024-pokemon
  • s3199495/mod4-wp-2023-2024-pokemon
  • s3163660/mod4-wp-2023-2024-pokemon
  • s3172708/mod4-wp-2023-2024-pokemon
  • s3206068/mod4-wp-2023-2024-pokemon
  • s3210774/mod4-wp-2023-2024-pokemon
  • s3200175/mod4-wp-2023-2024-pokemon
  • s3127141/mod4-wp-2023-2024-pokemon
  • s2995522/pokemon-practical-2-module-4
  • s3156621/mod4-wp-2023-2024-pokemon
  • s3126099/mod4-wp-2023-2024-pokemon
  • s3128121/mod4-wp-2023-2024-pokemon
  • s3233405/mod4-wp-2023-2024-pokemon
  • s3087921/mod4-wp-2023-2024-pokemon
  • s3202119/mod4-wp-2023-2024-pokemon
  • claudenirmf/mod4-wp-2023-2024-pokemon
168 results
Show changes
Commits on Source (3)
Showing
with 572 additions and 138 deletions
...@@ -12,7 +12,14 @@ and to submit their own contributions. ...@@ -12,7 +12,14 @@ and to submit their own contributions.
![](./design/models/Class%20Diagram.png) ![](./design/models/Class%20Diagram.png)
## External resources **NOTE: this diagram has been simplified in the implementation and several fields have been omitted.**
## Support files
- `/design`: this folder different files to support the design of the PokeApp including an [OpenAPI specification](./design/open-api.yaml) containing all routes and various [HTTP request files](./design/requests) to be executed directly from IntelliJ's HTTP client.
- `./meetings/practical-session-3.md`: [this file](./meetings/practical-session-3.md) contains different guides and tips to help you work on the practical session (e.g., how to checkout a new remote branch, or how to run HTTP requests).
## Credits
The following datasets and resources have been used in the development this project. The following datasets and resources have been used in the development this project.
......
openapi: 3.0.3
info:
title: Example OpenAPI document
description: Example OpenAPI document
version: 1.0.0
servers:
- url: 'https://example.com'
paths:
'/api/pokemon':
get:
description: Retrieves pokemon resources.
responses:
200:
description: OK
\ No newline at end of file
...@@ -20,8 +20,8 @@ tags: ...@@ -20,8 +20,8 @@ tags:
description: Routes for managing data about trainers. description: Routes for managing data about trainers.
- name: Pokémon - name: Pokémon
description: Routes for managing data about pokémon. description: Routes for managing data about pokémon.
# - name: Pokémon Type - name: Pokémon Type
# description: Routes for managing data about pokémon types. description: Routes for managing data about pokémon types.
paths: paths:
/trainers: /trainers:
get: get:
...@@ -42,6 +42,26 @@ paths: ...@@ -42,6 +42,26 @@ paths:
responses: responses:
200: 200:
description: OK description: OK
content:
application/json:
example:
{
"meta": {
"total": 1,
"pageNumber": 1,
"pageSize": 1
},
"data": [
{
"id": "1",
"name": "Red",
"created": "24/04/2024",
"lastUpDate": "2024-05-12T23:12:01.660866Z",
"profileUrl": "https://archives.bulbagarden.net/media/upload/thumb/d/d3/Lets_Go_Pikachu_Eevee_Red.png/500px-Lets_Go_Pikachu_Eevee_Red.png"
}
]
}
post: post:
description: Creates a resource on the route's collection. description: Creates a resource on the route's collection.
tags: tags:
...@@ -50,10 +70,30 @@ paths: ...@@ -50,10 +70,30 @@ paths:
content: content:
'application/json': 'application/json':
schema: schema:
type: object $ref: '#/components/schemas/Trainer'
examples:
full:
description: Complete POST example
value: {
"name": "Red",
"profileUrl": "https://archives.bulbagarden.net/media/upload/thumb/d/d3/Lets_Go_Pikachu_Eevee_Red.png/500px-Lets_Go_Pikachu_Eevee_Red.png"
}
min:
description: Minimum POST example
value: { }
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example:
{
"id": "1",
"name": "Red",
"created": "24/04/2024",
"lastUpDate": "2024-05-12T23:12:01.660866Z",
"profileUrl": "https://archives.bulbagarden.net/media/upload/thumb/d/d3/Lets_Go_Pikachu_Eevee_Red.png/500px-Lets_Go_Pikachu_Eevee_Red.png"
}
400: 400:
description: Bad request description: Bad request
405: 405:
...@@ -74,6 +114,16 @@ paths: ...@@ -74,6 +114,16 @@ paths:
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example:
{
"id": "1",
"name": "Red",
"created": "24/04/2024",
"lastUpDate": "2024-05-12T23:12:01.660866Z",
"profileUrl": "https://archives.bulbagarden.net/media/upload/thumb/d/d3/Lets_Go_Pikachu_Eevee_Red.png/500px-Lets_Go_Pikachu_Eevee_Red.png"
}
404: 404:
description: Not found description: Not found
put: put:
...@@ -93,10 +143,31 @@ paths: ...@@ -93,10 +143,31 @@ paths:
content: content:
'application/json': 'application/json':
schema: schema:
type: object $ref: '#/components/schemas/Trainer'
examples:
full:
description: Complete PUT example
value: {
"id": "1",
"name": "New Red Name",
"profileUrl": null
}
min:
description: Minimum PUT example
value: { "id": "1" }
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example:
{
"id": "1",
"name": "New Red Name",
"created": "24/04/2024",
"lastUpDate": "2024-05-12T23:12:01.660866Z",
"profileUrl": null
}
400: 400:
description: Bad request description: Bad request
404: 404:
...@@ -125,96 +196,174 @@ paths: ...@@ -125,96 +196,174 @@ paths:
405: 405:
description: Server error description: Server error
# /pokemon: /pokemon:
# get: get:
# description: Retrieves a collection of resources. description: Retrieves a collection of resources.
# tags: tags:
# - Pokémon - Pokémon
# responses: responses:
# 200: 200:
# description: OK description: OK
# post: content:
# description: Creates a resource on the route's collection. application/json:
# tags: example:
# - Pokémon {
# requestBody: "meta": {
# content: "total": 1,
# 'application/json': "pageNumber": 1,
# schema: "pageSize": 1
# type: object },
# responses: "data": [
# 200: {
# description: OK "id": "1",
# 400: "created": "24/04/2024",
# description: Bad request "lastUpDate": "2024-05-12T23:12:01.660866Z",
# 405: "name": "My Pikachu",
# description: Server error "pokemonType": "513",
# /pokemon/{id}: "trainerId": "1"
# get: }
# description: Retrieves a resource with matching a {id}. ]
# tags: }
# - Pokémon post:
# parameters: description: Creates a resource on the route's collection.
# - name: id tags:
# description: The {id} of the desired resource. - Pokémon
# in: path requestBody:
# schema: content:
# type: string 'application/json':
# minLength: 1 schema:
# required: true $ref: '#/components/schemas/Pokemon'
# responses: examples:
# 200: full:
# description: OK value: {
# 404: "name": "My Pikachu",
# description: Not found "pokemonType": "513",
# put: "trainerId": "1"
# description: Replaces the resource {id} with the provided one. }
# tags: description: Complete POST example
# - Pokémon min:
# parameters: value: { }
# - name: id description: Minimum POST example
# description: The {id} of the desired resource. responses:
# in: path 200:
# schema: description: OK
# type: string content:
# minLength: 1 'application/json':
# required: true example:
# {
# requestBody: "id": "1",
# content: "created": "24/04/2024",
# 'application/json': "lastUpDate": "2024-05-12T23:12:01.660866Z",
# schema: "name": "My Pikachu",
# type: object "pokemonType": "513",
# responses: "trainerId": "1"
# 200: }
# description: OK 400:
# 400: description: Bad request
# description: Bad request 405:
# 404: description: Server error
# description: Not found /pokemon/{id}:
# 405: get:
# description: Server error description: Retrieves a resource with matching a {id}.
# delete: tags:
# description: Deletes the resource identified as {id}. - Pokémon
# tags: parameters:
# - Pokémon - name: id
# parameters: description: The {id} of the desired resource.
# - name: id in: path
# description: The {id} of the desired resource. schema:
# in: path type: string
# schema: minLength: 1
# type: string required: true
# minLength: 1 responses:
# required: true 200:
# responses: description: OK
# 204: content:
# description: No content application/json:
# 400: example:
# description: Bad request {
# 404: "id": "1",
# description: Not found "name": "My Pikachu",
# 405: "created": "24/04/2024",
# description: Server error "lastUpDate": "2024-05-12T23:12:01.660866Z",
"pokemonType": "513",
"trainerId": "1"
}
404:
description: Not found
put:
description: Replaces the resource {id} with the provided one.
tags:
- Pokémon
parameters:
- name: id
description: The {id} of the desired resource.
in: path
schema:
type: string
minLength: 1
required: true
requestBody:
content:
'application/json':
schema:
$ref: '#/components/schemas/Pokemon'
examples:
full:
value: {
"id": "1",
"name": "It's Blue's charmander",
"pokemonType": "4",
"trainerId": "2"
}
description: Complete PUT example
min:
value: {
"id": "1"
}
description: Minimum PUT example
responses:
200:
description: OK
content:
'application/json':
example:
{
"id": "1",
"created": "24/04/2024",
"lastUpDate": "2024-05-12T23:12:01.660866Z",
"name": "It's Blue's charmander",
"pokemonType": "4",
"trainerId": "2"
}
400:
description: Bad request
404:
description: Not found
405:
description: Server error
delete:
description: Deletes the resource identified as {id}.
tags:
- Pokémon
parameters:
- name: id
description: The {id} of the desired resource.
in: path
schema:
type: string
minLength: 1
required: true
responses:
204:
description: No content
400:
description: Bad request
404:
description: Not found
405:
description: Server error
/pokemonTypes: /pokemonTypes:
get: get:
...@@ -244,6 +393,44 @@ paths: ...@@ -244,6 +393,44 @@ paths:
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example: {
"meta": {
"total": 1,
"pageNumber": 1,
"pageSize": 1
},
"data": [
{
"id": "1",
"name": "Abomasnow",
"created": "24/04/2024",
"lastUpDate": "24/04/2024",
"pokedexNumber": 460,
"generation": 4,
"japaneseName": "Yukinoohユキノオー",
"classification": "Frosted Tree Pokémon",
"abilities": [
"Snow Warning",
"Soundproof"
],
"baseHeight": 2.2,
"baseWeight": 135.5,
"baseHp": 90,
"baseAttack": 132,
"baseSpAttack": 132,
"baseDefense": 105,
"baseSpDefense": 105,
"baseSpeed": 30,
"captureRate": 60,
"isLegendary": false,
"imgUrl": "./images/abomasnow.png",
"primaryType": "grass",
"secondaryType": "ice"
}
]
}
post: post:
description: Creates a resource on the route's collection. description: Creates a resource on the route's collection.
tags: tags:
...@@ -252,10 +439,48 @@ paths: ...@@ -252,10 +439,48 @@ paths:
content: content:
'application/json': 'application/json':
schema: schema:
$ref: '#/components/schemas/Trainer' $ref: '#/components/schemas/PokemonType'
examples:
partial:
value: {
"id": "804",
"name": "New Pokemon Type",
"pokedexNumber": 999
}
description: Partial POST example
min:
value: { }
description: Minimum POST example
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example:
{
"id": "804",
"name": "New Pokemon Type",
"created": null,
"lastUpDate": "2024-05-13T08:07:50.212596Z",
"pokedexNumber": 999,
"generation": 0,
"japaneseName": null,
"classification": null,
"abilities": null,
"baseHeight": 0.0,
"baseWeight": 0.0,
"baseHp": 0,
"baseAttack": 0,
"baseSpAttack": 0,
"baseDefense": 0,
"baseSpDefense": 0,
"baseSpeed": 0,
"captureRate": 0,
"isLegendary": false,
"imgUrl": null,
"primaryType": null,
"secondaryType": null
}
400: 400:
description: Bad request description: Bad request
405: 405:
...@@ -276,6 +501,33 @@ paths: ...@@ -276,6 +501,33 @@ paths:
responses: responses:
200: 200:
description: OK description: OK
content:
'application/json':
example:
{
"id": "804",
"name": "Modified Pokemon Type",
"created": "2024-05-13T08:04:03.186221Z",
"lastUpDate": "2024-05-13T08:04:03.186308Z",
"pokedexNumber": 1000,
"generation": 0,
"japaneseName": null,
"classification": "The most powerful pokemon",
"abilities": null,
"baseHeight": 0.0,
"baseWeight": 0.0,
"baseHp": 0,
"baseAttack": 0,
"baseSpAttack": 0,
"baseDefense": 0,
"baseSpDefense": 0,
"baseSpeed": 0,
"captureRate": 0,
"isLegendary": false,
"imgUrl": null,
"primaryType": null,
"secondaryType": null
}
404: 404:
description: Not found description: Not found
put: put:
...@@ -295,7 +547,17 @@ paths: ...@@ -295,7 +547,17 @@ paths:
content: content:
'application/json': 'application/json':
schema: schema:
type: object $ref: '#/components/schemas/PokemonType'
examples:
partial:
value: {
"name": "Modified Pokemon Type",
"pokedexNumber": 1000
}
description: Partial PUT example
min:
value: { }
description: Minimum PUT example
responses: responses:
200: 200:
description: OK description: OK
...@@ -359,41 +621,28 @@ components: ...@@ -359,41 +621,28 @@ components:
type: string type: string
minLength: 1 minLength: 1
# Pokemon: Pokemon:
# description: Schema describing the overall shape of pokemon resources. description: Schema describing the overall shape of pokemon resources.
# type: object type: object
# properties: properties:
# id: id:
# type: string type: string
# minLength: 1 minLength: 1
# created: created:
# type: string type: string
# format: date-time format: date-time
# lastUpdate: lastUpdate:
# type: string type: string
# format: date-time format: date-time
# name: name:
# type: string type: string
# minLength: 1 minLength: 1
# height: pokemonType:
# type: number type: string
# weight: minLength: 1
# type: number trainerId:
# hp: type: string
# type: number minLength: 1
# attack:
# type: number
# spAttack:
# type: number
# defense:
# type: number
# spDefense:
# type: number
# speed:
# type: number
# pokemonType:
# type: string
# minLength: 1
PokemonType: PokemonType:
description: Schema describing the overall shape of pokemon type resources. description: Schema describing the overall shape of pokemon type resources.
......
###
GET http://localhost:8080/pokemon/api/pokemonTypes
###
GET http://localhost:8080/pokemon/api/pokemonTypes?pageSize=1&pageNumber=1
###
GET http://localhost:8080/pokemon/api/pokemonTypes/1
###
POST http://localhost:8080/pokemon/api/pokemonTypes
Content-Type: application/json
{}
###
# Run this after creating a new pokemon type
PUT http://localhost:8080/pokemon/api/pokemonTypes/802
Content-Type: application/json
{
"id": "802",
"name": "Modified Pokemon Type"
}
###
# Run this after creating a new pokemon type
DELETE http://localhost:8080/pokemon/api/pokemonTypes/802
###
GET http://localhost:8080/pokemon/api/pokemon
###
# Run rhis after implementing pagination
GET http://localhost:8080/pokemon/api/pokemon?pageSize=1&pageNumber=1
###
# Run rhis after implementing sorting
GET http://localhost:8080/pokemon/api/pokemon?sortBy=name
###
# If you run this before creating a pokemon, it should return a 404 error
GET http://localhost:8080/pokemon/api/pokemon/1
###
POST http://localhost:8080/pokemon/api/pokemon
Content-Type: application/json
{
"name": "My new pokemon",
"pokemonType": "1",
"trainerId": "1"
}
###
# Run this after creating a new pokemon
PUT http://localhost:8080/pokemon/api/pokemon/1
Content-Type: application/json
{
"id": "1",
"name": "My modified pokemon",
"pokemonType": "1",
"trainerId": "2"
}
###
# Run this after creating a new pokemon
DELETE http://localhost:8080/pokemon/api/pokemon/1
###
GET http://localhost:8080/pokemon/api/trainers
###
GET http://localhost:8080/pokemon/api/trainers?pageSize=1&pageNumber=1
###
GET http://localhost:8080/pokemon/api/trainers/1
###
POST http://localhost:8080/pokemon/api/trainers
Content-Type: application/json
{}
###
# Run this after creating a new trainer
PUT http://localhost:8080/pokemon/api/trainers/5
Content-Type: application/json
{
"id": "5",
"name": "Ash Ketchum"
}
###
# Run this after creating a new trainer
DELETE http://localhost:8080/pokemon/api/trainers/5
## Class Diagram ## Class Diagram
![](/design/models/Class%20Diagram.png) NOTE: this diagram has been simplified in the implementation and several fields have been omitted.
![](./models/Class%20Diagram.png)
meetings/http-client.animated.gif

2.1 MiB

meetings/intellij-git-checkout-branch.png

223 KiB

meetings/intellij-git-fetch-remote.png

94.1 KiB

meetings/intellij-git-push.png

142 KiB

meetings/intellij-git-remote.png

75.6 KiB

meetings/open-api.png

1.68 MiB

# Practical Session 3 - Guides and Tips
## Changing the application name on Tomcat
As we are using IntelliJ to build and send our application to the Tomcat server, we need to change the _Running Configurations_ in order to set the base route this application. For example, when using `/pokemon` as the base route, all other routes will be affected like `/pokemon/pokemonTypes.html` and `/pokemon/api/pokemonTypes`. To change this, please set the field _Application context_ under the tab _Deployment_ to `/pokemon`.
![](./running-configurations.png)
## Checkout new branch
In order to retrieve the code for the exercises of the practical session, perform the step below on your git client. Here we'll be using IntelliJ's git client:
1. Find or list the remote list of your git client
![](./intellij-git-remote.png)
2. Fetch from the remote repository containing the original project all updates
![](./intellij-git-fetch-remote.png)
3. Checkout the branch `practical-session-3` and start working on it
![](./intellij-git-checkout-branch.png)
4. After committing your changes, push the branch to the upstream (i.e., to your fork on GitLab)
![](./intellij-git-push.png)
5. On GitLab, open a new Merge Request
Work on implementing the issues tagged as both `feature-request` and `practical-session-3`
## Running HTTP request on IntelliJ
With IntelliJ, you can create files ending with `.http` to write and run requests directly from the IDE. You can find sample files [here](./../design/requests) and the full documentation [here](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html).
![](./http-client.animated.gif)
## REST API documentations with OpenAPI
OpenAPI is a standard for documenting REST APIs in JSON (or YAML). On IntelliJ, you can open the [our OpenAPI specification](./../design/open-api.yaml) and check all routes implemented or to be implemented, including examples.
![](./open-api.png)
meetings/running-configurations.png

537 KiB

...@@ -35,4 +35,5 @@ public class InitializationListener implements ServletContextListener { ...@@ -35,4 +35,5 @@ public class InitializationListener implements ServletContextListener {
} }
System.out.println("PokeApp shutdown."); System.out.println("PokeApp shutdown.");
} }
} }
package nl.utwente.mod4.pokemon;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerRequestFilter;
import jakarta.ws.rs.ext.Provider;
@Provider
public class RequestFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) {
System.out.println("Incoming Request:");
System.out.println("Method: " + requestContext.getMethod());
System.out.println("URI: " + requestContext.getUriInfo().getRequestUri());
System.out.println("Headers: " + requestContext.getHeaders());
}
}
package nl.utwente.mod4.pokemon; package nl.utwente.mod4.pokemon;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
public class Utils { public class Utils {
public static String getAbsolutePathToResources() { public static String getAbsolutePathToResources() {
return Utils.class.getClassLoader().getResource("").getPath(); var path = Utils.class.getClassLoader().getResource("").getPath();
return URLDecoder.decode(path, StandardCharsets.UTF_8);
} }
public static <T extends Comparable<T>> int compare(T o1, T o2) { public static <T extends Comparable<T>> int compare(T o1, T o2) {
......
...@@ -98,8 +98,8 @@ public enum PokemonTypeDao { ...@@ -98,8 +98,8 @@ public enum PokemonTypeDao {
.get(); .get();
} }
public PokemonType update(PokemonType updated) { public PokemonType replace(PokemonType updated) {
if(!updated.isValid()) if(!updated.checkIsValid())
throw new BadRequestException("Invalid pokemon type."); throw new BadRequestException("Invalid pokemon type.");
if(pokemonTypes.get(updated.id) == null) if(pokemonTypes.get(updated.id) == null)
throw new NotFoundException("Pokemon type id '" + updated.id + "' not found."); throw new NotFoundException("Pokemon type id '" + updated.id + "' not found.");
......
...@@ -88,8 +88,8 @@ public enum TrainerDao { ...@@ -88,8 +88,8 @@ public enum TrainerDao {
return newTrainer; return newTrainer;
} }
public Trainer update(Trainer updated) { public Trainer replace(Trainer updated) {
if(!updated.isValid()) if(!updated.checkIsValid())
throw new BadRequestException("Invalid trainer."); throw new BadRequestException("Invalid trainer.");
if(trainers.get(updated.id) == null) if(trainers.get(updated.id) == null)
throw new NotFoundException("Trainer id '" + updated.id + "' not found."); throw new NotFoundException("Trainer id '" + updated.id + "' not found.");
......