OpenAPITools / OpenAPITools/openapi-generator

[BUG] code generation PHP generates duplicate function names for operationID

Open
#2,549 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist

I have the following snippet in my .yaml file for my api. I am generating a php client and I get duplicate function names

public function addCustomer($customer = null, $image = null)
public function addCustomer($body)

This is not allowed in php and generates a syntax error. How can I have an operating type per request type?

yaml operation id addCustomer

  summary: Add a new customer to the store
  operationId: addCustomer
  requestBody:
    content:
      application/json:
        schema:
          $ref: '#/components/schemas/NewCustomerWithImageUrl'
      multipart/form-data:
        schema:
          $ref: '#/components/schemas/NewCustomerWithImage'
    description: Customer object that needs to be added to the store
    required: true

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI YAML, especially the addCustomer operationId and its JSON and multipart request bodies, then reproduce the generated PHP client output. Trace how those request variants become methods; done means the PHP client no longer contains duplicate addCustomer function names and generates valid syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, php, yaml
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.