feat(casing): snake/wire surface parity across params, bodies, presentation and columns (#131); hyphenated wire names alias cleanly (#119) - #140
Open
jeffreyaven wants to merge 1 commit into
Conversation
…tation and columns (#131); hyphenated wire names alias cleanly (#119) - casing.ToSnake treats '-' as a word boundary, so header names such as openai-organization gain a usable snake alias. - Parameter retry paths (GetParameter, parameterMatch, namespaceParameterMatch, GetOperationParameter) resolve a snake key through the declared wire names (ToSnake-derived), so acronym-headed names (IPProtocol, BinaryId) round-trip; FromSnake stays as a fallback. - data__ body keys: the revert path maps a snake key to its wire property when the method declares nativeCasing, so the default body regime sends wire keys. - Presentation (SHOW METHODS / SHOW INSERT via RenameRequestBodyAttribute and ToPresentationMap) is snake only when the method declares nativeCasing and the provider enables snake_case_aliases; resolution keeps every wire spelling. - A request block without a body schema is no longer an error from GetRequestBodySchema, so metadata-only blocks on body-less EXEC methods dispatch; the body-attribute accessors keep their error contract. - Schema.GetProperty / FindByPath accept the snake alias of a wire property under snake_case_aliases, wire-first. All gated on provider config; absent both flags every path is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Closes #131. Closes #119.
Every change is gated on provider doc config (
request.nativeCasingon themethod,
config.snake_case_aliaseson the provider). Resolution is wire-firston every surface: the key as written matches first, the snake alias second, and
no wire spelling is removed from any resolvable set. Absent both flags every
path is byte-identical.
#119 - hyphenated wire names
casing.ToSnakenow treats-as a word boundary, transforming each segmentwith the existing botocore rules:
openai-organization->openai_organization,OpenAI-Organization->open_ai_organization,X-Amz-Date->x_amz_date.Non-hyphenated names are unchanged (
VPCId->vpc_id,training_file->identity).
FromSnake(_, kebab)was already the correct inverse.#131
Schema.GetPropertyandFindByPathaccept the snake alias of a wire property whensnake_case_aliasesis on (wire-first), so snake projections resolve their property schema.GetParameter,parameterMatch,namespaceParameterMatchandGetOperationParameterresolve a snake key through the declared wire names (ToSnake-derived alias map) before the mechanicalFromSnakefallback, soip_protocol->IPProtocol,binary_id->BinaryId.GetParametersIncludingNativeCasingaliasesdata__body keys with the prefix kept.data__regimerevertRequestBodyAttributeRenamemaps a snake body key to its wire property when the method declaresnativeCasing, sodata__storage_classanddata__storageClassboth send{"storageClass": ...}. Unknown keys pass through as today (an error here would break free-form bodies).RenameRequestBodyAttribute(SHOW INSERT) andToPresentationMap(SHOW METHODS) present snake names only when the method declaresnativeCasingand the provider enablessnake_case_aliases; nested body contents and server variables keep wire casing. The unexported rename used for resolution is unchanged, soGetParameters()keeps the wire keys.GetRequestBodySchemareturnsnil, nilwhen no body schema is declared, so a metadata-onlyrequestblock on a body-less method no longer fails before dispatch. The internal body-attribute accessors keep their error contract, which preserves routing exactly (they previously short-circuited before required server variables were added).Verification
go build ./...,go test ./...(21 packages), gofmt on changed hunks, lintclean on changed lines. New tests:
pkg/casinghyphen cases andinternal/anysdk/casing_alias_resolution_test.go(one test per item, eachasserting the wire spelling still resolves and the flag-off path is unchanged).
registry provider with
snake_case_aliases: trueand per-methodnativeCasing, mock logging method/path/query/header/body:WHERE openai_organization = 'org-x'(kebab header)openai-organization: org-xon the wireINSERT ... (data__name, data__storage_class){"storage_class": ...}(silently ignored by an API){"storageClass": ...}INSERT ... (data__name, data__storageClass){"storageClass": ...}EXEC ...stop @machineId(body-less,request: {nativeCasing})no request body for operationPOST /machines/m1/stopSHOW METHODS(stop)machineIdmachine_idSHOW INSERTdata__storageClassdata__storage_classWHERE max_results = 2/WHERE maxResults = 2?maxResults=2SELECT machine_type, creation_timestamp, ip_protocolRemaining in stackql (wire-through)
Two acceptance points in #131 sit in stackql's own layers and are unchanged by
this PR; both now have the any-sdk primitives they need:
SELECT machineTypewithsnake_case_aliases): stillno such column: machineTypefrom the SQLbackend.
unary_selection.gobuilds the column descriptor from the SQLidentifier; with
FindByPathnow alias-aware it can rename the descriptor tothe resolved property's snake display name.
EXEC ... @machine_id): the analyzermatches required exec args by wire name; resolving them through
GetParameter/GetParametersIncludingNativeCasingmakes required andoptional exec args uniform.
analyzeSchemaVsMapshould nil-guard the schema now that a body-less methodreports
nil, nil: an EXEC that supplies a payload to such a method musterror rather than dereference nil.
🤖 Generated with Claude Code