Skip to content

Generate with datetime = :zoned for schema 0.4.0 - #45

Merged
jd-lara merged 4 commits into
mainfrom
jd/sdk-0.4.0
Nov 2, 2026
Merged

jd-lara merged 4 commits into
mainfrom
jd/sdk-0.4.0

Conversation

@jd-lara

@jd-lara jd-lara commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

SiennaSchemas 0.4.0 (Sienna-Platform/SiennaSchemas#109) declares a zoneless series timestamp
as date-time-local, and gives every timestamp an ECMA-262 pattern. Under the default
datetime = :utc, OpenAPI.jl reads a missing offset as UTC and drops every offset. This PR
switches 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-262 pattern semantics). This
PR sets OpenAPI = "1.3", the expected version of that release. CI cannot resolve it
until 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).
    • A date-time is a ZonedDateTime that keeps its offset.
    • A date-time-local is a Dates.DateTime wall clock.
    • A series' initial_timestamp is the anyOf wrapper, and its branch is chosen by
      schema.
    • drop_unused_timezones removes using TimeZones from a package that has no
      date-time field. The base package keeps it.
  • scripts/validate_once.jl:
    • The _encode_zoned( calls in a model's encode body are rewritten to
      _encode_unvalidated(, so a nested model is still validated only once.
    • _encode_unvalidated falls back to OpenAPI.Runtime._encode_zoned, which writes a
      date-time-local DateTime with 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's
      utc rule accept it. Python and Rust write Z, so the outputs are equivalent but not
      byte-identical.
  • Project.toml:
    • TimeZones joins the deps of InfrastructureCoreOpenAPIModels and
      InfrastructureTimeSeriesOpenAPIModels.
    • OpenAPI = "1.3" in the six packages and in scripts/.
    • No version bump: the automated PR bumps all seven.
  • Tests:
    • The tests build series from the wire form, so they pass before and after the
      regeneration. A zero offset is expected as Z before it (:utc) and +00:00 after
      it (:zoned).
    • Checks that need schema 0.4.0 run when READER_VERSION is 0.4 or later: an offset
      kept, a wall clock written with no offset, rejected non-RFC-3339 forms,
      time_reference rules, and a zoneless DataSource timestamp rejected.

Release order

  1. OpenAPI.jl releases #135 and #136.
  2. Raise the compat here if needed, then merge this PR.
  3. SiennaSchemas#109 merges, and v0.4.0 is tagged.
  4. update-schema opens the regeneration PR, which bumps the seven packages to 0.4.0.
    Merging it registers them.

The codegen image resolves scripts/Project.toml from the registry. So steps 1 and 2 must
come before step 3, or the regeneration PR cannot generate.

Downstream

InfrastructureSystems passes Dates.DateTime into DataSource.retrieved_at
(src/openapi_converters.jl). After 0.4.0 that field is a ZonedDateTime, so IS must
convert 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:

  • On the committed output (schema 0.3.0, :utc): all seven suites pass.
    • InfrastructureCore 104, InfrastructureTimeSeries 45, PowerCore 95,
      PowerOperations 100, PowerInvestments 48, PowerDynamics 99, PowerOpenAPIModels 1047.
    • Total 1538, 0 failures.
  • Dry run of the automated regeneration against the release tree of
    SiennaSchemas#109:
    • Steps: generate_native.jl, make schema-version package-assets, and
      bump_version.py v0.3.0 v0.4.0.
    • All seven suites pass, with the 0.4.0 checks active: 106, 56, 95, 100, 48, 99, 1057.
      Total 1561, 0 failures.
    • Every module has require_contract(5, "1.3.0"). using TimeZones is only in the two
      date-time packages.
    • The output was discarded after the run.

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.
@jd-lara
jd-lara requested a review from daniel-thom October 28, 2026 01:09
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).
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

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

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
jd-lara marked this pull request as ready for review November 2, 2026 14:56
@jd-lara
jd-lara merged commit d80405a into main Nov 2, 2026
8 of 9 checks passed
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