{
  "openapi": "3.0.0",
  "info": {
    "title": "Workstation API",
    "description": "Workstation AI Platform API Documentation",
    "version": "2.0.0",
    "contact": {
      "name": "Workstation Support",
      "email": "info@workstation.co.uk"
    }
  },
  "servers": [
    {
      "url": "http://localhost:4010/api/v2",
      "description": "Development server"
    },
    {
      "url": "https://test-opsapi.workstation.co.uk",
      "description": "Test server"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "User authentication and authorization"
    },
    {
      "name": "Blogs",
      "description": "Blog management endpoints"
    },
    {
      "name": "Business",
      "description": "Business operations"
    }
  ],
  "paths": {
    "/auth/login": {
      "post": {
        "tags": ["Authentication"],
        "summary": "User login",
        "description": "Authenticate user and return access token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "example": "user@example.com"
                  },
                  "password": {
                    "type": "string",
                    "format": "password",
                    "example": "SecurePassword123!"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful authentication",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string",
                      "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
                    },
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/business/{businessCode}/public/blogs": {
      "get": {
        "tags": ["Blogs"],
        "summary": "Get public blogs",
        "description": "Retrieve all public blog posts for a business",
        "parameters": [
          {
            "name": "businessCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "WSDOC"
            },
            "description": "Business code identifier"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "Page number for pagination"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 10
            },
            "description": "Number of items per page"
          }
        ],
        "responses": {
          "200": {
            "description": "List of blogs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "content": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Blog"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/business/{businessCode}/public/blog/{uuid}": {
      "get": {
        "tags": ["Blogs"],
        "summary": "Get blog by UUID",
        "description": "Retrieve a specific blog post by its UUID",
        "parameters": [
          {
            "name": "businessCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "WSDOC"
            }
          },
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "49acb027-cf14-5559-ae05-ff804e4baf66"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Blog details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "content": {
                          "$ref": "#/components/schemas/Blog"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Blog not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Blog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "42411"
          },
          "uuid": {
            "type": "string",
            "format": "uuid",
            "example": "49acb027-cf14-5559-ae05-ff804e4baf66"
          },
          "title": {
            "type": "string",
            "example": "Building Cloud-Native Applications with Kubernetes"
          },
          "sub_title": {
            "type": "string",
            "example": "A comprehensive guide to modern container orchestration"
          },
          "content": {
            "type": "string",
            "description": "HTML content of the blog post"
          },
          "code": {
            "type": "string",
            "example": "building-cloud-native-kubernetes"
          },
          "slug": {
            "type": "string",
            "example": "building-cloud-native-kubernetes"
          },
          "meta_title": {
            "type": "string"
          },
          "meta_description": {
            "type": "string"
          },
          "meta_keywords": {
            "type": "string"
          },
          "publish_date": {
            "type": "string",
            "example": "1728259200"
          },
          "created": {
            "type": "string",
            "format": "date-time",
            "example": "2025-10-07 10:00:00"
          },
          "image": {
            "type": "string",
            "example": "/img/19.jpg"
          },
          "status": {
            "type": "string",
            "enum": ["0", "1"],
            "description": "0 = draft, 1 = published"
          },
          "blog_type": {
            "type": "string",
            "enum": ["1", "2"],
            "description": "1 = public, 2 = private"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "cat_name": {
                  "type": "string",
                  "example": "DevOps"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}
