Skip to content

Commit

Permalink
Bumping typscript-generator version (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmcnamara committed Apr 18, 2016
1 parent 2197f53 commit bfa9cd4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ guavaVersion=18.0
feignVersion=8.10.0
jacksonVersion=2.6.1
jaxRsVersion=2.0.1
typescriptGeneratorVersion=1.6.173
typescriptGeneratorVersion=1.7.190
commonsIOVersion=2.4
findbugsAnnotationsVersion=3.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import com.palantir.code.ts.generator.model.ServiceModel;
import com.palantir.code.ts.generator.utils.PathUtils;

import cz.habarta.typescript.generator.ModelCompiler;
import cz.habarta.typescript.generator.TsType;
import cz.habarta.typescript.generator.TypeScriptGenerator;
import cz.habarta.typescript.generator.compiler.ModelCompiler;


public final class ServiceClassParser {
Expand Down Expand Up @@ -113,7 +113,7 @@ private static List<ServiceEndpointModel> computeEndpointModels(Set<Method> endp
ImmutableServiceEndpointModel.Builder ret = ImmutableServiceEndpointModel.builder();
ret.endpointName(endpointNameGetter.get(endpoint));
ret.javaReturnType(endpoint.getGenericReturnType());
ret.tsReturnType(compiler.typeFromJavaWithReplacement(endpoint.getGenericReturnType()));
ret.tsReturnType(compiler.javaToTypeScript(endpoint.getGenericReturnType()));
ret.endpointMethodType(getMethodType(endpoint));

String annotationValue = "";
Expand Down Expand Up @@ -168,7 +168,7 @@ private static List<ServiceEndpointModel> computeEndpointModels(Set<Method> endp
}

parameterModel.javaType(javaParameterType);
TsType tsType = compiler.typeFromJavaWithReplacement(javaParameterType);
TsType tsType = compiler.javaToTypeScript(javaParameterType);
parameterModel.tsType(tsType);
if (tsType instanceof TsType.OptionalType || query != null) {
optionalParameters.add(parameterModel.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import cz.habarta.typescript.generator.Settings;
import cz.habarta.typescript.generator.TypeProcessor;
import cz.habarta.typescript.generator.TypeProcessor.Context;
import cz.habarta.typescript.generator.TypeProcessor.Result;
import cz.habarta.typescript.generator.TypeScriptGenerator;
import cz.habarta.typescript.generator.compiler.SymbolTable;

public final class ServiceEmitter {

Expand Down Expand Up @@ -285,27 +285,15 @@ public static Set<Class<?>> getReferencedClasses(Set<Type> referencedTypes, Type
continue;
}

// dummy context used for below check
Context nullContext = new Context() {

@Override
public Result processType(Type javaType) {
return null;
}

@Override
public String getMappedName(Class<?> cls) {
return null;
}
};

if (t instanceof Class && ((Class<?>) t).isEnum()) {
ret.add((Class<?>) t);
continue;
}

// dummy context used for below check
Context nullContext = new Context(new SymbolTable(settings.getSettings()), settings.customTypeProcessor());
// Don't add any classes that the user has made an exception for
if (settings.customTypeProcessor() == null || settings.customTypeProcessor().processType(t, nullContext) == null) {
if (settings.customTypeProcessor().processType(t, nullContext) == null) {
if (t instanceof Class) {
ret.add((Class<?>) t);
} else if(t instanceof ParameterizedType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import cz.habarta.typescript.generator.JsonLibrary;
import cz.habarta.typescript.generator.Settings;
import cz.habarta.typescript.generator.TsType;
import cz.habarta.typescript.generator.TsType.StructuralType;
import cz.habarta.typescript.generator.TypeScriptOutputKind;
import cz.habarta.typescript.generator.compiler.Symbol;

public class ServiceClassParserTest {

Expand Down Expand Up @@ -107,9 +107,9 @@ public void parseComplexClassTest() throws NoSuchMethodException, SecurityExcept
{
ServiceEndpointParameterModel aParam = ImmutableServiceEndpointParameterModel.builder().pathParam("a").javaType(String.class).tsType(TsType.String).build();
ServiceEndpointParameterModel bParam = ImmutableServiceEndpointParameterModel.builder().queryParam("b").javaType(Integer.class).tsType(TsType.Number).build();
ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.StructuralType("DataObject")).build();
ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.ReferenceType(new Symbol("DataObject"))).build();
endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(genericReturnType)
.tsReturnType(new StructuralType("GenericObject<MyObject>"))
.tsReturnType(new TsType.ReferenceType(new Symbol("GenericObject<MyObject>")))
.parameters(Lists.newArrayList(aParam, dataParam, bParam))
.endpointName("allOptionsPost")
.endpointPath("allOptionsPost/{a}")
Expand All @@ -120,17 +120,17 @@ public void parseComplexClassTest() throws NoSuchMethodException, SecurityExcept
{
ServiceEndpointParameterModel xParam = ImmutableServiceEndpointParameterModel.builder().queryParam("x").javaType(Boolean.class).tsType(TsType.Boolean).build();
endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(MyObject.class)
.tsReturnType(new TsType.StructuralType("MyObject"))
.tsReturnType(new TsType.ReferenceType(new Symbol("MyObject")))
.parameters(Lists.newArrayList(xParam))
.endpointName("queryGetter")
.endpointPath("queryGetter")
.endpointMethodType("GET")
.build());
}
{
ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.StructuralType("DataObject")).build();
ServiceEndpointParameterModel dataParam = ImmutableServiceEndpointParameterModel.builder().javaType(DataObject.class).tsType(new TsType.ReferenceType(new Symbol("DataObject"))).build();
endpoints.add(ImmutableServiceEndpointModel.builder().javaReturnType(ImmutablesObject.class)
.tsReturnType(new TsType.StructuralType("ImmutablesObject"))
.tsReturnType(new TsType.ReferenceType(new Symbol("ImmutablesObject")))
.parameters(Lists.newArrayList(dataParam))
.endpointName("simplePut")
.endpointPath("simplePut")
Expand Down

0 comments on commit bfa9cd4

Please sign in to comment.