-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wsdl2apigee 69550284 v1 #16
base: master
Are you sure you want to change the base?
Changes from all commits
a86951c
15238c0
83dd355
50c9001
62ea817
63b2678
0e29f68
7da5ef2
b0bf203
cf97085
bb5a231
95de204
51f7686
5f55775
ed158f7
fa80461
b25b5b1
097cf19
dd6a67e
a40a209
535a494
b439b06
2e762fd
ac1c03c
ba57aa4
94bc596
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,9 +71,15 @@ public static JsonArray getQueryParameters(ArrayList<String> queryParams) { | |
JsonObject parameter = null; | ||
for (String queryParam : queryParams) { | ||
parameter = new JsonObject(); | ||
parameter.addProperty("name", queryParam); | ||
String paramSplit[] = queryParam.split("_"); | ||
parameter.addProperty("name", paramSplit[0]); | ||
parameter.addProperty("in", "query"); | ||
parameter.addProperty("required", false); | ||
if(paramSplit.length>1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consistent spacing please same comment throughout this PR. |
||
parameter.addProperty("required", Boolean.valueOf(paramSplit[1])); | ||
}else { | ||
parameter.addProperty("required",false); | ||
} | ||
|
||
parameter.addProperty("type", "string"); | ||
parameters.add(parameter); | ||
} | ||
|
@@ -104,6 +110,90 @@ public static void addObject(JsonObject parent, String parentName, String object | |
properties.add(objectName, object); | ||
} | ||
|
||
public static void addObject(JsonObject parent, String parentName, String objectName,boolean isChildComplexType, String qNameLocal) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. param |
||
JsonObject properties = parent.getAsJsonObject("properties"); | ||
JsonObject object = new JsonObject(); | ||
if(isChildComplexType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this logic correct? if !isChildComplexType, we're just adding an empty jsonObject to parent's properties? |
||
{ | ||
object.addProperty("$ref", "#/definitions/"+qNameLocal); | ||
} | ||
properties.add(objectName, object); | ||
|
||
} | ||
|
||
/* | ||
* inorder to retrieve inner properties attribute to assign output elements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment is hard to understand. also it looks like you've copy&pasted this comment to several functions, please dedupe. |
||
* | ||
*/ | ||
public static void addObjectOutputRes(JsonObject parent, String parentName, String objectName,boolean isChildComplexType, String qNameLocal) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function looks pretty close to the previous one, can we dedupe these and just have the caller pass in the appropriate parent to handle both cases? |
||
JsonObject properties = parent.getAsJsonObject("properties").getAsJsonObject(parentName).getAsJsonObject("properties"); | ||
JsonObject object = new JsonObject(); | ||
if(isChildComplexType) | ||
{ | ||
object.addProperty("$ref", "#/definitions/"+qNameLocal); | ||
} | ||
properties.add(objectName, object); | ||
|
||
|
||
} | ||
|
||
/* | ||
* inorder to retrieve inner properties attribute to assign output elements | ||
* | ||
*/ | ||
public static void addObjectOutputArrayProp(JsonObject parent, String parentName, String objectName, | ||
boolean isChildComplexType, String qNameLocal, String subArrayElement) { | ||
|
||
if(null != parent.getAsJsonObject("properties").getAsJsonObject(parentName)) { | ||
|
||
JsonObject properties = parent.getAsJsonObject("properties").getAsJsonObject(parentName).getAsJsonObject("properties"); | ||
JsonObject innerProp = new JsonObject(); | ||
JsonObject subArrayJson = new JsonObject(); | ||
innerProp.add(subArrayElement, subArrayJson); | ||
|
||
JsonObject jsoonOuterProp = new JsonObject(); | ||
jsoonOuterProp.add("properties", innerProp); | ||
jsoonOuterProp.addProperty("type", "object"); | ||
properties.add(objectName, jsoonOuterProp); | ||
}else { | ||
JsonObject properties = parent.getAsJsonObject("properties"); | ||
JsonObject innerProp = new JsonObject(); | ||
JsonObject subArrayJson = new JsonObject(); | ||
innerProp.add(subArrayElement, subArrayJson); | ||
|
||
JsonObject jsoonOuterProp = new JsonObject(); | ||
jsoonOuterProp.add("properties", innerProp); | ||
jsoonOuterProp.addProperty("type", "object"); | ||
properties.add(objectName, jsoonOuterProp); | ||
} | ||
} | ||
|
||
/* | ||
* inorder to retrieve inner properties attribute to assign output elements | ||
* | ||
*/ | ||
public static void addObjectOutputForArray(JsonObject parent, String parentName, String objectName, | ||
boolean isChildComplexType, String qNameLocal, String subArrayElement) { | ||
|
||
if(null != parent.getAsJsonObject("properties").getAsJsonObject(parentName)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the if and else blocks here look identical except for the |
||
JsonObject rep = parent.getAsJsonObject("properties").getAsJsonObject(parentName).getAsJsonObject("properties"). | ||
getAsJsonObject(objectName).getAsJsonObject("properties").getAsJsonObject(subArrayElement); | ||
JsonObject items = new JsonObject(); | ||
|
||
items.addProperty("$ref", "#/definitions/"+subArrayElement); | ||
rep.add("items", items); | ||
rep.addProperty("type", "array"); | ||
}else { | ||
JsonObject rep = parent.getAsJsonObject("properties").getAsJsonObject(objectName).getAsJsonObject("properties"). | ||
getAsJsonObject(subArrayElement); | ||
JsonObject items = new JsonObject(); | ||
|
||
items.addProperty("$ref", "#/definitions/"+subArrayElement); | ||
rep.add("items", items); | ||
rep.addProperty("type", "array"); | ||
} | ||
} | ||
|
||
public static JsonObject createComplexType(String name, String min, String max) { | ||
JsonObject complexType = new JsonObject(); | ||
JsonObject properties = new JsonObject(); | ||
|
@@ -122,7 +212,7 @@ public static JsonObject createComplexType(String name, String min, String max) | |
Integer minimum = Integer.parseInt(min); | ||
|
||
complexType.add("properties", properties); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit unneeded whitespace |
||
if (maximum == -1 || maximum > 1) { | ||
complexType.addProperty("type", "array"); | ||
//in json schemas, if the elements are unbounded, don't set maxItems | ||
|
@@ -134,6 +224,55 @@ public static JsonObject createComplexType(String name, String min, String max) | |
} | ||
return complexType; | ||
} | ||
|
||
public static JsonObject createComplexTypeRep(String name, String min, String max) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused params |
||
JsonObject complexType = new JsonObject(); | ||
JsonObject properties = new JsonObject(); | ||
complexType.add("properties", properties); | ||
|
||
complexType.addProperty("type", "object"); | ||
return complexType; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit consistent newlines please, one blank newline between functions, here and elsewhere |
||
public static JsonObject createExtension(String baseName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function appears to do the exact same thing as the previous function, plus param is unused |
||
JsonObject extension = new JsonObject(); | ||
JsonObject properties = new JsonObject(); | ||
extension.addProperty("type", "object"); | ||
extension.add("properties", properties); | ||
|
||
return extension; | ||
} | ||
public static JsonObject createRestriction(String type, String min, String max) { | ||
JsonObject restriction = createSimpleType(type,min,max); | ||
JsonArray enumArray = new JsonArray(); | ||
if(restriction.get("items") != null) | ||
{ | ||
JsonObject items = (JsonObject)restriction.get("items"); | ||
items.add("enum", enumArray); | ||
} | ||
else | ||
{ | ||
restriction.add("enum", enumArray); | ||
} | ||
|
||
return restriction; | ||
} | ||
|
||
/* | ||
* Method used to create inner properties for each response attribute under #definitions of OAS | ||
* | ||
*/ | ||
public static JsonObject createComplexTypeOP(String name, JsonObject jsonObj) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please avoid abbreviations in names, they can be confusing. |
||
JsonObject properties = jsonObj.getAsJsonObject("properties"); | ||
JsonObject innerProp = new JsonObject(); | ||
JsonObject jsoonOuterProp = new JsonObject(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit spelling |
||
jsoonOuterProp.add("properties", innerProp); | ||
properties.add(name, jsoonOuterProp); | ||
|
||
return properties; | ||
} | ||
|
||
|
||
public static JsonObject createSimpleType(String type, String min, String max) { | ||
JsonObject simpleType = new JsonObject(); | ||
|
@@ -199,5 +338,20 @@ public static JsonObject createSimpleType(String type, String min, String max) { | |
return simpleType; | ||
} | ||
|
||
public static String manipulateQueryParams(String name, String min, String max) { | ||
|
||
String queryParamStr = ""; | ||
String required = "false"; | ||
if (max.equalsIgnoreCase("unbounded")) { | ||
max = "-1"; | ||
} | ||
if(Integer.parseInt(min) ==1 && Integer.parseInt(max) ==1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this logic seems wrong, shouldn't we still consider the param required if min > 1? |
||
required = "true"; | ||
} | ||
|
||
queryParamStr = queryParamStr.concat(name+"_"+required); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why concat, can we just set queryParamStr's initial value here, or even just |
||
return queryParamStr; | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the query param name itself has an underscore in it? where is this behavior documented?