I am attempting to create R code via OpenAPI Generator which has worked fine generally; now I have realized that there is in fact a problem with enums. When attempting to source() these classes, I get an Error "bad value", which, on inspection makes sense - this is the generated code:
#' EnumTest Class
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
EnumTest <- R6::R6Class(
'EnumTest',
public = list(
initialize = function(, ...){# <-- here is the issue imo (the comma)
local.optional.var <- list(...)
},
toJSON = function() {
EnumTestObject <- list()
EnumTestObject
},
fromJSON = function(EnumTestJson) {
EnumTestObject <- jsonlite::fromJSON(EnumTestJson)
},
toJSONString = function() {
sprintf(
'{
}',
)
},
fromJSONString = function(EnumTestJson) {
EnumTestObject <- jsonlite::fromJSON(EnumTestJson)
self
}
)
)
The issue is the comma in line 10, I think: writing something like function(test, ...)
lets me read the class without error.
The Problem, however, persists: I cannot see any reason why this code would do anything that an enum would, and indeed printing e.g. print(EnumTest$new("enum-value"))
shows that my actual value is nowhere to be found, and $self
is NULL as expected as well.
Was the generated code faulty from the beginning on? or am I missing something?
EDIT:
The entry in my OpenAPI JSON Schema is as follows, if that helps:
"EnumTest": {
"enum": [
"One",
"Two",
"Three"
],
"type": "string"
}`