Skip to content

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

Open
dean505 wants to merge 4 commits into
OpenAPITools:masterfrom
dean505:jaxrs-spec-jsonb-4104
Open

dean505 wants to merge 4 commits into
OpenAPITools:masterfrom
dean505:jaxrs-spec-jsonb-4104

Conversation

@dean505

@dean505 dean505 commented Oct 8, 2026 •

Copy link
Copy Markdown

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.

Written for commit 6001324. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 87 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread samples/server/petstore/jaxrs-spec-jsonb/.openapi-generator/VERSION Outdated
Comment thread samples/server/petstore/jaxrs-spec-jsonb/README.md
@dean505

dean505 commented Oct 8, 2026

Copy link
Copy Markdown
Author

The JAX-RS sample CI jobs are currently failing during Maven initialization due to a Develocity Maven extension error (DevelocityLifecycleManager.afterProjectsRead, Guice/NullInjectedIntoNonNullable).

The failure occurs before any Maven goals are executed (0 goals, 0 executed) and also affects existing JAX-RS samples.

The new jaxrs-spec-jsonb sample was regenerated locally without any Git diff and built successfully. The focused generator and regression tests also passed (193 tests, 0 failures).

This appears to be a CI environment issue rather than a JSON-B compilation failure.

@wing328

wing328 commented Oct 8, 2026

Copy link
Copy Markdown
Member

due to a Develocity Maven extension error

I'll try to fix/workaround it shortly.

Thanks for the PR

@dean505

dean505 commented Oct 8, 2026 •

Copy link
Copy Markdown
Author

Update: I found and applied a workaround for the remaining CI failure.

The issue was caused by the GitHub Actions runner using Maven 3.10.0. Its Maven Resolver 2.x no longer provides org.eclipse.aether.spi.locator.ServiceLocator, which is required by the legacy Quarkus 1.13.7.Final plugin.

I reproduced the failure on upstream master, confirming that it is unrelated to the JSON-B changes.

Fix applied: I updated .github/workflows/samples-jaxrs.yaml so that only jaxrs-spec-microprofile-openapi-annotations uses the repository's existing Maven Wrapper (3.8.8). All other 22 samples continue using the default Maven version.

Local verification:

  • Java 11 + Maven 3.10.0: build fails with the original error.
  • Java 11 + Maven Wrapper 3.8.8: BUILD SUCCESS.
  • Workflow validation with actionlint: passed.
  • No samples or tests were disabled.

The workaround is included in this PR to restore CI compatibility. Since the underlying issue also affects upstream master, I'm happy to separate the CI change if preferred.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Generate JsonB model (JSR 367 Specification)

2 participants