Swagr Codegen: Updates to generate comments properly for models

This commit is contained in:
Deepak Michael 2011-07-27 10:20:59 +05:30
parent 1f738486ee
commit b61d3b2914
3 changed files with 32 additions and 25 deletions

View File

@ -15,17 +15,19 @@ import $import$;
*/
public class $className$ extends $extends$ {
$fields:{ field |
//$field.description$
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;
}$
$fields:{ field |
//$field.description$
$if(field.required)$
@Required $endif$
$if(field.allowableValues)$
@AllowableValues(value="$field.allowableValues$")$endif$
$fields:{ field |
/**
* $field.description$
*/
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;$\r$}$
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowableValues)$@AllowableValues(value="$field.allowedValuesString$")$endif$
*/
public $field.fieldDefinition.returnType$ get$field.fieldDefinition.NameForMethod$() {
return $field.fieldDefinition.name$;
}
@ -33,5 +35,6 @@ public class $className$ extends $extends$ {
public void set$field.fieldDefinition.NameForMethod$($field.fieldDefinition.returnType$ $field.fieldDefinition.name$) {
this.$field.fieldDefinition.name$ = $field.fieldDefinition.name$;
}
}$
}$
}

View File

@ -96,8 +96,10 @@ public class ModelField {
public String getAllowedValuesString() {
String result = "";
for(String allowedValue: this.allowableValues){
result += (allowedValue +",");
if (this.allowableValues != null) {
for(String allowedValue: this.allowableValues){
result += (allowedValue +",");
}
}
if(result.length() == 0)
return null;

View File

@ -15,17 +15,19 @@ import $import$;
*/
public class $className$ extends $extends$ {
$fields:{ field |
//$field.description$
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;
}$
$fields:{ field |
/**
* $field.description$
*/
private $field.fieldDefinition.returnType$ $field.fieldDefinition.name$ $field.fieldDefinition.initialization$;$\n$
}$
$fields:{ field |
//$field.description$
$if(field.required)$
@Required $endif$
$if(field.allowableValues)$
@AllowableValues(value="$field.allowableValues$")$endif$
$fields:{ field |
/**
* $field.description$
* $if(field.required)$@Required$endif$
* $if(field.allowedValuesString)$@AllowableValues(value="$field.allowableValues$")$endif$
*/
public $field.fieldDefinition.returnType$ get$field.fieldDefinition.NameForMethod$() {
return $field.fieldDefinition.name$;
}
@ -33,5 +35,5 @@ public class $className$ extends $extends$ {
public void set$field.fieldDefinition.NameForMethod$($field.fieldDefinition.returnType$ $field.fieldDefinition.name$) {
this.$field.fieldDefinition.name$ = $field.fieldDefinition.name$;
}
}$
}$
}