diff --git a/conf/as3/templates/WrapperObject.st b/conf/as3/templates/WrapperObject.st new file mode 100644 index 00000000000..73f853c9f89 --- /dev/null +++ b/conf/as3/templates/WrapperObject.st @@ -0,0 +1,29 @@ +package $packageName$ { + +$imports:{ import | +import $import$; +}$ + + /** + * $model.description$ + * NOTE: This class is auto generated by the drive code generator program so please do not edit the class manually. + * @author deepak + * + */ + public class $className$ extends $extends$ { + + $fields:{ field | + + /** + * $field.description$ + * $if(field.required)$@Required$endif$ + * $if(field.allowableValues)$[AllowableValues(value="$field.allowedValuesString$"]$endif$ + */ +$if(!field.fieldDefinition.collectionItemType)$ + [XmlElement(name="$field.fieldDefinition.name$")]$endif$ +$if(field.fieldDefinition.collectionItemType)$ + [XmlElements(name="$field.fieldDefinition.collectionItemName$", type="$field.fieldDefinition.collectionItemType$")]$endif$ + public var $field.fieldDefinition.name$: $field.fieldDefinition.returnType$ $field.fieldDefinition.initialization$;$\r$}$ + + } +} \ No newline at end of file diff --git a/src/main/java/com/wordnik/swagger/codegen/LibraryCodeGenerator.java b/src/main/java/com/wordnik/swagger/codegen/LibraryCodeGenerator.java index 540b081d001..101f97d5c87 100644 --- a/src/main/java/com/wordnik/swagger/codegen/LibraryCodeGenerator.java +++ b/src/main/java/com/wordnik/swagger/codegen/LibraryCodeGenerator.java @@ -46,6 +46,7 @@ public class LibraryCodeGenerator { private static String MODEL_OBJECT_TEMPLATE = "ModelObject"; private static String API_OBJECT_TEMPLATE = "ResourceObject"; private static final String ENUM_OBJECT_TEMPLATE = "EnumObject"; + private static final String WRAPPER_OBJECT_TEMPLATE = "WrapperObject"; private static final String PACKAGE_NAME = "packageName"; private ApiConfiguration config = null; @@ -273,7 +274,11 @@ public class LibraryCodeGenerator { private void generateOutputWrappers(List resources, StringTemplateGroup templateGroup) { List generatedClasses = new ArrayList(); - StringTemplate template; + StringTemplate template = templateGroup.getInstanceOf(WRAPPER_OBJECT_TEMPLATE); + if(template == null){ + System.out.println("WrapperObject template not found to generate output wrappers"); + return; + } for(Resource resource: resources) { if(resource.getEndPoints() != null) { @@ -298,7 +303,7 @@ public class LibraryCodeGenerator { } } } - template = templateGroup.getInstanceOf(MODEL_OBJECT_TEMPLATE); + template = templateGroup.getInstanceOf(WRAPPER_OBJECT_TEMPLATE); template.setAttribute("fields", model.getFields()); template.setAttribute("imports", imports);