{
  "openapi": "3.1.0",
  "info": {
    "title": "ChengOS Workflow Catalog API",
    "version": "1.0.0",
    "description": "Public read-only discovery APIs used by LLM agents to inspect workflow templates, node schemas, and available LLM models before generating importable workflow JSON."
  },
  "servers": [
    {
      "url": "https://catalog.chengos.dev/api/v1",
      "description": "Production catalog API"
    }
  ],
  "tags": [
    {
      "name": "Workflow Templates",
      "description": "Template discovery and template definition reads."
    },
    {
      "name": "Node Catalog",
      "description": "Node type and schema discovery."
    },
    {
      "name": "LLM Models",
      "description": "Available chat and embedding model discovery."
    }
  ],
  "paths": {
    "/workflows/templates": {
      "get": {
        "tags": ["Workflow Templates"],
        "summary": "List workflow template summaries",
        "description": "Returns template summaries such as name, description, node count, edge count, tags, and visibility. Use this first when the user's request resembles a common workflow pattern.",
        "operationId": "listWorkflowTemplates",
        "responses": {
          "200": {
            "description": "Template summary list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkflowTemplateSummary"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/workflows/templates/{id}": {
      "get": {
        "tags": ["Workflow Templates"],
        "summary": "Get one full workflow template",
        "description": "Returns a full template definition including nodes and edges. Use this to adapt an existing template instead of inventing a workflow from scratch.",
        "operationId": "getWorkflowTemplate",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Template identifier returned by /workflows/templates."
          }
        ],
        "responses": {
          "200": {
            "description": "Full workflow template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowTemplate"
                }
              }
            }
          }
        }
      }
    },
    "/nodes/types": {
      "get": {
        "tags": ["Node Catalog"],
        "summary": "List available node types",
        "description": "Returns node type IDs, categories, descriptions, input/output schemas, and i18n keys. Use this before generating workflow JSON.",
        "operationId": "listNodeTypes",
        "responses": {
          "200": {
            "description": "Node type list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NodeType"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/nodes/schema/{nodeType}": {
      "get": {
        "tags": ["Node Catalog"],
        "summary": "Get schema for one node type",
        "description": "Returns detailed input and output JSON Schema for one node type. Use exact schema property keys as workflow edge ports.",
        "operationId": "getNodeSchema",
        "parameters": [
          {
            "name": "nodeType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "examples": ["ai/llm"]
            },
            "description": "Node typeId in {category}/{type} format."
          }
        ],
        "responses": {
          "200": {
            "description": "Node schema",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NodeType"
                }
              }
            }
          }
        }
      }
    },
    "/llm/models": {
      "get": {
        "tags": ["LLM Models"],
        "summary": "List available LLM models",
        "description": "Returns models grouped by provider, including chat and embedding models. Use this for ai/llm, ai/llm_config, embedding, RAG, summarization, classification, and extraction nodes.",
        "operationId": "listLlmModels",
        "responses": {
          "200": {
            "description": "Model list grouped by provider",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WorkflowTemplateSummary": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "nodeCount": { "type": "integer" },
          "edgeCount": { "type": "integer" },
          "tags": {
            "type": "array",
            "items": { "type": "string" }
          },
          "visibility": { "type": "string" }
        }
      },
      "WorkflowTemplate": {
        "allOf": [
          { "$ref": "#/components/schemas/WorkflowTemplateSummary" },
          {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "definition": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                  "nodes": {
                    "type": "array",
                    "items": { "type": "object", "additionalProperties": true }
                  },
                  "edges": {
                    "type": "array",
                    "items": { "type": "object", "additionalProperties": true }
                  }
                }
              }
            }
          }
        ]
      },
      "NodeType": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "typeId": { "type": "string", "description": "Use this exact value as nodeType in generated workflow JSON." },
          "category": { "type": "string" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "inputSchema": { "type": "object", "additionalProperties": true },
          "outputSchema": { "type": "object", "additionalProperties": true }
        }
      }
    }
  }
}
