{
  "openapi": "3.1.0",
  "info": {
    "title": "Kronik API",
    "version": "1.0.0",
    "description": "Portfolio-friendly summaries of a GitHub user's public development activity."
  },
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "health.get",
        "parameters": [],
        "security": [],
        "responses": {
          "200": {
            "description": "Health",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        },
        "description": "Report Worker liveness without probing GitHub.",
        "summary": "Check Kronik health"
      }
    },
    "/v1/users/{username}/commits": {
      "get": {
        "tags": [
          "Activity"
        ],
        "operationId": "v1.activity.commits",
        "parameters": [
          {
            "name": "username",
            "in": "path",
            "schema": {
              "$ref": "#/components/schemas/GitHubUsername"
            },
            "required": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Cursor"
            },
            "required": false
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "CommitPage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommitPage"
                }
              }
            }
          },
          "400": {
            "description": "InvalidRequestProblem | InvalidCursorProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestProblem"
                    },
                    {
                      "$ref": "#/components/schemas/InvalidCursorProblem"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "UserNotFoundProblem | LatestCommitNotFoundProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/UserNotFoundProblem"
                    },
                    {
                      "$ref": "#/components/schemas/LatestCommitNotFoundProblem"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "RateLimitedProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedProblem"
                }
              }
            }
          },
          "502": {
            "description": "UpstreamFailureProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpstreamFailureProblem"
                }
              }
            }
          },
          "503": {
            "description": "ServiceUnavailableProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceUnavailableProblem"
                }
              }
            }
          }
        },
        "description": "List default-branch commits whose primary author GitHub resolves to the requested user. Initial requests default to ten items; continuation requests use only an opaque cursor.",
        "summary": "List public commits",
        "x-codeSamples": [
          {
            "id": "initial",
            "lang": "bash",
            "label": "Initial request",
            "source": "curl 'https://api.example.com/v1/users/octocat/commits?limit=25'"
          },
          {
            "id": "continuation",
            "lang": "bash",
            "label": "Continuation request",
            "source": "curl 'https://api.example.com/v1/users/octocat/commits?cursor=CURSOR_FROM_PREVIOUS_RESPONSE'"
          }
        ]
      }
    },
    "/v1/users/{username}/commits/latest": {
      "get": {
        "tags": [
          "Activity"
        ],
        "operationId": "v1.activity.latestCommit",
        "parameters": [
          {
            "name": "username",
            "in": "path",
            "schema": {
              "$ref": "#/components/schemas/GitHubUsername"
            },
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "LatestCommit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LatestCommit"
                }
              }
            }
          },
          "400": {
            "description": "InvalidRequestProblem | InvalidCursorProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestProblem"
                    },
                    {
                      "$ref": "#/components/schemas/InvalidCursorProblem"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "UserNotFoundProblem | LatestCommitNotFoundProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/UserNotFoundProblem"
                    },
                    {
                      "$ref": "#/components/schemas/LatestCommitNotFoundProblem"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "RateLimitedProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedProblem"
                }
              }
            }
          },
          "502": {
            "description": "UpstreamFailureProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpstreamFailureProblem"
                }
              }
            }
          },
          "503": {
            "description": "ServiceUnavailableProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceUnavailableProblem"
                }
              }
            }
          }
        },
        "description": "Return the most recently committed matching public default-branch commit.",
        "summary": "Get the latest public commit"
      }
    },
    "/v1/users/{username}/activity": {
      "get": {
        "tags": [
          "Activity"
        ],
        "operationId": "v1.activity.summary",
        "parameters": [
          {
            "name": "username",
            "in": "path",
            "schema": {
              "$ref": "#/components/schemas/GitHubUsername"
            },
            "required": true
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/IsoDate"
            },
            "required": false
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/IsoDate"
            },
            "required": false
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "ActivitySummary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivitySummary"
                }
              }
            }
          },
          "400": {
            "description": "InvalidRequestProblem | InvalidCursorProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestProblem"
                    },
                    {
                      "$ref": "#/components/schemas/InvalidCursorProblem"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "UserNotFoundProblem | LatestCommitNotFoundProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/UserNotFoundProblem"
                    },
                    {
                      "$ref": "#/components/schemas/LatestCommitNotFoundProblem"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "RateLimitedProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedProblem"
                }
              }
            }
          },
          "502": {
            "description": "UpstreamFailureProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpstreamFailureProblem"
                }
              }
            }
          },
          "503": {
            "description": "ServiceUnavailableProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceUnavailableProblem"
                }
              }
            }
          }
        },
        "description": "Aggregate at most 100 matching commits and repository language bytes over an inclusive activity window. The default is UTC today and the previous 29 dates.",
        "summary": "Summarize public activity"
      }
    },
    "/v1/users/{username}/streak": {
      "get": {
        "tags": [
          "Activity"
        ],
        "operationId": "v1.activity.streak",
        "parameters": [
          {
            "name": "username",
            "in": "path",
            "schema": {
              "$ref": "#/components/schemas/GitHubUsername"
            },
            "required": true
          }
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "ContributionStreak",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContributionStreak"
                }
              }
            }
          },
          "400": {
            "description": "InvalidRequestProblem | InvalidCursorProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestProblem"
                    },
                    {
                      "$ref": "#/components/schemas/InvalidCursorProblem"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "UserNotFoundProblem | LatestCommitNotFoundProblem",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/UserNotFoundProblem"
                    },
                    {
                      "$ref": "#/components/schemas/LatestCommitNotFoundProblem"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "RateLimitedProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedProblem"
                }
              }
            }
          },
          "502": {
            "description": "UpstreamFailureProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpstreamFailureProblem"
                }
              }
            }
          },
          "503": {
            "description": "ServiceUnavailableProblem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceUnavailableProblem"
                }
              }
            }
          }
        },
        "description": "Evaluate current and longest streaks over GitHub's trailing 365-day contribution calendar.",
        "summary": "Get contribution streaks"
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceUnavailableProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              503
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "UpstreamFailureProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              502
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "RateLimitedProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              429
            ]
          },
          "retryAfterSeconds": {
            "type": "integer",
            "maximum": 9007199254740991,
            "exclusiveMinimum": 0
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status",
          "retryAfterSeconds"
        ],
        "additionalProperties": false
      },
      "LatestCommitNotFoundProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              404
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "UserNotFoundProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              404
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "InvalidCursorProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              400
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "InvalidRequestProblem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "status": {
            "type": "number",
            "enum": [
              400
            ]
          }
        },
        "required": [
          "type",
          "title",
          "detail",
          "instance",
          "status"
        ],
        "additionalProperties": false
      },
      "ContributionStreak": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "from": {
            "$ref": "#/components/schemas/IsoDate"
          },
          "to": {
            "$ref": "#/components/schemas/IsoDate"
          },
          "currentStreak": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "longestStreak": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "active": {
            "type": "boolean"
          }
        },
        "required": [
          "user",
          "from",
          "to",
          "currentStreak",
          "longestStreak",
          "active"
        ],
        "additionalProperties": false
      },
      "IsoDate": {
        "type": "string"
      },
      "User": {
        "type": "object",
        "properties": {
          "login": {
            "$ref": "#/components/schemas/GitHubUsername"
          },
          "url": {
            "type": "string",
            "allOf": [
              {
                "format": "uri"
              }
            ]
          },
          "avatarUrl": {
            "type": "string",
            "allOf": [
              {
                "format": "uri"
              }
            ]
          }
        },
        "required": [
          "login",
          "url",
          "avatarUrl"
        ],
        "additionalProperties": false
      },
      "GitHubUsername": {
        "type": "string"
      },
      "ActivitySummary": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "window": {
            "$ref": "#/components/schemas/ActivityWindow"
          },
          "coverage": {
            "$ref": "#/components/schemas/ActivityCoverage"
          },
          "totals": {
            "$ref": "#/components/schemas/ActivityTotals"
          },
          "languages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Language"
            }
          },
          "otherBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "user",
          "window",
          "coverage",
          "totals",
          "languages",
          "otherBytes"
        ],
        "additionalProperties": false
      },
      "Language": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "percentage": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          }
        },
        "required": [
          "name",
          "color",
          "bytes",
          "percentage"
        ],
        "additionalProperties": false
      },
      "ActivityTotals": {
        "type": "object",
        "properties": {
          "commits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "additions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "deletions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "changedLines": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "commits",
          "additions",
          "deletions",
          "changedLines"
        ],
        "additionalProperties": false
      },
      "ActivityCoverage": {
        "type": "object",
        "properties": {
          "complete": {
            "type": "boolean"
          },
          "matchedCommits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "aggregatedCommits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "complete",
          "matchedCommits",
          "aggregatedCommits"
        ],
        "additionalProperties": false
      },
      "ActivityWindow": {
        "type": "object",
        "properties": {
          "from": {
            "$ref": "#/components/schemas/IsoDate"
          },
          "to": {
            "$ref": "#/components/schemas/IsoDate"
          }
        },
        "required": [
          "from",
          "to"
        ],
        "additionalProperties": false
      },
      "LatestCommit": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "commit": {
            "$ref": "#/components/schemas/CommitSummary"
          }
        },
        "required": [
          "user",
          "commit"
        ],
        "additionalProperties": false
      },
      "CommitSummary": {
        "type": "object",
        "properties": {
          "sha": {
            "$ref": "#/components/schemas/CommitSha"
          },
          "url": {
            "type": "string",
            "allOf": [
              {
                "format": "uri"
              }
            ]
          },
          "repository": {
            "$ref": "#/components/schemas/Repository"
          },
          "headline": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "bodyTruncated": {
            "type": "boolean"
          },
          "authoredAt": {
            "$ref": "#/components/schemas/IsoTimestamp"
          },
          "committedAt": {
            "$ref": "#/components/schemas/IsoTimestamp"
          },
          "additions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "deletions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "changedLines": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "parents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommitParent"
            }
          }
        },
        "required": [
          "sha",
          "url",
          "repository",
          "headline",
          "body",
          "bodyTruncated",
          "authoredAt",
          "committedAt",
          "additions",
          "deletions",
          "changedLines",
          "parents"
        ],
        "additionalProperties": false
      },
      "CommitParent": {
        "type": "object",
        "properties": {
          "sha": {
            "$ref": "#/components/schemas/CommitSha"
          },
          "url": {
            "type": "string",
            "allOf": [
              {
                "format": "uri"
              }
            ]
          }
        },
        "required": [
          "sha",
          "url"
        ],
        "additionalProperties": false
      },
      "CommitSha": {
        "type": "string"
      },
      "IsoTimestamp": {
        "type": "string"
      },
      "Repository": {
        "type": "object",
        "properties": {
          "nameWithOwner": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "allOf": [
              {
                "format": "uri"
              }
            ]
          }
        },
        "required": [
          "nameWithOwner",
          "url"
        ],
        "additionalProperties": false
      },
      "CommitPage": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommitSummary"
            }
          },
          "previous": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Cursor"
              },
              {
                "type": "null"
              }
            ]
          },
          "next": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Cursor"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "user",
          "items",
          "previous",
          "next"
        ],
        "additionalProperties": false
      },
      "Cursor": {
        "type": "string"
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": false
      }
    },
    "securitySchemes": {}
  },
  "security": [],
  "tags": [
    {
      "name": "Health"
    },
    {
      "name": "Activity"
    }
  ]
}
