Skip to content

Serialize enum values for API requests - #35

Open
jsachs wants to merge 1 commit into
ulfsri:mainfrom
jsachs:codex/serialize-enum-values
Open

Serialize enum values for API requests#35
jsachs wants to merge 1 commit into
ulfsri:mainfrom
jsachs:codex/serialize-enum-values

Conversation

@jsachs

@jsachs jsachs commented Aug 4, 2026

Copy link
Copy Markdown

Problem

The generated API models use Python Enum classes. requests serializes a normal
enum using its Python string representation rather than its wire value.

For example:

client.list_entities(state=StatesTerrs.AL)

previously prepared a query parameter equivalent to:

?state=StatesTerrs.AL

The API expects:

?state=AL

This can cause entity filtering and sorting requests to return no results or be
rejected as invalid query parameters.
The same issue affects incident-status updates. For example:

client.update_incident_status(
    "FD24000001",
    "IN24000001",
    TypeIncidentStatusValue.APPROVED,
)

previously sent:

{"status": "TypeIncidentStatusValue.APPROVED"}

rather than the API value:

{"status": "APPROVED"}

Fix

Normalize Enum values to their .value representation before sending query
parameters, including lists of enum values. Send the incident status enum's
.value in the update request.

Tests

Added regression coverage for:

  • enum query parameters being sent as API values;
  • incident status updates sending "APPROVED" instead of the Python enum name.

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