{
  "openapi": "3.0.3",
  "info": {
    "title": "COIProve API",
    "version": "1.0.0",
    "description": "Vendor insurance compliance: extract COIs, list vendors, read status."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ck_live_..."
      }
    },
    "schemas": {
      "Vendor": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "compliant",
              "expiring",
              "deficient",
              "expired",
              "missing"
            ]
          },
          "expires": {
            "type": "string",
            "nullable": true
          },
          "days_left": {
            "type": "integer",
            "nullable": true
          },
          "gl_each": {
            "type": "integer",
            "nullable": true
          },
          "additional_insured": {
            "type": "boolean",
            "nullable": true
          },
          "waiver_of_subrogation": {
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "Extraction": {
        "type": "object",
        "properties": {
          "insured_name": {
            "type": "string",
            "nullable": true
          },
          "insurers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "policies": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "additional_insured": {
            "type": "boolean",
            "nullable": true
          },
          "waiver_of_subrogation": {
            "type": "boolean",
            "nullable": true
          },
          "confidence": {
            "type": "number"
          },
          "engine": {
            "type": "string",
            "example": "ocr:embedded-image"
          },
          "ocr": {
            "type": "object",
            "properties": {
              "used": {
                "type": "boolean"
              },
              "available": {
                "type": "boolean"
              },
              "strategy": {
                "type": "string"
              },
              "pages": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/api/v1/vendors": {
      "get": {
        "summary": "List vendors",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create vendor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "trade": {
                    "type": "string"
                  },
                  "contact_email": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/api/v1/vendors/{id}": {
      "get": {
        "summary": "Vendor detail",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/extract": {
      "post": {
        "summary": "Extract a COI",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extraction result"
          }
        }
      }
    },
    "/api/v1/compliance": {
      "get": {
        "summary": "Portfolio compliance",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}