Description
I tried to make a new API package using the following with code pulled on September 18. :
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar -i http://petstore.swagger.io/v2/swagger.json -l r -o /tmp/test
Below are a number of suggestions and bugs:
Minor Issue 1: Include Installation Instructions
This would be useful in the README.md.
Set up to use CRAN package repository
setRepositories(ind=1:6)
options(repos="http://cran.rstudio.com/")
if(!require(devtools)) { install.packages("devtools") }
Install package
library(devtools)
install(".")
First Bug: The above doesn't work.
The code needs a NAMESPACE file in the top directory. Any function that had an @export in the template will need to be represented in the NAMESPACE file as below:
export(func1)
export(func2)
Second Bug: Syntax issue
The NAMESPACE can be generated in R, so I tried to do that, but came across this issue when building the NAMESPACE file using roxygen (http://r-pkgs.had.co.nz/namespace.html):
Error in parse(text = lines, n = -1, srcfile = srcfile) :
/tmp/test/R/ApiResponse.r:47:39: unexpected symbol
46: ApiResponseObject <- jsonlite::fromJSON(ApiResponseJson)
47: self$code
<- ApiResponseObject$code
The backtick is in the wrong place, it should be after the dollar sign. Also, the backtick is probably not needed at all unless spaces can appear in the strings.
Third Bug: Use API name in DESCRIPTION
This line:
Package: swagger
will end up conflicting if multiple Swagger packages are installed. Libraries in R are loaded as library(swagger) using the package string. Can "title":"Swagger Petstore" be grabbed instead? The space won't work. Some options: CamelCase or just turn it into all lowercase replacing spaces with underscores or dashes?
Background:
- http://r-pkgs.had.co.nz/package.html (names should be unique)
- https://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file ([Package] should contain only (ASCII) letters, numbers and dot, have at least two characters and start with a letter and not end in a dot.)
Minor Issue 2:
What is git_push.sh for? Is it necessary? Can it be removed from the code generation?
Fourth Bug: Duplicated code
Response and Element classes are duplicated in several files.