Skip to content

fix(generator): handle list-typed nullable fields from upstream spec#93

Draft
natalie-o-perret wants to merge 1 commit into
exoscale:masterfrom
natalie-o-perret:fix/list-type-handling
Draft

fix(generator): handle list-typed nullable fields from upstream spec#93
natalie-o-perret wants to merge 1 commit into
exoscale:masterfrom
natalie-o-perret:fix/list-type-handling

Conversation

@natalie-o-perret

@natalie-o-perret natalie-o-perret commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The upstream Exoscale OpenAPI v2 spec now emits type as a list
for nullable fields, e.g. "type": ["integer", "null"]. The code
generator at generator.py:74 assumed type is always a str,
causing TypeError: unhashable type: list`` on import.

Before (master): pytest collects 0 items, 2 errors

tests/test_client.py ▸ exoscale/api/v2.py:97 ▸ generator.py:74
  typ = _type_translations[item["type"]]
TypeError: cannot use "list" as a dict key (unhashable type: "list")

After (fix):

collected 16 items
tests/test_client.py ........                                        [ 50%]
tests/test_partner_client.py ........                                [100%]
============================== 16 passed in 0.08s ==============================

Changes:

  • Added _translate_type() helper in generator.py that handles both
    str and list type values (list → "int | None")
  • Replaced all 7 direct _type_translations[<expr>] call sites with
    _translate_type(<expr>)
  • Added uv run pytest step to openapi.yaml auto-update workflow so
    spec changes are verified before committing to master

Note

AI-assisted for initial investigation and implementation.

The upstream Exoscale OpenAPI spec now emits type as a list for nullable
fields (e.g. ["integer", "null"]), which is valid JSON Schema but was
not handled by the generator. Added _translate_type() helper that
normalizes both str and list type values.

Also added a test verification step to the openapi.yaml auto-update
workflow so master is no longer broken silently.
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