Skip to content
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

Check exclude filter when parsing spring controller classes by annotation #731

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jpstratman
Copy link
Contributor

Adding class exclusion functionality in SpringApplicationParser when scanSpringApplication is not true (class exclusion is already working when scanSpringApplication is true)

@vojtechhabarta
Copy link
Owner

The class exclusion is done before the list of classes is passed to generateTypeScript method.
When I try sample-maven-spring project and configure <excludeClassPatterns> it works:

<configuration>
    ...
    <classPatterns>
        <pattern>cz.habarta.typescript.generator.sample.spring.**</pattern>
    </classPatterns>
    <excludeClassPatterns>
        <pattern>cz.habarta.typescript.generator.sample.spring.SpringTestApplication</pattern>
    </excludeClassPatterns>
    <scanSpringApplication>false</scanSpringApplication>
    <generateSpringApplicationClient>true</generateSpringApplicationClient>
</configuration>

Do you think it is needed to apply exclusion filter also in SpringApplicationParser?

@vojtechhabarta
Copy link
Owner

BTW build is failing because in main branch JUnit 4 was upgraded to version 5 where Assert was replaced by Assertions.

@jpstratman
Copy link
Contributor Author

The class exclusion is done before the list of classes is passed to generateTypeScript method. When I try sample-maven-spring project and configure <excludeClassPatterns> it works:

<configuration>
    ...
    <classPatterns>
        <pattern>cz.habarta.typescript.generator.sample.spring.**</pattern>
    </classPatterns>
    <excludeClassPatterns>
        <pattern>cz.habarta.typescript.generator.sample.spring.SpringTestApplication</pattern>
    </excludeClassPatterns>
    <scanSpringApplication>false</scanSpringApplication>
    <generateSpringApplicationClient>true</generateSpringApplicationClient>
</configuration>

Do you think it is needed to apply exclusion filter also in SpringApplicationParser?

I tried that out as well, but the generated spring endpoint class still contained the SpringTestApplication methods even though it correctly excluded the type interfaces from that class. From what I can tell, there is a check needed in SpringApplicationParser to get that to work. After the changes in this PR, it is excluding that class from the generation correctly.

@vojtechhabarta
Copy link
Owner

I am still not sure. SpringTestApplication is not a controller and doesn't have any REST method. Do you mean SpringTestApplication.GreetingController? If I try mentioned configuration then generated RestApplicationClient contains just greeting method which I think is correct. I want to understand your point better because it might be also relevant to JAX-RS applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants