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$
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
See above. I used your Docker container, downloaded yesterday
See above, I followed your recommended invocation.
N/A
N/A
I've tested your spec with this PR: https://github.com/OpenAPITools/openapi-generator/pull/5728, which provides better support for Enum in R.
I was able to install it after purging some incorrect test files generated for Enum type:
/tmp/R-test $ R CMD INSTALL openapi_1.0.0.tar.gz
* installing to library ‘/usr/local/lib/R/3.5/site-library’
* installing *source* package ‘openapi’ ...
** R
** byte-compile and prepare package for lazy loading
** help
No man pages found in package ‘openapi’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (openapi)
Can you please also give it a try by building the JAR locally?
git checkout -b LiNk-NY-enum master
git pull https://github.com/LiNk-NY/openapi-generator.git enum
mvn clean package -DskipTests
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g r -i ~/Downloads/openapi-v1.txt -o /tmp/R-test
Thanks for the reply, and happy to try, but could you (if possible) provide a Docker-based setup? I have very little Java on my machine. What container with mvn could I start from?
I leaned on a colleague and we got it sorted out. Thumbs up for the PR https://github.com/OpenAPITools/openapi-generator/pull/5728. Resulting package now builds, lacks some documentation (normal at this stage) and fails some unit tests (ditto). I can live with that.
So take this as my thumbs up for merging the PR!
(For completeness I updated the initial post with the new URL of the YAML file describing our service; we have done some work at our end and that repo is now public.)
There is one new bug. The generated code tries to deparse a content field on the returned JSON but does not notice that the chars are raw and need to converted from raw first. Shall I file a new issue for that?
Yes please open a new issue with the details for tracking
Done, #6767. Thanks in advance for your consideration, it is appreciated!
For the enum issue in auto-generated test files, I've filed https://github.com/OpenAPITools/openapi-generator/pull/6936 to fix it.
I am getting the same error as OP when I try to build my package: Error in parse(outFile) : bad value.
Steps to reproduce:
git clone https://github.com/Scripta-Qumranica-Electronica/SQE_API_Connectors.git
cd SQE_API_Connectors/libs/r
R CMD build .
R CMD check qumranicaApiConnector_0.7.2.tar.gz
Unfortunately I don't have enough experience with building R packages to debug much further than that, but perhaps there is some data type in my openapi spec that is giving some trouble.
The r client code can be generated from the project root SQE_API_Connectors folder with yarn generate-r-api (assuming you have the node dependencies installed by running yarn --pure-lockfile at the project root). I am using v2.0.3 of @openapitools/openapi-generator-cli.
Thanks for any help you can provide, this is a really cool project.
Most helpful comment
I leaned on a colleague and we got it sorted out. Thumbs up for the PR https://github.com/OpenAPITools/openapi-generator/pull/5728. Resulting package now builds, lacks some documentation (normal at this stage) and fails some unit tests (ditto). I can live with that.
So take this as my thumbs up for merging the PR!