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

maven-plugin make it easier to scan dependend schemas #967

Merged
merged 1 commit into from
Nov 20, 2021

Conversation

Postremus
Copy link
Contributor

@Postremus Postremus commented Nov 11, 2021

Added new options scan.profiles and scan.exclude.profiles to filter the operations that are kept in the schema.
Only one of the configured profiles is needed to either include, or exclude, the operation. Exclusions are checked first, then inclusions. Extensions containing profiles have to start with "x-smallrye-profile", and will not be included in the openapi document.
Naming of these new options are kept in line with the openapi scan.package and scan.external.package options.

closes #952

demo-annotation-inclusion

@MikeEdgar
Copy link
Member

@Postremus - thank you for putting this together, definitely some cool functionality. The thing I am wondering is, can it be done using standard annotations? For example, instead of a custom annotation, what if the @Extension annotation was used with names like x-smallrye-profile-external or x-smallrye-profile-internal. That would allow the user to assign a "profile" to endpoint methods that could be selected in the config - in this case external and internal. Extensions starting with x-smallrye-profile- would be dropped from the final result. It would also have the benefit of being usable with the static document.

Just an idea.

@Postremus
Copy link
Contributor Author

@MikeEdgar
I like your idea.
This allows the user to simply set the include (or exclude) profiles using configuration. On the operation or paths, the profile extensions can be specified like this:

@Extension(name = "x-smallrye-profile-external", value = "")

Way simpler to use, and better user experience. I will update the implementation accordingly.

Thank you!

Added new options scan.profiles and scan.exclude.profiles to filter the operations that are kept in the schema.
Only one of the configured profiles is needed to either include, or exclude, the operation. Exclusions are checked first, then inclusions. Extensions containing profiles have to start with "x-smallrye-profile", and will not be included in the openapi document.
Naming of these new options are kept in line with the openapi scan.package and scan.external.package options.
@Postremus
Copy link
Contributor Author

Hi @MikeEdgar, I implemented the approach using profiles defined as part of extensions, like you suggested.
Please review again. Thanks!

@phillip-kruger
Copy link
Member

@MikeEdgar please can you have a look ?

@MikeEdgar
Copy link
Member

Thanks @Postremus. I'm planning on looking at this later today or tomorrow morning.

Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks @Postremus . I left one small comment that you might update if you rebase again, but otherwise this looks reasonable. At some point it might be worthwhile to rearrange how things are scanned in the JAX-RS (and other) scanners so that the profiles are checked more pre-emptively, but I wouldn't worry about that now.

Comment on lines +416 to +419
String classes = getStringConfigValue(OpenApiConstants.SCAN_PROFILES);
if (classes == null) {
classes = getStringConfigValue(OpenApiConstants.SCAN_PROFILES);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required, but if you re-base again you might rename this variable and the equivalent in the "exclude" method.

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.

maven-plugin make it easier to scan dependend schemas
3 participants