Skip to content

[BUG][R] Generated samples/client/echo_api/r cannot be run #24816

Description

@jwimberl

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The generated echo_api client for R breaks out of the box because of invalid R syntax:

initialize = function(`id` = NULL, `outcomes` = [SUCCESS, FAILURE], `suffix` = NULL, `text` = NULL, `date` = NULL, ...) {

The = [SUCCESS, FAILURE] has the appearance of Python code that has snuck in.

openapi-generator version

This is found in the master branch and is an issue in generated integration test code, not an issue found actually running the generator.

OpenAPI declaration file content or url

NA; this is an integration test bug

Generation Details

NA; this is an integration test bug

Steps to reproduce

Navigating to samples/client/echo_api/r, trying to load the package or run tests fails because of the syntax error:

r % Rscript -e 'devtools::test()'
ℹ Testing openapi
Error in `load_all()`:
! Failed to load R/data_query.R
Caused by error in `parse()`:
! At R/data_query.R:37:53: unexpected '['
36:     #' @param ... Other optional arguments.
37:     initialize = function(`id` = NULL, `outcomes` = [
Related issues/PRs

Not found

Suggest a fix

I am not quite sure what template source is responsible for this errant R code. According to

templateDir: modules/openapi-generator/src/main/resources/r

this uses the same template as the working petstore R client tests; however, the latter three all use settings

  exceptionPackage: rlang
  useRlangExceptionHandling: true
  returnExceptionOnFailure: true

do to which they are following a quite different code generation path that might bypass wherever the issue is. I don't see SUCCESS or FAILURE anywhere in that template directory so I couldn't trace it back any further than that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions