[BUG][Java] default value in referenced Enum produces corrupted code
Bug Report Checklist
- [ ] Have you provided a full/minimal spec to reproduce the issue?
- [ ] Have you validated the input using an OpenAPI validator (example)?
- [ ] What's the version of OpenAPI Generator used?
- [ ] Have you search for related issues/PRs?
- [ ] What's the actual output vs expected output?
Description
Refed Enum with default value causes build break in jaxrs-jersey generator.
openapi-generator version
current master (4e8599349094ebc47a38baf7a60c4e1712c268d7)
probably since c871e3bc8168c8a9cba5af413d4cc06783320a1a
Build break is a regression. I known that old version also didn't generate a suitable output (cf https://github.com/OpenAPITools/openapi-generator/issues/1323).
OpenAPI declaration file content or url
bug can be reproduced with https://github.com/fujigon/openapi-generator/commit/e80828468593eab9d614cb09861b195b04d4a413
Command line used for generation
re-generate samples with bin/openapi3/jaxrs-jersey-petstore.sh (https://github.com/fujigon/openapi-generator/commit/cab6857d908c436b78622c68335b40da727d732c)
Steps to reproduce
Related issues/PRs
- https://github.com/OpenAPITools/openapi-generator/issues/1323
Suggest a fix
Might be a duplicate of https://github.com/OpenAPITools/openapi-generator/issues/1927
Thanks for reply.The problem is that here causes build break.
Thank you for the analysis. I knew that PR #2001 was not sufficient in some corner cases... but the situation is worse than I thought.
If you have following enum Schemas:
components:
schemas:
IntEnum:
type: integer
format: int32
default: 2
enum:
- 1
- 2
- 3
LongEnum:
type: integer
format: int64
default: 30
enum:
- 20
- 30
- 40
StringEnum:
type: string
default: "b"
enum:
- "c"
- "b"
- "a"
EnumWithCustomName:
type: integer
format: int32
default: 2
enum:
- 1
- 2
x-enum-varnames:
- FOO
- BAR
And following schema:
ObjWithEnumProperties:
type: object
properties:
iprop:
$ref: "#/components/schemas/IntEnum"
lprop:
$ref: "#/components/schemas/LongEnum"
sprop:
$ref: "#/components/schemas/StringEnum"
custom:
$ref: "#/components/schemas/EnumWithCustomName"
Then only the string case is correctly managed. I have the feeling that almost all java generator are affected by the issue.
Let me change the title of this issue.
See PR https://github.com/OpenAPITools/openapi-generator/pull/2175