openapi: 3.1.0 info: title: Api version: 0.1.0 description: Park Sense Smart Parking System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication operations - name: parkingLots description: Parking lot operations - name: parkingSlots description: Parking slot operations - name: bookings description: Booking operations - name: payments description: Payment operations - name: reviews description: Review operations - name: admin description: Admin operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/login: post: operationId: login tags: [auth] summary: Login or register a user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/LoginResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /parking-lots: get: operationId: listParkingLots tags: [parkingLots] summary: List all parking lots parameters: - name: search in: query schema: type: string - name: city in: query schema: type: string - name: available in: query schema: type: boolean responses: "200": description: List of parking lots content: application/json: schema: $ref: "#/components/schemas/ParkingLotListResponse" post: operationId: createParkingLot tags: [parkingLots] summary: Create a new parking lot (admin) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateParkingLotRequest" responses: "201": description: Parking lot created content: application/json: schema: $ref: "#/components/schemas/ParkingLot" /parking-lots/{lotId}: get: operationId: getParkingLot tags: [parkingLots] summary: Get a parking lot by ID parameters: - name: lotId in: path required: true schema: type: integer responses: "200": description: Parking lot details content: application/json: schema: $ref: "#/components/schemas/ParkingLotDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /parking-lots/{lotId}/slots: get: operationId: listParkingSlots tags: [parkingSlots] summary: List slots for a parking lot parameters: - name: lotId in: path required: true schema: type: integer - name: slotType in: query schema: type: string enum: [standard, compact, handicapped, ev_charging] - name: available in: query schema: type: boolean responses: "200": description: List of parking slots content: application/json: schema: $ref: "#/components/schemas/ParkingSlotListResponse" /bookings: get: operationId: listBookings tags: [bookings] summary: List bookings for the current user parameters: - name: status in: query schema: type: string enum: [pending, confirmed, active, completed, cancelled] responses: "200": description: List of bookings content: application/json: schema: $ref: "#/components/schemas/BookingListResponse" post: operationId: createBooking tags: [bookings] summary: Create a new booking requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateBookingRequest" responses: "201": description: Booking created content: application/json: schema: $ref: "#/components/schemas/Booking" "400": description: Bad request (slot unavailable, etc.) content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /bookings/{bookingId}: get: operationId: getBooking tags: [bookings] summary: Get a booking by ID parameters: - name: bookingId in: path required: true schema: type: integer responses: "200": description: Booking details content: application/json: schema: $ref: "#/components/schemas/Booking" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /bookings/{bookingId}/cancel: post: operationId: cancelBooking tags: [bookings] summary: Cancel a booking parameters: - name: bookingId in: path required: true schema: type: integer responses: "200": description: Booking cancelled content: application/json: schema: $ref: "#/components/schemas/Booking" "400": description: Cannot cancel content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /bookings/{bookingId}/qr: get: operationId: getBookingQr tags: [bookings] summary: Get QR code data for a booking parameters: - name: bookingId in: path required: true schema: type: integer responses: "200": description: QR code data content: application/json: schema: $ref: "#/components/schemas/QrCodeResponse" /payments: post: operationId: createPayment tags: [payments] summary: Process payment for a booking requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePaymentRequest" responses: "201": description: Payment processed content: application/json: schema: $ref: "#/components/schemas/Payment" "400": description: Payment failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /payments/history: get: operationId: listPayments tags: [payments] summary: List payment history for current user responses: "200": description: List of payments content: application/json: schema: $ref: "#/components/schemas/PaymentListResponse" /reviews: get: operationId: listReviews tags: [reviews] summary: List reviews for a parking lot parameters: - name: lotId in: query required: true schema: type: integer responses: "200": description: List of reviews content: application/json: schema: $ref: "#/components/schemas/ReviewListResponse" post: operationId: createReview tags: [reviews] summary: Submit a review for a parking lot requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateReviewRequest" responses: "201": description: Review submitted content: application/json: schema: $ref: "#/components/schemas/Review" /admin/stats: get: operationId: getAdminStats tags: [admin] summary: Get overall system statistics (admin) responses: "200": description: System statistics content: application/json: schema: $ref: "#/components/schemas/AdminStats" /admin/bookings: get: operationId: listAllBookings tags: [admin] summary: List all bookings (admin) parameters: - name: status in: query schema: type: string - name: page in: query schema: type: integer - name: limit in: query schema: type: integer responses: "200": description: All bookings content: application/json: schema: $ref: "#/components/schemas/AdminBookingListResponse" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string message: type: string required: - error User: type: object properties: id: type: integer name: type: string email: type: string phone: type: string nullable: true role: type: string enum: [user, admin] createdAt: type: string format: date-time required: - id - name - email - role - createdAt LoginRequest: type: object properties: email: type: string format: email password: type: string name: type: string required: - email - password LoginResponse: type: object properties: user: $ref: "#/components/schemas/User" token: type: string required: - user - token ParkingLot: type: object properties: id: type: integer name: type: string address: type: string city: type: string latitude: type: number format: float nullable: true longitude: type: number format: float nullable: true totalSlots: type: integer availableSlots: type: integer pricePerHour: type: number format: float imageUrl: type: string nullable: true rating: type: number format: float nullable: true reviewCount: type: integer isOpen: type: boolean openTime: type: string nullable: true closeTime: type: string nullable: true amenities: type: array items: type: string createdAt: type: string format: date-time required: - id - name - address - city - totalSlots - availableSlots - pricePerHour - isOpen - reviewCount - amenities - createdAt ParkingLotDetail: allOf: - $ref: "#/components/schemas/ParkingLot" - type: object properties: slots: type: array items: $ref: "#/components/schemas/ParkingSlot" required: - slots ParkingLotListResponse: type: object properties: lots: type: array items: $ref: "#/components/schemas/ParkingLot" total: type: integer required: - lots - total CreateParkingLotRequest: type: object properties: name: type: string address: type: string city: type: string latitude: type: number nullable: true longitude: type: number nullable: true totalSlots: type: integer pricePerHour: type: number openTime: type: string nullable: true closeTime: type: string nullable: true amenities: type: array items: type: string required: - name - address - city - totalSlots - pricePerHour ParkingSlot: type: object properties: id: type: integer lotId: type: integer slotNumber: type: string slotType: type: string enum: [standard, compact, handicapped, ev_charging] floor: type: integer nullable: true isAvailable: type: boolean pricePerHour: type: number format: float required: - id - lotId - slotNumber - slotType - isAvailable - pricePerHour ParkingSlotListResponse: type: object properties: slots: type: array items: $ref: "#/components/schemas/ParkingSlot" total: type: integer available: type: integer required: - slots - total - available Booking: type: object properties: id: type: integer userId: type: integer slotId: type: integer lotId: type: integer lotName: type: string slotNumber: type: string status: type: string enum: [pending, confirmed, active, completed, cancelled] startTime: type: string format: date-time endTime: type: string format: date-time totalAmount: type: number format: float qrCode: type: string nullable: true vehicleNumber: type: string nullable: true createdAt: type: string format: date-time required: - id - userId - slotId - lotId - lotName - slotNumber - status - startTime - endTime - totalAmount - createdAt BookingListResponse: type: object properties: bookings: type: array items: $ref: "#/components/schemas/Booking" total: type: integer required: - bookings - total CreateBookingRequest: type: object properties: slotId: type: integer startTime: type: string format: date-time endTime: type: string format: date-time vehicleNumber: type: string nullable: true required: - slotId - startTime - endTime QrCodeResponse: type: object properties: bookingId: type: integer qrData: type: string qrImageUrl: type: string nullable: true required: - bookingId - qrData Payment: type: object properties: id: type: integer bookingId: type: integer userId: type: integer amount: type: number format: float paymentMethod: type: string enum: [credit_card, debit_card, upi, wallet, cash] status: type: string enum: [pending, completed, failed, refunded] transactionId: type: string nullable: true createdAt: type: string format: date-time required: - id - bookingId - userId - amount - paymentMethod - status - createdAt PaymentListResponse: type: object properties: payments: type: array items: $ref: "#/components/schemas/Payment" total: type: integer required: - payments - total CreatePaymentRequest: type: object properties: bookingId: type: integer paymentMethod: type: string enum: [credit_card, debit_card, upi, wallet, cash] amount: type: number required: - bookingId - paymentMethod - amount Review: type: object properties: id: type: integer lotId: type: integer userId: type: integer userName: type: string rating: type: integer minimum: 1 maximum: 5 comment: type: string nullable: true createdAt: type: string format: date-time required: - id - lotId - userId - userName - rating - createdAt ReviewListResponse: type: object properties: reviews: type: array items: $ref: "#/components/schemas/Review" total: type: integer averageRating: type: number format: float nullable: true required: - reviews - total CreateReviewRequest: type: object properties: lotId: type: integer rating: type: integer minimum: 1 maximum: 5 comment: type: string nullable: true required: - lotId - rating AdminStats: type: object properties: totalLots: type: integer totalSlots: type: integer availableSlots: type: integer totalBookings: type: integer activeBookings: type: integer totalRevenue: type: number format: float todayRevenue: type: number format: float totalUsers: type: integer required: - totalLots - totalSlots - availableSlots - totalBookings - activeBookings - totalRevenue - todayRevenue - totalUsers AdminBookingListResponse: type: object properties: bookings: type: array items: $ref: "#/components/schemas/Booking" total: type: integer page: type: integer limit: type: integer required: - bookings - total - page - limit