Merge pull request #2676 from Vrolijkx/master

Typescript angular2 client can be published to npm
This commit is contained in:
wing328
2016-04-23 14:58:28 +08:00
40 changed files with 1069 additions and 93 deletions

View File

@@ -5,11 +5,15 @@ import com.google.common.collect.ImmutableMap;
import java.util.Map;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider {
public static final String SORT_PARAMS_VALUE = "false";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
public static final String NMP_NAME = "npmName";
private static final String NMP_VERSION = "1.1.2";
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
@Override
public String getLanguage() {
@@ -22,6 +26,10 @@ public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
.put(TypeScriptAngular2ClientCodegen.NPM_NAME, NMP_NAME)
.put(TypeScriptAngular2ClientCodegen.NPM_VERSION, NMP_VERSION)
.put(TypeScriptAngular2ClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
.put(TypeScriptAngular2ClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
.build();
}

View File

@@ -119,10 +119,10 @@ public class TypeScriptAngular2ModelTest {
final CodegenProperty property1 = cm.vars.get(0);
Assert.assertEquals(property1.baseName, "children");
Assert.assertEquals(property1.datatype, "model.Children");
Assert.assertEquals(property1.datatype, "models.Children");
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.defaultValue, "null");
Assert.assertEquals(property1.baseType, "model.Children");
Assert.assertEquals(property1.baseType, "models.Children");
Assert.assertNull(property1.required);
Assert.assertTrue(property1.isNotContainer);
}
@@ -143,8 +143,8 @@ public class TypeScriptAngular2ModelTest {
final CodegenProperty property1 = cm.vars.get(0);
Assert.assertEquals(property1.baseName, "children");
Assert.assertEquals(property1.complexType, "model.Children");
Assert.assertEquals(property1.datatype, "Array<model.Children>");
Assert.assertEquals(property1.complexType, "models.Children");
Assert.assertEquals(property1.datatype, "Array<models.Children>");
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "Array");
Assert.assertNull(property1.required);
@@ -178,6 +178,6 @@ public class TypeScriptAngular2ModelTest {
Assert.assertEquals(cm.description, "a map model");
Assert.assertEquals(cm.vars.size(), 0);
Assert.assertEquals(cm.imports.size(), 1);
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("model.Children")).size(), 1);
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("models.Children")).size(), 1);
}
}