mirror of
https://github.com/LukeHagar/api-specs.git
synced 2025-12-06 04:19:09 +00:00
added feature for checking enum values
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"folderStrategy": "Tags",
|
||||
"requestParametersResolution": "Schema",
|
||||
"exampleParametersResolution": "Schema",
|
||||
"requestParametersResolution": "Example",
|
||||
"exampleParametersResolution": "Example",
|
||||
"parametersResolution": "Example",
|
||||
"disableOptionalParameters": true,
|
||||
"optimizeConversion": false,
|
||||
"stackLimit": 50,
|
||||
|
||||
@@ -108,17 +108,23 @@ const requestFromLocal = (localRequest, responses) => {
|
||||
}
|
||||
|
||||
const responseFromLocal = (localResponse, requestObject) => {
|
||||
const headers = localResponse.header
|
||||
.map((item) => ({ key: item.key, value: item.value }))
|
||||
.sort((a, b) => {
|
||||
if (a.key < b.key) {
|
||||
return -1;
|
||||
}
|
||||
if (a.key > b.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
let headers = []
|
||||
if (localResponse.header) {
|
||||
headers = localResponse.header
|
||||
.map((item) => ({ key: item.key, value: item.value }))
|
||||
.sort((a, b) => {
|
||||
if (a.key < b.key) {
|
||||
return -1;
|
||||
}
|
||||
if (a.key > b.key) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
console.log(`missing headers for response ${localResponse.name}`)
|
||||
}
|
||||
|
||||
const response = {
|
||||
// owner: '8119550',
|
||||
// lastUpdatedBy: '8119550',
|
||||
|
||||
@@ -12,16 +12,68 @@ const postmanCollections = {
|
||||
v3Uid: '23226990-67f2ed91-57dc-470b-b2fb-bc2ed1dfd655',
|
||||
v3Public: '23226990-3721beea-5615-44b4-9459-e858a0ca7aed',
|
||||
v3Location: 'postman/collections/sailpoint-api-v3.json',
|
||||
v3SpecLocation: 'dereferenced/deref-sailpoint-api.v3.json',
|
||||
beta: '6617193f-0b30-4f11-b42d-6aa7e60759ca',
|
||||
betaUid: '23226990-6617193f-0b30-4f11-b42d-6aa7e60759ca',
|
||||
betaPublic: '23226990-3b87172a-cd55-40a2-9ace-1560a1158a4e',
|
||||
betaLocation: 'postman/collections/sailpoint-api-beta.json',
|
||||
betaSpecLocation: 'dereferenced/deref-sailpoint-api.beta.json',
|
||||
nerm: '91b47f89-5fc4-4111-b9c6-382cf29d1475',
|
||||
nermUid: '23226990-91b47f89-5fc4-4111-b9c6-382cf29d1475',
|
||||
nermPublic: '23226990-20d718e3-b9b3-43ad-850c-637b00864ae2',
|
||||
nermLocation: 'postman/collections/sailpoint-api-nerm.json'
|
||||
|
||||
}
|
||||
|
||||
const enumRecordsToIgnore = [
|
||||
'type',
|
||||
'approverType',
|
||||
'operation',
|
||||
'localeOrigin',
|
||||
'reassignmentType',
|
||||
'state',
|
||||
'scheme',
|
||||
'status',
|
||||
'attributes', //objects
|
||||
'completionStatus',
|
||||
'approvalStatus',
|
||||
'provisioningStatus',
|
||||
'clientMetadata', //objects
|
||||
'executionStatus',
|
||||
'requestedObjectType',
|
||||
'capabilities', //objects
|
||||
'level',
|
||||
'correlatedStatus',
|
||||
'operator',
|
||||
'targetType',
|
||||
'reportType',
|
||||
'mandatoryCommentRequirement',
|
||||
'campaignType',
|
||||
'phase',
|
||||
'usageDaysState',
|
||||
'decision',
|
||||
'mode',
|
||||
'action',
|
||||
'details', //objects
|
||||
'data', //objects
|
||||
'grantTypes', //objects
|
||||
'accessType',
|
||||
'availableFormats',
|
||||
'requestStatus',
|
||||
'actionInProcess',
|
||||
'requestType',
|
||||
'result',
|
||||
'legacyMembershipInfo',
|
||||
'roleAssignmentSource',
|
||||
'indices',
|
||||
'columns',
|
||||
'_type',
|
||||
'assignmentRule',
|
||||
'features',
|
||||
'usageType'
|
||||
|
||||
]
|
||||
|
||||
const release = async () => {
|
||||
|
||||
|
||||
@@ -29,6 +81,7 @@ const release = async () => {
|
||||
privateRemoteCollectionIdUid = postmanCollections[args[2].toLowerCase() + 'Uid']
|
||||
mainPublicCollectionId = postmanCollections[args[2].toLowerCase() + 'Public']
|
||||
localCollection = JSON.parse(fs.readFileSync(postmanCollections[args[2].toLowerCase() + 'Location'], 'utf8'))
|
||||
SpecCollection = JSON.parse(fs.readFileSync(postmanCollections[args[2].toLowerCase() + 'SpecLocation'], 'utf8'))
|
||||
|
||||
|
||||
let remoteCollection = await refreshRemoteCollection(privateRemoteCollectionId)
|
||||
@@ -231,6 +284,9 @@ function syncKeys(obj1, obj2) {
|
||||
|
||||
|
||||
function isDeepEqual(obj1, obj2) {
|
||||
if (obj1['name'] && obj1['name'] === 'List of Access Profiles') {
|
||||
console.log('here')
|
||||
}
|
||||
if (areValuesEqual(obj1, obj2)) {
|
||||
return true
|
||||
}
|
||||
@@ -247,13 +303,17 @@ function isDeepEqual(obj1, obj2) {
|
||||
}
|
||||
|
||||
for (let key of keys1) {
|
||||
const val1 = obj1[key];
|
||||
const val2 = obj2[key];
|
||||
let val1 = findJSONObjects(obj1[key]);
|
||||
let val2 = findJSONObjects(obj2[key]);
|
||||
if (shouldIgnore(key)) {
|
||||
continue;
|
||||
}
|
||||
const areObjects = isObject(val1) && isObject(val2);
|
||||
if (
|
||||
areObjects && !isDeepEqual(val1, val2) ||
|
||||
(!areObjects && !areValuesEqual(val1, val2))
|
||||
) {
|
||||
console.log(`found difference in ${key} value1: ${val1} value2: ${val2}`)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -261,6 +321,30 @@ function isDeepEqual(obj1, obj2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function shouldIgnore(key) {
|
||||
return enumRecordsToIgnore.includes(key)
|
||||
}
|
||||
|
||||
function findJSONObjects(obj) {
|
||||
const jsonObjects = {};
|
||||
|
||||
if (typeof obj === 'string') {
|
||||
try {
|
||||
// Attempt to parse the string as JSON
|
||||
const parsed = JSON.parse(obj);
|
||||
|
||||
// Check if the parsed result is an object (and not a number, string, etc.)
|
||||
if (parsed !== null && typeof parsed === 'object') {
|
||||
return parsed;
|
||||
}
|
||||
} catch (e) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function areValuesEqual(val1, val2) {
|
||||
if (isNullorEmpty(val1) && isNullorEmpty(val2)) {
|
||||
return true;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user