mirror of https://github.com/apache/cloudstack.git
bug 10405: Added annontation since for API Commands and request parameters. Whenever a new APi or parameter is added since=version should be added
status 10405: resolved fixed
This commit is contained in:
parent
57ac50799b
commit
8ee876a9a2
|
|
@ -30,4 +30,5 @@ public @interface Implementation {
|
|||
Class<?> responseObject();
|
||||
String description() default "";
|
||||
boolean includeInApiDoc() default true;
|
||||
String since() default "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,5 +37,6 @@ public @interface Parameter {
|
|||
boolean expose() default true;
|
||||
boolean includeInApiDoc() default true;
|
||||
int length() default 255;
|
||||
String since() default "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,6 +295,11 @@ public class ApiXmlDocWriter {
|
|||
else
|
||||
System.out.println("Command " + apiCommand.getName() + " misses description");
|
||||
|
||||
//Set version when the API is added
|
||||
if(!impl.since().isEmpty()){
|
||||
apiCommand.setSinceVersion(impl.since());
|
||||
}
|
||||
|
||||
// Set request parameters
|
||||
Field[] fields = clas.getDeclaredFields();
|
||||
|
||||
|
|
@ -319,7 +324,7 @@ public class ApiXmlDocWriter {
|
|||
} else {
|
||||
apiCommand.setAsync(false);
|
||||
}
|
||||
|
||||
|
||||
// Get response parameters
|
||||
Class<?> responseClas = impl.responseObject();
|
||||
Field[] responseFields = responseClas.getDeclaredFields();
|
||||
|
|
@ -404,7 +409,11 @@ public class ApiXmlDocWriter {
|
|||
if (parameterAnnotation.type() == BaseCmd.CommandType.LIST || parameterAnnotation.type() == BaseCmd.CommandType.MAP) {
|
||||
reqArg.setType(parameterAnnotation.type().toString().toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
if(!parameterAnnotation.since().isEmpty()){
|
||||
reqArg.setSinceVersion(parameterAnnotation.since());
|
||||
}
|
||||
|
||||
if (reqArg.isRequired() == true) {
|
||||
if (parameterAnnotation.name().equals("id")) {
|
||||
id = reqArg;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class Argument implements Comparable{
|
|||
private String description;
|
||||
private Boolean required;
|
||||
private String type;
|
||||
private String sinceVersion = null;
|
||||
private List<Argument> arguments;
|
||||
|
||||
public Argument(String name) {
|
||||
|
|
@ -77,6 +78,14 @@ public class Argument implements Comparable{
|
|||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public String getSinceVersion() {
|
||||
return sinceVersion;
|
||||
}
|
||||
|
||||
public void setSinceVersion(String sinceVersion) {
|
||||
this.sinceVersion = sinceVersion;
|
||||
}
|
||||
|
||||
public int compareTo(Object anotherAgrument) throws ClassCastException {
|
||||
if (!(anotherAgrument instanceof Argument))
|
||||
throw new ClassCastException("An Argument object expected.");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class Command {
|
|||
private String name;
|
||||
private String description;
|
||||
private boolean isAsync;
|
||||
private String sinceVersion = null;
|
||||
private ArrayList<Argument> request;
|
||||
private ArrayList<Argument> response;
|
||||
|
||||
|
|
@ -75,6 +76,14 @@ public class Command {
|
|||
this.isAsync = isAsync;
|
||||
}
|
||||
|
||||
public String getSinceVersion() {
|
||||
return sinceVersion;
|
||||
}
|
||||
|
||||
public void setSinceVersion(String sinceVersion) {
|
||||
this.sinceVersion = sinceVersion;
|
||||
}
|
||||
|
||||
public Argument getReqArgByName(String name){
|
||||
for (Argument a : this.getRequest()) {
|
||||
if (a.getName().equals(name)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue