feat: improve parameter handling#109
Open
mromaszewicz wants to merge 2 commits intooapi-codegen:mainfrom
Open
Conversation
Add AllowReserved support for OpenAPI parameter serialization Add the AllowReserved field to StyleParamOptions, BindStyledParameterOptions, and BindQueryParameterOptions. When set to true for query parameters, RFC 3986 reserved characters are left unencoded in the serialized output, per the OpenAPI 3.x allowReserved specification. Changes: - Add AllowReserved bool to all parameter option structs - Implement escapeQueryAllowReserved for custom escaping that preserves reserved characters while still encoding spaces and control characters - Thread allowReserved through internal helpers (stylePrimitive, styleSlice, styleStruct, styleMap, processFieldDict) - Fix styleStruct recursive call to use StyleParamWithOptions instead of StyleParamWithLocation, which was silently dropping options Partially resolves oapi-codegen/oapi-codegen#1342 Prerequisite for oapi-codegen/oapi-codegen#2183 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add escapeParameterName helper that percent-encodes parameter names in the prefix/separator construction of styleSlice, stylePrimitive, and processFieldDict. This ensures characters like [] in parameter names (e.g. user_ids[]) are properly encoded as %5B%5D in query strings, per RFC 3986. Note: MarshalDeepObject handles its own serialization independently and does not yet encode parameter names in bracket notation. 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 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.
Add AllowReserved support for OpenAPI parameter serialization
Add the AllowReserved field to StyleParamOptions,
BindStyledParameterOptions, and BindQueryParameterOptions. When set to true for query parameters, RFC 3986 reserved characters are left unencoded in the serialized output, per the OpenAPI 3.x allowReserved specification.
Changes:
Partially resolves oapi-codegen/oapi-codegen#1342
Prerequisite for oapi-codegen/oapi-codegen#2183