0

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"
  }`
Yato
  • 64
  • 8
  • apparently it is a bug in the OpenAPI generator itself; I have issued a bug report on their github repo, but I think I will keep this question open for others with the same problem – Yato Jul 16 '19 at 15:01
  • Yup, it's not yet supported. We need help from the community to implement the enum support in the R client: https://github.com/OpenAPITools/openapi-generator/issues/3367. – William Cheng Jul 27 '19 at 03:52

0 Answers0