Repository navigation
Commit 288e54b
committed
[Java][microprofile] add JSpecify support
useJspecify was rejected for the microprofile library, even though the
option is listed in its generated documentation. This enables it, reusing
the machinery already shared in AbstractJavaCodegen:
- add MICROPROFILE to JSPECIFY_SUPPORTED_LIBRARIES
- emit @nullable on optional properties and operation parameters via the
shared nullable_var_annotations partial, and route types through
nullableDataType/nullableDatatypeWithEnum so annotations on qualified
types are placed type-use style (java.math.@nullable BigDecimal)
- declare the org.jspecify:jspecify dependency in both microprofile poms
The @NullMarked package-info.java files already came from the base
applyJspecify(), which resolves against the shared Java template dir.
Every template change is guarded by {{#useJspecify}}, so output with the
flag off is byte-identical to before (verified by diffing generated
output against master). The guard is required rather than cosmetic:
jakarta.annotation.Nullable/Nonnull only exist from jakarta.annotation-api
2.1.1, while the microprofile poms pin 1.3.5 and 2.0.0, so emitting the
default annotations produces code that does not compile.
Two cases need the annotation partial paired with the datatype lambda,
which stashes and re-emits it: the enum getter branches, and the literal
File / List<File> type in the isFile form-parameter branch. Without that
pairing the annotation is silently dropped.
Adds a sample (microprofile-rest-client-3.0-jspecify, registered in the
jdk11 samples workflow) and tests covering type-use placement, JAX-RS
parameter annotations coexisting with @nullable, sealed oneOf interfaces,
enum getters, optional file parameters, and that required properties are
not annotated.1 parent 029523d commit 288e54b
50 files changed
Lines changed: 2837 additions & 17 deletions
File tree
- .github/workflows
- bin/configs
- docs/generators
- modules/openapi-generator/src
- main
- java/org/openapitools/codegen/languages
- resources/Java/libraries/microprofile
- test
- java/org/openapitools/codegen/java
- resources/3_0/java
- samples/client/petstore/java/microprofile-rest-client-3.0-jspecify
- .openapi-generator
- docs
- src
- main/java/org/openapitools/client
- api
- model
- test/java/org/openapitools/client
- api
- model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments