Skip to content

update openapi de-serialize - #607

Merged
jd-lara merged 4 commits into
IS4from
jd/openapi_is_attributes
Aug 15, 2026
Merged

update openapi de-serialize#607
jd-lara merged 4 commits into
IS4from
jd/openapi_is_attributes

Conversation

@jd-lara

@jd-lara jd-lara commented Aug 15, 2026

Copy link
Copy Markdown
Member

No description provided.

Line-wrapping only, from the GeoJSON test fixtures in the previous commit: the
Point geometries are longer than the placeholder dictionaries they replaced and
crossed the line limit.
The path source resolved only in a workspace checkout. CI clones this repo alone,
so instantiation failed before any test ran:

  ERROR: expected package `PowerCoreOpenAPIModels [b7b40286]` to exist at path
    /home/runner/work/InfrastructureSystems.jl/PowerOpenAPIModels/PowerCoreOpenAPIModels.jl

That is what took down all five test jobs; the format check was passing throughout.
`subdir` is required because PowerCoreOpenAPIModels is a subdirectory package, and a
branch rev rather than a version because PowerOpenAPIModels is not registered.

KNOWN BROKEN UNTIL PowerOpenAPIModels jd/openapi_regen MERGES TO main. main is 19
commits behind it and does not yet carry model_DataSource.jl, added in 09ff27b, so
loading InfrastructureSystems currently raises:

  UndefVarError: `DataSource` not defined in `PowerCoreOpenAPIModels`

Pinned to main deliberately rather than to the feature branch, so no follow-up edit
is needed once that merge lands; it resolves itself at that point with no change here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates InfrastructureSystems’ OpenAPI (de)serialization support for supplemental attributes and tightens GeographicInfo handling by validating that stored geo_json is valid GeoJSON.

Changes:

  • Added from_openapi / to_openapi converters for GeographicInfo and DataSource, including UTC normalization for DataSource timestamps.
  • Added GeoJSON parsing-based validation for GeographicInfo.geo_json.
  • Updated tests to use valid GeoJSON Point objects instead of ad-hoc dictionaries.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/test_system_data.jl Updates GeographicInfo test data to valid GeoJSON.
test/test_supplemental_attributes.jl Updates multiple GeographicInfo test fixtures and mutation assertions to GeoJSON Point shape.
test/test_serialization.jl Updates serialization test fixture to valid GeoJSON Point.
src/openapi_converters.jl New OpenAPI ↔ IS conversion layer for GeographicInfo and DataSource.
src/InfrastructureSystems.jl Imports new deps and includes the new converter file.
src/geographic_supplemental_attribute.jl Adds GeoJSON validation to GeographicInfo construction.
Project.toml Adds new dependencies and a [sources] path override for PowerCoreOpenAPIModels.
Suppressed comments (1)

src/geographic_supplemental_attribute.jl:31

  • The docstring claims the stored value "stays the caller's own dictionary", but GeographicInfo stores geo_json::Dict{String, Any}. If callers pass a Dict{String, T} with T != Any, it will be converted (copied) to Dict{String, Any} during construction, so the original dictionary identity is not preserved. Consider clarifying the wording to avoid implying identity preservation.
The parse result is discarded — `GeoJSON` reads coordinates as `Float32`, and the stored
value stays the caller's own dictionary rather than a lossy round-trip of it.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/geographic_supplemental_attribute.jl
Comment thread src/openapi_converters.jl
Parsing alone did not establish validity. GeoJSON.read accepts {"type": "Point"}
with no coordinates at all, and {"type": "Feature"} with no geometry, returning an
object whose required member is `nothing` rather than raising. Both are invalid
GeoJSON, and both passed validate_geo_json, so a geometry with no coordinates could
be stored and only fail in whatever consumed it later.

The parse is now followed by a completeness check on the parsed object, dispatched
per shape so each accessor only ever meets the type it is defined for.
GeometryCollection needs its own method because it is an AbstractGeometry but is
keyed on `geometries` rather than `coordinates`. The `::Any` fallback returns true
deliberately: parsing succeeded and there is no rule for that shape, which is not
grounds to reject it.

Rejections name the parsed type and the member that is missing, rather than
repeating the generic "not valid GeoJSON" message, since the input did parse.

Verified against 13 cases: the seven valid shapes still pass, the three previously
accepted holes now fail, and the three pre-existing rejections are unchanged. Run
against the definitions extracted from this file rather than through the package,
because InfrastructureSystems still cannot load while PowerCoreOpenAPIModels is
pinned to main; this wants a real suite run once that pin resolves.
@jd-lara
jd-lara merged commit 8feae57 into IS4 Aug 15, 2026
1 of 7 checks passed
@jd-lara
jd-lara deleted the jd/openapi_is_attributes branch August 15, 2026 01:00
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.

3 participants