fix issues reported by roxygen in r client (#13176)

This commit is contained in:
William Cheng 2022-08-13 12:23:49 +08:00 committed by GitHub
parent 123f92d136
commit 1f42b09b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 42 deletions

View File

@ -173,7 +173,7 @@ ApiClient <- R6::R6Class(
#' @param content_types The HTTP content-type headers. #' @param content_types The HTTP content-type headers.
#' @param body The HTTP request body. #' @param body The HTTP request body.
#' @param is_oauth True if the endpoints required OAuth authentication. #' @param is_oauth True if the endpoints required OAuth authentication.
#' @param oauth_scoeps OAuth scopes. #' @param oauth_scopes OAuth scopes.
#' @param stream_callback Callback function to process the data stream. #' @param stream_callback Callback function to process the data stream.
#' @param ... Other optional arguments. #' @param ... Other optional arguments.
#' @return HTTP response #' @return HTTP response
@ -204,7 +204,7 @@ ApiClient <- R6::R6Class(
#' @param content_types The HTTP content-type headers. #' @param content_types The HTTP content-type headers.
#' @param body The HTTP request body. #' @param body The HTTP request body.
#' @param is_oauth True if the endpoints required OAuth authentication. #' @param is_oauth True if the endpoints required OAuth authentication.
#' @param oauth_scoeps OAuth scopes. #' @param oauth_scopes OAuth scopes.
#' @param stream_callback Callback function to process data stream. #' @param stream_callback Callback function to process data stream.
#' @param ... Other optional arguments. #' @param ... Other optional arguments.
#' @return HTTP response #' @return HTTP response

View File

@ -1,8 +1,21 @@
#' @docType class
#' @title {{classname}}
#' @description {{classname}} Class
#' @format An \code{R6Class} generator object
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export #' @export
{{#allowableValues}} {{#allowableValues}}
{{classname}} <- R6::R6Class( {{classname}} <- R6::R6Class(
"{{classname}}", "{{classname}}",
public = list( public = list(
#' Initialize a new {{{classname}}} class.
#'
#' @description
#' Initialize a new {{{classname}}} class.
#'
#' @param ... Optional arguments.
#' @export
initialize = function(...) { initialize = function(...) {
local.optional.var <- list(...) local.optional.var <- list(...)
val <- unlist(local.optional.var) val <- unlist(local.optional.var)
@ -15,20 +28,50 @@
paste0(enumvec, collapse = ", ")) paste0(enumvec, collapse = ", "))
private$value <- val private$value <- val
}, },
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return {{{classname}}} in JSON format
#' @export
toJSON = function() { toJSON = function() {
jsonlite::toJSON(private$value, auto_unbox = TRUE) jsonlite::toJSON(private$value, auto_unbox = TRUE)
}, },
fromJSON = function({{classname}}Json) { #' Deserialize JSON string into an instance of {{{classname}}}
private$value <- jsonlite::fromJSON({{classname}}Json, #'
#' @description
#' Deserialize JSON string into an instance of {{{classname}}}
#'
#' @param input_json the JSON input
#' @return the instance of {{{classname}}}
#' @export
fromJSON = function(input_json) {
private$value <- jsonlite::fromJSON(input_json,
simplifyVector = FALSE) simplifyVector = FALSE)
self self
}, },
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return {{{classname}}} in JSON format
#' @export
toJSONString = function() { toJSONString = function() {
as.character(jsonlite::toJSON(private$value, as.character(jsonlite::toJSON(private$value,
auto_unbox = TRUE)) auto_unbox = TRUE))
}, },
fromJSONString = function({{classname}}Json) { #' Deserialize JSON string into an instance of {{{classname}}}
private$value <- jsonlite::fromJSON({{classname}}Json, #'
#' @description
#' Deserialize JSON string into an instance of {{{classname}}}
#'
#' @param input_json the JSON input
#' @return the instance of {{{classname}}}
#' @export
fromJSONString = function(input_json) {
private$value <- jsonlite::fromJSON(input_json,
simplifyVector = FALSE) simplifyVector = FALSE)
self self
} }
@ -40,9 +83,7 @@
# add to utils.R # add to utils.R
.parse_{{name}} <- function(vals) { .parse_{{name}} <- function(vals) {
res <- gsub("^\\[|\\]$", "", res <- gsub("^\\[|\\]$", "", "{{{values}}}")
"{{{values}}}"
)
unlist(strsplit(res, ", ")) unlist(strsplit(res, ", "))
} }
{{/allowableValues}} {{/allowableValues}}

View File

@ -166,7 +166,7 @@ ApiClient <- R6::R6Class(
#' @param content_types The HTTP content-type headers. #' @param content_types The HTTP content-type headers.
#' @param body The HTTP request body. #' @param body The HTTP request body.
#' @param is_oauth True if the endpoints required OAuth authentication. #' @param is_oauth True if the endpoints required OAuth authentication.
#' @param oauth_scoeps OAuth scopes. #' @param oauth_scopes OAuth scopes.
#' @param stream_callback Callback function to process the data stream. #' @param stream_callback Callback function to process the data stream.
#' @param ... Other optional arguments. #' @param ... Other optional arguments.
#' @return HTTP response #' @return HTTP response
@ -197,7 +197,7 @@ ApiClient <- R6::R6Class(
#' @param content_types The HTTP content-type headers. #' @param content_types The HTTP content-type headers.
#' @param body The HTTP request body. #' @param body The HTTP request body.
#' @param is_oauth True if the endpoints required OAuth authentication. #' @param is_oauth True if the endpoints required OAuth authentication.
#' @param oauth_scoeps OAuth scopes. #' @param oauth_scopes OAuth scopes.
#' @param stream_callback Callback function to process data stream. #' @param stream_callback Callback function to process data stream.
#' @param ... Other optional arguments. #' @param ... Other optional arguments.
#' @return HTTP response #' @return HTTP response