APIs.json List by Tag
<script type="text/jscript">
var $apiurl = "";
var $Pallette = {};
var $FullCount = 0;
function processAPIsJSONListByTag($apisjsonURL)
{
$apiHumanURL = "";
$FullCount = $FullCount + 1;
var loadIt = $.getJSON($apisjsonURL, function(apisJSON) {
$masterName = apisJSON['name'];
$masterDesc = apisJSON['description'];
$masterLogo = apisJSON['image'];
$masterURL = apisJSON['url'];
$masterTags = apisJSON['tags'];
$masterIncludes = apisJSON['include'];
$.each($masterIncludes, function(masterKey, masterValue) {
$includeName = masterValue['name'];
$includeRootUrl = masterValue['url'];
$FullCount = $FullCount + 1;
var loadIt2 = $.getJSON($includeRootUrl, function(apisJSON) {
$singleName = apisJSON['name'];
console.log($singleName);
$singleDesc = apisJSON['description'];
$singleLogo = apisJSON['image'];
$singleURL = apisJSON['url'];
$singleTags = apisJSON['tags'];
$singleAPIs = apisJSON['apis'];
$.each($singleAPIs, function(apiKey, apiVal) {
$apiName = apiVal['name'];
$apiDesc = apiVal['description'];
$apiLogo = apiVal['image'];
$apiHumanURL = apiVal['humanURL'];
$apiBaseURL = apiVal['baseURL'];
$apiProperties = apiVal['properties'];
$.each($apiProperties, function(propertyKey, propertyValue) {
$type = propertyValue['type'];
$url = propertyValue['url'];
if($type=='x-openapi-spec')
{
$FullCount = $FullCount + 1;
//console.log("loading 3 " + $type);
//console.log("loading 3 " + $url);
var loadIt3 = $.getJSON($url, function($openapispec) {
$paths = $openapispec['paths'];
$title = $openapispec['info']['title'];
$apiSlug = $title.replace(/ /g,"-");
$apiSlug = $apiSlug.toLowerCase();
// show the unique host
$host = $openapispec['host'];
$.each($paths, function(pathKey, pathValue) {
$path_name = pathKey;
$.each(pathValue, function(methodKey, methodValue) {
$method = methodKey;
$method_summary = methodValue['summary'];
$tags = methodValue['tags'];
$.each($tags, function($tagKey, $tagValue) {
$tag = $tagValue;
$tagslug = $tag.replace(/ /g,"-");
$tagslug = $tagslug.toLowerCase();
if(!Array.isArray($Pallette[$tag]))
{
$Pallette[$tag] = [];
}
$T = {};
$T['summary'] = $method_summary;
$T['method'] = $method.toUpperCase();
$T['path'] = $path_name;
$T['url'] = $url;
$T['host'] = $host;
$Pallette[$tag].push($T);
});
});
});
});
loadIt3.complete(function() {
$FullCount = $FullCount - 1;
if($FullCount==0){
$viewer = JSON.stringify($Pallette, null, 4);
document.getElementById("jsonViewerDetails").value = $viewer;
sortPage();
}
});
}
});
});
});
loadIt2.complete(function() {
$FullCount = $FullCount - 1;
});
});
});
loadIt.complete(function() {
$FullCount = $FullCount - 1;
});
}
function sortPage()
{
$screenJSON = document.getElementById("jsonViewerDetails").value;
var unordered = JSON.parse($screenJSON);
const ordered = {};
Object.keys(unordered).sort().forEach(function(key) {
ordered[key] = unordered[key];
});
$.each(ordered, function(tagKey, tagValue) {
$thisvalue = tagValue;
$thisvalue.sort(function(a, b){
if(a.summary < b.summary) return -1;
if(a.summary > b.summary) return 1;
return 0;
});
ordered[tagKey] = $thisvalue;
});
$.each(ordered, function(tagKey, tagValue) {
$tag = tagKey;
$tagslug = $tag.replace(/ /g,"-");
$tagslug = $tagslug.toLowerCase();
$html = '<p><strong>' + $tag + '</strong></p><ul id="' + $tagslug + '"></ul>';
$('#jsonBrowser').append($html);
$.each(tagValue, function(methodKey, methodValue) {
$method_summary = methodValue['summary'];
$method = methodValue['method'];
$path_name = methodValue['path'];
$url = methodValue['url'];
$host = methodValue['host'];
$li = '<li>' + $method_summary + ' - (<strong>' + $method + '</strong>) - <a href="#" title=' + $host + '>' + $path_name + '</a></li>';
$('#' + $tagslug).append($li);
});
});
}
$apisjsonURL = "https://raw.githubusercontent.com/gsa-data/index/master/_data/apis.json";
//console.log("loading..." + $apisjsonURL);
processAPIsJSONListByTag($apisjsonURL);
</script>
<div id="jsonBrowser"></div>
<!-- For Viewing-->
<textarea rows="10" cols="100" id="jsonViewerDetails" style="display: none;"></textarea>