aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Forsyth <jf2512@att.com>2018-04-17 17:21:30 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-17 17:21:30 +0000
commit4f0e505712345f197efa693c17069d2a053f2791 (patch)
tree452ff583bdfeabe3f4961cdb44045707582c792f
parentc72945d26a5ad16ef68c9f445f6f315efe511471 (diff)
parente915c058cb99a013906d789f1134f79cf0a0245b (diff)
Merge "Change version numbers on aai_swagger_HTML files"
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/swagger/Api.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java32
-rw-r--r--aai-core/src/main/resources/swagger.html.ftl2
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>