Repository navigation
Generate with datetime = :zoned for schema 0.4.0 - #45
Merged
Merged
Conversation
SiennaSchemas 0.4.0 declares a zoneless series timestamp as date-time-local. Under the default datetime = :utc, OpenAPI.jl reads a missing offset as UTC and drops every offset. - generate_native.jl passes datetime = :zoned. A date-time is a ZonedDateTime that keeps its offset, and a date-time-local is a Dates.DateTime wall clock. drop_unused_timezones removes `using TimeZones` from packages with no date-time field. - validate_once.jl rewrites _encode_zoned calls to _encode_unvalidated. _encode_unvalidated writes a DateTime with no offset and a zero offset as Z, as the Python and Rust packages do. - TimeZones joins the deps of the two packages with date-time fields. OpenAPI compat is 1.3: the release with date-time-local and ECMA-262 pattern semantics (JuliaComputing/OpenAPI.jl#135, #136). - The tests build series from the wire form, so they pass before and after the regeneration. Checks of the new behavior run from schema 0.4.0. The update-schema workflow regenerates the packages after the schema release.
validate_once.jl overrode the ZonedDateTime encoding to write `Z` for a zero offset. OpenAPI.jl writes `+00:00`, which RFC 3339 and the schema's `utc` rule accept, so the override goes. _encode_unvalidated now falls back to OpenAPI.Runtime._encode_zoned, which writes a date-time-local DateTime with no offset and passes every other value to _encode. No timestamp-specific method remains, so drop_unused_timezones needs no exception for the base package. The tests expect `Z` before the 0.4.0 regeneration (:utc) and `+00:00` after it (:zoned).
daniel-thom
approved these changes
Oct 28, 2026
OpenAPI.jl 1.3.0 writes `_encode_zoned` and `_decode_zoned` into each generated module. They are not in `OpenAPI.Runtime`, and they refer to `TimeZones.ZonedDateTime`. - `_encode_unvalidated` calls the module-local `_encode_zoned`. - Keep `using TimeZones` in every generated module, and add the dependency to the four packages that did not have it.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The image warms its depot with the OpenAPI.jl version that scripts/Project.toml resolves.
jd-lara
marked this pull request as ready for review
November 2, 2026 14:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
SiennaSchemas 0.4.0 (Sienna-Platform/SiennaSchemas#109) declares a zoneless series timestamp
as
date-time-local, and gives every timestamp an ECMA-262pattern. Under the defaultdatetime = :utc, OpenAPI.jl reads a missing offset as UTC and drops every offset. This PRswitches the generator to
datetime = :zoned.It contains infrastructure changes only. The update-schema workflow regenerates the seven
packages after the schema release.
Draft until OpenAPI.jl releases JuliaComputing/OpenAPI.jl#135 (
date-time-local,offset required under
:zoned, contract 5) and #136 (ECMA-262patternsemantics). ThisPR sets
OpenAPI = "1.3", the expected version of that release. CI cannot resolve ituntil the release exists. If the release gets a different version, the compat entries
change with it.
Changes
scripts/generate_native.jl:OpenAPI.client(...; datetime = :zoned).date-timeis aZonedDateTimethat keeps its offset.date-time-localis aDates.DateTimewall clock.initial_timestampis theanyOfwrapper, and its branch is chosen byschema.
drop_unused_timezonesremovesusing TimeZonesfrom a package that has nodate-time field. The base package keeps it.
scripts/validate_once.jl:_encode_zoned(calls in a model's encode body are rewritten to_encode_unvalidated(, so a nested model is still validated only once._encode_unvalidatedfalls back toOpenAPI.Runtime._encode_zoned, which writes adate-time-localDateTimewith no offset. There is no timestamp-specific method:a zero offset is written as OpenAPI.jl writes it,
+00:00. RFC 3339 and the schema'sutcrule accept it. Python and Rust writeZ, so the outputs are equivalent but notbyte-identical.
Project.toml:InfrastructureCoreOpenAPIModelsandInfrastructureTimeSeriesOpenAPIModels.OpenAPI = "1.3"in the six packages and inscripts/.regeneration. A zero offset is expected as
Zbefore it (:utc) and+00:00afterit (
:zoned).READER_VERSIONis 0.4 or later: an offsetkept, a wall clock written with no offset, rejected non-RFC-3339 forms,
time_referencerules, and a zonelessDataSourcetimestamp rejected.Release order
v0.4.0is tagged.Merging it registers them.
The codegen image resolves
scripts/Project.tomlfrom the registry. So steps 1 and 2 mustcome before step 3, or the regeneration PR cannot generate.
Downstream
InfrastructureSystems passes
Dates.DateTimeintoDataSource.retrieved_at(
src/openapi_converters.jl). After 0.4.0 that field is aZonedDateTime, so IS mustconvert both ways before it adopts 0.4.0. IS pins
0.3, so nothing breaks at release.Test plan
Both runs used a local OpenAPI.jl with #135 and #136 combined, at version 1.3.0:
:utc): all seven suites pass.PowerOperations 100, PowerInvestments 48, PowerDynamics 99, PowerOpenAPIModels 1047.
SiennaSchemas#109:
generate_native.jl,make schema-version package-assets, andbump_version.py v0.3.0 v0.4.0.Total 1561, 0 failures.
require_contract(5, "1.3.0").using TimeZonesis only in the twodate-time packages.