Skip to content

[BUG] [R] Code generated not immediately useable #6714

@eddelbuettel

Description

@eddelbuettel

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Using the (Docker-based) openapi-generator-cli on a yaml template used otherwise, I end up with an R package that is not installable as a portion of the files are not parseable by R.

To reproduce:

edd@rob:~$ mkdir /tmp/openapi-generator-issue; cd /tmp/openapi-generator-issue
edd@rob:/tmp/openapi-generator-issue/$ curl https://raw.githubusercontent.com/TileDB-Inc/TileDB-Cloud-API-Spec/master/openapi-v1.yaml -o openapi-v1.yaml
edd@rob:/tmp/openapi-generator-issue/$ docker run --rm -u 1000:1000 -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/openapi-v1.yaml -g r -o /local/r-pkg/
edd@rob:/tmp/openapi-generator-issue/$ cd r-pkg
edd@rob:/tmp/openapi-generator-issue/r-pkg$ R CMD build .                                          # standard step of building R package
edd@rob:/tmp/openapi-generator-issue/r-pkg$ R CMD INSTALL openapi_1.0.0.tar.gz

which fails on

edd@rob:/tmp/openapi-generator-issue/r-pkg$ R CMD INSTALL openapi_1.0.0.tar.gz 
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘openapi’ ...
** using staged installation
** R
Error in parse(outFile) : bad value
ERROR: unable to collate and parse R files for package ‘openapi’
* removing ‘/usr/local/lib/R/site-library/openapi’
* restoring previous ‘/usr/local/lib/R/site-library/openapi’
edd@rob:/tmp/openapi-generator-issue/r-pkg$ 

I am actually pretty experienced in R but find this hard to debug too. We can list the files that yield 'bad value' on sourcing though:

edd@rob:/tmp/openapi-generator-issue/r-pkg/R$ Rscript -e 'files <- dir("."); for (f in files) { res <- try(source(f), silent=TRUE); if (inherits(res, "try-error")) cat("Error processing file", f, "\n") }'
Error processing file activity_event_type.R 
Error processing file array_actions.R 
Error processing file array_task_status.R 
Error processing file array_task_type.R 
Error processing file array_type.R 
Error processing file datatype.R 
Error processing file filter_option.R 
Error processing file filter_type.R 
Error processing file invitation_status.R 
Error processing file invitation_type.R 
Error processing file layout.R 
Error processing file namespace_actions.R 
Error processing file organization_roles.R 
Error processing file pricing_aggregate_usage.R 
Error processing file pricing_currency.R 
Error processing file pricing_interval.R 
Error processing file pricing_type.R 
Error processing file pricing_unit_label.R 
Error processing file public_share_filter.R 
Error processing file querystatus.R 
Error processing file querytype.R 
Error processing file sso_provider.R 
Error processing file udf_actions.R 
Error processing file udf_language.R 
Error processing file udf_result_type.R 
Error processing file udf_type.R 
edd@rob:/tmp/openapi-generator-issue/r-pkg/R$ 


##### openapi-generator version

```sh
edd@rob:/tmp/openapi-generator-issue/r-pkg/R$ docker run --rm openapitools/openapi-generator-cli --version
openapi-generator-cli 5.0.0-SNAPSHOT
  commit : 52b80e9
  built  : 2020-06-18T17:05:53Z
  source : https://github.com/openapitools/openapi-generator
  docs   : https://openapi-generator.tech/

edd@rob:/tmp/openapi-generator-issue/r-pkg/R$ 
OpenAPI declaration file content or url

The YAML file is given above in the snippet and from here: https://github.com/TileDB-Inc/TileDB-Cloud-API-Spec/blob/master/openapi-v1.yaml

Command line used for generation

See above. I used your Docker container, downloaded yesterday

Steps to reproduce

See above, I followed your recommended invocation.

Related issues/PRs

N/A

Suggest a fix

N/A

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