GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: support Java 8 date/time formats per OpenAPI Formats Registry (#5172) by kuntal1461 · Pull Request #5184 · swagger-api/swagger-core

Conversation

@kuntal1461

@kuntal1461 kuntal1461 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #5172

Java 8 introduced java.time.* types that have become the standard for date/time handling, largely replacing java.util.Date and Joda-Time. The OpenAPI Formats Registry now defines standard format strings that map to these types. This PR brings swagger-core into alignment with that registry.

What was wrong

Java Type Before this PR Should be
java.time.OffsetTime Expanded as complex object (broken) "time"
java.time.Duration Expanded as complex object (broken) "duration"
java.time.LocalDateTime "date-time" (wrong format name) "date-time-local"
java.time.LocalTime Complex object, or "partial-time" via opt-in "time-local"

OffsetTime and Duration had no mapping at all — they fell through to Jackson's object expansion, producing unusable schemas with internal JDK fields. LocalDateTime was mapped to "date-time" which is the RFC 3339 offset date-time format — incorrect for a type that carries no timezone.

Why not just fix everything as the default?

LocalDateTime → "date-time" is the current default and has been since the early versions of this library. Many existing users depend on this mapping in generated specs, client SDKs, and validation logic. Silently changing it would break them on upgrade with no warning.

OffsetTime and Duration are fixed as the new default because their previous output (a complex object schema) was never usable — no user could have a working integration built on that output.

What this PR does

Fixed by default (no user action required):

  • java.time.OffsetTime → string / "time"
  • java.time.Duration → string / "duration"

Opt-in via PrimitiveType.enableJava8Formats():

  • java.time.LocalDateTime → string / "date-time-local"
  • java.time.LocalTime → string / "time-local"
// Add once at application startup to get fully correct OpenAPI Formats Registry mappings
PrimitiveType.enableJava8Formats();

This follows the same opt-in pattern already established by enablePartialTime() in this codebase.

enablePartialTime() is deprecated in favour of enableJava8Formats(), which supersedes it with the correct registry format name ("time-local" instead of "partial-time"). The old method is kept as-is so existing callers are not broken.

Migration path

v2.2.51 (this PR) → call enableJava8Formats() to opt in
v3.x (next major) → enableJava8Formats() behaviour becomes the default

New schema model classes (swagger-models)

Class Format
DateTimeLocalSchema "date-time-local"
TimeSchema "time"
TimeLocalSchema "time-local"
DurationSchema "duration"

Each follows the same structure as the existing DateTimeSchema and DateSchema.

Type of Change

  • ✨ New feature
  • 🐛 Bug fix (OffsetTime and Duration were broken by default)
  • 📝 Documentation (enablePartialTime() deprecation Javadoc)

Checklist

  • I have added/updated tests as needed (Java8DateFormatsTest covers both default and opt-in behaviour)
  • The PR title is descriptive
  • The code builds and passes tests locally (689 tests, 0 failures)
  • I have linked related issues ([Feature]: Support for Java 8 date formats #5172)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ColoredCarrot reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@kuntal1461
feat: add support for Java 8 date/time formats per OpenAPI Formats Re…
ef05660
…gistry (swagger-api#5172)

- Add DateTimeLocalSchema, TimeSchema, TimeLocalSchema, DurationSchema model classes
- Map java.time.OffsetTime  → format "time"     by default (was incorrect complex object)
- Map java.time.Duration    → format "duration"  by default (was incorrect complex object)
- Add PrimitiveType.enableJava8Formats() opt-in to map:
    java.time.LocalDateTime → "date-time-local"
    java.time.LocalTime     → "time-local"
- Deprecate enablePartialTime() in favour of enableJava8Formats()
- Add Java8DateFormatsTest and TestObjectJava8Dates covering default and opt-in behaviour

LocalDateTime and LocalTime are opt-in only to preserve backward compatibility.
The default will change in the next major version.

Authored-By: Kuntal Maity <[email protected]>
@ewaostrowska ewaostrowska added the backlog label May 28, 2026 — with Claude
@ewaostrowska ewaostrowska added the Feature label Jul 17, 2026
daniel-kmiecik added 2 commits August 11, 2026 14:05
@daniel-kmiecik
Merge branch 'master' into feature/5172-java8-date-formats
59d7f7e
@daniel-kmiecik
fix: support Java 8 date/time formats (swagger-api#5184)
0f48087
@daniel-kmiecik daniel-kmiecik added Bug and removed Feature labels Aug 11, 2026
@daniel-kmiecik

daniel-kmiecik commented Aug 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

@kuntal1461 ModelDeserializer.java wasn't updated for the 4 new formats. I fixed deserialization for these formats and tests have been added.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daniel-kmiecik
daniel-kmiecik approved these changes Aug 11, 2026
View reviewed changes
daniel-kmiecik added 3 commits August 13, 2026 11:36
@daniel-kmiecik
fix: support Java 8 date/time formats (swagger-api#5184)
71ea628
@daniel-kmiecik
test: preserve state for partial-time format
0081fdf
@daniel-kmiecik
test: add tests
1ffc92a
ewaostrowska
ewaostrowska reviewed Aug 13, 2026
View reviewed changes
Comment thread modules/swagger-core/src/main/java/io/swagger/v3/core/util/PrimitiveType.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@daniel-kmiecik
chore: update version in comment
e285232
ewaostrowska
ewaostrowska approved these changes Aug 13, 2026
View reviewed changes
@daniel-kmiecik

daniel-kmiecik commented Aug 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

This one also fixes: #4404

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daniel-kmiecik
daniel-kmiecik merged commit 27890ee into swagger-api:master Aug 13, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 13, 2026
Add support for more java.time objects #4404
Closed
Add DurationSchema for java.time.Duration as PrimitiveType #4821
Closed
[Feature]: Support for Java 8 date formats #5172
Closed
@daniel-kmiecik daniel-kmiecik added the Feature label Aug 13, 2026
@daniel-kmiecik

daniel-kmiecik commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

@kuntal1461 thanks for the PR! We really appreciate you taking the time to contribute to the project. Great work!

kuntal1461 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Allsimon Allsimon mentioned this pull request Aug 13, 2026
Support date-time-local format #5113
Closed
5 of 11 tasks
@Mattias-Sehlstedt Mattias-Sehlstedt mentioned this pull request Sep 6, 2026
upgrade swagger-core from 2.2.53 to 2.2.54 springdoc/springdoc-openapi#3351
Merged
bnasslahsen added a commit to springdoc/springdoc-openapi that referenced this pull request Sep 6, 2026
@bnasslahsen
Merge pull request #3351 from Mattias-Sehlstedt/update-swagger-core
2498ffb
upgrade swagger-core from 2.2.53 to 2.2.54

swagger-core now resolves java.time.Duration, LocalTime and OffsetTime
itself (swagger-api/swagger-core#5184), so the corresponding entries of
initExtraSchemas can be dropped.
bnasslahsen added a commit to springdoc/springdoc-openapi that referenced this pull request Sep 6, 2026
@bnasslahsen
Merge backport of #3351 - swagger-core 2.2.54
2e7d271
swagger-core now resolves java.time.Duration, LocalTime and OffsetTime
itself (swagger-api/swagger-core#5184), so the corresponding entries of
initExtraSchemas can be dropped.
@Mattias-Sehlstedt Mattias-Sehlstedt mentioned this pull request Oct 17, 2026
fix: scope the Scalar filter to the Scalar starters springdoc/springdoc-openapi#3389
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daniel-kmiecik daniel-kmiecik daniel-kmiecik approved these changes
@ewaostrowska ewaostrowska ewaostrowska approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backlog Bug Feature

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Feature]: Support for Java 8 date formats

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kuntal1461 @daniel-kmiecik @ewaostrowska
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.