{
  "openapi": "3.0.3",
  "info": {
    "title": "Azpor Public API",
    "version": "1.0.0",
    "description": "Read-only REST API for Azpor's published editorial content -- articles and their taxonomy (categories, topics, tags). This is the subset of Payload CMS's own REST API that is genuinely public and unauthenticated; collections that require login (users, comments, likes, bookmarks, payments) are intentionally not part of this spec. A `pro`-access article's `content` field is stripped from the response for an unauthenticated or non-Pro request -- everything else on the article stays visible.",
    "contact": {
      "url": "https://azpor.com/kontak"
    }
  },
  "servers": [{ "url": "https://azpor.com/api" }],
  "paths": {
    "/posts": {
      "get": {
        "summary": "List published articles",
        "description": "Returns published articles only (draft/scheduled/archived posts are never included, regardless of query). Newest first unless overridden with `sort`.",
        "parameters": [
          { "$ref": "#/components/parameters/limit" },
          { "$ref": "#/components/parameters/page" },
          { "$ref": "#/components/parameters/depth" },
          { "$ref": "#/components/parameters/sort" },
          { "$ref": "#/components/parameters/where" }
        ],
        "responses": {
          "200": {
            "description": "A page of articles",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PostList" }
              }
            }
          }
        }
      }
    },
    "/posts/{id}": {
      "get": {
        "summary": "Get one article by id",
        "parameters": [{ "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/depth" }],
        "responses": {
          "200": {
            "description": "The article",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Post" } } }
          },
          "404": { "description": "No published article with this id" }
        }
      }
    },
    "/categories": {
      "get": {
        "summary": "List categories",
        "parameters": [
          { "$ref": "#/components/parameters/limit" },
          { "$ref": "#/components/parameters/page" },
          { "$ref": "#/components/parameters/where" }
        ],
        "responses": {
          "200": {
            "description": "A page of categories",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CategoryList" } } }
          }
        }
      }
    },
    "/topics": {
      "get": {
        "summary": "List topics",
        "parameters": [
          { "$ref": "#/components/parameters/limit" },
          { "$ref": "#/components/parameters/page" },
          { "$ref": "#/components/parameters/where" }
        ],
        "responses": {
          "200": {
            "description": "A page of topics",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TopicList" } } }
          }
        }
      }
    },
    "/tags": {
      "get": {
        "summary": "List tags",
        "parameters": [
          { "$ref": "#/components/parameters/limit" },
          { "$ref": "#/components/parameters/page" },
          { "$ref": "#/components/parameters/where" }
        ],
        "responses": {
          "200": {
            "description": "A page of tags",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TagList" } } }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": { "type": "integer" }
      },
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "Docs per page. Default 10, 0 means no limit.",
        "schema": { "type": "integer", "default": 10 }
      },
      "page": {
        "name": "page",
        "in": "query",
        "schema": { "type": "integer", "default": 1 }
      },
      "depth": {
        "name": "depth",
        "in": "query",
        "description": "How many levels of relationship fields (author, category, topics, tags, coverImage) to populate instead of returning bare ids. 0-2, default 1.",
        "schema": { "type": "integer", "default": 1, "minimum": 0, "maximum": 2 }
      },
      "sort": {
        "name": "sort",
        "in": "query",
        "description": "Field to sort by; prefix with `-` for descending, e.g. `-publishedAt`.",
        "schema": { "type": "string" }
      },
      "where": {
        "name": "where",
        "in": "query",
        "description": "Payload's bracket-notation query DSL, e.g. `where[category][equals]=3`. Full operator reference: https://payloadcms.com/docs/queries/overview",
        "schema": { "type": "string" },
        "style": "deepObject",
        "explode": true
      }
    },
    "schemas": {
      "PaginationFields": {
        "type": "object",
        "properties": {
          "totalDocs": { "type": "integer" },
          "limit": { "type": "integer" },
          "page": { "type": "integer" },
          "totalPages": { "type": "integer" },
          "hasNextPage": { "type": "boolean" },
          "hasPrevPage": { "type": "boolean" }
        }
      },
      "Post": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "title": { "type": "string" },
          "slug": { "type": "string" },
          "excerpt": { "type": "string", "nullable": true },
          "content": {
            "description": "Tiptap/ProseMirror JSON document. Absent entirely (not null) when the requester isn't entitled to a `pro`-access article's body.",
            "nullable": true
          },
          "author": { "description": "User id, or a populated author object at depth >= 1" },
          "category": { "description": "Category id, or a populated Category at depth >= 1", "nullable": true },
          "topics": { "type": "array", "items": {} },
          "tags": { "type": "array", "items": {} },
          "access": { "type": "string", "enum": ["public", "pro"] },
          "status": { "type": "string", "enum": ["published"], "description": "Always `published` -- this API never returns draft/scheduled/archived posts." },
          "publishedAt": { "type": "string", "format": "date-time", "nullable": true },
          "readingTime": { "type": "integer", "description": "Minutes, estimated from word count.", "nullable": true }
        }
      },
      "PostList": {
        "allOf": [
          { "$ref": "#/components/schemas/PaginationFields" },
          { "type": "object", "properties": { "docs": { "type": "array", "items": { "$ref": "#/components/schemas/Post" } } } }
        ]
      },
      "Category": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "description": { "type": "string", "nullable": true }
        }
      },
      "CategoryList": {
        "allOf": [
          { "$ref": "#/components/schemas/PaginationFields" },
          { "type": "object", "properties": { "docs": { "type": "array", "items": { "$ref": "#/components/schemas/Category" } } } }
        ]
      },
      "Topic": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "description": { "type": "string", "nullable": true }
        }
      },
      "TopicList": {
        "allOf": [
          { "$ref": "#/components/schemas/PaginationFields" },
          { "type": "object", "properties": { "docs": { "type": "array", "items": { "$ref": "#/components/schemas/Topic" } } } }
        ]
      },
      "Tag": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": "string" }
        }
      },
      "TagList": {
        "allOf": [
          { "$ref": "#/components/schemas/PaginationFields" },
          { "type": "object", "properties": { "docs": { "type": "array", "items": { "$ref": "#/components/schemas/Tag" } } } }
        ]
      }
    }
  }
}
