Skip to content
Snippets Groups Projects
Commit 0390b666 authored by Martin Slovík's avatar Martin Slovík
Browse files

Implementing AirplaneDto, AirplaneTypeDto. Adding many-to-many relationship...

Implementing AirplaneDto, AirplaneTypeDto. Adding many-to-many relationship between StewardDto and FlightDto.
parent 52189a24
No related branches found
No related tags found
No related merge requests found
package cz.muni.fi.pa165.core.rest;
import cz.muni.fi.pa165.core.api.StewardApiDelegate;
import cz.muni.fi.pa165.core.model.PageStewardDto;
import cz.muni.fi.pa165.core.model.PageableObject;
import cz.muni.fi.pa165.core.model.SortObject;
import cz.muni.fi.pa165.core.model.StewardDto;
import cz.muni.fi.pa165.core.model.*;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.HttpStatus;
......@@ -70,4 +67,14 @@ public class StewardController implements StewardApiDelegate {
return new ResponseEntity<>(pageStewardDto, HttpStatus.OK);
}
@Override
public ResponseEntity<StewardDto> createSteward(NewStewardDtoRequest newStewardDtoRequest) {
return StewardApiDelegate.super.createSteward(newStewardDtoRequest);
}
@Override
public ResponseEntity<Void> deleteSteward(Long id) {
return StewardApiDelegate.super.deleteSteward(id);
}
}
......@@ -46,11 +46,35 @@ paths:
type: array
items:
$ref: '#/components/schemas/StewardDto'
post:
tags:
- Steward
summary: Create a new steward
description: |
Receives data both in request body and as URL parameter and stores them as a new steward.
Returns the new steward as response.
operationId: createSteward
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NewStewardDtoRequest'
required: true
responses:
"201":
$ref: '#/components/responses/SingleStewardDtoResponse'
"400":
description: input data were not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/api/stewards/{id}:
get:
tags:
- Steward
summary: Returns identified steward
summary: Get steward by id
description: Looks up a stewards by id.
operationId: getSteward
parameters:
......@@ -69,6 +93,29 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
delete:
tags:
- Steward
summary: Delete steward by id
operationId: deleteSteward
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"204":
description: deleted
"404":
description: steward not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
'401':
description: unauthorized
/api/stewards/paged:
get:
tags:
......@@ -194,6 +241,31 @@ components:
type: string
description: last name of a steward
example: Doe
flights:
type: array
description: flights assigned to a steward
items:
$ref: '#/components/schemas/FlightDto'
NewStewardDtoRequest:
allOf:
- $ref: '#/components/schemas/DomainEntity'
type: object
title: steward
required:
- id
- firstName
- lastName
properties:
firstName:
type: string
description: first name of a steward
example: John
lastName:
type: string
description: last name of a steward
example: Doe
description: |
object for requesting new steward
FlightDto:
allOf:
- $ref: '#/components/schemas/DomainEntity'
......@@ -202,8 +274,68 @@ components:
description: represents a flight
required:
- id
- departureTime
- arrivalTime
- stewards
- airplane
properties:
departureTime:
type: string
description: time of flight departure
format: date-time
example: 2022-12-22T12:04:04.493908908+01:00
arrivalTime:
type: string
description: time of flight arrival
format: date-time
example: 2022-12-22T12:04:04.493908908+01:00
stewards:
type: array
description: stewards assigned to a flight
items:
$ref: '#/components/schemas/StewardDto'
airplane:
$ref: '#/components/schemas/AirplaneDto'
AirplaneTypeDto:
allOf:
- $ref: '#/components/schemas/DomainEntity'
type: object
title: airplane type
description: represents airplane type
required:
- id
- name
properties:
name:
type: string
description: airplane type name
example: Boeing 747, Airbus A380, ...
AirplaneDto:
allOf:
- $ref: '#/components/schemas/DomainEntity'
type: object
title: airplane
description: represents airplane
required:
- id
- name
- capacity
- type
properties:
name:
type: string
description: airplane name
example: Spitfire, Messerschmidt, ...
capacity:
type: integer
description: airplane seat capacity
format: int32
example: 150
type:
$ref: '#/components/schemas/AirplaneTypeDto'
PageableObject:
type: object
title: pageable object
properties:
offset:
type: integer
......@@ -222,6 +354,7 @@ components:
type: boolean
SortObject:
type: object
title: sort object
properties:
empty:
type: boolean
......@@ -231,6 +364,7 @@ components:
type: boolean
PageStewardDto:
type: object
title: paged stewards
properties:
totalPages:
type: integer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment