[BUG][R] Generating R enums results in empty class with no values
Created by: Leo-Rutschmann
Description
I have noticed that R enums are not generated properly, that is, instead of a proper enum structure, an empty class is generated. In it, there is nothing but the to-/fromJSON-methods; the values of the enum - that are specified in the schema - are not present.
openapi-generator version
openapi generator 4.0.1 (gradle plugin)
OpenAPI declaration file content or url
generated with json Schema:
{
"openapi": "3.0.0",
"info": {
"title": "JSON test",
"version": "1.0.0-SNAPSHOT"
},
"paths": {
},
"components": {
"schemas": {
"EnumTest": {
"enum": [
"One",
"Two",
"Three"
],
"type": "string"
}
}
}
}
Command line used for generation
task generate_R_test(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { inputSpec = "$rootDir/src/schema/new/test.schema.json".toString() outputDir = "$rootDir/src/data/r_model/test".toString() generatorName = 'r'
systemProperties = [
models: "", // generate only models, but all of them
]
}
Steps to reproduce
- use the gradle plugin with the above command to generate the enum
- open the enum file (enum_test.R)
- see that it generates an empty class without any of the enum values
Related issues/PRs
I have seearched for this issue but not found a similar case for R (only for Javascript, see https://github.com/swagger-api/swagger-codegen/issues/4819, but I do not know how helpful that will be)
Suggest a fix
I am not really familiar with the whole code, but upon looking at the code, I think the problem is that model.moustache is also used to generate enums. Because the values are described differently in the Schema, they might not be recognised properly