mirror of
https://github.com/LukeHagar/api-specs.git
synced 2025-12-06 04:19:09 +00:00
added scripts and postman collections for new build
This commit is contained in:
@@ -19,10 +19,13 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
- name: Install swagger-cli
|
||||
- name: Install swagger-cli and postman
|
||||
run: |
|
||||
npm install -g swagger-cli
|
||||
npm install -g openapi-to-postmanv2
|
||||
- name: Dereference Beta API Specification
|
||||
run: |
|
||||
swagger-cli bundle --dereference idn/sailpoint-api.beta.yaml -t yaml -o dereferenced/deref-sailpoint-api.beta.yaml
|
||||
openapi2postmanv2 -s dereferenced/deref-sailpoint-api.beta.yaml -o postman/collections/sailpoint-api-beta.json -p -O folderStrategy=Tags,requestParametersResolution=Schema,exampleParametersResolution=Schema,disableOptionalParameters=true,optimizeConversion=false,stackLimit=50,alwaysInheritAuthentication=true
|
||||
node postman-script/modify-collection.js postman/collections/sailpoint-api-beta.json
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
|
||||
@@ -18,11 +18,15 @@ jobs:
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
- name: Install swagger-cli
|
||||
node-version: "18"
|
||||
- name: Install swagger-cli and postman
|
||||
run: |
|
||||
npm install -g swagger-cli
|
||||
npm install -g openapi-to-postmanv2
|
||||
- name: Dereference API Specification
|
||||
run: |
|
||||
swagger-cli bundle --dereference idn/sailpoint-api.v3.yaml -t yaml -o dereferenced/deref-sailpoint-api.v3.yaml
|
||||
openapi2postmanv2 -s dereferenced/deref-sailpoint-api.v3.yaml -o postman/collections/sailpoint-api-v3.json -p -O folderStrategy=Tags,requestParametersResolution=Schema,exampleParametersResolution=Schema,disableOptionalParameters=true,optimizeConversion=false,stackLimit=50,alwaysInheritAuthentication=true
|
||||
node postman-script/modify-collection.js postman/collections/sailpoint-api-v3.json
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
|
||||
10
postman-script/base-auth.json
Normal file
10
postman-script/base-auth.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{accessToken}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
48
postman-script/modify-collection.js
Normal file
48
postman-script/modify-collection.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const fs = require('fs');
|
||||
|
||||
// Function to recursively delete "auth" key from an object
|
||||
const deleteAuthKey = (obj) => {
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
deleteAuthKey(obj[key]); // Recursive call for nested objects
|
||||
}
|
||||
if (key === 'auth') {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const args = process.argv;
|
||||
|
||||
// Read the JSON file
|
||||
fs.readFile(args[2], 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.error('Error reading the file:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Parse the JSON content
|
||||
const jsonObject = JSON.parse(data);
|
||||
|
||||
|
||||
|
||||
// Delete all occurrences of the key "auth"
|
||||
deleteAuthKey(jsonObject);
|
||||
jsonObject.auth = JSON.parse(fs.readFileSync('postman-script/base-auth.json', 'utf8'));
|
||||
jsonObject.event = JSON.parse(fs.readFileSync('postman-script/pre-script.json', 'utf8'));
|
||||
jsonObject.variable = JSON.parse(fs.readFileSync('postman-script/variable.json', 'utf8'));
|
||||
|
||||
|
||||
// Write the modified JSON content back to the file
|
||||
fs.writeFile(args[2], JSON.stringify(jsonObject, null, 2), (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing the file:', writeErr);
|
||||
} else {
|
||||
console.log('Auth keys deleted and file updated successfully.');
|
||||
}
|
||||
});
|
||||
} catch (parseError) {
|
||||
console.error('Error parsing JSON:', parseError);
|
||||
}
|
||||
});
|
||||
65
postman-script/pre-script.json
Normal file
65
postman-script/pre-script.json
Normal file
@@ -0,0 +1,65 @@
|
||||
[
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const domain = pm.environment.get('domain') ? pm.environment.get('domain') : pm.collectionVariables.get('domain')",
|
||||
"const tokenUrl = 'https://' + pm.environment.get('tenant') + '.api.' + domain + '.com/oauth/token';",
|
||||
"const clientId = pm.environment.get('clientId');",
|
||||
"const clientSecret = pm.environment.get('clientSecret');",
|
||||
"",
|
||||
"const getTokenRequest = {",
|
||||
" method: 'POST',",
|
||||
" url: tokenUrl,",
|
||||
" body: {",
|
||||
" mode: 'formdata',",
|
||||
" formdata: [{",
|
||||
" key: 'grant_type',",
|
||||
" value: 'client_credentials'",
|
||||
" },",
|
||||
" {",
|
||||
" key: 'client_id',",
|
||||
" value: clientId",
|
||||
" },",
|
||||
" {",
|
||||
" key: 'client_secret',",
|
||||
" value: clientSecret",
|
||||
" }",
|
||||
" ]",
|
||||
" }",
|
||||
"};",
|
||||
"",
|
||||
"",
|
||||
"var moment = require('moment');",
|
||||
"if (!pm.environment.has('tokenExpTime')) {",
|
||||
" pm.environment.set('tokenExpTime', moment());",
|
||||
"}",
|
||||
"",
|
||||
"if (moment(pm.environment.get('tokenExpTime')) <= moment() || !pm.environment.get('tokenExpTime') || !pm.environment.get('accessToken')) {",
|
||||
" var time = moment();",
|
||||
" time.add(12, 'hours');",
|
||||
" pm.environment.set('tokenExpTime', time);",
|
||||
" pm.sendRequest(getTokenRequest, (err, response) => {",
|
||||
" const jsonResponse = response.json();",
|
||||
" if (response.code != 200) {",
|
||||
" throw new Error(`Unable to authenticate: ${JSON.stringify(jsonResponse)}`);",
|
||||
" }",
|
||||
" const newAccessToken = jsonResponse.access_token;",
|
||||
" pm.environment.set('accessToken', newAccessToken);",
|
||||
" });",
|
||||
"",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
12
postman-script/variable.json
Normal file
12
postman-script/variable.json
Normal file
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"key": "domain",
|
||||
"value": "identitynow",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "baseUrl",
|
||||
"value": "https://{{tenant}}.api.{{domain}}.com",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
177940
postman/collections/sailpoint-api-beta.json
Normal file
177940
postman/collections/sailpoint-api-beta.json
Normal file
File diff suppressed because one or more lines are too long
2176
postman/collections/sailpoint-api-cc.json
Normal file
2176
postman/collections/sailpoint-api-cc.json
Normal file
File diff suppressed because one or more lines are too long
1336
postman/collections/sailpoint-api-v2.json
Normal file
1336
postman/collections/sailpoint-api-v2.json
Normal file
File diff suppressed because it is too large
Load Diff
101548
postman/collections/sailpoint-api-v3.json
Normal file
101548
postman/collections/sailpoint-api-v3.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user