You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 323c20b
Browse filesBrowse the repository at this point in the historyBrowse files
Adds a useSealed option to the jaxrs-spec generator.
- With useOneOfInterfaces=true, the generated oneOf interface is sealed and
permits its subtypes, which become final classes implementing the interface.
- On its own, an allOf class hierarchy driven by a parent discriminator becomes
a sealed parent class permitting its subclasses, which extend it and become
final; standalone models become final.
- JavaJAXRSSpecServerCodegen: useSealed option (constant/field/CliOption/processOpts);
postProcessAllModels drops oneOf-derived permits from models rendered as plain
classes (their oneOf members do not extend them, so a permits clause would not
compile).
- sealed.mustache / permits.mustache emit the sealed/permits/final modifiers,
gated on useSealed; oneof_interface.mustache and pojo.mustache reference them.
- pom.mustache bumps java.version to 17 when useSealed (sealed types need JDK 17+);
the default stays 1.8.
- Tests: sealed oneOf interface, sealed allOf class hierarchy, useSealed without
useOneOfInterfaces (compilable output), defaults unchanged without useSealed.
- Adds a jaxrs-spec-sealed sample (registered in the JDK17 samples workflow).
The feature stays opt-in; default jaxrs-spec output is unchanged.
Copy file name to clipboardExpand all lines: docs/generators/jaxrs-cxf-cdi.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
87
87
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.||false|
88
88
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.||false|
89
89
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface||false|
90
+
|useSealed|Whether to generate sealed model interfaces and classes.||false|
90
91
|useSwaggerAnnotations|Whether to generate Swagger annotations.||true|
91
92
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.||false|
92
93
|useTags|use tags for creating interface and controller classnames||false|
Copy file name to clipboardExpand all lines: docs/generators/jaxrs-spec.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
88
88
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.||false|
89
89
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.||false|
90
90
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface||false|
91
+
|useSealed|Whether to generate sealed model interfaces and classes.||false|
91
92
|useSwaggerAnnotations|Whether to generate Swagger annotations.||true|
92
93
|useSwaggerV3Annotations|Whether to generate Swagger v3 (OpenAPI v3) annotations.||false|
93
94
|useTags|use tags for creating interface and controller classnames||false|
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
@@ -162,6 +166,7 @@ public JavaJAXRSSpecServerCodegen() {
162
166
cliOptions.add(CliOption.newBoolean(USE_JAKARTA_SECURITY_ANNOTATIONS, "Whether to generate Jakarta security annotations (@RolesAllowed, @PermitAll). Requires useJakartaEe=true. Currently only supported when library is set to quarkus.", useJakartaSecurityAnnotations));
163
167
cliOptions.add(CliOption.newBoolean(GENERATE_JSON_CREATOR, "Whether to generate @JsonCreator constructor for required properties.", generateJsonCreator));
164
168
cliOptions.add(CliOption.newBoolean(USE_ENUM_CASE_INSENSITIVE, "Use `equalsIgnoreCase` when String for enum comparison", useEnumCaseInsensitive));
169
+
cliOptions.add(CliOption.newBoolean(USE_SEALED, "Whether to generate sealed model interfaces and classes.", useSealed));
public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {
56
+
public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} {{>permits}}{
0 commit comments