OpenAPITools / OpenAPITools/openapi-generator

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

Open Beginner friendly
#24,816 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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:

https://github.com/OpenAPITools/openapi-generator/blob/4242641f766d500f3ffb48a5481e1f63866a1f1c/samples/client/echo_api/r/R/data_query.R#L37

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

https://github.com/OpenAPITools/openapi-generator/blob/4242641f766d500f3ffb48a5481e1f63866a1f1c/bin/configs/r-echo-api.yaml#L4

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with samples/client/echo_api/r/R/data_query.R at line 37 and reproduce the failure with devtools::test(). Compare the sample configuration in bin/configs/r-echo-api.yaml with the working R client test settings, then trace the R template path that produces = [SUCCESS, FAILURE]. Done means the generated echo_api R package loads and its tests run without the syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.