{
  "openapi": "3.1.0",
  "info": {
    "title": "RACCO Read-only Reports API",
    "version": "1.0.0",
    "description": "ユーザー自身の実績を参照するHTTP API。APIキーは設定のAPI連携から発行します。"
  },
  "servers": [
    {
      "url": "https://app.racco-app.link/api/external/v1"
    }
  ],
  "security": [
    {
      "ApiKeyBearer": []
    }
  ],
  "paths": {
    "/reports/monthly": {
      "get": {
        "operationId": "getMonthlyReports",
        "summary": "本人の月次実績",
        "description": "日本時間・分単位。稼働中を含む。月ごと・案件ごとに集計し、メモ・勤務時刻・契約条件は返さない。",
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^(?!0000)\\d{4}-(0[1-9]|1[0-2])$"
            }
          },
          {
            "name": "projectId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "本人の集計と日別実績。該当なしは空配列。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "serverNow"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MonthlyReport"
                      }
                    },
                    "serverNow": {
                      "type": "string",
                      "format": "date-time",
                      "description": "レスポンス生成時刻（UTC）"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "流量制限。間隔を空けて再試行してください。"
          },
          "500": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reports/range": {
      "get": {
        "operationId": "getRangeReports",
        "summary": "本人の期間指定実績（最大366日、両端を含む）",
        "description": "日本時間・分単位。稼働中を含む。月ごと・案件ごとに集計し、メモ・勤務時刻・契約条件は返さない。",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "projectId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "本人の集計と日別実績。該当なしは空配列。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "serverNow"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MonthlyReport"
                      }
                    },
                    "serverNow": {
                      "type": "string",
                      "format": "date-time",
                      "description": "レスポンス生成時刻（UTC）"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "流量制限。間隔を空けて再試行してください。"
          },
          "500": {
            "description": "リクエストの処理に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "requestId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "RACCO API key"
      }
    },
    "schemas": {
      "DailyReport": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "date",
          "actualMinutes",
          "billableMinutes",
          "breakMinutes"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "actualMinutes": {
            "type": "integer",
            "minimum": 0
          },
          "billableMinutes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "breakMinutes": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "MonthlyReport": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "month",
          "projectId",
          "projectName",
          "actualMinutes",
          "billableMinutes",
          "breakMinutes",
          "workDays",
          "days"
        ],
        "properties": {
          "month": {
            "type": "string",
            "pattern": "^(?!0000)\\d{4}-(0[1-9]|1[0-2])$"
          },
          "projectId": {
            "type": "string",
            "format": "uuid"
          },
          "projectName": {
            "type": "string"
          },
          "actualMinutes": {
            "type": "integer",
            "minimum": 0
          },
          "billableMinutes": {
            "type": "integer",
            "minimum": 0
          },
          "breakMinutes": {
            "type": "integer",
            "minimum": 0
          },
          "workDays": {
            "type": "integer",
            "minimum": 0
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyReport"
            }
          }
        }
      }
    }
  }
}
