Skip to content

fix(rust-types): render nullable arrays as Option - #1970

Merged
gtema merged 1 commit into
mainfrom
codegenerator_1003297
Sep 2, 2026
Merged

fix(rust-types): render nullable arrays as Option#1970
gtema merged 1 commit into
mainfrom
codegenerator_1003297

Conversation

@gtema

@gtema gtema commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Fields declared as required with a type list that includes 'null'
(e.g. type: [array, null]) were rendered as plain types because the
field's is_nullable flag was not taken into account when computing the
Rust type hint.

The oneOf conversion already moved the Option wrapper into is_nullable
(and additionally unwrapped the Array for nullable arrays), but
StructFieldResponse.type_hint only wrapped based on is_optional.
Required nullable arrays therefore became Vec<T> and failed to
deserialize responses where the API legitimately returns null (e.g.
trusted_image_certificates, hosts, fixed_ips), silently degrading
CLI tables to the minimal fallback schema.

Emit Option<T> for nullable fields as well, and mark them as
structable optional so None values render as empty cells instead of
the string "null".

Changes are triggered by https://review.opendev.org/c/openstack/codegenerator/+/1003297

Signed-off-by: Artem Goncharov artem.goncharov@gmail.com

@gtema
gtema force-pushed the codegenerator_1003297 branch from 7328eda to 7077443 Compare September 2, 2026 11:15
Fields declared as `required` with a type list that includes 'null'
(e.g. `type: [array, null]`) were rendered as plain types because the
field's is_nullable flag was not taken into account when computing the
Rust type hint.

The oneOf conversion already moved the Option wrapper into is_nullable
(and additionally unwrapped the Array for nullable arrays), but
StructFieldResponse.type_hint only wrapped based on is_optional.
Required nullable arrays therefore became `Vec<T>` and failed to
deserialize responses where the API legitimately returns null (e.g.
`trusted_image_certificates`, `hosts`, `fixed_ips`), silently degrading
CLI tables to the minimal fallback schema.

Emit `Option<T>` for nullable fields as well, and mark them as
structable `optional` so `None` values render as empty cells instead of
the string "null".

Changes are triggered by https://review.opendev.org/c/openstack/codegenerator/+/1003297

Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
@gtema
gtema force-pushed the codegenerator_1003297 branch from 7077443 to d27f9b4 Compare September 2, 2026 11:16
@gtema
gtema merged commit f9c2b96 into main Sep 2, 2026
19 checks passed
@gtema-release-plz gtema-release-plz Bot mentioned this pull request Sep 2, 2026
@gtema
gtema deleted the codegenerator_1003297 branch September 2, 2026 16:32
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.

1 participant