[Java][JAX-RS] Add JSON-B support to jaxrs-spec

Merged
DE
1mo ago
+14090-8

Fixes #4104

Description

Adds JSON-B as an optional serialization library for the jaxrs-spec generator.

Jackson remains the default serialization library to preserve backward compatibility.

The implementation includes:

  • serializationLibrary: jsonb support for jaxrs-spec
  • JSON-B annotations for generated models
  • JSON-B serialization/deserialization support for enums
  • JSON-B dependencies in generated Maven projects
  • validation for unsupported serialization library combinations and date libraries
  • a JSON-B sample project and generator tests

Tests

The JAX-RS Spec generator tests and the added JSON-B regression tests have been run successfully.

After rebasing onto the current master:

Tests run: 193, Failures: 0, Errors: 0, Skipped: 0

Reviewers

Java Technical Committee: @jfiala @cbornet @martin-mfg

Feedback and review are welcome.

Acknowledgements

This contribution was developed as part of my work at software4production.

PR checklist

  • Read the contribution guidelines.
  • Run the full project build and update all samples.
  • Mention the technical committee members.

Summary by cubic

Adds JSON-B as an opt-in serialization library for the jaxrs-spec generator. Jackson remains the default, so existing generated output is unchanged.

New Features

  • serializationLibrary: jsonb generates models with JSON-B annotations (@JsonbProperty, @JsonbCreator) and JSON-B/JSON-P dependencies for both Jakarta (jakarta.*) and legacy (javax.*) packages.
  • Enums get JSON-B serializers/deserializers for string, integer, and number values, including case-insensitive and unknown-default handling.
  • Adds a petstore sample and tests covering nullable properties, enum handling, and OpenAPI 3.0/3.1.
  • Rejects unsupported combinations of serialization library and date library options.

Behavior change

  • JavaJAXRSCXFCDIServerCodegen always uses Jackson, so it now removes the serializationLibrary option instead of advertising a setting that has no effect.
  • The samples CI workflow now builds jaxrs-spec-jsonb and pins the legacy Quarkus JAX-RS sample to the Maven Wrapper, since Maven 3.10 no longer ships Maven Resolver 1.x required by quarkus-maven-plugin 1.x.