{
  "openapi": "3.1.0",
  "info": {
    "title": "Structura Headless Delivery API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://us-central1-structura-8d158.cloudfunctions.net/headlessReadPosts/{workspaceId}/{activationId}",
      "variables": {
        "workspaceId": {
          "default": "YOUR_WORKSPACE_ID"
        },
        "activationId": {
          "default": "YOUR_SITE_ID"
        }
      }
    }
  ],
  "security": [],
  "paths": {
    "/posts": {
      "get": {
        "summary": "List posts",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Content language, for example de.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Older page. Pass nextCursor, omitting before.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "Newer page. Pass prevCursor, omitting cursor.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Category slug. Omit tag.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "description": "Tag slug. Omit category.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List posts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostPage"
                }
              }
            }
          },
          "404": {
            "description": "Site or published post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/posts/{slug}": {
      "get": {
        "summary": "Single post",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Single post",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostResponse"
                }
              }
            }
          },
          "404": {
            "description": "Site or published post not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/terms": {
      "get": {
        "summary": "Archives",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Content language, for example de.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Archives",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Archives"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PostPage": {
        "type": "object",
        "properties": {
          "posts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostSummary"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "prevCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "posts",
          "nextCursor",
          "prevCursor"
        ]
      },
      "PostSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "featuredImage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Image"
              },
              {
                "type": "null"
              }
            ]
          },
          "publishedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "slug",
          "title",
          "excerpt",
          "categories",
          "tags",
          "featuredImage",
          "publishedAt",
          "updatedAt"
        ]
      },
      "PostResponse": {
        "type": "object",
        "properties": {
          "post": {
            "$ref": "#/components/schemas/Post"
          }
        },
        "required": [
          "post"
        ]
      },
      "Post": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PostSummary"
          },
          {
            "type": "object",
            "properties": {
              "html": {
                "type": "string"
              },
              "blocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Block"
                }
              },
              "bodyImage": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Image"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "metaTitle": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "metaDescription": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "keyphrase": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "author": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Author"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "og": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "image": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "title",
                  "description",
                  "image"
                ]
              },
              "schema": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            },
            "required": [
              "html",
              "blocks",
              "bodyImage",
              "metaTitle",
              "metaDescription",
              "keyphrase",
              "author",
              "og",
              "schema"
            ]
          }
        ]
      },
      "Author": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "bio": {
            "type": [
              "string",
              "null"
            ]
          },
          "avatarUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "profileUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "sameAs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "bio",
          "avatarUrl",
          "profileUrl",
          "sameAs"
        ]
      },
      "Image": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "width": {
            "type": "integer"
          },
          "height": {
            "type": "integer"
          },
          "alt": {
            "type": "string"
          },
          "caption": {
            "type": "string"
          }
        },
        "required": [
          "url",
          "width",
          "height"
        ]
      },
      "Archives": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          }
        },
        "required": [
          "categories",
          "tags"
        ]
      },
      "Term": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "slug",
          "name",
          "count"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Block": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "children": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attrs": {
            "type": "object"
          },
          "table_content": {
            "type": "object",
            "properties": {
              "headers": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "rows": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "footers": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
