[GitHub] YAML
GET https://api.github.com/repos/{{githubRepoOwner}}/{{githubRepoName}}/contents/{{githubFilePathYAML}}
GitHub Repository
Calls a GitHub respository to obtain the contents of your specified API schema.
Authorization
This Request uses OAuth 2.0 to authorize the Request. You will need to take the following steps in GitHub, and store the following information for this request to work:
- Click on your avatar at the top right and select Settings in the drop-down.
- On the left navigation menu, click Developer Settings, go to OAuth Apps.
- Create a new OAuth App for this project.
- Add an easily recognizable name.
- Add your app Homepage URL (anything you want).
- Add the following URL for the Authorization callback URL value:
https://oauth.pstmn.io/v1/browser-callback
- Click the Register application button at the bottom.
- Once created, store your Client ID somewhere secure where you can access it again easily.
- Generate a new Client Secret, store your Client Secret somewhere secure where you can access it again easily.
Now that you have this information stored, click into the Authorization tab of this Request. On this tab, use the following steps:
- Type: OAuth 2.0
- Add authorization data to: Request Headers
- Token Name: [any recognizable name]
- Grant Type: Authorization Code
- Auth URL:
https://github.com/login/oauth/authorize
- Access Token URL:
https://github.com/login/oauth/access_token
- Client ID: [your stored Client ID] - update the associated Collection Variable
- Client Secret: [your stored Client Secret] - update the associated Collection Variable
- Scope:
repo workflow
- State: [optional]
- Client Authentication: Send as Basic Auth header
Format your request
The URL will need to use the repo owner, repo name and file path.
- For the repo owner, use the GitHub username of the account that owns the repo.
- The file path is a combination of the directory in which your schema file is located, along with the schema file name.
Update the following Collection Variables with your GitHub information:
githubRepoOwner
githubRepoName
githubFilePathYAML
You can now send a Request to any stored file in your GitHub repo.
If you need assistance on how to properly format your Request to your GitHub repository, please see GitHub's REST API documentation here: https://docs.github.com/en/rest/repos/contents
Example request: https://api.github.com/repos/[yourProfile]/[yourRepo]/contents/[yourSchemaFilePath]
Overview
Pre-request Script tab
Sends a message to the Console that the Request is starting to acquire your specified Git repository.
Tests tab
- Checks for a 200 HTTP response to confirm that the schema information was acquired.
- Parses the Response.
- Decodes contents from your Git repo from base64.
- Sets the JSON that is obtained from your Git repo as the value for
yamlSchemaFromRepo
Collection Variable. - Stringify the value and sets this to
yamlSchemaFromRepo_stringified
Collection Variable.