Skip to content

fix(openapi): default explode to true for form and cookie style param…#7891

Open
Roemerdt wants to merge 5 commits intoapi-platform:4.3from
Roemerdt:fix/openapi-parameter-explode-default
Open

fix(openapi): default explode to true for form and cookie style param…#7891
Roemerdt wants to merge 5 commits intoapi-platform:4.3from
Roemerdt:fix/openapi-parameter-explode-default

Conversation

@Roemerdt
Copy link
Copy Markdown

Q A
Branch? 4.3
Tickets Related: #2370, #2783
License MIT
Doc PR

The Parameter class defaults explode to false for all parameters. Per the OpenAPI 3.1 spec (section 4.8.12), the default for explode depends on style: true for form, false for all other styles. OpenAPI 3.2 extends this to also include the new cookie style.

The class already derives style from in when not explicitly set (defaulting to form for query/cookie parameters). This fix applies the same pattern to explode: when not explicitly set, it defaults to true for form and cookie styles, false for everything else.

Current wrong behaviour: Array query parameters (like PropertyFilter's properties[]) are serialised with explode: false in the generated spec, causing Swagger UI to join multiple values with commas (properties[]=name,description) instead of repeating the parameter (properties[]=name&properties[]=description).

Fix: Make $explode nullable, default to null, then resolve based on style in the constructor, matching the OpenAPI spec defaults.

(Came across this while following the DragonTreasure API tutorial from @weaverryan and decided to dive into it.)

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.

1 participant