Code Master

Code Master · Ações GPT

GitHub Repository Contents API

  • GET /repos/{owner}/{repo}/contents/{path}Get repository content

    Retrieves the contents of a file or directory in a repository.

Esquema API original
{
  "openapi": "3.0.0",
  "info": {
    "title": "GitHub Repository Contents API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.github.com"
    }
  ],
  "paths": {
    "/repos/{owner}/{repo}/contents/{path}": {
      "get": {
        "summary": "Get repository content",
        "description": "Retrieves the contents of a file or directory in a repository.",
        "operationId": "getRepositoryContent",
        "parameters": [
          {
            "name": "owner",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The account owner of the repository."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The name of the repository without the `.git` extension."
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The file path or directory in the repository."
          },
          {
            "name": "ref",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the commit/branch/tag. Defaults to the repository’s default branch."
          }
        ],
        "responses": {
          "200": {
            "description": "Content retrieved successfully",
            "content": {
              "application/vnd.github+json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentTree"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ContentTree": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "sha": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "git_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "html_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentTreeEntry"
            }
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        },
        "required": [
          "type",
          "size",
          "name",
          "path",
          "sha",
          "url",
          "git_url",
          "html_url",
          "download_url",
          "_links"
        ]
      },
      "ContentTreeEntry": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "sha": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "git_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "html_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "_links": {
            "$ref": "#/components/schemas/Links"
          }
        },
        "required": [
          "type",
          "size",
          "name",
          "path",
          "sha",
          "url",
          "git_url",
          "html_url",
          "download_url",
          "_links"
        ]
      },
      "Links": {
        "type": "object",
        "properties": {
          "git": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "html": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "self": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "git",
          "html",
          "self"
        ]
      }
    }
  }
}