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

Ability to use wildcards in resourcePackages #84

Closed
harveycggit opened this issue Jun 21, 2021 · 5 comments
Closed

Ability to use wildcards in resourcePackages #84

harveycggit opened this issue Jun 21, 2021 · 5 comments

Comments

@harveycggit
Copy link

Hi, thanks for this excellent plugin! I've tried using wildcards in the resourcePackages tag, is that supported? I seem to get null pointers no matter what I try. Note it works perfectly when I specify the exact package(s). Currently I use holon to generate swagger.yaml but it only does that when the app is up and running, and since my apps are behind an API gateway I have to briefly expose the app publicly during the jenkins build in order to get the yaml to feed the gateway, which is a security risk for me. So this is the perfect solution for me! However, populating the gateway is framework code and in my opinion something that the developers should not need to be concerned with, so ideally if they add a new REST API class, the services would just appear in the gateway during the next build without them having to configure additional packages in the build section of the pom. And the only solution I can see for that is allowing wildcards in the resources declaration:

    <resourcePackages>
      <resourcePackage>edu.upenn.isc.*</resourcePackage>
    </resourcePackages>

Please let me know if this would be possible and if you would be interested, I could attempt to contribute code if needed.

Best,
Charles Harvey

@langecode
Copy link
Member

langecode commented Jun 21, 2021 via email

@harveycggit
Copy link
Author

Thank you for the quick response! I am not using an upstream pom; I have a template that is used for new projects where some automated search and replace goes on in the project templates, so the build plugin would exist for every project. My main interest is having this functionality be removed from the developers' stable of responsibilities; I don't have to train them and they make fewer mistakes. I'm using the generated swagger in a Jenkins pipeline to populate both 3scale (my API gateway) and SwaggerHub and would be happier if a developer was never in a situation where they added a new REST resource in a new package and were then puzzled by why they don't see it in SwaggerHub, etc. We work pretty hard here to keep developers writing code as opposed to worrying about configurations :)

I'll have a look and see if I can figure out how to change to scan all classes that are within the project's code given a syntax like:

edu.upenn.isc.*

there would be no need to scan any library jars, etc.

Thank you, I'll get back to you if I can figure it out. From your perspective, would you prefer an additional config property like true or would simply ending the resourcePackage with an asterisk be enough?

Best,
Charles

@harveycggit
Copy link
Author

Sorry it ate my examples. From your perspective, would you prefer an additional config property like <recursiveScan>true<recursiveScan> or would simply ending the resourcePackage with an asterisk be enough?

@harveycggit
Copy link
Author

Ok, maybe I am confused, but the following setting seems to do exactly what I want to do, which is find @Api in every package under edu.upenn.isc.esb.openshiftUtils - does that seem correct?

<configuration>
<useResourcePackagesChildren>true</useResourcePackagesChildren>
<resourcePackages>
<resourcePackage>edu.upenn.isc.esb.openshiftUtils</resourcePackage>
</resourcePackages>

@langecode
Copy link
Member

Yes you are right - we seem to have this feature already. If you enable userResourcePackagesChildren you should get recursive behaviour - implemented here: https://github.com/openapi-tools/swagger-maven-plugin/blob/master/src/main/java/io/openapitools/swagger/JaxRSScanner.java#L72

Been long since we did that code so I actually did not remember. Let me know if it does not work.

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

No branches or pull requests

2 participants