Skip to content

Add native JPMS module descriptors to Swagger Core 3 - #5365

Closed
GedMarc wants to merge 1 commit into
swagger-api:3.0.0from
GedMarc:feat/jpms-module-descriptors
Closed

GedMarc wants to merge 1 commit into
swagger-api:3.0.0from
GedMarc:feat/jpms-module-descriptors

Conversation

@GedMarc

@GedMarc GedMarc commented Oct 25, 2026

Copy link
Copy Markdown

Description

Adds native module-info.java descriptors to the six Swagger Core 3 runtime libraries, using their existing Automatic-Module-Name values. A named-module application can now resolve and link the official artifacts directly with jlink, without adding downstream wrapper descriptors.

Related to #4991. This follows the Jackson 3 discussion and our migration from the community fork to the official 3.0.0 artifacts; it targets the 3.0.0 branch.

The descriptors export the existing packages, expose dependencies used by public APIs transitively, open model/configuration packages to Jackson, and declare the three Swagger service consumers plus the servlet initializer provider. The Servlet API remains optional for Reader-only usage via requires static transitive in swagger-rest.

An opt-in jpms-it profile launches a named-module consumer against packaged JARs. It verifies all six explicit descriptors, four service contracts, REST class/package scanning, and JSON/YAML round trips for OpenAPI 3.0 and 3.1 with typed-map references. Existing unit and servlet integration tests keep their classpath environment. Both Maven workflows run the new consumer on their Java 17/21/25 matrix.

Type of Change

  • ✨ New feature
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues

Validation

  • Java 17: full Maven reactor verify -Pjpms-it passed, including Javadocs, servlet integration tests and Maven-plugin tests. Test reports contain 1,893 tests with zero failures, errors or skips.
  • Packaged module-path consumer passed on Java 17, 21 and 25.
  • Java 17 jlink image built successfully and ran the same consumer, including ClassGraph package scanning.
  • A separate minimal named-module consumer ran Reader successfully with jakarta.servlet absent from the resolved module graph.

See JPMS.md for module names, application descriptors, service providers and verification commands. The integration-test artifact is excluded from install/deploy. Hosted CI remains to run; the Gradle-plugin build was not run locally.

Preserve module names, declare reflective access and service contracts, and verify packaged modules through an opt-in integration test on Java 17, 21 and 25.

Refs: swagger-api#4991

swagger-api#4991
Copilot AI balanced review requested due to automatic review settings October 25, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The REST descriptor blocks reflective context injection needed to initialize the built-in OpenAPI endpoints on the module path.

1 open issue
What changed in this PR

Adds native Java module descriptors to the six Swagger Core 3 runtime libraries, enabling explicit module-path use and jlink integration while preserving classpath support.

Changes:

  • Defines module exports, dependencies, reflective access, and service contracts.
  • Adds an opt-in packaged-module smoke test and runs it in both Maven workflows.
  • Documents module configuration and verification while keeping existing tests on the classpath.
File Description
README.md Links to Java module documentation.
pom.xml Adds the jpms-it profile and preserves classpath testing.
modules/​swagger-rest/​src/​main/​java/​module-info.java Defines REST exports, dependencies, and extension consumption.
modules/​swagger-rest-servlet-initializer/​src/​main/​java/​module-info.java Registers the servlet initializer provider.
modules/​swagger-models/​src/​main/​java/​module-info.java Exports model packages and opens them to Jackson.
modules/​swagger-jpms-integration-test/​src/​main/​java/​module-info.java Defines the test consumer and service providers.
modules/​swagger-jpms-integration-test/​src/​main/​java/​io/​swagger/​v3/​jpms/​test/​ModulePathSmoke.java Checks descriptors, services, scanning, and serialization.
modules/​swagger-jpms-integration-test/​pom.xml Launches the packaged consumer without publishing it.
modules/​swagger-integration/​src/​main/​java/​module-info.java Defines integration exports and configuration service consumption.
modules/​swagger-core/​src/​main/​java/​module-info.java Defines core dependencies, exports, and converter consumption.
modules/​swagger-annotations/​src/​main/​java/​module-info.java Exports annotation packages.
JPMS.md Documents module usage, reflection, services, and verification.
.github/​workflows/​maven.yml Runs the module-path integration test.
.github/​workflows/​maven-pulls.yml Runs the module-path integration test for pull requests.

Review effort: Balanced

exports io.swagger.v3.rest.ext;
exports io.swagger.v3.rest.integration;
exports io.swagger.v3.rest.integration.api;
exports io.swagger.v3.rest.integration.resources;

@GedMarc GedMarc Oct 25, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@copilot Illegal reflection post JDK 8 is disabled intentionally - please review accordingly

@GedMarc

GedMarc commented Oct 25, 2026

Copy link
Copy Markdown
Author

As the core - there are frameworks that still perform field injection post jdk 8 (Why g*d WHY!!!) - will keep the strict shade on the library for guicedee

@GedMarc GedMarc closed this Oct 25, 2026
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.

2 participants