Skip to content

Commit e3ba06c

Browse files
jschelbertwing328
authored andcommitted
Fix some bugs for the R client (#6535)
* * Fix bugs in api.mustache, model.mustache, mostly bracket errors or small typos * Added section about installation in README.mustace TODO: fix tests in testthat TODO: fix bug in description.mustace regarding package name * Updates to sample for R client caused by running ./bin/r-petstore.sh (or .\bin\windows\r-petstore.bat) * Add R specific files to .gitignore * [R] add additional files generated by the petstore sample. (see #6520)
1 parent 5e9d977 commit e3ba06c

File tree

24 files changed

+1189
-60
lines changed

24 files changed

+1189
-60
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,6 @@ samples/client/petstore/kotlin/src/main/kotlin/test/
174174
.stack-work
175175
.cabal-sandbox
176176
cabal.project.local
177+
178+
# R
179+
.Rproj.user

modules/swagger-codegen/src/main/resources/r/README.mustache

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,22 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
1818
{{/infoUrl}}
1919

2020
## Installation
21+
You'll need the `devtools` package in order to build the API.
22+
Make sure you have a proper CRAN repository from which you can download packages.
2123

22-
TODO
24+
### Prerequisites
25+
Install the `devtools` package with the following command.
26+
```R
27+
if(!require(devtools)) { install.packages("devtools") }
28+
```
29+
30+
### Installation of the API package
31+
Make sure you set the working directory to where the API code is located.
32+
Then execute
33+
```R
34+
library(devtools)
35+
install(".")
36+
```
2337

2438
## Author
2539

modules/swagger-codegen/src/main/resources/r/api.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
{{#queryParams}}
3737
"{{baseName}}" = {{paramName}}{{#hasMore}},{{/hasMore}}
3838
{{/queryParams}}
39+
)
3940
{{/hasQueryParams}}
4041
)
4142

modules/swagger-codegen/src/main/resources/r/model.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@
8181
{{classname}}Object <- jsonlite::fromJSON({{classname}}Json)
8282
{{#vars}}
8383
{{#isPrimitiveType}}
84-
self$`{{baseName}}` <- {{classname}}Object`${{baseName}}`
84+
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
8585
{{/isPrimitiveType}}
8686
{{^isPrimitiveType}}
8787
{{#isListContainer}}
88-
self$`{{baseName}}` <- lapply({{classname}}Object$`{{baseName}}`, function(x) {{datatype}}$new()$fromJSON(jsonlite::toJSON(x))
88+
self$`{{baseName}}` <- lapply({{classname}}Object$`{{baseName}}`, function(x) {{datatype}}$new()$fromJSON(jsonlite::toJSON(x)))
8989
{{/isListContainer}}
9090
{{^isListContainer}}
91-
self$`{{baseName}}` <- {{datatype}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}))
91+
self$`{{baseName}}` <- {{datatype}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}))
9292
{{/isListContainer}}
9393
{{/isPrimitiveType}}
9494
{{/vars}}

samples/client/petstore/R/.gitignore

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
.Rproj.user
1+
# ref: https://github.com/github/gitignore/blob/master/R.gitignore
2+
3+
# History files
24
.Rhistory
5+
.Rapp.history
6+
7+
# Session Data files
38
.RData
9+
10+
# Example code in package build process
11+
*-Ex.R
12+
13+
# Output files from R CMD build
14+
/*.tar.gz
15+
16+
# Output files from R CMD check
17+
/*.Rcheck/
18+
19+
# RStudio files
20+
.Rproj.user/
21+
22+
# produced vignettes
23+
vignettes/*.html
24+
vignettes/*.pdf
25+
26+
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
27+
.httr-oauth
28+
29+
# knitr and R markdown default cache directories
30+
/*_cache/
31+
/cache/
32+
33+
# Temporary files created by R markdown
34+
*.utf8.md
35+
*.knit.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.3.0-SNAPSHOT

samples/client/petstore/R/.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ref: https://docs.travis-ci.com/user/languages/r/
2+
language: r
3+
cache: packages

samples/client/petstore/R/DESCRIPTION

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
Package: petstore
2-
Title: R Package Client for <http://swagger.io> Petstore APIs
3-
Version: 0.0.0.9000
4-
Authors@R: person("Ramkumar", "Chandrasekaran", email = "ramkumar.november@gmail.com", role = c("aut", "cre"))
5-
Description: R Package Client for <http://swagger.io> Petstore APIs.
2+
Title: R Package Client for Swagger Petstore
3+
Version: 1.0.0
4+
Authors@R: person("Swagger Codegen community", email = "apiteam@swagger.io", role = c("aut", "cre"))
5+
Description: This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
66
Depends: R (>= 3.3.3)
77
Encoding: UTF-8
8-
License: MIT
8+
License: Unlicense
99
LazyData: true
1010
Suggests: testthat
1111
Imports: jsonlite, httr, R6
1212
RoxygenNote: 6.0.1.9000
13-

samples/client/petstore/R/NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(ApiResponse)
4+
export(Category)
35
export(Element)
6+
export(Order)
47
export(Pet)
58
export(PetStoreClient)
69
export(Response)
10+
export(Tag)
11+
export(User)

0 commit comments

Comments
 (0)