Merge pull request #1225 from wing328/fix_getHasXXXParam

Fix getHasXxxParam in CodegenOperation
This commit is contained in:
wing328 2015-09-13 22:15:50 +08:00
commit c8edacb25c

View File

@ -30,24 +30,51 @@ public class CodegenOperation {
public List<Map<String, String>> examples; public List<Map<String, String>> examples;
public ExternalDocs externalDocs; public ExternalDocs externalDocs;
public Map<String, Object> vendorExtensions; public Map<String, Object> vendorExtensions;
public String nickname; // legacy support
private boolean nonempty(List<CodegenParameter> params) /**
{ * Check if there's at least one parameter
*
* @return true if parameter exists, false otherwise
*/
private boolean nonempty(List<CodegenParameter> params) {
return params != null && params.size() > 0; return params != null && params.size() > 0;
} }
/**
* Check if there's at least one body parameter
*
* @return true if body parameter exists, false otherwise
*/
public boolean getHasBodyParam() { public boolean getHasBodyParam() {
return nonempty(bodyParams); return nonempty(bodyParams);
} }
/**
* Check if there's at least one query parameter
*
* @return true if query parameter exists, false otherwise
*/
public boolean getHasQueryParams() { public boolean getHasQueryParams() {
return nonempty(bodyParams); return nonempty(queryParams);
} }
public boolean getHasHeaderParams() {
return nonempty(bodyParams); /**
} * Check if there's at least one header parameter
public boolean getHasPathParams() { *
return nonempty(bodyParams); * @return true if header parameter exists, false otherwise
*/
public boolean getHasHeaderParams() {
return nonempty(headerParams);
}
/**
* Check if there's at least one path parameter
*
* @return true if path parameter exists, false otherwise
*/
public boolean getHasPathParams() {
return nonempty(pathParams);
} }
// legacy support
public String nickname;
} }