Open fantavlik opened 5 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Hi, is there any updates on this issue?
The issue is still relevant btw.
Only fix I've been able to find is to reference enum type:
$ref: "#/components/schemas/YourEnumType"
$ref: "./schemas/YourEnumType.yml"
Inline definitions, such as:
# YourModel.yml
type: object
properties:
your_enum:
type: string
enum:
- value_1
- value_2
unfortunately won't work.
<= v6.6.0
of the generator, but isn't a long-term solution.For users of v7.0.0+
, this issue can be better addressed by setting RESOLVE_INLINE_ENUMS=true
Bug Report Checklist
Description
Enums that are declared inline are simply being declared as strings, while the same enum defined as a separate schema is properly captured with all legal values.
openapi-generator version
4.0.0-SNAPSHOT
built from this commit: https://github.com/OpenAPITools/openapi-generator/commit/b128d1470709c44c6c7b6a906e1993d1c2758b52OpenAPI declaration file content or url
sample.yaml:
Command line used for generation
java -jar openapi-generator-cli.jar generate -i sample.yaml -g go -o ./sample-go
Steps to reproduce
git clone https://github.com/OpenAPITools/openapi-generator.git
cd openapi-generator
git checkout b128d1470709c44c6c7b6a906e1993d1c2758b52
mvn clean install
ln -s modules/openapi-generator-cli/target/openapi-generator-cli.jar .
java -jar openapi-generator-cli.jar generate -i sample.yaml -g go -o ./sample-go
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/2200 https://github.com/OpenAPITools/openapi-generator/issues/1702 https://github.com/OpenAPITools/openapi-generator/issues/1706
Actual vs Expected output
Go: model_status_details.go (actual):
model_status_details.go (expected):
Suggest a fix
PR has been put up: https://github.com/OpenAPITools/openapi-generator/pull/2494