Skip to content

[BUG][PHP] Wrong query parameter name used in generated PHP controller (paramName instead of baseName) #23217

@PhilSeWL

Description

@PhilSeWL

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating PHP server code using openapi-generator, query parameters are read from the Symfony request using paramName instead of the OpenAPI‑defined baseName.
This causes query parameters not to be read correctly whenever:

paramName ≠ baseName (e.g. camelCase vs snake_case)
the OpenAPI parameter uses snake_case (common in OCPI / REST APIs)

As a result:

optional query parameters are silently ignored
filtering logic behaves incorrectly
generated controllers are not compliant with the OpenAPI contract

openapi-generator version

Observed with: 7.21.0-SNAPSHOT
Also reproducible with: latest master at the time of testing
This does not appear to be a regression; behavior exists in current releases.

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Test API
  version: 1.0.0

paths:
  /test:
    get:
      parameters:
        - name: date_from
          in: query
          schema:
            type: string
      responses:
        '200':
          description: OK

In this case:

baseName = date_from
paramName = dateFrom

Generation Details

openapi-generator-cli generate
-g php-symfony
-i openapi.yaml
-o generated
--additional-properties=phpVersion=8.1
``
No custom templates used.

Steps to reproduce
  1. Define a query parameter using snake_case in OpenAPI
  2. Generate PHP Symfony server code
  3. Call the endpoint with ?date_from=...
  4. Observe that the parameter value is null in the controller
Related issues/PRs

No existing issue found that explicitly addresses the paramName vs baseName mismatch for PHP Symfony server generators.

Suggest a fix
- ${{paramName}} = $request->query->get('{{paramName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});
+ ${{paramName}} = $request->query->get('{{baseName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions