-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[php][DefaultCodegen.java] Fix invalid enum const names #3524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit a0429a0.
It seems to be a good idea to debug the generated jar and start with a breakpoint in DefaultCodegen and then perform "Step Into" when "importPath→OpenAPI\Client\Model.EnumTest" appears. and then see what happens with outerEnumInteger Enum_Test:
type: object
required:
- enum_string_required
properties:
enum_string:
type: string
enum:
- UPPER
- lower
- ''
enum_string_required:
type: string
enum:
- UPPER
- lower
- ''
enum_integer:
type: integer
format: int32
enum:
- 1
- -1
enum_number:
type: number
format: double
enum:
- 1.1
- -1.2
outerEnum:
$ref: '#/components/schemas/OuterEnum'
outerEnumInteger:
$ref: '#/components/schemas/OuterEnumInteger'
outerEnumDefaultValue:
$ref: '#/components/schemas/OuterEnumDefaultValue'
outerEnumIntegerDefaultValue:
$ref: '#/components/schemas/OuterEnumIntegerDefaultValue' d07efac leads to at some point. But in the end class OuterEnumInteger
{
/**
* Possible values of this enum
*/
const 0 = 0;
const 1 = 1;
const 2 = 2;
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::0,
self::1,
self::2,
];
}
} is generated. Probably because after OuterEnumInteger is processed as part of EnumTest it is also processed later separately: . |
The final approach: change Generated all samples by executing shell scripts in bin and bin/openapi3 folders using a script generate_all_sample_clients.sh. |
Is this PR is still relevant or it should be closed? |
Hi guys, I'm still seeing this issue, which means I can't use the files as they are generated - I have to add another step manually, which beats the purpose. Oddly enough, when I use the version that the Jetbrains plugin retrieves automatically (https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.3/swagger-codegen-cli-3.0.3.jar) , the enum problem doesn't exist (but then there's another bug - BigDecimal instead of float). Is there a version where both issues are fixed? |
@asabramo It seems that you're talking about About bug itself, I don't know whether it fixed or not. Maybe we should add part of the spec from related issue to samples and check PHP syntax of generated models with |
@jebentier, @dkarlovi, @mandrean, @jfastnacht, @ackintosh, @ybelenko, @renepardon
Fix #1475