fix roxygen warnings in oneof, anyof, api_client (#12654)

This commit is contained in:
William Cheng 2022-06-21 16:35:24 +08:00 committed by GitHub
parent 042f717352
commit f2cc3b8611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 134 additions and 44 deletions

View File

@ -1,5 +1,4 @@
{{>partial_header}} {{>partial_header}}
#' ApiClient Class #' ApiClient Class
#' #'
#' Generic API client for OpenAPI client library builds. #' Generic API client for OpenAPI client library builds.
@ -18,11 +17,11 @@
#' @format An \code{R6Class} generator object #' @format An \code{R6Class} generator object
#' @field base_path Base url #' @field base_path Base url
#' @field user_agent Default user agent #' @field user_agent Default user agent
#' @field default_headers #' @field default_headers Default headers
#' @field username Username for HTTP basic authentication #' @field username Username for HTTP basic authentication
#' @field password Password for HTTP basic authentication #' @field password Password for HTTP basic authentication
#' @field api_keys #' @field api_keys API keys
#' @field access_token #' @field access_token Access token
#' @field timeout Default timeout in seconds #' @field timeout Default timeout in seconds
#' @field retry_status_codes vector of status codes to retry #' @field retry_status_codes vector of status codes to retry
#' @field max_retry_attempts maximum number of retries for the status codes #' @field max_retry_attempts maximum number of retries for the status codes
@ -54,7 +53,22 @@ ApiClient <- R6::R6Class(
retry_status_codes = NULL, retry_status_codes = NULL,
# Maximum number of retry attempts for the retry status codes # Maximum number of retry attempts for the retry status codes
max_retry_attempts = NULL, max_retry_attempts = NULL,
# constructor #' Initialize a new ApiClient.
#'
#' @description
#' Initialize a new ApiClient.
#'
#' @param base_path Base path.
#' @param user_agent User agent.
#' @param default_headers Default headers.
#' @param username User name.
#' @param password Password.
#' @param api_keys API keys.
#' @param access_token Access token.
#' @param timeout Timeout.
#' @param retry_status_codes Status codes for retry.
#' @param max_retry_attempts Maxmium number of retry.
#' @export
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL, initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
username=NULL, password=NULL, api_keys=NULL, username=NULL, password=NULL, api_keys=NULL,
access_token=NULL, timeout=NULL, access_token=NULL, timeout=NULL,
@ -101,7 +115,19 @@ ApiClient <- R6::R6Class(
self$max_retry_attempts <- max_retry_attempts self$max_retry_attempts <- max_retry_attempts
} }
}, },
#' Prepare to make an API call with the retry logic.
#'
#' @description
#' Prepare to make an API call with the retry logic.
#'
#' @param url URL.
#' @param method HTTP method.
#' @param query_params The query parameters.
#' @param header_params The header parameters.
#' @param body The HTTP request body.
#' @param ... Other optional arguments.
#' @return HTTP response
#' @export
CallApi = function(url, method, query_params, header_params, body, ...) { CallApi = function(url, method, query_params, header_params, body, ...) {
resp <- self$Execute(url, method, query_params, header_params, body, ...) resp <- self$Execute(url, method, query_params, header_params, body, ...)
@ -126,7 +152,19 @@ ApiClient <- R6::R6Class(
resp resp
}, },
#' Make an API call
#'
#' @description
#' Make an API call
#'
#' @param url URL.
#' @param method HTTP method.
#' @param query_params The query parameters.
#' @param header_params The header parameters.
#' @param body The HTTP request body.
#' @param ... Other optional arguments.
#' @return HTTP response
#' @export
Execute = function(url, method, query_params, header_params, body, ...) { Execute = function(url, method, query_params, header_params, body, ...) {
headers <- httr::add_headers(c(header_params, self$default_headers)) headers <- httr::add_headers(c(header_params, self$default_headers))
@ -158,18 +196,33 @@ ApiClient <- R6::R6Class(
{{/useRlangExceptionHandling}} {{/useRlangExceptionHandling}}
} }
}, },
#' Deserialize the content of api response to the given type.
# Deserialize the content of api response to the given type. #'
#' @description
#' Deserialize the content of api response to the given type.
#'
#' @param resp Response object.
#' @param return_type R return type.
#' @param pkg_env Package environment.
#' @return Deserialized object.
#' @export
deserialize = function(resp, return_type, pkg_env) { deserialize = function(resp, return_type, pkg_env) {
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
self$deserializeObj(resp_obj, return_type, pkg_env) self$deserializeObj(resp_obj, return_type, pkg_env)
}, },
#' Deserialize the response from jsonlite object based on the given type
# Deserialize the response from jsonlite object based on the given type #'
# by handling complex and nested types by iterating recursively #' @description
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc., #' Deserialize the response from jsonlite object based on the given type
#' by handling complex and nested types by iterating recursively
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
#'
#' @param obj Response object.
#' @param return_type R return type.
#' @param pkg_env Package environment.
#' @return Deserialized object.
#' @export
deserializeObj = function(obj, return_type, pkg_env) { deserializeObj = function(obj, return_type, pkg_env) {
return_obj <- NULL return_obj <- NULL
primitive_types <- c("character", "numeric", "integer", "logical", "complex") primitive_types <- c("character", "numeric", "integer", "logical", "complex")

View File

@ -24,7 +24,6 @@
#' #'
#' @param instance an instance of the object defined in the anyOf schemas: {{#anyOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/anyOf}} #' @param instance an instance of the object defined in the anyOf schemas: {{#anyOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/anyOf}}
#' @export #' @export
#' @md
initialize = function(instance = NULL) { initialize = function(instance = NULL) {
if (is.null(instance)) { if (is.null(instance)) {
# do nothing # do nothing
@ -43,7 +42,6 @@
#' @param input The input JSON. #' @param input The input JSON.
#' @return An instance of {{{classname}}}. #' @return An instance of {{{classname}}}.
#' @export #' @export
#' @md
fromJSON = function(input) { fromJSON = function(input) {
error_messages <- list() error_messages <- list()
@ -73,7 +71,6 @@
#' #'
#' @return JSON string reprenation of the {{{classname}}}. #' @return JSON string reprenation of the {{{classname}}}.
#' @export #' @export
#' @md
toJSON = function() { toJSON = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString() self$actual_instance$toJSONString()
@ -89,7 +86,6 @@
#' #'
#' @param input The input JSON. #' @param input The input JSON.
#' @export #' @export
#' @md
validateJSON = function(input) { validateJSON = function(input) {
# backup current values # backup current values
actual_instance_bak <- self$actual_instance actual_instance_bak <- self$actual_instance

View File

@ -24,7 +24,6 @@
#' #'
#' @param instance an instance of the object defined in the oneOf schemas: {{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}} #' @param instance an instance of the object defined in the oneOf schemas: {{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}}
#' @export #' @export
#' @md
initialize = function(instance = NULL) { initialize = function(instance = NULL) {
if (is.null(instance)) { if (is.null(instance)) {
# do nothing # do nothing
@ -43,7 +42,6 @@
#' @param input The input JSON. #' @param input The input JSON.
#' @return An instance of {{{classname}}}. #' @return An instance of {{{classname}}}.
#' @export #' @export
#' @md
fromJSON = function(input) { fromJSON = function(input) {
matched <- 0 # match counter matched <- 0 # match counter
matched_schemas <- list() #names of matched schemas matched_schemas <- list() #names of matched schemas
@ -88,7 +86,6 @@
#' #'
#' @return JSON string reprenation of the {{{classname}}}. #' @return JSON string reprenation of the {{{classname}}}.
#' @export #' @export
#' @md
toJSON = function() { toJSON = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString() self$actual_instance$toJSONString()
@ -104,7 +101,6 @@
#' #'
#' @param input The input JSON. #' @param input The input JSON.
#' @export #' @export
#' @md
validateJSON = function(input) { validateJSON = function(input) {
# backup current values # backup current values
actual_instance_bak <- self$actual_instance actual_instance_bak <- self$actual_instance

View File

@ -32,7 +32,6 @@ AnyOfPig <- R6::R6Class(
#' #'
#' @param instance an instance of the object defined in the anyOf schemas: "BasquePig", "DanishPig" #' @param instance an instance of the object defined in the anyOf schemas: "BasquePig", "DanishPig"
#' @export #' @export
#' @md
initialize = function(instance = NULL) { initialize = function(instance = NULL) {
if (is.null(instance)) { if (is.null(instance)) {
# do nothing # do nothing
@ -54,7 +53,6 @@ AnyOfPig <- R6::R6Class(
#' @param input The input JSON. #' @param input The input JSON.
#' @return An instance of AnyOfPig. #' @return An instance of AnyOfPig.
#' @export #' @export
#' @md
fromJSON = function(input) { fromJSON = function(input) {
error_messages <- list() error_messages <- list()
@ -96,7 +94,6 @@ AnyOfPig <- R6::R6Class(
#' #'
#' @return JSON string reprenation of the AnyOfPig. #' @return JSON string reprenation of the AnyOfPig.
#' @export #' @export
#' @md
toJSON = function() { toJSON = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString() self$actual_instance$toJSONString()
@ -112,7 +109,6 @@ AnyOfPig <- R6::R6Class(
#' #'
#' @param input The input JSON. #' @param input The input JSON.
#' @export #' @export
#' @md
validateJSON = function(input) { validateJSON = function(input) {
# backup current values # backup current values
actual_instance_bak <- self$actual_instance actual_instance_bak <- self$actual_instance

View File

@ -6,7 +6,6 @@
#' Generated by: https://openapi-generator.tech #' Generated by: https://openapi-generator.tech
#' #'
#' ApiClient Class #' ApiClient Class
#' #'
#' Generic API client for OpenAPI client library builds. #' Generic API client for OpenAPI client library builds.
@ -25,11 +24,11 @@
#' @format An \code{R6Class} generator object #' @format An \code{R6Class} generator object
#' @field base_path Base url #' @field base_path Base url
#' @field user_agent Default user agent #' @field user_agent Default user agent
#' @field default_headers #' @field default_headers Default headers
#' @field username Username for HTTP basic authentication #' @field username Username for HTTP basic authentication
#' @field password Password for HTTP basic authentication #' @field password Password for HTTP basic authentication
#' @field api_keys #' @field api_keys API keys
#' @field access_token #' @field access_token Access token
#' @field timeout Default timeout in seconds #' @field timeout Default timeout in seconds
#' @field retry_status_codes vector of status codes to retry #' @field retry_status_codes vector of status codes to retry
#' @field max_retry_attempts maximum number of retries for the status codes #' @field max_retry_attempts maximum number of retries for the status codes
@ -59,7 +58,22 @@ ApiClient <- R6::R6Class(
retry_status_codes = NULL, retry_status_codes = NULL,
# Maximum number of retry attempts for the retry status codes # Maximum number of retry attempts for the retry status codes
max_retry_attempts = NULL, max_retry_attempts = NULL,
# constructor #' Initialize a new ApiClient.
#'
#' @description
#' Initialize a new ApiClient.
#'
#' @param base_path Base path.
#' @param user_agent User agent.
#' @param default_headers Default headers.
#' @param username User name.
#' @param password Password.
#' @param api_keys API keys.
#' @param access_token Access token.
#' @param timeout Timeout.
#' @param retry_status_codes Status codes for retry.
#' @param max_retry_attempts Maxmium number of retry.
#' @export
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL, initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
username=NULL, password=NULL, api_keys=NULL, username=NULL, password=NULL, api_keys=NULL,
access_token=NULL, timeout=NULL, access_token=NULL, timeout=NULL,
@ -106,7 +120,19 @@ ApiClient <- R6::R6Class(
self$max_retry_attempts <- max_retry_attempts self$max_retry_attempts <- max_retry_attempts
} }
}, },
#' Prepare to make an API call with the retry logic.
#'
#' @description
#' Prepare to make an API call with the retry logic.
#'
#' @param url URL.
#' @param method HTTP method.
#' @param query_params The query parameters.
#' @param header_params The header parameters.
#' @param body The HTTP request body.
#' @param ... Other optional arguments.
#' @return HTTP response
#' @export
CallApi = function(url, method, query_params, header_params, body, ...) { CallApi = function(url, method, query_params, header_params, body, ...) {
resp <- self$Execute(url, method, query_params, header_params, body, ...) resp <- self$Execute(url, method, query_params, header_params, body, ...)
@ -131,7 +157,19 @@ ApiClient <- R6::R6Class(
resp resp
}, },
#' Make an API call
#'
#' @description
#' Make an API call
#'
#' @param url URL.
#' @param method HTTP method.
#' @param query_params The query parameters.
#' @param header_params The header parameters.
#' @param body The HTTP request body.
#' @param ... Other optional arguments.
#' @return HTTP response
#' @export
Execute = function(url, method, query_params, header_params, body, ...) { Execute = function(url, method, query_params, header_params, body, ...) {
headers <- httr::add_headers(c(header_params, self$default_headers)) headers <- httr::add_headers(c(header_params, self$default_headers))
@ -157,18 +195,33 @@ ApiClient <- R6::R6Class(
rlang::abort(message = err_msg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = err_msg)) rlang::abort(message = err_msg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = err_msg))
} }
}, },
#' Deserialize the content of api response to the given type.
# Deserialize the content of api response to the given type. #'
#' @description
#' Deserialize the content of api response to the given type.
#'
#' @param resp Response object.
#' @param return_type R return type.
#' @param pkg_env Package environment.
#' @return Deserialized object.
#' @export
deserialize = function(resp, return_type, pkg_env) { deserialize = function(resp, return_type, pkg_env) {
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
self$deserializeObj(resp_obj, return_type, pkg_env) self$deserializeObj(resp_obj, return_type, pkg_env)
}, },
#' Deserialize the response from jsonlite object based on the given type
# Deserialize the response from jsonlite object based on the given type #'
# by handling complex and nested types by iterating recursively #' @description
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc., #' Deserialize the response from jsonlite object based on the given type
#' by handling complex and nested types by iterating recursively
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
#'
#' @param obj Response object.
#' @param return_type R return type.
#' @param pkg_env Package environment.
#' @return Deserialized object.
#' @export
deserializeObj = function(obj, return_type, pkg_env) { deserializeObj = function(obj, return_type, pkg_env) {
return_obj <- NULL return_obj <- NULL
primitive_types <- c("character", "numeric", "integer", "logical", "complex") primitive_types <- c("character", "numeric", "integer", "logical", "complex")

View File

@ -32,7 +32,6 @@ Pig <- R6::R6Class(
#' #'
#' @param instance an instance of the object defined in the oneOf schemas: "BasquePig", "DanishPig" #' @param instance an instance of the object defined in the oneOf schemas: "BasquePig", "DanishPig"
#' @export #' @export
#' @md
initialize = function(instance = NULL) { initialize = function(instance = NULL) {
if (is.null(instance)) { if (is.null(instance)) {
# do nothing # do nothing
@ -54,7 +53,6 @@ Pig <- R6::R6Class(
#' @param input The input JSON. #' @param input The input JSON.
#' @return An instance of Pig. #' @return An instance of Pig.
#' @export #' @export
#' @md
fromJSON = function(input) { fromJSON = function(input) {
matched <- 0 # match counter matched <- 0 # match counter
matched_schemas <- list() #names of matched schemas matched_schemas <- list() #names of matched schemas
@ -112,7 +110,6 @@ Pig <- R6::R6Class(
#' #'
#' @return JSON string reprenation of the Pig. #' @return JSON string reprenation of the Pig.
#' @export #' @export
#' @md
toJSON = function() { toJSON = function() {
if (!is.null(self$actual_instance)) { if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString() self$actual_instance$toJSONString()
@ -128,7 +125,6 @@ Pig <- R6::R6Class(
#' #'
#' @param input The input JSON. #' @param input The input JSON.
#' @export #' @export
#' @md
validateJSON = function(input) { validateJSON = function(input) {
# backup current values # backup current values
actual_instance_bak <- self$actual_instance actual_instance_bak <- self$actual_instance