openapi: 3.0.2 info: title: API Project For An Airline Company description: API for display available ticket, buy and cancel ticket. version: 1.0.0 servers: - url: http://localhost:3000 description: Local server - url: https://airlinemanagmentsystem.azurewebsites.net/ description: Production server tags: - name: Authentication description: Authentication - name: Ticket description: Ticket paths: /auth/login: post: summary: Login to the application tags: - Authentication requestBody: required: true content: application/json: schema: type: object properties: username: type: string password: type: string responses: "200": description: Successful login content: application/json: example: status: Success passenger: passengerId: 1 username: john_doe fullName: John Doe accessToken: "400": description: Incorrect username or password content: application/json: example: error: Incorrect username or password /auth/register: post: summary: Register a new user tags: - Authentication requestBody: required: true content: application/json: schema: type: object properties: username: type: string password: type: string fullName: type: string responses: "200": description: Registration successful content: application/json: example: status: Success "500": description: Internal Server Error content: application/json: example: error: Internal Server Error /auth/passengers: get: summary: Get all passengers tags: - Authentication responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Passenger" example: - PassengerId: 1 Username: john_doe FullName: John Doe "500": description: Internal Server Error content: application/json: example: error: Internal Server Error /ticket/flights: get: summary: Get all flights tags: - Ticket responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Ticket" example: - FlightId: 1 Date: "2023-12-01" FlightNumber: "ABC123" Price: 100.00 AvailableSeats: 50 "500": description: Internal Server Error content: application/json: example: error: Internal Server Error /ticket: post: summary: Get the defined available tickets. tags: - Ticket requestBody: required: true content: application/json: schema: type: object properties: date: type: string format: date fromLocation: type: string toLocation: type: string numberOfPeople: type: integer responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Ticket" example: - FlightId: 1 Date: "2023-12-01" FlightNumber: "AA123" Price: 350.00 AvailableSeats: 149 "400": description: Bad request content: application/json: example: error: Bad request "500": description: Internal Server Error content: application/json: example: error: Internal Server Error /ticket/buyticket: post: summary: Buy a ticket tags: - Ticket security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: date: type: string fromLocation: type: string toLocation: type: string fullName: type: string responses: "200": description: Successful purchase content: application/json: example: status: Success "400": description: No seats available content: application/json: example: error: No seats available "409": description: Ticket already purchased content: application/json: example: error: You already bought the ticket in advance! "500": description: Internal Server Error content: application/json: example: error: Internal Server Error /ticket/cancelticket: delete: summary: Cancel a ticket tags: - Ticket security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: flightNumber: type: string passengerId: type: integer responses: "200": description: Successful cancellation content: application/json: example: status: Success "404": description: Ticket not found content: application/json: example: error: Ticket not found "500": description: Internal Server Error content: application/json: example: error: Internal Server Error components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: Ticket: type: object required: - date - fromLocation - toLocation - numberOfPeople properties: date: type: string format: date description: The date of the flight fromLocation: type: string description: The location of the flight toLocation: type: string description: The destination of the flight numberOfPeople: type: integer description: The number of people that will travel example: FlightId: 1, Date: "2023-12-01T00:00:00.000Z" FlightNumber: "AA123" Price: 350, AvailableSeats: 148 Passenger: type: object required: - fullName - username - password properties: fullName: type: string description: The full name of the passenger username: type: string description: The username of the passenger password: type: string description: The password of the passenger example: username: test password: 12345