{
 "openapi": "3.1.0",
 "info": {
  "title": "API pública da Nove",
  "version": "1.0.0",
  "description": "Conteúdo público do nove.care, só leitura e sem autenticação: semanas da gestação, data provável do parto, busca, preços e recursos do app Nove. Informação geral, não diagnóstico.",
  "contact": {
   "email": "contato@nove.care",
   "url": "https://nove.care/developers"
  },
  "termsOfService": "https://nove.care/termos"
 },
 "servers": [
  {
   "url": "https://nove.care"
  }
 ],
 "paths": {
  "/api/v1/semanas": {
   "get": {
    "operationId": "listarSemanas",
    "summary": "As semanas de 4 a 40, paginadas",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Itens por página (1 a 50)",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 50,
       "default": 50
      }
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "description": "Quantos itens pular",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Página de semanas",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "items",
          "total",
          "limit",
          "offset"
         ],
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Semana"
           }
          },
          "total": {
           "type": "integer"
          },
          "limit": {
           "type": "integer"
          },
          "offset": {
           "type": "integer"
          },
          "next": {
           "type": [
            "string",
            "null"
           ],
           "description": "URL da próxima página, ou null"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Erro"
     }
    }
   }
  },
  "/api/v1/semanas/{semana}": {
   "get": {
    "operationId": "obterSemana",
    "summary": "Uma semana da gestação",
    "parameters": [
     {
      "name": "semana",
      "in": "path",
      "required": true,
      "description": "Semana de 4 a 40",
      "schema": {
       "type": "integer",
       "minimum": 4,
       "maximum": 40
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Semana",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Semana"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Erro"
     },
     "404": {
      "$ref": "#/components/responses/Erro"
     }
    }
   }
  },
  "/api/v1/dpp": {
   "get": {
    "operationId": "calcularDpp",
    "summary": "Data provável do parto e semanas de hoje",
    "parameters": [
     {
      "name": "dum",
      "in": "query",
      "required": false,
      "description": "Primeiro dia da última menstruação (AAAA-MM-DD)",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "us_data",
      "in": "query",
      "required": false,
      "description": "Data do ultrassom (AAAA-MM-DD)",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "us_semanas",
      "in": "query",
      "required": false,
      "description": "Semanas no laudo do ultrassom",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "us_dias",
      "in": "query",
      "required": false,
      "description": "Dias no laudo (0 a 6)",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "dpp",
      "in": "query",
      "required": false,
      "description": "DPP já conhecida (AAAA-MM-DD)",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Resultado",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "due_date": {
           "type": "string"
          },
          "weeks": {
           "type": "integer"
          },
          "days": {
           "type": "integer"
          },
          "trimester": {
           "type": "integer"
          },
          "week_page": {
           "type": "string"
          },
          "note": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Erro"
     }
    }
   }
  },
  "/api/v1/buscar": {
   "get": {
    "operationId": "buscar",
    "summary": "Busca no conteúdo do site",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "description": "O que procurar",
      "schema": {
       "type": "string",
       "minLength": 2
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Itens por página (1 a 50)",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 50,
       "default": 50
      }
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "description": "Quantos itens pular",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Resultados",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "query": {
           "type": "string"
          },
          "results": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Resultado"
           }
          },
          "total": {
           "type": "integer"
          },
          "limit": {
           "type": "integer"
          },
          "offset": {
           "type": "integer"
          },
          "next": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/Erro"
     }
    }
   }
  },
  "/api/v1/precos": {
   "get": {
    "operationId": "obterPrecos",
    "summary": "Preços do grátis e do Nove+",
    "responses": {
     "200": {
      "description": "Preços",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Precos"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/recursos": {
   "get": {
    "operationId": "listarRecursos",
    "summary": "Recursos do app",
    "responses": {
     "200": {
      "description": "Recursos",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Recurso"
         }
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Semana": {
    "type": "object",
    "properties": {
     "week": {
      "type": "integer"
     },
     "trimester": {
      "type": "integer"
     },
     "fruit": {
      "type": "string"
     },
     "cm": {
      "type": "number"
     },
     "g": {
      "type": "number"
     },
     "baby": {
      "type": "string"
     },
     "body": {
      "type": "string"
     },
     "url": {
      "type": "string"
     },
     "tips": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "ask": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "exams": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "name": {
         "type": "string"
        },
        "sub": {
         "type": "string"
        }
       }
      }
     }
    }
   },
   "Resultado": {
    "type": "object",
    "properties": {
     "url": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "score": {
      "type": "number"
     }
    }
   },
   "Recurso": {
    "type": "object",
    "required": [
     "name",
     "url"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "url": {
      "type": "string",
      "format": "uri"
     }
    }
   },
   "Plano": {
    "type": "object",
    "properties": {
     "price": {
      "type": "number"
     },
     "period": {
      "type": "string"
     },
     "trial_days": {
      "type": "integer"
     },
     "valid_until": {
      "type": "string"
     }
    }
   },
   "Precos": {
    "type": "object",
    "required": [
     "currency"
    ],
    "properties": {
     "currency": {
      "type": "string",
      "example": "BRL"
     },
     "free": {
      "type": "object",
      "properties": {
       "price": {
        "type": "number"
       },
       "includes": {
        "type": "array",
        "items": {
         "type": "string"
        }
       },
       "limits": {
        "type": "object",
        "additionalProperties": {
         "type": "integer"
        }
       }
      }
     },
     "plus_monthly": {
      "$ref": "#/components/schemas/Plano"
     },
     "plus_pregnancy": {
      "$ref": "#/components/schemas/Plano"
     },
     "plus_includes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "url": {
      "type": "string",
      "format": "uri"
     }
    }
   },
   "Erro": {
    "type": "object",
    "description": "Problem Details (RFC 9457)",
    "required": [
     "type",
     "title",
     "status",
     "detail",
     "code"
    ],
    "properties": {
     "type": {
      "type": "string",
      "format": "uri"
     },
     "title": {
      "type": "string"
     },
     "status": {
      "type": "integer"
     },
     "detail": {
      "type": "string"
     },
     "code": {
      "type": "string",
      "enum": [
       "invalid_week",
       "week_not_found",
       "missing_date",
       "missing_query",
       "invalid_json",
       "method_not_allowed",
       "not_found"
      ]
     }
    }
   }
  },
  "responses": {
   "Erro": {
    "description": "Erro (application/problem+json)",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Erro"
      }
     }
    }
   }
  }
 }
}