Skip to content

Check exclude filter when parsing spring controller methods #721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ private void parseController(JaxrsApplicationParser.Result result, JaxrsApplicat
final List<Method> methods = getAllRequestMethods(controllerClass);
methods.sort(Utils.methodComparator());
for (Method method : methods) {
parseControllerMethod(result, context, controllerClass, method);
// Do not use default Method.toString since that will include parameter types
String fullMethodName = String.format("%s.%s", method.getDeclaringClass(), method.getName());
if (!settings.getExcludeFilter().test(fullMethodName)) {
parseControllerMethod(result, context, controllerClass, method);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ public void testInheritance() {
Assert.assertFalse(output.contains("uriEncoding`test/b`"));
}

@Test
public void testExclusion1() {
final Settings settings = TestUtils.settings();
settings.outputFileType = TypeScriptFileType.implementationFile;
settings.generateSpringApplicationClient = true;
settings.setExcludeFilter(null, Arrays.asList("**.doSomethingElseAgain"));
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(Controller6.class));
Assert.assertTrue(output.contains("doSomethingElse(id: number): RestResponse<number>"));
Assert.assertFalse(output.contains("doSomethingElseAgain(): RestResponse<number>"));
}

@Test
public void testExclusion2() {
final Settings settings = TestUtils.settings();
settings.outputFileType = TypeScriptFileType.implementationFile;
settings.generateSpringApplicationClient = true;
settings.setExcludeFilter(null, Arrays.asList("**Controller6.*Again"));
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(Controller6.class));
Assert.assertTrue(output.contains("doSomethingElse(id: number): RestResponse<number>"));
Assert.assertFalse(output.contains("doSomethingElseAgain(): RestResponse<number>"));
}

@RestController
@RequestMapping("/owners/{ownerId}")
public static class Controller1 {
Expand Down