This repository was archived by the owner on Apr 14, 2026. It is now read-only.
Fix form-urlencoded request body code generation#6
Merged
mromaszewicz merged 1 commit intomainfrom Feb 8, 2026
Merged
Conversation
Operations with application/x-www-form-urlencoded request bodies produced uncompilable code: the SimpleClient referenced undefined typed body structs and methods because the code generator only recognized application/json content types. This change introduces a config-driven ContentTypeMatcher that determines which content types get typed request body methods, replacing the hard-coded IsJSON checks. form-urlencoded is now included in the default content-type list alongside JSON. For form-encoded bodies, serialization uses a new marshalForm helper (reflection-based, using json struct tags) instead of json.Marshal, avoiding a JSON round-trip that would produce incorrect form encoding. Key changes: - Replace RequestBodyDescriptor.IsJSON with GenerateTyped (config-driven) and IsFormEncoded (content-type flag) - Add ContentTypeMatcher to operationGatherer and all Gather*Operations call sites - Add DefaultTypedBody/HasTypedBody to OperationDescriptor so the SimpleClient template picks the correct typed body - Add marshalForm/marshalFormImpl helper template for struct-to-url.Values serialization - Update client, initiator, and simple-client templates to branch on IsFormEncoded vs JSON for body serialization Closes #2 Co-Authored-By: Claude Opus 4.6 <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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Operations with application/x-www-form-urlencoded request bodies produced uncompilable code: the SimpleClient referenced undefined typed body structs and methods because the code generator only recognized application/json content types.
This change introduces a config-driven ContentTypeMatcher that determines which content types get typed request body methods, replacing the hard-coded IsJSON checks. form-urlencoded is now included in the default content-type list alongside JSON.
For form-encoded bodies, serialization uses a new marshalForm helper (reflection-based, using json struct tags) instead of json.Marshal, avoiding a JSON round-trip that would produce incorrect form encoding.
Key changes:
Closes #2