diff options
author | Epp, Richard (re6517) <re6517@us.att.com> | 2018-04-08 17:24:04 -0400 |
---|---|---|
committer | James Forsyth <jf2512@att.com> | 2018-04-17 16:42:01 +0000 |
commit | e915c058cb99a013906d789f1134f79cf0a0245b (patch) | |
tree | 0367ea30261e836a51a30f295a385303f9ea25d3 /aai-core | |
parent | ebfe92d82135a9daea5efea2e329331ea63229ba (diff) |
Change version numbers on aai_swagger_HTML files
Change-Id: Ice7b38273c6c4701dd16da573c03fa121abfe298
Issue-ID: AAI-971
Signed-off-by: Epp, Richard (re6517) <re6517@us.att.com>
Diffstat (limited to 'aai-core')
3 files changed, 36 insertions, 4 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/swagger/Api.java b/aai-core/src/main/java/org/onap/aai/util/swagger/Api.java index 8ec58049..7d654489 100644 --- a/aai-core/src/main/java/org/onap/aai/util/swagger/Api.java +++ b/aai-core/src/main/java/org/onap/aai/util/swagger/Api.java @@ -279,6 +279,8 @@ public class Api { private String description; + private String version; + public String getResponseCode() { return responseCode; } @@ -302,6 +304,10 @@ public class Api { ", description='" + description + '\'' + '}'; } + + public void setVersion(String version) { + this.version = version; + } } } diff --git a/aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java b/aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java index ab34a3ee..7fdc8059 100644 --- a/aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java +++ b/aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java @@ -36,7 +36,7 @@ public class GenerateSwagger { public static final String DEFAULT_WIKI = ""; public static final String DEFAULT_SCHEMA_DIR = "../aai-schema"; - public static final String CURRENT_VERSION = Version. getLatest().toString(); + public static final String CURRENT_VERSION = Version.getLatest().toString(); //if the program is run from aai-common, use this directory as default" public static final String ALT_SCHEMA_DIR = "aai-schema"; //used to check to see if program is run from aai-core @@ -60,7 +60,7 @@ public class GenerateSwagger { } if(versionToGenerate == null){ - System.out.println("Warning: Version to generate is not set so using default version: " + CURRENT_VERSION); + System.out.println("Warning: Version to generate is not set so using default versionToGenerate " + CURRENT_VERSION); versionToGenerate = CURRENT_VERSION; } @@ -122,6 +122,7 @@ public class GenerateSwagger { resultMap.put("sortedAaiApis", sortedTagMap); resultMap.put("wikiLink", wikiLink); resultMap.put("definitions", definitionList); + resultMap.put("version", versionToGenerate); if (infoMap.containsKey("description")) { String infoDescription = infoMap.get("description").toString(); @@ -129,6 +130,9 @@ public class GenerateSwagger { .map(line -> { line = line.trim(); String hyperLink = ""; + if(line.trim().contains("Differences versus")) { + return String.format(""); + } if(line.trim().contains("https://")){ int startIndex = line.indexOf("https://"); int endIndex = line.lastIndexOf("/"); @@ -239,6 +243,26 @@ public class GenerateSwagger { if(requestBodyList != null && requestBodyList.size() == 1){ requestBody = requestBodyList.get(0); + for(String key : requestBody.keySet()) { + //Filter out all the relationship links that appear in the YAML + if(key.equals("description")) { + String reqBody=(String)requestBody.get(key); + if(reqBody.replaceAll("\\[.*.json\\)", "") != reqBody) { + requestBody.put(key, reqBody.replaceAll("\\[.*.json\\)", "")); + } + } + //Filter out all the patchDefinition links that appear in the YAML + if(key.equals("schema")) { + LinkedHashMap<String,String> reqBody = (LinkedHashMap<String,String>)requestBody.get(key); + String schema=reqBody.get("$ref"); + String schemaNopatch = schema.replace("patchDefinitions", "definitions"); + + if(! schema.equals(schemaNopatch)) { + reqBody.put("$ref", schemaNopatch); + requestBody.put(key, reqBody); + } + } + } httpVerb.setBodyParametersEnabled(true); httpVerb.setBodyParameters(requestBody); @@ -274,13 +298,15 @@ public class GenerateSwagger { response.setResponseCode(responseMap.getKey()); response.setDescription((String) responseValueMap.get("description")); + response.setVersion((String) responseValueMap.get("version")); if(responseValueMap != null && responseValueMap.containsKey("schema")){ Map<String, Object> schemaMap = (Map<String, Object>)responseValueMap.get("schema"); if(schemaMap != null && schemaMap.containsKey("$ref")){ String schemaLink = schemaMap.get("$ref").toString(); httpVerb.setHasReturnSchema(true); - httpVerb.setReturnSchemaLink(schemaLink); + //Filter out all the getDefinition links that appear in the YAML + httpVerb.setReturnSchemaLink(schemaLink.replace("getDefinitions", "definitions")); int retCode = schemaLink.lastIndexOf('/'); if(retCode != -1 && retCode != schemaLink.length()){ httpVerb.setReturnSchemaObject(schemaLink.substring(retCode)); diff --git a/aai-core/src/main/resources/swagger.html.ftl b/aai-core/src/main/resources/swagger.html.ftl index 0dff5dec..3f9dc4e0 100644 --- a/aai-core/src/main/resources/swagger.html.ftl +++ b/aai-core/src/main/resources/swagger.html.ftl @@ -37,7 +37,7 @@ <body> <div class="container"> <h1>Active and Available Inventory REST API.</h1> - <p class="sw-info-version">Version: <span>v12</span></p> + <p class="sw-info-version">Version: <span>${version}</span></p> <p><p>${description}</p> </p> |