{
  "openapi": "3.0.3",
  "info": {
    "title": "GeoPulse News API",
    "version": "1.0.0",
    "description": "API publik GeoPulse News: artikel terbit, kategori, sumber, dan pencarian. Endpoint admin memerlukan sesi redaksi atau token API (Bearer gp_…). Batas laju publik: 60 permintaan/menit/IP untuk /news dan /categories, 30/menit untuk /search dan /sources.",
    "contact": {
      "name": "Redaksi GeoPulse News"
    }
  },
  "servers": [
    {
      "url": "https://geopulse-news.ditzdev.web.id"
    }
  ],
  "tags": [
    {
      "name": "publik",
      "description": "Endpoint baca publik"
    },
    {
      "name": "sistem",
      "description": "Status layanan"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "tags": [
          "sistem"
        ],
        "summary": "Status operasional layanan",
        "responses": {
          "200": {
            "description": "Status layanan dan pemeriksaan basis data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "ok": true,
                  "data": {
                    "status": "ok",
                    "service": "GeoPulse News API",
                    "version": "v1"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/news": {
      "get": {
        "tags": [
          "publik"
        ],
        "summary": "Daftar artikel terbit",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 120
            },
            "description": "Kata kunci pada judul/teras/isi"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Slug kategori, mis. nasional"
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Slug wilayah, mis. jawa-timur"
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Slug topik"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Nama penerbit sumber yang dirujuk"
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Tanggal terbit minimal (ISO-8601)"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Tanggal terbit maksimal (ISO-8601)"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30,
              "default": 12
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Daftar artikel + paginasi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NewsList"
                }
              }
            }
          },
          "400": {
            "description": "Parameter tidak valid"
          },
          "429": {
            "description": "Batas laju terlampaui"
          }
        }
      }
    },
    "/api/v1/news/{slug}": {
      "get": {
        "tags": [
          "publik"
        ],
        "summary": "Detail satu artikel terbit",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Artikel lengkap termasuk sumber dan koreksi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NewsDetail"
                }
              }
            }
          },
          "404": {
            "description": "Artikel tidak ditemukan"
          }
        }
      }
    },
    "/api/v1/categories": {
      "get": {
        "tags": [
          "publik"
        ],
        "summary": "Daftar kategori aktif",
        "responses": {
          "200": {
            "description": "Kategori aktif",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sources": {
      "get": {
        "tags": [
          "publik"
        ],
        "summary": "Registry sumber berita (bidang aman)",
        "responses": {
          "200": {
            "description": "Sumber terekonfigurasi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/search": {
      "get": {
        "tags": [
          "publik"
        ],
        "summary": "Pencarian artikel",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hasil pencarian",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NewsList"
                }
              }
            }
          },
          "400": {
            "description": "Parameter q hilang/terlalu pendek"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Envelope": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "data": {
            "type": "object"
          }
        },
        "required": [
          "ok"
        ]
      },
      "Article": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "deck": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string"
          },
          "storyType": {
            "type": "string",
            "enum": [
              "REPORTAJ",
              "OPINI",
              "ANALISIS",
              "FOTO",
              "VIDEO",
              "AUDIO"
            ]
          },
          "category": {
            "type": "object",
            "nullable": true,
            "properties": {
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "region": {
            "type": "object",
            "nullable": true
          },
          "author": {
            "type": "string",
            "nullable": true
          },
          "cover": {
            "type": "object",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "readingMinutes": {
            "type": "integer",
            "nullable": true
          },
          "isDemo": {
            "type": "boolean",
            "description": "true = konten demonstrasi"
          },
          "viewCount": {
            "type": "integer"
          }
        }
      },
      "NewsList": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "properties": {
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Article"
                }
              },
              "pagination": {
                "type": "object",
                "properties": {
                  "page": {
                    "type": "integer"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "total": {
                    "type": "integer"
                  },
                  "pages": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "NewsDetail": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Article"
              }
            ],
            "type": "object",
            "properties": {
              "bodyHtml": {
                "type": "string"
              },
              "bodyText": {
                "type": "string"
              },
              "sources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "publisher": {
                      "type": "string",
                      "nullable": true
                    },
                    "url": {
                      "type": "string"
                    },
                    "publishedAt": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              },
              "corrections": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Token API GeoPulse (gp_…) — dibatalkan bisa dari Admin"
      }
    }
  },
  "security": []
}