From 31943cd9f8aec786e58187175ad32c9af0c0297e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Slov=C3=ADk?= <xslovik@fi.muni.cz> Date: Wed, 22 Mar 2023 09:35:29 +0100 Subject: [PATCH] Implementing StewardDto endpoints. Fixing consistency issues. --- .../fi/pa165/core/rest/StewardController.java | 20 ++ openapi.yaml | 195 ++++++++++++------ 2 files changed, 157 insertions(+), 58 deletions(-) diff --git a/core/src/main/java/cz/muni/fi/pa165/core/rest/StewardController.java b/core/src/main/java/cz/muni/fi/pa165/core/rest/StewardController.java index 10876bb..931e16f 100644 --- a/core/src/main/java/cz/muni/fi/pa165/core/rest/StewardController.java +++ b/core/src/main/java/cz/muni/fi/pa165/core/rest/StewardController.java @@ -77,4 +77,24 @@ public class StewardController implements StewardApiDelegate { public ResponseEntity<Void> deleteSteward(Long id) { return StewardApiDelegate.super.deleteSteward(id); } + + @Override + public ResponseEntity<StewardDto> createStewardFlights(Long stewardId, Long flightId) { + return StewardApiDelegate.super.createStewardFlights(stewardId, flightId); + } + + @Override + public ResponseEntity<Void> deleteStewardFlights(Long stewardId, Long flightId) { + return StewardApiDelegate.super.deleteStewardFlights(stewardId, flightId); + } + + @Override + public ResponseEntity<StewardDto> updateSteward(Long id, NewStewardDtoRequest newStewardDtoRequest) { + return StewardApiDelegate.super.updateSteward(id, newStewardDtoRequest); + } + + @Override + public ResponseEntity<StewardDto> updateStewardFlights(Long stewardId, Long flightId) { + return StewardApiDelegate.super.updateStewardFlights(stewardId, flightId); + } } diff --git a/openapi.yaml b/openapi.yaml index af654d2..99946df 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -26,16 +26,15 @@ servers: default: "8080" tags: - name: Core - description: microservice for core + description: Microservice for core. paths: /api/stewards: get: tags: - Steward - summary: Get all stewards + summary: Get all stewards. description: | - Returns an array of objects representing stewards, ordered from the newest to the oldest. - Each steward must have an **id**, **firstName** and **lastName**. + Returns an array of objects representing stewards. operationId: getAllStewards responses: "200": @@ -49,10 +48,9 @@ paths: post: tags: - Steward - summary: Create a new 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. + Creates a new steward and returns it as a response. operationId: createSteward requestBody: content: @@ -64,7 +62,7 @@ paths: "201": $ref: '#/components/responses/SingleStewardDtoResponse' "400": - description: input data were not correct + description: Input data not correct content: application/json: schema: @@ -74,7 +72,7 @@ paths: tags: - Steward summary: Get steward by id - description: Looks up a stewards by id. + description: Returns a steward by id. operationId: getSteward parameters: - name: id @@ -85,9 +83,13 @@ paths: format: int64 responses: "200": - $ref: '#/components/responses/SingleStewardDtoResponse' + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/StewardDto' "404": - description: steward not found + description: Not Found content: application/json: schema: @@ -95,7 +97,7 @@ paths: delete: tags: - Steward - summary: Delete steward by id + summary: Delete steward by id. operationId: deleteSteward parameters: - name: id @@ -106,19 +108,17 @@ paths: format: int64 responses: "204": - description: deleted + description: Deleted "404": - description: steward not found + description: Not Found content: application/json: schema: $ref: '#/components/schemas/ErrorMessage' - '401': - description: unauthorized put: tags: - Steward - summary: Update steward by id + summary: Update steward by id. operationId: updateSteward parameters: - name: id @@ -128,19 +128,100 @@ paths: type: integer format: int64 description: | - Receives data both in request body and as URL parameter and updates a steward by id. - Returns the updated steward as response. + Updates a steward by id and returns it as a response. requestBody: content: application/json: schema: - $ref: '#/components/schemas/StewardDto' + $ref: '#/components/schemas/NewStewardDtoRequest' required: true + responses: + "200": + $ref: '#/components/responses/SingleStewardDtoResponse' + "400": + description: Input data not correct + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + /api/stewards/{stewardId}/flights/{flightId}: + post: + tags: + - Steward + summary: Assign steward to a flight. + operationId: createStewardFlights + parameters: + - name: stewardId + in: path + required: true + schema: + type: integer + format: int64 + - name: flightId + in: path + required: true + schema: + type: integer + format: int64 responses: "201": $ref: '#/components/responses/SingleStewardDtoResponse' "400": - description: input data were not correct + description: Input data not correct + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + put: + tags: + - Steward + summary: Update assignment of steward to a flight. + operationId: updateStewardFlights + parameters: + - name: stewardId + in: path + required: true + schema: + type: integer + format: int64 + - name: flightId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "200": + $ref: '#/components/responses/SingleStewardDtoResponse' + "400": + description: Input data not correct + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + delete: + tags: + - Steward + summary: Delete assignment of steward to a flight. + operationId: deleteStewardFlights + parameters: + - name: stewardId + in: path + required: true + schema: + type: integer + format: int64 + - name: flightId + in: path + required: true + schema: + type: integer + format: int64 + responses: + "204": + description: Deleted + "404": + description: Not Found content: application/json: schema: @@ -151,7 +232,7 @@ paths: - Steward summary: Paged stewards description: | - Returns a page of stewards. Stewards are ordered from the newest to the oldest. + Returns a page of stewards. The parameter `page` specifies zero-based index of the requested page, and the parameter `size` specifies the size of the page. operationId: getStewardsPaged @@ -192,10 +273,9 @@ paths: get: tags: - Flight - summary: Get all flights + summary: Get all flights. description: | - Returns an array of objects representing flights, ordered from the newest to the oldest. - Each steward must have an **id**. + Returns an array of objects representing flights. operationId: getAllFlights responses: "200": @@ -209,15 +289,15 @@ paths: components: schemas: DomainEntity: - title: domain entity - description: represents a domain entity + title: Domain Entity + description: Represents a Domain Entity type: object required: - id properties: id: type: integer - description: id of domain entity + description: unique id format: int64 example: 1 discriminator: @@ -225,8 +305,8 @@ components: ErrorMessage: allOf: - $ref: '#/components/schemas/DomainEntity' - title: error message - description: response body for HTML statuses + title: Error Message + description: Response body for HTML statuses. type: object properties: timestamp: @@ -255,8 +335,8 @@ components: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: steward - description: represents a steward on a flight + title: Steward + description: Represents a steward on a flight. required: - id - firstName @@ -279,7 +359,8 @@ components: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: steward + title: New Steward Request + description: Object for requesting a new Steward. required: - id - firstName @@ -293,14 +374,12 @@ components: type: string description: last name of a steward example: Doe - description: | - object for requesting new steward FlightDto: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: flight - description: represents a flight + title: Flight + description: Represents a flight. required: - id - departureTime @@ -329,8 +408,8 @@ components: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: airplane type - description: represents airplane type + title: Airplane Type + description: Represents an Airplane Type. required: - id - name @@ -338,13 +417,13 @@ components: name: type: string description: airplane type name - example: Boeing 747, Airbus A380, ... + example: Boeing 747 AirplaneDto: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: airplane - description: represents an airplane + title: Airplane + description: Represents an Airplane. required: - id - name @@ -354,7 +433,7 @@ components: name: type: string description: airplane name - example: Spitfire, Messerschmidt, ... + example: Spitfire capacity: type: integer description: airplane seat capacity @@ -364,7 +443,7 @@ components: $ref: '#/components/schemas/AirplaneTypeDto' PageableObject: type: object - title: pageable object + title: Pageable Object properties: offset: type: integer @@ -383,7 +462,7 @@ components: type: boolean SortObject: type: object - title: sort object + title: Sort Object properties: empty: type: boolean @@ -393,7 +472,7 @@ components: type: boolean PageStewardDto: type: object - title: paged stewards + title: Paged Stewards properties: totalPages: type: integer @@ -428,8 +507,8 @@ components: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: country - description: represents a country + title: Country + description: Represents a country. required: - id - name @@ -437,13 +516,13 @@ components: name: type: string description: country name - example: Canada, France, ... + example: Canada CityDto: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: city - description: represents a city in a country containing airports + title: City + description: Represents a City in a Country containing Airports. required: - id - name @@ -460,8 +539,8 @@ components: $ref: '#/components/schemas/AirplaneDto' GPSLocationDto: type: object - title: GPS location - description: represents a GPS location of latitude and longitude + title: GPS Location + description: Represents a GPS Location of latitude and longitude. required: - latitude - longitude @@ -478,8 +557,8 @@ components: allOf: - $ref: '#/components/schemas/DomainEntity' type: object - title: airport - description: represents an airport + title: Airport + description: Represents an Airport. required: - id - name @@ -492,11 +571,11 @@ components: name: type: string description: airport name - example: John F. Kennedy International Airport, Charles de Gaulle International Airport, ... + example: John F. Kennedy International Airport code: type: string description: airport code in IATA format - example: JFK, CDG, ... + example: JFK departingFlights: type: array items: @@ -511,7 +590,7 @@ components: $ref: '#/components/schemas/GPSLocationDto' responses: SingleStewardDtoResponse: - description: response containing a single steward + description: Response containing a single Steward. content: application/json: schema: -- GitLab