[GitLab] YAML
GitLab Repository
Calls a GitLab 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 Gitlab, and store the following information for this request to work:
- On the top bar, in the upper-right corner, select your avatar.
- Select Edit profile.
- On the left sidebar, select Applications.
- Enter a Name and use
https://oauth.pstmn.io/v1/browser-callback
for the Redirect URI. - Select the read_api scope for your app.
- Click the Save application button at the bottom.
- Once created, store your Application ID and 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://gitlab.com/oauth/authorize
- Access Token URL:
https://gitlab.com/oauth/token
- Client ID: [your stored Client ID] - update the associated Collection Variable
- Client Secret: [your stored Client Secret] - update the associated Collection Variable
- Scope:
read_api
- State: [optional]
- Client Authentication: Send as Basic Auth header
Format your request
The URL will need to use your Project ID, file path and branch name.
- To get your Project ID, click on your Project name in the list of Projects and the ID should be directly under your Project name.
- The file path is a URL encoded full path to your schema file. For example, the URL encoded path for
app/models/key.rb
would be using%-2-F
(without the-
) for the slashes in the path and%-2-E
(without the-
) for the period. - The branch name refers to the branch where your file exists.
Update the following Collection Variables with your GitLab information:
gitlabProjectId
gitlabFilePathYAML
gitlabBranchName
You can now send a Request to any stored file in your GitLab repo.
If you need assistance on how to properly format your Request to your GitLab repository, please see GitLab's REST API documentation here: https://docs.gitlab.com/ee/api/oauth2.html
Example request: https://gitlab.com/api/v4/projects/[yourProjectId]/repository/files/[yourSchemaFilePath].json?ref=[yourBranchName]
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.
- Parse the Response.
- Decodes contents from your Git repo from base64.
- Parses the returned JSON.
- Sets the JSON that is obtained from your Git repo as the value for
yamlSchemaFromRepo
Collection Variable. - Adds extra formatting to this JSON so it can be successfully passed back into the Qodex API and sets this to
yamlSchemaFromRepo_stringified
Collection Variable.
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
ref | string |