{
  "openapi": "3.1.0",
  "info": {
    "title": "KuKu public blog",
    "version": "1.0",
    "description": "Read published KuKu articles. Follow the article’s canonical website URL when citing it."
  },
  "servers": [
    {
      "url": "https://www.kukuapp.io"
    }
  ],
  "paths": {
    "/api/blog": {
      "get": {
        "operationId": "readKuKuBlog",
        "summary": "List articles or read one article by slug",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "description": "Return one published article by its current or previously published slug.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Continue a list using the nextCursor from the previous response.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of articles in a list page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of published articles, or one article.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "posts",
                        "nextCursor"
                      ],
                      "properties": {
                        "posts": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Post"
                          }
                        },
                        "nextCursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "post",
                        "canonicalSlug"
                      ],
                      "properties": {
                        "canonicalSlug": {
                          "type": "string"
                        },
                        "post": {
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/Post"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "body": {
                                  "type": "string",
                                  "description": "Markdown article body"
                                }
                              },
                              "required": [
                                "body"
                              ]
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query or cursor."
          },
          "404": {
            "description": "No public article at that slug."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Post": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "author": {
            "type": "string"
          },
          "publishAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "coverUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "First-party image path or HTTPS cover image URL."
          },
          "coverAlt": {
            "type": "string"
          },
          "seoTitle": {
            "type": "string"
          },
          "seoDescription": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "slug",
          "title",
          "excerpt",
          "author",
          "publishAt",
          "updatedAt"
        ]
      }
    }
  }
}
