Skip to content

Fix java11 date library configuration - #1434

Open
theaprince001 wants to merge 1 commit into
swagger-api:masterfrom
theaprince001:fix/java11-date-library-1433
Open

theaprince001 wants to merge 1 commit into
swagger-api:masterfrom
theaprince001:fix/java11-date-library-1433

Conversation

@theaprince001

Copy link
Copy Markdown

Pull Request

Thank you for contributing to swagger-codegen-generators!

Description

Fixes the handling of dateLibrary=java11 in Java generators.

Previously, although java11 was listed as a supported date library option, selecting it did not correctly configure the Java 11 date and time mappings. As a result, generated models could continue using legacy java.util.Date types instead of Java Time API types.

This PR:

  • Adds explicit handling for dateLibrary=java11 in AbstractJavaCodegen.
  • Enables Java 11 mode and JSR-310 support automatically.
  • Configures the following type mappings:
    • date → LocalDate
    • DateTime → OffsetDateTime
  • Adds the corresponding java.time import mappings.
  • Updates SpringCodegen to enable its Java 11-specific configuration when dateLibrary=java11 is selected.
  • Adds unit and integration tests to verify the mappings and generator configuration.

Fixes: #1433

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 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 the relevant tests pass locally
  • I have linked related issues (if any)

How to Test

Configure a Java generator with:

dateLibrary: java11

Verify that generated model properties use:

  • LocalDate for OpenAPI format: date
  • OffsetDateTime for OpenAPI format: date-time

Tests added/updated cover:

  • AbstractJavaCodegen Java 11 date-library mappings.
  • Java JAX-RS server Java 11 configuration.
  • Spring generator Java 11 configuration.
  • Java client schema property mappings using a dedicated OpenAPI fixture.

The relevant tests were executed individually in IntelliJ IDEA and passed.

Note: Maven compilation succeeded, but the existing Maven/Surefire configuration discovered zero tests during mvn test. This PR does not modify the unrelated test-discovery configuration.

Screenshots / Additional Context

No screenshots are required. The changes are covered by automated tests.

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.

Setting dateLibrary=java11 fails to map "java.time" types

1 participant