OpenAPITools / OpenAPITools/openapi-generator
PHP Client does not handle default values correctly when they are ENUM references
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
The default values set in the constructor for PHP Model classes does not correctly reference self::.
I believe the offending code is this line:
https://github.com/OpenAPITools/openapi-generator/blob/d9a6f4d7261d523d933e4cd33e6abc48d4d0b5e2/modules/openapi-generator/src/main/resources/php/model_generic.mustache#L164
example generated code:
$this->container['code'] = isset($data['code']) ? $data['code'] : CODE_200;
expected:
$this->container['code'] = isset($data['code']) ? $data['code'] : self::CODE_200;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/resources/php/model_generic.mustache at the referenced line and inspect how default values are rendered for enum references. Generate a PHP model containing an enum default and verify that the resulting constructor uses self::CODE_200 rather than CODE_200; done means the generated default is a valid class-constant reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100