Skip to content

Preserve snake_case wire field names in generated SDK models#132

Merged
travis-hoover-glean merged 1 commit into
mainfrom
fix/preserve-snake-case-field-names
Jul 2, 2026
Merged

Preserve snake_case wire field names in generated SDK models#132
travis-hoover-glean merged 1 commit into
mainfrom
fix/preserve-snake-case-field-names

Conversation

@travis-hoover-glean

Copy link
Copy Markdown
Contributor

Summary

The generated TypeScript SDK currently normalizes response field names to camelCase (e.g. the wire returns agent_id/request_id but the SDK surfaces agentId/requestId). This causes the SDK response shape to diverge from the raw API response.

This sets preserveModelFieldNames: true in .speakeasy/gen.yaml so generated models keep the exact field names from the OpenAPI spec, matching the raw HTTP response 1:1.

Why preserveModelFieldNames instead of modelPropertyCasing: snake

Our API is mixed on the wire — some fields are snake_case (agent_id) and some are camelCase (agentId). modelPropertyCasing: snake would incorrectly rename the genuinely-camel fields. preserveModelFieldNames: true preserves each field exactly as sent, so all cases match.

Note: with preserveModelFieldNames enabled, modelPropertyCasing only affects synthetic fields (e.g. additionalProperties), so it's left as-is.

Impact

⚠️ Breaking change for existing SDK consumers — property access changes (res.agentIdres.agent_id, etc.). Should ship with a major version bump.

Scope

TypeScript only. Python already emits snake_case; Go/Java use language-idiomatic casing and don't support this option.

Set preserveModelFieldNames: true so generated TypeScript models keep the
exact field names from the OpenAPI spec (e.g. agent_id, request_id) instead
of normalizing them to camelCase. This makes the SDK surface match the raw
API response 1:1, including the API's mixed snake_case/camelCase wire fields.
@travis-hoover-glean travis-hoover-glean requested a review from a team as a code owner July 2, 2026 13:59
@travis-hoover-glean travis-hoover-glean requested a review from a team July 2, 2026 14:33
@travis-hoover-glean travis-hoover-glean merged commit fa8f432 into main Jul 2, 2026
4 checks passed
@travis-hoover-glean travis-hoover-glean deleted the fix/preserve-snake-case-field-names branch July 2, 2026 17:30
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