Open soundstripe opened 4 years ago
Looks like this applies only to numeric values. The following change to line 164 seems to fix it for me:
$this->container['{{name}}'] = isset($data['{{name}}']) ? $data['{{name}}'] : {{#defaultValue}}{{#isEnum}}{{#isNumeric}}self::{{/isNumeric}}{{/isEnum}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}};
The fact that string default values are not referencing the defined enums (instead being passed through the template as literals) was disturbing so I traced that further.... may be a problem here:
Agreed https://github.com/OpenAPITools/openapi-generator/blob/6a61910df15447356a8b223fa465e37781c3fdac/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L5296 may be a problem. Thanks for the trace.
Looks like this applies only to numeric values. The following change to line 164 seems to fix it for me:
Can you please file a PR with the suggested fix?
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:
expected: