Skip to content

Commit

Permalink
Fixing bug when service classes had no path specified (#50)
Browse files Browse the repository at this point in the history
Correct behavior is to default to the empty path
  • Loading branch information
ryanmcnamara committed Apr 26, 2016
1 parent 4a6bab3 commit 6b087ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ServiceModel parseServiceClass(Class<?> mainServiceClass, TypescriptServi
for (Class<?> serviceClass : serviceClazzes) {
ImmutableInnerServiceModel.Builder innerServiceModel = ImmutableInnerServiceModel.builder();
Path servicePathAnnotation = serviceClass.getAnnotation(Path.class);
innerServiceModel.servicePath(PathUtils.trimSlashes(servicePathAnnotation.value()));
innerServiceModel.servicePath(servicePathAnnotation == null ? "" : PathUtils.trimSlashes(servicePathAnnotation.value()));
innerServiceModel.name(serviceClass.getSimpleName());

Set<Method> serviceMethods = getAllServiceMethods(serviceClass, settings.methodFilter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.palantir.code.ts.generator.model.ServiceEndpointModel;
import com.palantir.code.ts.generator.model.ServiceEndpointParameterModel;
import com.palantir.code.ts.generator.model.ServiceModel;
import com.palantir.code.ts.generator.utils.TestUtils;
import com.palantir.code.ts.generator.utils.TestUtils.DataObject;
import com.palantir.code.ts.generator.utils.TestUtils.DuplicateMethodNamesService;
import com.palantir.code.ts.generator.utils.TestUtils.GenericObject;
Expand Down Expand Up @@ -290,4 +291,12 @@ public void plainTextTest() {
assertEquals(expectedServiceModel, model);
}

@Test
public void noServiceClassPathTest() {
ServiceModel model = serviceClassParser.parseServiceClass(TestUtils.NoPathService.class, settings);

assertEquals(1, model.innerServiceModels().size());
assertEquals(1, model.innerServiceModels().get(0).endpointModels().size());
assertEquals("", model.innerServiceModels().get(0).servicePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ public interface PlainTextService {
public String plainText(String dataBody);
}

public interface NoPathService {

@GET
@Path("foo")
public String foo();
}

public enum MyEnum {
VALUE1, VALUE2
}
Expand Down

0 comments on commit 6b087ad

Please sign in to comment.