Change version numbers on aai_swagger_HTML files 07/41607/3
authorEpp, Richard (re6517) <re6517@us.att.com>
Sun, 8 Apr 2018 21:24:04 +0000 (17:24 -0400)
committerJames Forsyth <jf2512@att.com>
Tue, 17 Apr 2018 16:42:01 +0000 (16:42 +0000)
Change-Id: Ice7b38273c6c4701dd16da573c03fa121abfe298
Issue-ID: AAI-971
Signed-off-by: Epp, Richard (re6517) <re6517@us.att.com>
aai-core/src/main/java/org/onap/aai/util/swagger/Api.java
aai-core/src/main/java/org/onap/aai/util/swagger/GenerateSwagger.java
aai-core/src/main/resources/swagger.html.ftl

index 8ec5804..7d65448 100644 (file)
@@ -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;                         
+                       }
         }
 
     }
index ab34a3e..7fdc805 100644 (file)
@@ -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));
index 0dff5de..3f9dc4e 100644 (file)
@@ -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>