Skip to content

feat(gen): space delimited query style - #1716

Merged
ernado merged 2 commits into
ogen-go:mainfrom
alpacahq:feat/space-delimited-query-style
Jul 24, 2026
Merged

ernado merged 2 commits into
ogen-go:mainfrom
alpacahq:feat/space-delimited-query-style

Conversation

@m-ali-akbay

Copy link
Copy Markdown
Contributor

Summary

Enables the spaceDelimited query parameter style, which was previously rejected by the generator with ErrNotImplemented.

It was originally disabled because the old implementation joined items on the literal string "%20" and then ran that through url.Values.Encode(), which double-encoded the % (producing %2520). This takes the same approach as the existing pipeDelimited support: join array items with a real space and let url.Values.Encode() handle the encoding.

Details

  • explode: true already behaved like form (repeated keys); this fills in the explode: false case for arrays.
  • On the wire, spaces are encoded as + (the application/x-www-form-urlencoded form). Decoding accepts both + and %20, so round-trips are stable.
  • Objects still aren't allowed for this style, matching the spec (spaceDelimited is array-only).

Tests

  • Re-enabled the previously commented-out spaceDelimited encoder/decoder unit tests, plus a %20 decode case.
  • Added an end-to-end spaceDelimited operation to the parameters integration test.
  • Regenerated code committed separately.

@m-ali-akbay

Copy link
Copy Markdown
Contributor Author

@ernado May I ask for a review?
Or an approval to run the workflows for now 🙏

@ernado
ernado merged commit defc912 into ogen-go:main Jul 24, 2026
15 checks passed
ernado pushed a commit that referenced this pull request Aug 7, 2026
inferParamExplode picked the default from the parameter location instead of the style, so
every query and cookie parameter without an explicit "explode" got explode: true. For
spaceDelimited and pipeDelimited arrays that is the form serialization, and the declared
style is silently dropped. Three array parameters with styles form, pipeDelimited and
spaceDelimited, none of them setting explode, RawQuery observed on the wire:

    before: fm=1&fm=2&fm=3&pd=1&pd=2&pd=3&sp=1&sp=2&sp=3
    after:  fm=1&fm=2&fm=3&pd=1%7C2%7C3&sp=1+2+3

OpenAPI 3.0.3 and 3.1 both say the default is true only when style is form, which is what
the comment in the function already quoted.

The shorthand dates to 6b48c0f (2022-04-14), which introduced the inference.
pipeDelimited arrays were already supported at that commit — uri/query_encoder.go
implemented the style and gen.isSupportedParamStyle rejected pipeDelimited for objects
only — so pipeDelimited has been serialized as form since v0.26.0, four years.
spaceDelimited returned ErrNotImplemented until #1716 enabled it for arrays, extending the
same defect to a second style.

Take the style, not the location. Query and cookie parameters default to style form, so
their default explode is unchanged; path and header parameters default to simple and were
already false. Only an explicitly declared non-form style changes, and only when the spec
does not set explode itself.

The Encoding Object shares the inference, so a urlencoded or multipart body property with
a declared non-form style is corrected the same way. Body observed for an encoding entry
of {tags: {style: pipeDelimited}} over an array of "a", "b", "c":

    before: tags=a&tags=b&tags=c
    after:  tags=a%7Cb%7Cc

deepObject keeps defaulting to true. The style/explode table in validateParamStyle accepts
{deepObject, true} only, so a literal reading of the spec (false for every style but form)
would make a bare "style: deepObject" fail to parse, which three checked-in specs use
(_testdata/positive/parameters.json, _testdata/positive/additionalPropertiesPatternProperties.yml
and the encoding object in _testdata/positive/form.json).

