{
    "openapi": "3.1.0",
    "info": {
        "title": "Portal CM7 API",
        "version": "1.4.2",
        "description": "Notícias de Manaus e Amazonas A API REST completa do WordPress está em https://www.cm7brasil.com/wp-json/."
    },
    "servers": [
        {
            "url": "https://www.cm7brasil.com/wp-json/o4ai/v1"
        }
    ],
    "paths": {
        "/search": {
            "get": {
                "operationId": "searchContent",
                "summary": "Busca conteúdo publicado",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 10
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resultados",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "integer"
                                            },
                                            "type": {
                                                "type": "string"
                                            },
                                            "title": {
                                                "type": "string"
                                            },
                                            "url": {
                                                "type": "string",
                                                "format": "uri"
                                            },
                                            "date": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "excerpt": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/content": {
            "get": {
                "operationId": "getContent",
                "summary": "Conteúdo completo em Markdown por ID ou URL",
                "parameters": [
                    {
                        "name": "id",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "url",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Conteúdo",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "integer"
                                                },
                                                "type": {
                                                    "type": "string"
                                                },
                                                "title": {
                                                    "type": "string"
                                                },
                                                "url": {
                                                    "type": "string",
                                                    "format": "uri"
                                                },
                                                "date": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "excerpt": {
                                                    "type": "string"
                                                }
                                            }
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "markdown": {
                                                    "type": "string"
                                                },
                                                "tokens": {
                                                    "type": "integer"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Não encontrado"
                    }
                }
            }
        },
        "/health": {
            "get": {
                "operationId": "health",
                "summary": "Status da API",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "oauth2": {
                "type": "oauth2",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://www.cm7brasil.com/wp-login.php?action=o4ai_authorize",
                        "tokenUrl": "https://www.cm7brasil.com/wp-json/o4ai/v1/oauth/token",
                        "scopes": {
                            "read": "Leitura",
                            "write": "Escrita em nome do usuário"
                        }
                    }
                }
            }
        }
    }
}