openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: buses description: Bus search and live tracking - name: bookings description: Passenger bookings paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /buses: get: operationId: listBuses tags: [buses] summary: List upcoming buses description: Returns upcoming buses, optionally filtered by bus number. parameters: - name: number in: query required: false schema: type: string pattern: "^[0-9]{2}$" description: Two-digit bus number such as 01, 12, or 34. responses: "200": description: Upcoming buses content: application/json: schema: type: array items: $ref: "#/components/schemas/Bus" /buses/{number}/tracking: get: operationId: getBusTracking tags: [buses] summary: Get live bus tracking description: Returns the current location, route progress, and ETA for a bus. parameters: - name: number in: path required: true schema: type: string pattern: "^[0-9]{2}$" responses: "200": description: Current bus location and route progress content: application/json: schema: $ref: "#/components/schemas/BusTracking" "404": description: Bus not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /buses/{number}/location: post: operationId: updateBusLocation tags: [buses] summary: Send the latest GPS location for a bus description: Driver devices use this endpoint to share the bus's current GPS position. parameters: - name: number in: path required: true schema: type: string pattern: "^[0-9]{2}$" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LocationUpdate" responses: "200": description: Location accepted content: application/json: schema: $ref: "#/components/schemas/BusLocation" "400": description: Invalid location content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /bookings: post: operationId: createBooking tags: [bookings] summary: Create a bus seat booking requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BookingInput" responses: "201": description: Booking confirmed content: application/json: schema: $ref: "#/components/schemas/Booking" "400": description: Invalid booking content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /bookings/{reference}: get: operationId: getBooking tags: [bookings] summary: Get a booking by reference parameters: - name: reference in: path required: true schema: type: string responses: "200": description: Booking details content: application/json: schema: $ref: "#/components/schemas/Booking" "404": description: Booking not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: schemas: HealthStatus: type: object properties: status: type: string required: - status Bus: type: object required: - number - name - origin - destination - departureTime - arrivalTime - fare - availableSeats - totalSeats - status - nextStop - etaMinutes properties: number: type: string name: type: string origin: type: string destination: type: string departureTime: type: string arrivalTime: type: string fare: type: number availableSeats: type: number totalSeats: type: number status: type: string enum: [on-time, delayed, boarding, completed] nextStop: type: string etaMinutes: type: number route: type: array items: type: string BusTracking: type: object required: - number - currentStop - nextStop - etaMinutes - progress - updatedAt - status - stops - isLive - source - latitude - longitude - accuracyMeters properties: number: type: string currentStop: type: string nextStop: type: string etaMinutes: type: number progress: type: number updatedAt: type: string status: type: string enum: [on-time, delayed, boarding] isLive: type: boolean source: type: string enum: [gps, schedule] latitude: type: [number, "null"] longitude: type: [number, "null"] accuracyMeters: type: [number, "null"] stops: type: array items: $ref: "#/components/schemas/TrackingStop" LocationUpdate: type: object required: [latitude, longitude] properties: latitude: type: number minimum: -90 maximum: 90 longitude: type: number minimum: -180 maximum: 180 accuracyMeters: type: number minimum: 0 speedKph: type: number minimum: 0 heading: type: number minimum: 0 maximum: 360 recordedAt: type: string BusLocation: type: object required: [number, latitude, longitude, accuracyMeters, isLive, updatedAt] properties: number: type: string latitude: type: number longitude: type: number accuracyMeters: type: [number, "null"] isLive: type: boolean updatedAt: type: string TrackingStop: type: object required: [name, time, passed] properties: name: type: string time: type: string passed: type: boolean BookingInput: type: object required: - busNumber - seatNumber - passengerName - passengerPhone properties: busNumber: type: string pattern: "^[0-9]{2}$" seatNumber: type: number minimum: 1 passengerName: type: string minLength: 2 passengerPhone: type: string minLength: 8 Booking: type: object required: - reference - busNumber - seatNumber - passengerName - passengerPhone - origin - destination - departureTime - fare - status - createdAt properties: reference: type: string busNumber: type: string seatNumber: type: number passengerName: type: string passengerPhone: type: string origin: type: string destination: type: string departureTime: type: string fare: type: number status: type: string enum: [confirmed, cancelled] createdAt: type: string ErrorResponse: type: object required: [error] properties: error: type: string