Last active
July 26, 2025 07:30
-
-
Save pubudu538/e530e9aa3a1e218bfffe3cd05c7ab1c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| openapi: 3.0.1 | |
| info: | |
| title: Train Ticket MGT API | |
| version: 1.0.0 | |
| description: This API is for train ticket management related functionality. | |
| servers: | |
| - url: https://tickets.trainhub.com | |
| paths: | |
| /trains: | |
| get: | |
| summary: Get all trains | |
| responses: | |
| "200": | |
| description: A list of trains | |
| content: | |
| application/json: | |
| schema: | |
| type: array | |
| items: | |
| $ref: "#/components/schemas/Train" | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| post: | |
| summary: Add a new train | |
| requestBody: | |
| required: true | |
| content: | |
| application/json: | |
| schema: | |
| $ref: "#/components/schemas/Train" | |
| responses: | |
| "200": | |
| description: Train added successfully | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| /tickets: | |
| get: | |
| summary: Get all tickets | |
| responses: | |
| "200": | |
| description: A list of tickets | |
| content: | |
| application/json: | |
| schema: | |
| type: array | |
| items: | |
| $ref: "#/components/schemas/Ticket" | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| post: | |
| summary: Book a new ticket | |
| requestBody: | |
| required: true | |
| content: | |
| application/json: | |
| schema: | |
| $ref: "#/components/schemas/Ticket" | |
| responses: | |
| "200": | |
| description: Ticket booked successfully | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| /users: | |
| get: | |
| summary: Get all users | |
| responses: | |
| "200": | |
| description: A list of users | |
| content: | |
| application/json: | |
| schema: | |
| type: array | |
| items: | |
| $ref: "#/components/schemas/User" | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| "/tickets/{ticketId}": | |
| delete: | |
| summary: Cancel a ticket | |
| parameters: | |
| - in: path | |
| name: ticketId | |
| required: true | |
| schema: | |
| type: string | |
| responses: | |
| "200": | |
| description: Ticket canceled successfully | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| "/trains/{trainId}": | |
| get: | |
| summary: Get details of a specific train | |
| parameters: | |
| - in: path | |
| name: trainId | |
| required: true | |
| schema: | |
| type: string | |
| responses: | |
| "200": | |
| description: Train details | |
| content: | |
| application/json: | |
| schema: | |
| $ref: "#/components/schemas/Train" | |
| "400": | |
| description: Bad Request | |
| "500": | |
| description: Internal Server Error | |
| components: | |
| schemas: | |
| Train: | |
| type: object | |
| properties: | |
| id: | |
| type: string | |
| name: | |
| type: string | |
| capacity: | |
| type: integer | |
| Ticket: | |
| type: object | |
| properties: | |
| id: | |
| type: string | |
| trainId: | |
| type: string | |
| userId: | |
| type: string | |
| seatNumber: | |
| type: string | |
| User: | |
| type: object | |
| properties: | |
| id: | |
| type: string | |
| name: | |
| type: string | |
| email: | |
| type: string | |
| phone: | |
| type: string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment