openapi: 3.0.0
info:
  title: BWeather API
  description: API Cuaca Real-time dan Prakiraan (Kemarin , Hari Ini - 3 Hari Kedepan), Berdasarkan Lokasi GPS atau Nama Kota
  version: 1.0.0

servers:
  - url: https://myporto.site/bweather-backend/public/index.php

paths:
  /weather:
    get:
      summary: Cuaca berdasarkan Latitude dan Longitude
      description: Mendapatkan data cuaca dari lokasi GPS
      parameters:
        - name: endpoint
          in: query
          required: true
          schema:
            type: string
            example: weather
        - name: latitude
          in: query
          required: true
          schema:
            type: number
            example: -7.802
        - name: longitude
          in: query
          required: true
          schema:
            type: number
            example: 112.168
      responses:
        "200":
          description: Data cuaca lengkap dari lokasi GPS
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WeatherResponse"

  /search:
    get:
      summary: Pencarian cuaca berdasarkan nama kota
      description: Cari lokasi berdasarkan nama kota dan tampilkan data cuaca lengkap
      parameters:
        - name: endpoint
          in: query
          required: true
          schema:
            type: string
            example: search
        - name: query
          in: query
          required: true
          schema:
            type: string
            example: Kediri
      responses:
        "200":
          description: Lokasi dan data cuaca dari hasil pencarian
          content:
            application/json:
              schema:
                type: object
                properties:
                  location:
                    type: object
                    properties:
                      lat:
                        type: number
                        example: -7.802
                      lon:
                        type: number
                        example: 112.168
                      name:
                        type: string
                        example: "Kabupaten Kediri, Jawa Timur, Indonesia"
                  weather:
                    $ref: "#/components/schemas/WeatherResponse"

components:
  schemas:
    Cuaca:
      type: object
      properties:
        waktu:
          type: string
          format: date-time
          example: "2025-05-21 13:00:00"
        suhu:
          type: number
          example: 30.1
        kelembapan:
          type: number
          example: 75
        kecepatan_angin:
          type: number
          example: 5.2
        arah_angin:
          type: number
          example: 180
        tekanan_udara:
          type: number
          example: 1009.3
        indeks_uv:
          type: number
          example: 3
        terasa_seperti:
          type: number
          example: 33.2
        peluang_hujan:
          type: number
          example: 50
        matahari_terbit:
          type: string
          example: "2025-05-21 06:01:00"
        matahari_terbenam:
          type: string
          example: "2025-05-21 17:45:00"
        bulan_terbit:
          type: string
          example: "2025-05-21 20:30:00"
        bulan_terbenam:
          type: string
          example: "2025-05-21 07:15:00"

    WeatherResponse:
      type: object
      properties:
        cuaca_saat_ini:
          $ref: "#/components/schemas/Cuaca"
        kemarin:
          type: array
          items:
            $ref: "#/components/schemas/Cuaca"
        hari_ini:
          type: array
          items:
            $ref: "#/components/schemas/Cuaca"
        besok:
          type: array
          items:
            $ref: "#/components/schemas/Cuaca"
        lusa:
          type: array
          items:
            $ref: "#/components/schemas/Cuaca"
        hari_ke_3:
          type: array
          items:
            $ref: "#/components/schemas/Cuaca"
