Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/samples-jdk17.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
- samples/server/petstore/java-helidon-server/v3/mp/**
- samples/server/petstore/java-helidon-server/v3/se/**
- samples/server/petstore/jaxrs-spec-sealed/**
- samples/server/petstore/jaxrs-spec-sealed-jsonb/**
- samples/server/petstore/jaxrs-spec/quarkus-security/**
- samples/server/petstore/jaxrs-spec-quarkus-jspecify/**
pull_request:
Expand All @@ -50,6 +51,7 @@ on:
- samples/server/petstore/java-helidon-server/v3/mp/**
- samples/server/petstore/java-helidon-server/v3/se/**
- samples/server/petstore/jaxrs-spec-sealed/**
- samples/server/petstore/jaxrs-spec-sealed-jsonb/**
- samples/server/petstore/jaxrs-spec/quarkus-security/**
- samples/server/petstore/jaxrs-spec-quarkus-jspecify/**
jobs:
Expand Down Expand Up @@ -82,6 +84,7 @@ jobs:
- samples/server/petstore/java-helidon-server/v3/mp/
- samples/server/petstore/java-helidon-server/v3/se
- samples/server/petstore/jaxrs-spec-sealed
- samples/server/petstore/jaxrs-spec-sealed-jsonb
- samples/server/petstore/jaxrs-spec/quarkus-security
- samples/server/petstore/jaxrs-spec-quarkus-jspecify
steps:
Expand Down
14 changes: 14 additions & 0 deletions bin/configs/jaxrs-spec-sealed-jsonb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-sealed-jsonb
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/jsonb_polymorphism_containers.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-sealed-jsonb-petstore-server
serializationLibrary: jsonb
jsonbDiscriminatorDeserializers: "true"
useJakartaEe: "true"
useOneOfInterfaces: "true"
useSealed: "true"
generateBuilders: "true"
serializableModel: "true"
hideGenerationTimestamp: "true"
4 changes: 3 additions & 1 deletion docs/generators/jaxrs-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. The match is case insensitive, like HTTP header names. Note: this parameter is ignored when implicitHeaders=true| |null|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|invokerPackage|root package for generated code| |org.openapitools.api|
|jsonbDiscriminatorDeserializers|With 'serializationLibrary=jsonb' and 'useJakartaEe=true': generate JSON-B deserializers that resolve the concrete class of a model, also in list, set and map properties, from its discriminator mapping, and create concrete models with their discriminator values. With Yasson before 3.0.5, this does not cover root containers, such as a request body of type Map<String, Pet> (with Yasson 3.0.2 also List<Pet>). With Johnzon 2.0.2 and 2.2.0, reading a model fails when a required list, set or map property with elements of such models is absent from the JSON (an explicit null is read).| |false|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dt>**kumuluzee**</dt><dd>Server using KumuluzEE</dd></dl>|&lt;default&gt;|
|licenseName|The name of the license| |Unlicense|
Expand All @@ -75,7 +76,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|scmDeveloperConnection|SCM developer connection in generated pom.xml| |scm:git:git@github.com:openapitools/openapi-generator.git|
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|serializableModel|boolean - toggle &quot;implements Serializable&quot; for generated models| |false|
|serializationLibrary|Serialization library used for the generated models. 'jsonb' is only supported by the default library (&lt;default&gt;). With 'jsonb', dateLibrary defaults to 'java8' ('java8-localdatetime' is also supported, 'joda' and 'legacy' are not), openApiNullable is disabled and no type annotations are generated for discriminator/oneOf polymorphism. Models with additionalProperties are generated as subclasses of HashMap without a JSON-B specific mapping, so they are (de)serialized as plain maps: declared properties are not written and are read into map entries instead of their fields. Properties with a null value are omitted, except required nullable properties, which are written as null; JsonbConfig.withNullValues(true) does not change this because the generated @JsonbProperty annotations default to nillable = false. Depending on the JSON-B implementation, enum values inside maps (and, with older implementations, inside lists) may not use the generated enum serializers/deserializers.|<dl><dt>**jsonb**</dt><dd>Use JSON-B as serialization library</dd><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd></dl>|jackson|
|serializationLibrary|Serialization library used for the generated models. 'jsonb' is only supported by the default library (&lt;default&gt;). With 'jsonb', dateLibrary defaults to 'java8' ('java8-localdatetime' is also supported, 'joda' and 'legacy' are not), openApiNullable is disabled and no type annotations are generated for discriminator/oneOf polymorphism (see jsonbDiscriminatorDeserializers). Models with additionalProperties are generated as subclasses of HashMap without a JSON-B specific mapping, so they are (de)serialized as plain maps: declared properties are not written and are read into map entries instead of their fields. Properties with a null value are omitted, except required nullable properties, which are written as null; JsonbConfig.withNullValues(true) does not change this because the generated @JsonbProperty annotations default to nillable = false. Depending on the JSON-B implementation, enum values inside maps (and, with older implementations, inside lists) may not use the generated enum serializers/deserializers.|<dl><dt>**jsonb**</dt><dd>Use JSON-B as serialization library</dd><dt>**jackson**</dt><dd>Use Jackson as serialization library</dd></dl>|jackson|
|serverPort|The port on which the server should be started| |8080|
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
Expand Down Expand Up @@ -110,6 +111,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null
|x-field-extra-annotation|Custom annotation(s) to be added to property; on an array `items` schema, generators that support element-type annotations add it to the element type instead (e.g. `List<@Foo T>`); accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
|x-abstract|Generate the model class as `abstract`, with `protected` constructors and without `builder()` and JSON creator. Every discriminator value must resolve to a concrete class: an explicit mapping to an abstract model fails the generation, an implicit one is replaced by mappings to its concrete subclasses. With `useSealed`, an abstract model needs a generated subclass.|MODEL|false


## IMPORT MAPPING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum VendorExtension {
X_SPRING_API_VERSION("x-spring-api-version", ExtensionLevel.OPERATION, "Value for 'version' attribute in @RequestMapping (for Spring 7 and above).", null),
X_SPRING_PROVIDE_ARGS("x-spring-provide-args", ExtensionLevel.OPERATION, "Allows adding additional hidden parameters in the API specification to allow access to content such as header values or properties", "empty array"),
X_DISCRIMINATOR_VALUE("x-discriminator-value", ExtensionLevel.MODEL, "Used with model inheritance to specify value for discriminator that identifies current model", ""),
X_ABSTRACT("x-abstract", ExtensionLevel.MODEL, "Generate the model class as `abstract`, with `protected` constructors and without `builder()` and JSON creator. Every discriminator value must resolve to a concrete class: an explicit mapping to an abstract model fails the generation, an implicit one is replaced by mappings to its concrete subclasses. With `useSealed`, an abstract model needs a generated subclass.", "false"),
X_SETTER_EXTRA_ANNOTATION("x-setter-extra-annotation", ExtensionLevel.FIELD, "Custom annotation that can be specified over java setter for specific field", "When field is array & uniqueItems, then this extension is used to add `@JsonDeserialize(as = LinkedHashSet.class)` over setter, otherwise no value"),
X_WEBCLIENT_BLOCKING("x-webclient-blocking", ExtensionLevel.OPERATION, "Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono<T>/Flux<T>` or `return T/List<T>/Set<T>` & execute `.block()` inside generated method)", "false"),
X_WEBCLIENT_RETURN_EXCEPT_LIST_OF_STRING("x-webclient-return-except-list-of-string", ExtensionLevel.OPERATION, "Specifies if method for specific operation should return the type except List<String> and Set<String>(ex: return type expect the `Mono<List<String>>/Flux<List<String>>` and `Mono<Set<String>>/Flux<Set<String>>`)", "false"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.VendorExtension;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.OperationsMap;
Expand Down Expand Up @@ -69,13 +70,27 @@ public JavaJAXRSCXFCDIServerCodegen() {
removeOption(USE_JSPECIFY);
// JSON-B support lives in the JavaJaxRS/spec templates as well; cxf-cdi always uses Jackson.
removeOption(CodegenConstants.SERIALIZATION_LIBRARY);
removeOption(JavaJAXRSSpecServerCodegen.JSONB_DISCRIMINATOR_DESERIALIZERS);
}

@Override
public String getName() {
return "jaxrs-cxf-cdi";
}

@Override
public List<VendorExtension> getSupportedVendorExtensions() {
// x-abstract is implemented by the JavaJaxRS/spec templates only; cxf-cdi uses its own templates.
List<VendorExtension> extensions = super.getSupportedVendorExtensions();
extensions.remove(VendorExtension.X_ABSTRACT);
return extensions;
}

@Override
protected boolean supportsAbstractModels() {
return false;
}

@Override
public void processOpts() {
// Force jspecify off before super.processOpts(), which is where applyJspecify() runs.
Expand All @@ -85,6 +100,7 @@ public void processOpts() {
additionalProperties.remove(USE_JSPECIFY);
setUseJspecify(false);
additionalProperties.remove(CodegenConstants.SERIALIZATION_LIBRARY);
additionalProperties.remove(JavaJAXRSSpecServerCodegen.JSONB_DISCRIMINATOR_DESERIALIZERS);

super.processOpts();

Expand Down
Loading
Loading