[CORE] Referenced Enums incorrectly tagged isEnum = false
Created by: LukeMarlin
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
With a referenced enum (meaning, a $ref pointing to an enum), a model that uses it in a property will have isEnum = false
. Following a discussion with @jimschubert on slack, it seems that it should be true
.
Expected output: a model property refering to an enum should have "isEnum" : "true"
Acutal output: "isEnum" : "false"
(more precisely, everything seems to be false, but allowableValues
are present: https://gist.github.com/LukeMarlin/1c521cdafe4e7a885e0a79ba221da135#file-extract-of-acutal-output-txt)
openapi-generator version
branch master, commit 47e24af369477
Based on the related issues I've found, this might exist since one or two years already.
OpenAPI declaration file content or url
https://gist.github.com/LukeMarlin/1c521cdafe4e7a885e0a79ba221da135#file-gistfile1-yaml
Command line used for generation
java -jar ./modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i enumSample.yaml -g java -o any
Note: I also tried with a generator I'm writing and I'm not modifying isEnum
, that's why I labelled this CORE. Also, there are existing issues for other generators.
Steps to reproduce
Run the command line with the given file and -DdebugModels to confirm that isEnum
is false
Related issues/PRs
Actually, there are quite some existing issues, but none reached an actual conclusion nor had an official statement about the situation. It is clear that the situation is at least confusing.
Open issues: https://github.com/OpenAPITools/openapi-generator/issues/5610 https://github.com/OpenAPITools/openapi-generator/issues/2645 https://github.com/OpenAPITools/openapi-generator/issues/1783 https://github.com/OpenAPITools/openapi-generator/issues/1559
Also, possibly relevant PR merged by error and reverted: https://github.com/OpenAPITools/openapi-generator/pull/3186 by @jmini
It seems that it's supposed to be included in 4.1.0, but there is no link to the actual commit. It looks like this was incorrectly marked as "included in 4.1.0" because of the merged by error situation.
Suggest a fix
Based on the other issues, it might be a case of backward compatibility stuff. If this is the case, it would be nice to at least know the preferred way to detect a referenced enum. For instance, is the solution proposed here good enough, will that cover corner cases?
If this is not problematic, I'd rather have isEnum = true
, allowing us to easily create the models instead of using a combination of if
s