Preserve snake_case wire field names in generated SDK models#132
Merged
Conversation
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.
chris-freeman-glean
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The generated TypeScript SDK currently normalizes response field names to camelCase (e.g. the wire returns
agent_id/request_idbut the SDK surfacesagentId/requestId). This causes the SDK response shape to diverge from the raw API response.This sets
preserveModelFieldNames: truein.speakeasy/gen.yamlso generated models keep the exact field names from the OpenAPI spec, matching the raw HTTP response 1:1.Why
preserveModelFieldNamesinstead ofmodelPropertyCasing: snakeOur API is mixed on the wire — some fields are snake_case (
agent_id) and some are camelCase (agentId).modelPropertyCasing: snakewould incorrectly rename the genuinely-camel fields.preserveModelFieldNames: truepreserves each field exactly as sent, so all cases match.Impact
res.agentId→res.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.