make generate examples produces no diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
robsonpeixoto pushed a commit to robsonpeixoto/ogen that referenced this pull request Aug 30, 2026
inferParamExplode picked the default from the parameter location instead of the style, so
every query and cookie parameter without an explicit "explode" got explode: true. For
spaceDelimited and pipeDelimited arrays that is the form serialization, and the declared
style is silently dropped. Three array parameters with styles form, pipeDelimited and
spaceDelimited, none of them setting explode, RawQuery observed on the wire:

    before: fm=1&fm=2&fm=3&pd=1&pd=2&pd=3&sp=1&sp=2&sp=3
    after:  fm=1&fm=2&fm=3&pd=1%7C2%7C3&sp=1+2+3

OpenAPI 3.0.3 and 3.1 both say the default is true only when style is form, which is what
the comment in the function already quoted.

The shorthand dates to 6b48c0f (2022-04-14), which introduced the inference.
pipeDelimited arrays were already supported at that commit — uri/query_encoder.go
implemented the style and gen.isSupportedParamStyle rejected pipeDelimited for objects
only — so pipeDelimited has been serialized as form since v0.26.0, four years.
spaceDelimited returned ErrNotImplemented until ogen-go#1716 enabled it for arrays, extending the
same defect to a second style.

Take the style, not the location. Query and cookie parameters default to style form, so
their default explode is unchanged; path and header parameters default to simple and were
already false. Only an explicitly declared non-form style changes, and only when the spec
does not set explode itself.

The Encoding Object shares the inference, so a urlencoded or multipart body property with
a declared non-form style is corrected the same way. Body observed for an encoding entry
of {tags: {style: pipeDelimited}} over an array of "a", "b", "c":

    before: tags=a&tags=b&tags=c
    after:  tags=a%7Cb%7Cc

deepObject keeps defaulting to true. The style/explode table in validateParamStyle accepts
{deepObject, true} only, so a literal reading of the spec (false for every style but form)
would make a bare "style: deepObject" fail to parse, which three checked-in specs use
(_testdata/positive/parameters.json, _testdata/positive/additionalPropertiesPatternProperties.yml
and the encoding object in _testdata/positive/form.json).

make generate examples produces no diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
robsonpeixoto pushed a commit to robsonpeixoto/ogen that referenced this pull request Sep 26, 2026
inferParamExplode picked the default from the parameter location instead of the style, so
every query and cookie parameter without an explicit "explode" got explode: true. For
spaceDelimited and pipeDelimited arrays that is the form serialization, and the declared
style is silently dropped. Three array parameters with styles form, pipeDelimited and
spaceDelimited, none of them setting explode, RawQuery observed on the wire:

    before: fm=1&fm=2&fm=3&pd=1&pd=2&pd=3&sp=1&sp=2&sp=3
    after:  fm=1&fm=2&fm=3&pd=1%7C2%7C3&sp=1+2+3

OpenAPI 3.0.3 and 3.1 both say the default is true only when style is form, which is what
the comment in the function already quoted.

The shorthand dates to 6b48c0f (2022-04-14), which introduced the inference.
pipeDelimited arrays were already supported at that commit — uri/query_encoder.go
implemented the style and gen.isSupportedParamStyle rejected pipeDelimited for objects
only — so pipeDelimited has been serialized as form since v0.26.0, four years.
spaceDelimited returned ErrNotImplemented until ogen-go#1716 enabled it for arrays, extending the
same defect to a second style.

Take the style, not the location. Query and cookie parameters default to style form, so
their default explode is unchanged; path and header parameters default to simple and were
already false. Only an explicitly declared non-form style changes, and only when the spec
does not set explode itself.

The Encoding Object shares the inference, so a urlencoded or multipart body property with
a declared non-form style is corrected the same way. Body observed for an encoding entry
of {tags: {style: pipeDelimited}} over an array of "a", "b", "c":

    before: tags=a&tags=b&tags=c
    after:  tags=a%7Cb%7Cc

deepObject keeps defaulting to true. The style/explode table in validateParamStyle accepts
{deepObject, true} only, so a literal reading of the spec (false for every style but form)
would make a bare "style: deepObject" fail to parse, which three checked-in specs use
(_testdata/positive/parameters.json, _testdata/positive/additionalPropertiesPatternProperties.yml
and the encoding object in _testdata/positive/form.json).

make generate examples produces no diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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