OpenAPITools / OpenAPITools/openapi-generator
[REQ] [Java] allow alternate jsr305 because of JPMS incompatibility
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
JSR305 findbugs jar is dead and unmaintained. It does not work with JPMS (jigsaw).
The problem, simply put is that 2 jar's can't contribute to javax.annotation package. javax.annotation.Generated comes from a different jar. Also jsr30 jar has never been updated to use either automatic module naming or an explicit java module, so it's not compatible.
Describe the solution you'd like
The easiest thing I can think of (because of at least one bad actor), and these are the defaults
useDefectDetection: "true"
nullableTypeAnnotation: "javax.annotation.Nullable"
nonnullTypeAnnotation: "javax.annotation.Nonnull"
I called these "TypeAnnotation" to distinguish from the validation API annotations which look similar, but are not type annotations.
current known providers off the top of my head, spring, jetbrains, and checker framework all have very popular implementations.
I added useDefectDetection (which is the name of jsr305, again dead), as an option for if you don't want them at all. Seems silly but I'd guess many people (foolishly?) don't care and don't use them elsewhere. This is a low priority configuration for me, although ours seem to be generated wrong, so maybe it wouldn't be a bad thing, remove them and assume everything is nullable...
Describe alternatives you've considered
use a "sed patch" whenever we update our generated code.
An alternative solution would be to simply declare providers, or the jar. I don't think this works well because of said bad actor that uses, IIRC NonNull instead of Nonnull unlike everyone else. Also because then if another vendor comes along!
defectDetectionLibrary: "findbugs|jetbrains|spring|checkerframework"
if you want to test this, generate some code with whatever that will add these annotations, then try to import it into a library that uses a module-info.java
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by locating the Java generator settings that emit JSR305 annotations, then generate code and import it into a library with a module-info.java as described; done means the annotation provider or defect-detection behavior is configurable and the generated code works with JPMS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100