{
    "openapi": "3.0.0",
    "info": {
        "title": "API Portal de Matrícula",
        "description": "API protegida por autenticação JWT",
        "version": "1.0.0"
    },
    "paths": {
        "/api/auth/login": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Autenticação do usuário e geração de access token e refresh token",
                "operationId": "dd51a484b7fa0f97c7680fdbde14cf5f",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email",
                                    "password"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "seu.email@graueducacional.com.br"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "123456"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login realizado com sucesso",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "access_token": {
                                            "type": "string",
                                            "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
                                        },
                                        "refresh_token": {
                                            "type": "string",
                                            "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
                                        },
                                        "token_type": {
                                            "type": "string",
                                            "example": "Bearer"
                                        },
                                        "expires_in": {
                                            "type": "integer",
                                            "example": 900
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Credenciais inválidas"
                    }
                }
            }
        },
        "/api/auth/refresh": {
            "post": {
                "tags": [
                    "Autenticação"
                ],
                "summary": "Gera um novo access token a partir de um refresh token válido",
                "operationId": "30c20c52f5f72828d8c531fd7c9ea3e7",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "refresh_token"
                                ],
                                "properties": {
                                    "refresh_token": {
                                        "type": "string",
                                        "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Access token renovado com sucesso",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "access_token": {
                                            "type": "string",
                                            "example": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
                                        },
                                        "token_type": {
                                            "type": "string",
                                            "example": "Bearer"
                                        },
                                        "expires_in": {
                                            "type": "integer",
                                            "example": 900
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Refresh token inválido ou expirado"
                    }
                }
            }
        },
        "/api/cursos/{cursoCodigo}/turmas": {
            "get": {
                "tags": [
                    "Cursos"
                ],
                "summary": "Lista as turmas abertas de um curso",
                "operationId": "caeb83d5029e5b1b4954200902d384b9",
                "parameters": [
                    {
                        "name": "cursoCodigo",
                        "in": "path",
                        "description": "Código do curso",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "00002"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lista de turmas retornada com sucesso"
                    },
                    "401": {
                        "description": "Token inválido ou expirado"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/payments/pix": {
            "post": {
                "tags": [
                    "PIX"
                ],
                "summary": "Cria um pagamento PIX",
                "operationId": "50e8be511632100ad8e54738eba4cd87",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "key",
                                    "value"
                                ],
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "example": "340ff806-1d8a-49cd-bbb2-b337a49db62d"
                                    },
                                    "value": {
                                        "description": "Valor em centavos",
                                        "type": "integer",
                                        "example": 2300
                                    },
                                    "summary": {
                                        "type": "string",
                                        "example": "Pagamento da matrícula"
                                    },
                                    "description": {
                                        "type": "string",
                                        "example": "Matrícula do curso de TI"
                                    },
                                    "precadastro_id": {
                                        "type": "integer",
                                        "example": 12345
                                    },
                                    "idempotency_key": {
                                        "type": "string",
                                        "example": "pix-precadastro-12345"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "PIX criado com sucesso",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "txid": {
                                                    "type": "string"
                                                },
                                                "emv": {
                                                    "type": "string"
                                                },
                                                "value": {
                                                    "type": "integer"
                                                },
                                                "state": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Token inválido ou expirado"
                    },
                    "500": {
                        "description": "Erro ao criar PIX"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/webhooks/zro/pix": {
            "post": {
                "tags": [
                    "PIX Webhook"
                ],
                "summary": "Webhook da Z.ro Bank para eventos PIX",
                "operationId": "197a6a9bed1649bb8656dee342777754",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "event": {
                                        "type": "string",
                                        "example": "pix.paid"
                                    },
                                    "txid": {
                                        "type": "string",
                                        "example": "tx_a8d9e7"
                                    },
                                    "paid_at": {
                                        "type": "string",
                                        "example": "2026-01-13 14:17:56"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Evento processado",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "PAID"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Assinatura inválida"
                    }
                }
            }
        },
        "/api/cursos/{cursoCodigo}/planos-pagamento": {
            "get": {
                "tags": [
                    "Planos de Pagamento"
                ],
                "summary": "Lista os planos de pagamento ativos de um curso",
                "operationId": "0fd119056d134a787aa101077e989f1a",
                "parameters": [
                    {
                        "name": "cursoCodigo",
                        "in": "path",
                        "description": "Código do curso",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "00002"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lista de planos retornada com sucesso",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "CURS_Codigo": {
                                                "type": "string"
                                            },
                                            "PLPG_IN_Codigo": {
                                                "type": "integer"
                                            },
                                            "PLPG_ST_Descricao": {
                                                "type": "string"
                                            },
                                            "plpg_dt_datainicial": {
                                                "type": "string",
                                                "format": "date"
                                            },
                                            "plpg_dt_datafinal": {
                                                "type": "string",
                                                "format": "date",
                                                "nullable": true
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Token inválido ou expirado"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/cursos/{cursoCodigo}/planos-pagamento/{planoCodigo}/detalhes": {
            "get": {
                "tags": [
                    "Planos de Pagamento"
                ],
                "summary": "Detalhes do plano de pagamento com cálculo de desconto",
                "operationId": "de95b847bd59579d7f7fa44de6b3bc8c",
                "parameters": [
                    {
                        "name": "cursoCodigo",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "00002"
                        }
                    },
                    {
                        "name": "planoCodigo",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 4134
                        }
                    },
                    {
                        "name": "desconto_matricula",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "number",
                            "example": 10
                        }
                    },
                    {
                        "name": "desconto_parcela",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "number",
                            "example": 5
                        }
                    },
                    {
                        "name": "data_vencimento_matricula",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "date",
                            "example": "2025-01-10"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Detalhes do plano calculados com sucesso"
                    },
                    "401": {
                        "description": "Token JWT inválido ou expirado"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/webhook/pix": {
            "post": {
                "tags": [
                    "Webhook"
                ],
                "summary": "Webhook PIX Z.ro",
                "operationId": "04151718ed1bb3713279e8db1a0f1400",
                "parameters": [
                    {
                        "name": "X-Signature",
                        "in": "header",
                        "description": "Assinatura HMAC SHA256",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "event": {
                                        "type": "string",
                                        "example": "pix.paid"
                                    },
                                    "txid": {
                                        "type": "string",
                                        "example": "tx_123"
                                    },
                                    "paid_at": {
                                        "type": "string",
                                        "example": "2026-01-13 14:17:56"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "description": "Invalid signature"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "description": "Informe o token JWT. Ex: Bearer eyJ0eXAiOiJKV1QiLCJh...",
                "bearerFormat": "JWT",
                "scheme": "bearer"
            }
        }
    },
    "tags": [
        {
            "name": "Autenticação",
            "description": "Autenticação"
        },
        {
            "name": "Cursos",
            "description": "Cursos"
        },
        {
            "name": "PIX",
            "description": "PIX"
        },
        {
            "name": "PIX Webhook",
            "description": "PIX Webhook"
        },
        {
            "name": "Planos de Pagamento",
            "description": "Planos de Pagamento"
        },
        {
            "name": "Webhook",
            "description": "Webhook"
        }
    ]
}