[R] fix a couple warnings reported by lintr (#12903)

* better code format in r client

* update code based on lintr

* update samples
This commit is contained in:
William Cheng 2022-07-17 23:49:37 +08:00 committed by GitHub
parent da28e12017
commit eb471db7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1160 additions and 825 deletions

View File

@ -625,7 +625,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
if (example == null) {
example = p.paramName + "_example";
}
example = "'" + escapeText(example) + "'";
example = "\"" + escapeText(example) + "\"";
} else if ("integer".equals(type)) {
if (example == null) {
example = "56";
@ -715,7 +715,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
return "'''" + p.getDefault() + "'''";
else
return "'" + ((String) p.getDefault()).replaceAll("'", "\'") + "'";
return "\"" + ((String) p.getDefault()).replaceAll("\"", "\\\"") + "\"";
}
} else if (ModelUtils.isArraySchema(p)) {
if (p.getDefault() != null) {

View File

@ -11,7 +11,9 @@
#' \describe{
{{#operation}}
#' \strong{ {{operationId}} } \emph{ {{summary}} }
{{#notes}}
#' {{notes}}
{{/notes}}
#'
#' \itemize{
{{#allParams}}
@ -160,8 +162,7 @@
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
}
else {
} else {
self$api_client <- ApiClient$new()
}
},
@ -175,7 +176,7 @@
#' @param {{{paramName}}} {{{description}}}
{{/requiredParams}}
{{#optionalParams}}
#' @param {{{paramName}}} (optional) {{{description}}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
#' @param {{{paramName}}} (optional){{{description}}} {{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
{{/optionalParams}}
{{#vendorExtensions.x-streaming}}
#' @param stream_callback (optional) callback function to process the data stream
@ -186,7 +187,7 @@
#' @param ... Other optional arguments
#' @return {{{returnType}}}{{^returnType}}void{{/returnType}}
#' @export
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback=NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file=NULL, {{/returnType}}...) {
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback=NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
api_response <- self${{{operationId}}}WithHttpInfo({{#allParams}}{{paramName}}, {{/allParams}}{{#vendorExtensions.x-streaming}}stream_callback = stream_callback, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = data_file, {{/returnType}}...)
{{#vendorExtensions.x-streaming}}
if (typeof(stream_callback) == "closure") { # return void if streaming is enabled
@ -236,7 +237,10 @@
stop("Missing required parameter `{{{paramName}}}`.")
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = "Missing required parameter `{{{paramName}}}`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `{{{paramName}}}`."))
rlang::abort(message = "Missing required parameter `{{{paramName}}}`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `{{{paramName}}}`."))
{{/useRlangExceptionHandling}}
}
@ -360,7 +364,9 @@
stop("Failed to deserialize response")
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
{{/useRlangExceptionHandling}}
}
)
@ -374,14 +380,16 @@
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
{{#returnExceptionOnFailure}}
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
{{#useDefaultExceptionHandling}}
stop(error_msg)
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
{{/useRlangExceptionHandling}}
{{/returnExceptionOnFailure}}
{{^returnExceptionOnFailure}}
@ -397,7 +405,9 @@
stop(error_msg)
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
{{/useRlangExceptionHandling}}
{{/returnExceptionOnFailure}}
{{^returnExceptionOnFailure}}
@ -413,7 +423,9 @@
stop(error_msg)
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
{{/useRlangExceptionHandling}}
{{/returnExceptionOnFailure}}
{{^returnExceptionOnFailure}}

View File

@ -69,10 +69,11 @@ ApiClient <- R6::R6Class(
#' @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,
username=NULL, password=NULL, api_keys=NULL,
access_token=NULL, timeout=NULL,
retry_status_codes=NULL, max_retry_attempts=NULL) {
initialize = function(base_path = NULL, user_agent = NULL,
default_headers = NULL,
username = NULL, password = NULL, api_keys = NULL,
access_token = NULL, timeout = NULL,
retry_status_codes = NULL, max_retry_attempts = NULL) {
if (!is.null(base_path)) {
self$base_path <- base_path
}
@ -146,7 +147,7 @@ ApiClient <- R6::R6Class(
resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...)
status_code <- httr::status_code(resp)
} else {
break;
break
}
}
}
@ -178,39 +179,57 @@ ApiClient <- R6::R6Class(
if (method == "GET") {
if (typeof(stream_callback) == "closure") {
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::GET(url, query = query_params, headers, http_timeout,
httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::GET(url, query = query_params, headers, http_timeout,
httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "POST") {
if (typeof(stream_callback) == "closure") {
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::POST(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::POST(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "PUT") {
if (typeof(stream_callback) == "closure") {
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::PUT(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::PUT(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "PATCH") {
if (typeof(stream_callback) == "closure") {
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::PATCH(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::PATCH(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "HEAD") {
if (typeof(stream_callback) == "closure") {
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::HEAD(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::HEAD(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "DELETE") {
if (typeof(stream_callback) == "closure") {
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::DELETE(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::DELETE(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else {
err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
@ -218,7 +237,9 @@ ApiClient <- R6::R6Class(
stop(err_msg)
{{/useDefaultExceptionHandling}}
{{#useRlangExceptionHandling}}
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))
{{/useRlangExceptionHandling}}
}
},
@ -255,16 +276,16 @@ ApiClient <- R6::R6Class(
# To handle the "map" type
if (startsWith(return_type, "map(")) {
inner_return_type <- regmatches(return_type, regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
inner_return_type <- regmatches(return_type,
regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
return_obj <- lapply(names(obj), function(name) {
self$deserializeObj(obj[[name]], inner_return_type, pkg_env)
})
names(return_obj) <- names(obj)
}
# To handle the "array" type
else if (startsWith(return_type, "array[")) {
inner_return_type <- regmatches(return_type, regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
} else if (startsWith(return_type, "array[")) {
# To handle the "array" type
inner_return_type <- regmatches(return_type,
regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
if (c(inner_return_type) %in% primitive_types) {
return_obj <- vector("list", length = length(obj))
if (length(obj) > 0) {
@ -277,24 +298,21 @@ ApiClient <- R6::R6Class(
return_obj <- vector("list", length = nrow(obj))
if (nrow(obj) > 0) {
for (row in 1:nrow(obj)) {
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], inner_return_type, pkg_env)
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE],
inner_return_type, pkg_env)
}
}
}
}
}
# To handle model objects which are not array or map containers. Ex:"Pet"
else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
} else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
# To handle model objects which are not array or map containers. Ex:"Pet"
return_type <- get(return_type, envir = as.environment(pkg_env))
return_obj <- return_type$new()
return_obj$fromJSON(
jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE)
)
}
# To handle primitive type
else {
} else {
# To handle primitive type
return_obj <- obj
}
return_obj

View File

@ -35,7 +35,7 @@ ApiException <- R6::R6Class(
if (!is.null(http_response)) {
self$status <- http_response$status_code
errorMsg <- toString(content(http_response))
if(errorMsg == ""){
if (errorMsg == "") {
errorMsg <- "Api exception encountered. No details given."
}
self$body <- errorMsg
@ -73,12 +73,12 @@ ApiException <- R6::R6Class(
}
if (!is.null(self$body)) {
errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "")
errorMsg <- paste(errorMsg, self$body,"\n")
errorMsg <- paste(errorMsg, self$body, "\n")
}
{{#errorObjectType}}
if (!is.null(self$errorObject)) {
errorMsg <- paste(errorMsg, "Error object : ", "\n", sep = "")
errorMsg <- paste(errorMsg, self$errorObject$toJSONString(),"\n")
errorMsg <- paste(errorMsg, self$errorObject$toJSONString(), "\n")
}
{{/errorObjectType}}
errorMsg

View File

@ -1,6 +1,7 @@
linters: linters_with_defaults(
line_length_linter(160),
object_name_linter = NULL
object_name_linter = NULL,
cyclocomp_linter = NULL
)
exclusions: list(
)

View File

@ -9,7 +9,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
{{classname}} <- R6::R6Class(
'{{classname}}',
"{{classname}}",
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
@ -28,10 +28,11 @@
if (is.null(instance)) {
# do nothing
} {{#anyOf}}else if (get(class(instance)[[1]], pos = -1)$classname == "{{{.}}}") {
self$actual_instance = instance
self$actual_type = "{{{.}}}"
self$actual_instance <- instance
self$actual_type <- "{{{.}}}"
} {{/anyOf}}else {
stop(paste("Failed to initialize {{{classname}}} with anyOf schemas {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Provided class name: ", get(class(instance)[[1]], pos = -1)$classname))
stop(paste("Failed to initialize {{{classname}}} with anyOf schemas {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Provided class name: ",
get(class(instance)[[1]], pos = -1)$classname))
}
},
#' Deserialize JSON string into an instance of {{{classname}}}.
@ -56,13 +57,14 @@
error = function(err) err
)
if (!is.null({{{.}}}_result['error'])) {
error_messages <- append(error_messages, {{{.}}}_result['message'])
if (!is.null({{{.}}}_result["error"])) {
error_messages <- append(error_messages, {{{.}}}_result["message"])
}
{{/anyOf}}
# no match
stop(paste("No match found when deserializing the payload into {{{classname}}} with anyOf schemas {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Details: ", paste(error_messages, collapse = ', ')))
stop(paste("No match found when deserializing the payload into {{{classname}}} with anyOf schemas {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Details: ",
paste(error_messages, collapse = ", ")))
},
#' Serialize {{{classname}}} to JSON string.
#'
@ -121,12 +123,12 @@
#' @export
toString = function() {
jsoncontent <- c(
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) {NULL} else {self$actual_instance$toJSONString()}),
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()),
sprintf('"actual_type": "%s"', self$actual_type),
sprintf('"any_of": "%s"', paste( unlist(self$any_of), collapse=', '))
sprintf('"any_of": "%s"', paste(unlist(self$any_of), collapse = ", "))
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::prettify(paste('{', jsoncontent, '}', sep = "")))
}
as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = "")))
}
)
)

View File

@ -5,7 +5,7 @@
#' @description {{classname}} Class
#' @format An \code{R6Class} generator object
{{#vars}}
#' @field {{name}} {{title}} {{#isContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/isContainer}}{{^isPrimitiveType}}\link{{=<% %>=}}{<%/isPrimitiveType%><%={{ }}=%>{{#isContainer}}{{#items}}{{dataType}}{{/items}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}{{=<% %>=}}<%^isPrimitiveType%>}<%={{ }}=%>{{/isPrimitiveType}}{{#isContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/isContainer}} {{^required}}[optional]{{/required}}
#' @field {{name}} {{title}} {{#isContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/isContainer}}{{^isPrimitiveType}}\link{{=<% %>=}}{<%/isPrimitiveType%><%={{ }}=%>{{#isContainer}}{{#items}}{{dataType}}{{/items}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}{{=<% %>=}}<%^isPrimitiveType%>}<%={{ }}=%>{{/isPrimitiveType}}{{#isContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/isContainer}}{{^required}} [optional]{{/required}}
{{/vars}}
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
@ -15,7 +15,7 @@
{{^isEnum}}
#' @export
{{classname}} <- R6::R6Class(
'{{classname}}',
"{{classname}}",
{{#parent}}
inherit = {{{.}}},
{{/parent}}
@ -37,7 +37,7 @@
#' @param ... Other optional arguments.
#' @export
initialize = function(
{{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
{{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
) {
{{#requiredVars}}
if (!missing(`{{name}}`)) {
@ -139,7 +139,7 @@
{{classname}}Object <- list()
{{#vars}}
if (!is.null(self$`{{name}}`)) {
{{classname}}Object[['{{baseName}}']] <-
{{classname}}Object[["{{baseName}}"]] <-
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
@ -211,62 +211,63 @@
jsoncontent <- c(
{{#vars}}
if (!is.null(self$`{{name}}`)) {
sprintf(
'"{{baseName}}":
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}[%s]
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isContainer}}',
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
paste(unlist(lapply(self$`{{{name}}}`, function(x) paste0('"', x, '"'))), collapse=",")
{{/isPrimitiveType}}
{{^isPrimitiveType}}
paste(sapply(self$`{{{name}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isBoolean}}tolower({{/isBoolean}}self$`{{name}}`{{#isBoolean}}){{/isBoolean}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(self$`{{name}}`$toJSON(), auto_unbox=TRUE, digits = NA)
{{/isPrimitiveType}}
{{/isContainer}}
)}{{^-last}},{{/-last}}
sprintf(
'"{{baseName}}":
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}[%s]
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}{{^isBoolean}}"{{/isBoolean}}%s{{^isBoolean}}"{{/isBoolean}}{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isContainer}}',
{{#isContainer}}
{{#isArray}}
{{#isPrimitiveType}}
paste(unlist(lapply(self$`{{{name}}}`, function(x) paste0('"', x, '"'))), collapse=",")
{{/isPrimitiveType}}
{{^isPrimitiveType}}
paste(sapply(self$`{{{name}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
{{/isPrimitiveType}}
{{/isArray}}
{{#isMap}}
{{#isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isBoolean}}tolower({{/isBoolean}}self$`{{name}}`{{#isBoolean}}){{/isBoolean}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(self$`{{name}}`$toJSON(), auto_unbox=TRUE, digits = NA)
{{/isPrimitiveType}}
{{/isContainer}}
)
}{{^-last}},{{/-last}}
{{/vars}}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of {{{classname}}}
#'

View File

@ -9,7 +9,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
{{classname}} <- R6::R6Class(
'{{classname}}',
"{{classname}}",
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
@ -28,10 +28,11 @@
if (is.null(instance)) {
# do nothing
} {{#oneOf}}else if (get(class(instance)[[1]], pos = -1)$classname == "{{{.}}}") {
self$actual_instance = instance
self$actual_type = "{{{.}}}"
self$actual_instance <- instance
self$actual_type <- "{{{.}}}"
} {{/oneOf}}else {
stop(paste("Failed to initialize {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Provided class name: ", get(class(instance)[[1]], pos = -1)$classname))
stop(paste("Failed to initialize {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Provided class name: ",
get(class(instance)[[1]], pos = -1)$classname))
}
},
#' Deserialize JSON string into an instance of {{{classname}}}.
@ -60,8 +61,8 @@
error = function(err) err
)
if (!is.null({{{.}}}_result['error'])) {
error_messages <- append(error_messages, {{{.}}}_result['message'])
if (!is.null({{{.}}}_result["error"])) {
error_messages <- append(error_messages, {{{.}}}_result["message"])
}
{{/oneOf}}
@ -71,10 +72,11 @@
self$actual_type <- instance_type
} else if (matched > 1) {
# more than 1 match
stop("Multiple matches found when deserializing the payload into {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. ")
stop("Multiple matches found when deserializing the payload into {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}.")
} else {
# no match
stop(paste("No match found when deserializing the payload into {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: ", paste(error_messages, collapse = ', ')))
stop(paste("No match found when deserializing the payload into {{{classname}}} with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: ",
paste(error_messages, collapse = ", ")))
}
self
@ -136,12 +138,12 @@
#' @export
toString = function() {
jsoncontent <- c(
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) {NULL} else {self$actual_instance$toJSONString()}),
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()),
sprintf('"actual_type": "%s"', self$actual_type),
sprintf('"one_of": "%s"', paste( unlist(self$one_of), collapse=', '))
sprintf('"one_of": "%s"', paste(unlist(self$one_of), collapse = ", "))
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::prettify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = "")))
}
)
)

View File

@ -1,6 +1,7 @@
linters: linters_with_defaults(
line_length_linter(160),
object_name_linter = NULL
object_name_linter = NULL,
cyclocomp_linter = NULL
)
exclusions: list(
)

View File

@ -19,7 +19,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
AllofTagApiResponse <- R6::R6Class(
'AllofTagApiResponse',
"AllofTagApiResponse",
public = list(
`id` = NULL,
`name` = NULL,
@ -39,7 +39,7 @@ AllofTagApiResponse <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id`=NULL, `name`=NULL, `code`=NULL, `type`=NULL, `message`=NULL, ...
`id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
@ -72,23 +72,23 @@ AllofTagApiResponse <- R6::R6Class(
toJSON = function() {
AllofTagApiResponseObject <- list()
if (!is.null(self$`id`)) {
AllofTagApiResponseObject[['id']] <-
AllofTagApiResponseObject[["id"]] <-
self$`id`
}
if (!is.null(self$`name`)) {
AllofTagApiResponseObject[['name']] <-
AllofTagApiResponseObject[["name"]] <-
self$`name`
}
if (!is.null(self$`code`)) {
AllofTagApiResponseObject[['code']] <-
AllofTagApiResponseObject[["code"]] <-
self$`code`
}
if (!is.null(self$`type`)) {
AllofTagApiResponseObject[['type']] <-
AllofTagApiResponseObject[["type"]] <-
self$`type`
}
if (!is.null(self$`message`)) {
AllofTagApiResponseObject[['message']] <-
AllofTagApiResponseObject[["message"]] <-
self$`message`
}
@ -131,43 +131,48 @@ AllofTagApiResponse <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)},
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)},
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)},
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)}
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of AllofTagApiResponse
#'

View File

@ -10,13 +10,13 @@
#' @title Animal
#' @description Animal Class
#' @format An \code{R6Class} generator object
#' @field className character
#' @field className character
#' @field color character [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Animal <- R6::R6Class(
'Animal',
"Animal",
public = list(
`className` = NULL,
`color` = NULL,
@ -26,11 +26,11 @@ Animal <- R6::R6Class(
#' Initialize a new Animal class.
#'
#' @param className className
#' @param color color. Default to 'red'.
#' @param color color. Default to "red".
#' @param ... Other optional arguments.
#' @export
initialize = function(
`className`, `color`='red', ...
`className`, `color` = "red", ...
) {
if (!missing(`className`)) {
stopifnot(is.character(`className`), length(`className`) == 1)
@ -51,11 +51,11 @@ Animal <- R6::R6Class(
toJSON = function() {
AnimalObject <- list()
if (!is.null(self$`className`)) {
AnimalObject[['className']] <-
AnimalObject[["className"]] <-
self$`className`
}
if (!is.null(self$`color`)) {
AnimalObject[['color']] <-
AnimalObject[["color"]] <-
self$`color`
}
@ -89,22 +89,24 @@ Animal <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)},
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)}
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Animal
#'

View File

@ -17,7 +17,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
AnyOfPig <- R6::R6Class(
'AnyOfPig',
"AnyOfPig",
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
@ -36,13 +36,14 @@ AnyOfPig <- R6::R6Class(
if (is.null(instance)) {
# do nothing
} else if (get(class(instance)[[1]], pos = -1)$classname == "BasquePig") {
self$actual_instance = instance
self$actual_type = "BasquePig"
self$actual_instance <- instance
self$actual_type <- "BasquePig"
} else if (get(class(instance)[[1]], pos = -1)$classname == "DanishPig") {
self$actual_instance = instance
self$actual_type = "DanishPig"
self$actual_instance <- instance
self$actual_type <- "DanishPig"
} else {
stop(paste("Failed to initialize AnyOfPig with anyOf schemas BasquePig, DanishPig. Provided class name: ", get(class(instance)[[1]], pos = -1)$classname))
stop(paste("Failed to initialize AnyOfPig with anyOf schemas BasquePig, DanishPig. Provided class name: ",
get(class(instance)[[1]], pos = -1)$classname))
}
},
#' Deserialize JSON string into an instance of AnyOfPig.
@ -66,8 +67,8 @@ AnyOfPig <- R6::R6Class(
error = function(err) err
)
if (!is.null(BasquePig_result['error'])) {
error_messages <- append(error_messages, BasquePig_result['message'])
if (!is.null(BasquePig_result["error"])) {
error_messages <- append(error_messages, BasquePig_result["message"])
}
DanishPig_result <- tryCatch({
@ -80,12 +81,13 @@ AnyOfPig <- R6::R6Class(
error = function(err) err
)
if (!is.null(DanishPig_result['error'])) {
error_messages <- append(error_messages, DanishPig_result['message'])
if (!is.null(DanishPig_result["error"])) {
error_messages <- append(error_messages, DanishPig_result["message"])
}
# no match
stop(paste("No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: ", paste(error_messages, collapse = ', ')))
stop(paste("No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: ",
paste(error_messages, collapse = ", ")))
},
#' Serialize AnyOfPig to JSON string.
#'
@ -144,13 +146,13 @@ AnyOfPig <- R6::R6Class(
#' @export
toString = function() {
jsoncontent <- c(
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) {NULL} else {self$actual_instance$toJSONString()}),
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()),
sprintf('"actual_type": "%s"', self$actual_type),
sprintf('"any_of": "%s"', paste( unlist(self$any_of), collapse=', '))
sprintf('"any_of": "%s"', paste(unlist(self$any_of), collapse = ", "))
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::prettify(paste('{', jsoncontent, '}', sep = "")))
}
as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = "")))
}
)
)

View File

@ -74,10 +74,11 @@ ApiClient <- R6::R6Class(
#' @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,
username=NULL, password=NULL, api_keys=NULL,
access_token=NULL, timeout=NULL,
retry_status_codes=NULL, max_retry_attempts=NULL) {
initialize = function(base_path = NULL, user_agent = NULL,
default_headers = NULL,
username = NULL, password = NULL, api_keys = NULL,
access_token = NULL, timeout = NULL,
retry_status_codes = NULL, max_retry_attempts = NULL) {
if (!is.null(base_path)) {
self$base_path <- base_path
}
@ -151,7 +152,7 @@ ApiClient <- R6::R6Class(
resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...)
status_code <- httr::status_code(resp)
} else {
break;
break
}
}
}
@ -182,43 +183,63 @@ ApiClient <- R6::R6Class(
if (method == "GET") {
if (typeof(stream_callback) == "closure") {
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::GET(url, query = query_params, headers, http_timeout,
httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::GET(url, query = query_params, headers, http_timeout,
httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "POST") {
if (typeof(stream_callback) == "closure") {
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::POST(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::POST(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "PUT") {
if (typeof(stream_callback) == "closure") {
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::PUT(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::PUT(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "PATCH") {
if (typeof(stream_callback) == "closure") {
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::PATCH(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::PATCH(url, query = query_params, headers, body = body,
httr::content_type("application/json"), http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "HEAD") {
if (typeof(stream_callback) == "closure") {
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::HEAD(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::HEAD(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else if (method == "DELETE") {
if (typeof(stream_callback) == "closure") {
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
httr::DELETE(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
} else {
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
httr::DELETE(url, query = query_params, headers, http_timeout,
http_timeout, httr::user_agent(self$`user_agent`), ...)
}
} else {
err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
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.
@ -254,16 +275,16 @@ ApiClient <- R6::R6Class(
# To handle the "map" type
if (startsWith(return_type, "map(")) {
inner_return_type <- regmatches(return_type, regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
inner_return_type <- regmatches(return_type,
regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
return_obj <- lapply(names(obj), function(name) {
self$deserializeObj(obj[[name]], inner_return_type, pkg_env)
})
names(return_obj) <- names(obj)
}
# To handle the "array" type
else if (startsWith(return_type, "array[")) {
inner_return_type <- regmatches(return_type, regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
} else if (startsWith(return_type, "array[")) {
# To handle the "array" type
inner_return_type <- regmatches(return_type,
regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
if (c(inner_return_type) %in% primitive_types) {
return_obj <- vector("list", length = length(obj))
if (length(obj) > 0) {
@ -276,24 +297,21 @@ ApiClient <- R6::R6Class(
return_obj <- vector("list", length = nrow(obj))
if (nrow(obj) > 0) {
for (row in 1:nrow(obj)) {
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], inner_return_type, pkg_env)
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE],
inner_return_type, pkg_env)
}
}
}
}
}
# To handle model objects which are not array or map containers. Ex:"Pet"
else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
} else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
# To handle model objects which are not array or map containers. Ex:"Pet"
return_type <- get(return_type, envir = as.environment(pkg_env))
return_obj <- return_type$new()
return_obj$fromJSON(
jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE)
)
}
# To handle primitive type
else {
} else {
# To handle primitive type
return_obj <- obj
}
return_obj

View File

@ -37,7 +37,7 @@ ApiException <- R6::R6Class(
if (!is.null(http_response)) {
self$status <- http_response$status_code
errorMsg <- toString(content(http_response))
if(errorMsg == ""){
if (errorMsg == "") {
errorMsg <- "Api exception encountered. No details given."
}
self$body <- errorMsg
@ -71,11 +71,11 @@ ApiException <- R6::R6Class(
}
if (!is.null(self$body)) {
errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "")
errorMsg <- paste(errorMsg, self$body,"\n")
errorMsg <- paste(errorMsg, self$body, "\n")
}
if (!is.null(self$errorObject)) {
errorMsg <- paste(errorMsg, "Error object : ", "\n", sep = "")
errorMsg <- paste(errorMsg, self$errorObject$toJSONString(),"\n")
errorMsg <- paste(errorMsg, self$errorObject$toJSONString(), "\n")
}
errorMsg
}

View File

@ -10,13 +10,13 @@
#' @title BasquePig
#' @description BasquePig Class
#' @format An \code{R6Class} generator object
#' @field className character
#' @field color character
#' @field className character
#' @field color character
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
BasquePig <- R6::R6Class(
'BasquePig',
"BasquePig",
public = list(
`className` = NULL,
`color` = NULL,
@ -51,11 +51,11 @@ BasquePig <- R6::R6Class(
toJSON = function() {
BasquePigObject <- list()
if (!is.null(self$`className`)) {
BasquePigObject[['className']] <-
BasquePigObject[["className"]] <-
self$`className`
}
if (!is.null(self$`color`)) {
BasquePigObject[['color']] <-
BasquePigObject[["color"]] <-
self$`color`
}
@ -89,22 +89,24 @@ BasquePig <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)},
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)}
sprintf(
'"color":
"%s"
',
self$`color`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of BasquePig
#'

View File

@ -10,14 +10,14 @@
#' @title Cat
#' @description Cat Class
#' @format An \code{R6Class} generator object
#' @field className character
#' @field className character
#' @field color character [optional]
#' @field declawed character [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Cat <- R6::R6Class(
'Cat',
"Cat",
inherit = Animal,
public = list(
`className` = NULL,
@ -29,12 +29,12 @@ Cat <- R6::R6Class(
#' Initialize a new Cat class.
#'
#' @param className className
#' @param color color. Default to 'red'.
#' @param color color. Default to "red".
#' @param declawed declawed
#' @param ... Other optional arguments.
#' @export
initialize = function(
`className`, `color`='red', `declawed`=NULL, ...
`className`, `color` = "red", `declawed` = NULL, ...
) {
if (!missing(`className`)) {
stopifnot(is.character(`className`), length(`className`) == 1)
@ -59,15 +59,15 @@ Cat <- R6::R6Class(
toJSON = function() {
CatObject <- list()
if (!is.null(self$`className`)) {
CatObject[['className']] <-
CatObject[["className"]] <-
self$`className`
}
if (!is.null(self$`color`)) {
CatObject[['color']] <-
CatObject[["color"]] <-
self$`color`
}
if (!is.null(self$`declawed`)) {
CatObject[['declawed']] <-
CatObject[["declawed"]] <-
self$`declawed`
}
@ -104,29 +104,32 @@ Cat <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)},
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)},
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`declawed`)) {
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)}
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Cat
#'

View File

@ -15,7 +15,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
CatAllOf <- R6::R6Class(
'CatAllOf',
"CatAllOf",
public = list(
`declawed` = NULL,
#' Initialize a new CatAllOf class.
@ -27,7 +27,7 @@ CatAllOf <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`declawed`=NULL, ...
`declawed` = NULL, ...
) {
if (!is.null(`declawed`)) {
stopifnot(is.logical(`declawed`), length(`declawed`) == 1)
@ -44,7 +44,7 @@ CatAllOf <- R6::R6Class(
toJSON = function() {
CatAllOfObject <- list()
if (!is.null(self$`declawed`)) {
CatAllOfObject[['declawed']] <-
CatAllOfObject[["declawed"]] <-
self$`declawed`
}
@ -75,15 +75,16 @@ CatAllOf <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`declawed`)) {
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)}
sprintf(
'"declawed":
%s
',
tolower(self$`declawed`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of CatAllOf
#'

View File

@ -16,7 +16,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
Category <- R6::R6Class(
'Category',
"Category",
public = list(
`id` = NULL,
`name` = NULL,
@ -30,7 +30,7 @@ Category <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id`=NULL, `name`=NULL, ...
`id` = NULL, `name` = NULL, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
@ -51,11 +51,11 @@ Category <- R6::R6Class(
toJSON = function() {
CategoryObject <- list()
if (!is.null(self$`id`)) {
CategoryObject[['id']] <-
CategoryObject[["id"]] <-
self$`id`
}
if (!is.null(self$`name`)) {
CategoryObject[['name']] <-
CategoryObject[["name"]] <-
self$`name`
}
@ -89,22 +89,24 @@ Category <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)}
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Category
#'

View File

@ -10,13 +10,13 @@
#' @title DanishPig
#' @description DanishPig Class
#' @format An \code{R6Class} generator object
#' @field className character
#' @field size integer
#' @field className character
#' @field size integer
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DanishPig <- R6::R6Class(
'DanishPig',
"DanishPig",
public = list(
`className` = NULL,
`size` = NULL,
@ -51,11 +51,11 @@ DanishPig <- R6::R6Class(
toJSON = function() {
DanishPigObject <- list()
if (!is.null(self$`className`)) {
DanishPigObject[['className']] <-
DanishPigObject[["className"]] <-
self$`className`
}
if (!is.null(self$`size`)) {
DanishPigObject[['size']] <-
DanishPigObject[["size"]] <-
self$`size`
}
@ -89,22 +89,24 @@ DanishPig <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)},
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)}
sprintf(
'"size":
%d
',
self$`size`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of DanishPig
#'

View File

@ -10,14 +10,14 @@
#' @title Dog
#' @description Dog Class
#' @format An \code{R6Class} generator object
#' @field className character
#' @field className character
#' @field color character [optional]
#' @field breed character [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Dog <- R6::R6Class(
'Dog',
"Dog",
inherit = Animal,
public = list(
`className` = NULL,
@ -29,12 +29,12 @@ Dog <- R6::R6Class(
#' Initialize a new Dog class.
#'
#' @param className className
#' @param color color. Default to 'red'.
#' @param color color. Default to "red".
#' @param breed breed
#' @param ... Other optional arguments.
#' @export
initialize = function(
`className`, `color`='red', `breed`=NULL, ...
`className`, `color` = "red", `breed` = NULL, ...
) {
if (!missing(`className`)) {
stopifnot(is.character(`className`), length(`className`) == 1)
@ -59,15 +59,15 @@ Dog <- R6::R6Class(
toJSON = function() {
DogObject <- list()
if (!is.null(self$`className`)) {
DogObject[['className']] <-
DogObject[["className"]] <-
self$`className`
}
if (!is.null(self$`color`)) {
DogObject[['color']] <-
DogObject[["color"]] <-
self$`color`
}
if (!is.null(self$`breed`)) {
DogObject[['breed']] <-
DogObject[["breed"]] <-
self$`breed`
}
@ -104,29 +104,32 @@ Dog <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`className`)) {
sprintf(
'"className":
"%s"
',
self$`className`
)},
sprintf(
'"className":
"%s"
',
self$`className`
)
},
if (!is.null(self$`color`)) {
sprintf(
'"color":
"%s"
',
self$`color`
)},
sprintf(
'"color":
"%s"
',
self$`color`
)
},
if (!is.null(self$`breed`)) {
sprintf(
'"breed":
"%s"
',
self$`breed`
)}
sprintf(
'"breed":
"%s"
',
self$`breed`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Dog
#'

View File

@ -15,7 +15,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
DogAllOf <- R6::R6Class(
'DogAllOf',
"DogAllOf",
public = list(
`breed` = NULL,
#' Initialize a new DogAllOf class.
@ -27,7 +27,7 @@ DogAllOf <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`breed`=NULL, ...
`breed` = NULL, ...
) {
if (!is.null(`breed`)) {
stopifnot(is.character(`breed`), length(`breed`) == 1)
@ -44,7 +44,7 @@ DogAllOf <- R6::R6Class(
toJSON = function() {
DogAllOfObject <- list()
if (!is.null(self$`breed`)) {
DogAllOfObject[['breed']] <-
DogAllOfObject[["breed"]] <-
self$`breed`
}
@ -75,15 +75,16 @@ DogAllOf <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`breed`)) {
sprintf(
'"breed":
"%s"
',
self$`breed`
)}
sprintf(
'"breed":
"%s"
',
self$`breed`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of DogAllOf
#'

View File

@ -41,8 +41,8 @@
#' #################### FakeDataFile ####################
#'
#' library(petstore)
#' var.dummy <- 'dummy_example' # character | dummy required parameter
#' var.var_data_file <- 'var_data_file_example' # character | header data file
#' var.dummy <- "dummy_example" # character | dummy required parameter
#' var.var_data_file <- "var_data_file_example" # character | header data file
#'
#' #test data_file to ensure it's escaped correctly
#' api.instance <- FakeApi$new()
@ -83,8 +83,7 @@ FakeApi <- R6::R6Class(
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
}
else {
} else {
self$api_client <- ApiClient$new()
}
},
@ -94,12 +93,12 @@ FakeApi <- R6::R6Class(
#' test data_file to ensure it's escaped correctly
#'
#' @param dummy dummy required parameter
#' @param var_data_file (optional) header data file
#' @param var_data_file (optional)header data file
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @return User
#' @export
FakeDataFile = function(dummy, var_data_file=NULL, data_file=NULL, ...) {
FakeDataFile = function(dummy, var_data_file=NULL, data_file = NULL, ...) {
api_response <- self$FakeDataFileWithHttpInfo(dummy, var_data_file, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -129,7 +128,10 @@ FakeApi <- R6::R6Class(
header_params <- c()
if (missing(`dummy`)) {
rlang::abort(message = "Missing required parameter `dummy`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `dummy`."))
rlang::abort(message = "Missing required parameter `dummy`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `dummy`."))
}
body <- NULL
@ -151,28 +153,36 @@ FakeApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
}
)

View File

@ -17,7 +17,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
ModelApiResponse <- R6::R6Class(
'ModelApiResponse',
"ModelApiResponse",
public = list(
`code` = NULL,
`type` = NULL,
@ -33,7 +33,7 @@ ModelApiResponse <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`code`=NULL, `type`=NULL, `message`=NULL, ...
`code` = NULL, `type` = NULL, `message` = NULL, ...
) {
if (!is.null(`code`)) {
stopifnot(is.numeric(`code`), length(`code`) == 1)
@ -58,15 +58,15 @@ ModelApiResponse <- R6::R6Class(
toJSON = function() {
ModelApiResponseObject <- list()
if (!is.null(self$`code`)) {
ModelApiResponseObject[['code']] <-
ModelApiResponseObject[["code"]] <-
self$`code`
}
if (!is.null(self$`type`)) {
ModelApiResponseObject[['type']] <-
ModelApiResponseObject[["type"]] <-
self$`type`
}
if (!is.null(self$`message`)) {
ModelApiResponseObject[['message']] <-
ModelApiResponseObject[["message"]] <-
self$`message`
}
@ -103,29 +103,32 @@ ModelApiResponse <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`code`)) {
sprintf(
'"code":
%d
',
self$`code`
)},
sprintf(
'"code":
%d
',
self$`code`
)
},
if (!is.null(self$`type`)) {
sprintf(
'"type":
"%s"
',
self$`type`
)},
sprintf(
'"type":
"%s"
',
self$`type`
)
},
if (!is.null(self$`message`)) {
sprintf(
'"message":
"%s"
',
self$`message`
)}
sprintf(
'"message":
"%s"
',
self$`message`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of ModelApiResponse
#'

View File

@ -16,7 +16,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
NestedOneOf <- R6::R6Class(
'NestedOneOf',
"NestedOneOf",
public = list(
`size` = NULL,
`nested_pig` = NULL,
@ -30,7 +30,7 @@ NestedOneOf <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`size`=NULL, `nested_pig`=NULL, ...
`size` = NULL, `nested_pig` = NULL, ...
) {
if (!is.null(`size`)) {
stopifnot(is.numeric(`size`), length(`size`) == 1)
@ -51,11 +51,11 @@ NestedOneOf <- R6::R6Class(
toJSON = function() {
NestedOneOfObject <- list()
if (!is.null(self$`size`)) {
NestedOneOfObject[['size']] <-
NestedOneOfObject[["size"]] <-
self$`size`
}
if (!is.null(self$`nested_pig`)) {
NestedOneOfObject[['nested_pig']] <-
NestedOneOfObject[["nested_pig"]] <-
self$`nested_pig`$toJSON()
}
@ -91,22 +91,24 @@ NestedOneOf <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`size`)) {
sprintf(
'"size":
%d
',
self$`size`
)},
sprintf(
'"size":
%d
',
self$`size`
)
},
if (!is.null(self$`nested_pig`)) {
sprintf(
'"nested_pig":
%s
',
jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox=TRUE, digits = NA)
)}
sprintf(
'"nested_pig":
%s
',
jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox=TRUE, digits = NA)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of NestedOneOf
#'

View File

@ -20,7 +20,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
Order <- R6::R6Class(
'Order',
"Order",
public = list(
`id` = NULL,
`petId` = NULL,
@ -42,7 +42,7 @@ Order <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id`=NULL, `petId`=NULL, `quantity`=NULL, `shipDate`=NULL, `status`=NULL, `complete`=FALSE, ...
`id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
@ -79,27 +79,27 @@ Order <- R6::R6Class(
toJSON = function() {
OrderObject <- list()
if (!is.null(self$`id`)) {
OrderObject[['id']] <-
OrderObject[["id"]] <-
self$`id`
}
if (!is.null(self$`petId`)) {
OrderObject[['petId']] <-
OrderObject[["petId"]] <-
self$`petId`
}
if (!is.null(self$`quantity`)) {
OrderObject[['quantity']] <-
OrderObject[["quantity"]] <-
self$`quantity`
}
if (!is.null(self$`shipDate`)) {
OrderObject[['shipDate']] <-
OrderObject[["shipDate"]] <-
self$`shipDate`
}
if (!is.null(self$`status`)) {
OrderObject[['status']] <-
OrderObject[["status"]] <-
self$`status`
}
if (!is.null(self$`complete`)) {
OrderObject[['complete']] <-
OrderObject[["complete"]] <-
self$`complete`
}
@ -145,50 +145,56 @@ Order <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`petId`)) {
sprintf(
'"petId":
%d
',
self$`petId`
)},
sprintf(
'"petId":
%d
',
self$`petId`
)
},
if (!is.null(self$`quantity`)) {
sprintf(
'"quantity":
%d
',
self$`quantity`
)},
sprintf(
'"quantity":
%d
',
self$`quantity`
)
},
if (!is.null(self$`shipDate`)) {
sprintf(
'"shipDate":
"%s"
',
self$`shipDate`
)},
sprintf(
'"shipDate":
"%s"
',
self$`shipDate`
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)},
sprintf(
'"status":
"%s"
',
self$`status`
)
},
if (!is.null(self$`complete`)) {
sprintf(
'"complete":
%s
',
tolower(self$`complete`)
)}
sprintf(
'"complete":
%s
',
tolower(self$`complete`)
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Order
#'

View File

@ -12,15 +12,15 @@
#' @format An \code{R6Class} generator object
#' @field id integer [optional]
#' @field category \link{Category} [optional]
#' @field name character
#' @field photoUrls list( character )
#' @field name character
#' @field photoUrls list( character )
#' @field tags list( \link{Tag} ) [optional]
#' @field status character [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Pet <- R6::R6Class(
'Pet',
"Pet",
public = list(
`id` = NULL,
`category` = NULL,
@ -42,7 +42,7 @@ Pet <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`name`, `photoUrls`, `id`=NULL, `category`=NULL, `tags`=NULL, `status`=NULL, ...
`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ...
) {
if (!missing(`name`)) {
stopifnot(is.character(`name`), length(`name`) == 1)
@ -81,27 +81,27 @@ Pet <- R6::R6Class(
toJSON = function() {
PetObject <- list()
if (!is.null(self$`id`)) {
PetObject[['id']] <-
PetObject[["id"]] <-
self$`id`
}
if (!is.null(self$`category`)) {
PetObject[['category']] <-
PetObject[["category"]] <-
self$`category`$toJSON()
}
if (!is.null(self$`name`)) {
PetObject[['name']] <-
PetObject[["name"]] <-
self$`name`
}
if (!is.null(self$`photoUrls`)) {
PetObject[['photoUrls']] <-
PetObject[["photoUrls"]] <-
self$`photoUrls`
}
if (!is.null(self$`tags`)) {
PetObject[['tags']] <-
PetObject[["tags"]] <-
lapply(self$`tags`, function(x) x$toJSON())
}
if (!is.null(self$`status`)) {
PetObject[['status']] <-
PetObject[["status"]] <-
self$`status`
}
@ -149,50 +149,56 @@ Pet <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`category`)) {
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox=TRUE, digits = NA)
)},
sprintf(
'"category":
%s
',
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox=TRUE, digits = NA)
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)},
sprintf(
'"name":
"%s"
',
self$`name`
)
},
if (!is.null(self$`photoUrls`)) {
sprintf(
'"photoUrls":
[%s]
',
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse=",")
)},
sprintf(
'"photoUrls":
[%s]
',
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse=",")
)
},
if (!is.null(self$`tags`)) {
sprintf(
'"tags":
[%s]
sprintf(
'"tags":
[%s]
',
paste(sapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
)},
paste(sapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
)
},
if (!is.null(self$`status`)) {
sprintf(
'"status":
"%s"
',
self$`status`
)}
sprintf(
'"status":
"%s"
',
self$`status`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Pet
#'

View File

@ -286,7 +286,7 @@
#'
#' library(petstore)
#' var.pet_id <- 56 # integer | Pet id to delete
#' var.api_key <- 'api_key_example' # character |
#' var.api_key <- "api_key_example" # character |
#'
#' #Deletes a pet
#' api.instance <- PetApi$new()
@ -312,7 +312,7 @@
#' #################### FindPetsByStatus ####################
#'
#' library(petstore)
#' var.status <- ['status_example'] # array[character] | Status values that need to be considered for filter
#' var.status <- ["status_example"] # array[character] | Status values that need to be considered for filter
#'
#' #Finds Pets by status
#' api.instance <- PetApi$new()
@ -340,7 +340,7 @@
#' #################### FindPetsByTags ####################
#'
#' library(petstore)
#' var.tags <- ['tags_example'] # array[character] | Tags to filter by
#' var.tags <- ["tags_example"] # array[character] | Tags to filter by
#'
#' #Finds Pets by tags
#' api.instance <- PetApi$new()
@ -453,8 +453,8 @@
#'
#' library(petstore)
#' var.pet_id <- 56 # integer | ID of pet that needs to be updated
#' var.name <- 'name_example' # character | Updated name of the pet
#' var.status <- 'status_example' # character | Updated status of the pet
#' var.name <- "name_example" # character | Updated name of the pet
#' var.status <- "status_example" # character | Updated status of the pet
#'
#' #Updates a pet in the store with form data
#' api.instance <- PetApi$new()
@ -481,7 +481,7 @@
#'
#' library(petstore)
#' var.pet_id <- 56 # integer | ID of pet to update
#' var.additional_metadata <- 'additional_metadata_example' # character | Additional data to pass to server
#' var.additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server
#' var.file <- File.new('/path/to/file') # data.frame | file to upload
#'
#' #uploads an image
@ -526,8 +526,7 @@ PetApi <- R6::R6Class(
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
}
else {
} else {
self$api_client <- ApiClient$new()
}
},
@ -541,7 +540,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Pet
#' @export
AddPet = function(pet, data_file=NULL, ...) {
AddPet = function(pet, data_file = NULL, ...) {
api_response <- self$AddPetWithHttpInfo(pet, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -570,7 +569,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet`)) {
rlang::abort(message = "Missing required parameter `pet`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet`."))
rlang::abort(message = "Missing required parameter `pet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet`."))
}
if (!missing(`pet`)) {
@ -599,28 +601,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Deletes a pet
@ -662,7 +672,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet_id`)) {
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
rlang::abort(message = "Missing required parameter `pet_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet_id`."))
}
body <- NULL
@ -685,22 +698,28 @@ PetApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Finds Pets by status
@ -713,7 +732,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return array[Pet]
#' @export
FindPetsByStatus = function(status, data_file=NULL, ...) {
FindPetsByStatus = function(status, data_file = NULL, ...) {
api_response <- self$FindPetsByStatusWithHttpInfo(status, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -742,7 +761,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`status`)) {
rlang::abort(message = "Missing required parameter `status`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `status`."))
rlang::abort(message = "Missing required parameter `status`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `status`."))
}
body <- NULL
@ -766,28 +788,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Finds Pets by tags
@ -800,7 +830,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return array[Pet]
#' @export
FindPetsByTags = function(tags, data_file=NULL, ...) {
FindPetsByTags = function(tags, data_file = NULL, ...) {
api_response <- self$FindPetsByTagsWithHttpInfo(tags, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -829,7 +859,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`tags`)) {
rlang::abort(message = "Missing required parameter `tags`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `tags`."))
rlang::abort(message = "Missing required parameter `tags`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `tags`."))
}
body <- NULL
@ -853,28 +886,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Find pet by ID
@ -887,7 +928,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Pet
#' @export
GetPetById = function(pet_id, data_file=NULL, ...) {
GetPetById = function(pet_id, data_file = NULL, ...) {
api_response <- self$GetPetByIdWithHttpInfo(pet_id, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -916,7 +957,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet_id`)) {
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
rlang::abort(message = "Missing required parameter `pet_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet_id`."))
}
body <- NULL
@ -946,28 +990,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Find pet by ID (streaming)
@ -981,7 +1033,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Pet
#' @export
GetPetByIdStreaming = function(pet_id, stream_callback=NULL, data_file=NULL, ...) {
GetPetByIdStreaming = function(pet_id, stream_callback=NULL, data_file = NULL, ...) {
api_response <- self$GetPetByIdStreamingWithHttpInfo(pet_id, stream_callback = stream_callback, data_file = data_file, ...)
if (typeof(stream_callback) == "closure") { # return void if streaming is enabled
return(invisible(NULL))
@ -1015,7 +1067,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet_id`)) {
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
rlang::abort(message = "Missing required parameter `pet_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet_id`."))
}
body <- NULL
@ -1050,28 +1105,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Update an existing pet
@ -1084,7 +1147,7 @@ PetApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Pet
#' @export
UpdatePet = function(pet, data_file=NULL, ...) {
UpdatePet = function(pet, data_file = NULL, ...) {
api_response <- self$UpdatePetWithHttpInfo(pet, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -1113,7 +1176,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet`)) {
rlang::abort(message = "Missing required parameter `pet`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet`."))
rlang::abort(message = "Missing required parameter `pet`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet`."))
}
if (!missing(`pet`)) {
@ -1142,28 +1208,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Updates a pet in the store with form data
@ -1172,8 +1246,8 @@ PetApi <- R6::R6Class(
#' Updates a pet in the store with form data
#'
#' @param pet_id ID of pet that needs to be updated
#' @param name (optional) Updated name of the pet
#' @param status (optional) Updated status of the pet
#' @param name (optional)Updated name of the pet
#' @param status (optional)Updated status of the pet
#' @param ... Other optional arguments
#' @return void
#' @export
@ -1207,7 +1281,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet_id`)) {
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
rlang::abort(message = "Missing required parameter `pet_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet_id`."))
}
body <- list(
@ -1234,22 +1311,28 @@ PetApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' uploads an image
@ -1258,13 +1341,13 @@ PetApi <- R6::R6Class(
#' uploads an image
#'
#' @param pet_id ID of pet to update
#' @param additional_metadata (optional) Additional data to pass to server
#' @param file (optional) file to upload
#' @param additional_metadata (optional)Additional data to pass to server
#' @param file (optional)file to upload
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @return ModelApiResponse
#' @export
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...) {
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file = NULL, ...) {
api_response <- self$UploadFileWithHttpInfo(pet_id, additional_metadata, file, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -1295,7 +1378,10 @@ PetApi <- R6::R6Class(
header_params <- c()
if (missing(`pet_id`)) {
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
rlang::abort(message = "Missing required parameter `pet_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `pet_id`."))
}
body <- list(
@ -1327,28 +1413,36 @@ PetApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
}
)

View File

@ -17,7 +17,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
Pig <- R6::R6Class(
'Pig',
"Pig",
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
@ -36,13 +36,14 @@ Pig <- R6::R6Class(
if (is.null(instance)) {
# do nothing
} else if (get(class(instance)[[1]], pos = -1)$classname == "BasquePig") {
self$actual_instance = instance
self$actual_type = "BasquePig"
self$actual_instance <- instance
self$actual_type <- "BasquePig"
} else if (get(class(instance)[[1]], pos = -1)$classname == "DanishPig") {
self$actual_instance = instance
self$actual_type = "DanishPig"
self$actual_instance <- instance
self$actual_type <- "DanishPig"
} else {
stop(paste("Failed to initialize Pig with oneOf schemas BasquePig, DanishPig. Provided class name: ", get(class(instance)[[1]], pos = -1)$classname))
stop(paste("Failed to initialize Pig with oneOf schemas BasquePig, DanishPig. Provided class name: ",
get(class(instance)[[1]], pos = -1)$classname))
}
},
#' Deserialize JSON string into an instance of Pig.
@ -70,8 +71,8 @@ Pig <- R6::R6Class(
error = function(err) err
)
if (!is.null(BasquePig_result['error'])) {
error_messages <- append(error_messages, BasquePig_result['message'])
if (!is.null(BasquePig_result["error"])) {
error_messages <- append(error_messages, BasquePig_result["message"])
}
DanishPig_result <- tryCatch({
@ -85,8 +86,8 @@ Pig <- R6::R6Class(
error = function(err) err
)
if (!is.null(DanishPig_result['error'])) {
error_messages <- append(error_messages, DanishPig_result['message'])
if (!is.null(DanishPig_result["error"])) {
error_messages <- append(error_messages, DanishPig_result["message"])
}
if (matched == 1) {
@ -95,10 +96,11 @@ Pig <- R6::R6Class(
self$actual_type <- instance_type
} else if (matched > 1) {
# more than 1 match
stop("Multiple matches found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. ")
stop("Multiple matches found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig.")
} else {
# no match
stop(paste("No match found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. Details: ", paste(error_messages, collapse = ', ')))
stop(paste("No match found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. Details: ",
paste(error_messages, collapse = ", ")))
}
self
@ -160,12 +162,12 @@ Pig <- R6::R6Class(
#' @export
toString = function() {
jsoncontent <- c(
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) {NULL} else {self$actual_instance$toJSONString()}),
sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()),
sprintf('"actual_type": "%s"', self$actual_type),
sprintf('"one_of": "%s"', paste( unlist(self$one_of), collapse=', '))
sprintf('"one_of": "%s"', paste(unlist(self$one_of), collapse = ", "))
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::prettify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = "")))
}
)
)

View File

@ -20,7 +20,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
Special <- R6::R6Class(
'Special',
"Special",
public = list(
`item_self` = NULL,
`item_private` = NULL,
@ -42,7 +42,7 @@ Special <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`item_self`=NULL, `item_private`=NULL, `item_super`=NULL, `123_number`=NULL, `array[test]`=NULL, `empty_string`=NULL, ...
`item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, ...
) {
if (!is.null(`item_self`)) {
stopifnot(is.numeric(`item_self`), length(`item_self`) == 1)
@ -79,27 +79,27 @@ Special <- R6::R6Class(
toJSON = function() {
SpecialObject <- list()
if (!is.null(self$`item_self`)) {
SpecialObject[['self']] <-
SpecialObject[["self"]] <-
self$`item_self`
}
if (!is.null(self$`item_private`)) {
SpecialObject[['private']] <-
SpecialObject[["private"]] <-
self$`item_private`
}
if (!is.null(self$`item_super`)) {
SpecialObject[['super']] <-
SpecialObject[["super"]] <-
self$`item_super`
}
if (!is.null(self$`123_number`)) {
SpecialObject[['123_number']] <-
SpecialObject[["123_number"]] <-
self$`123_number`
}
if (!is.null(self$`array[test]`)) {
SpecialObject[['array[test]']] <-
SpecialObject[["array[test]"]] <-
self$`array[test]`
}
if (!is.null(self$`empty_string`)) {
SpecialObject[['empty_string']] <-
SpecialObject[["empty_string"]] <-
self$`empty_string`
}
@ -145,50 +145,56 @@ Special <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`item_self`)) {
sprintf(
'"self":
%d
',
self$`item_self`
)},
sprintf(
'"self":
%d
',
self$`item_self`
)
},
if (!is.null(self$`item_private`)) {
sprintf(
'"private":
"%s"
',
self$`item_private`
)},
sprintf(
'"private":
"%s"
',
self$`item_private`
)
},
if (!is.null(self$`item_super`)) {
sprintf(
'"super":
"%s"
',
self$`item_super`
)},
sprintf(
'"super":
"%s"
',
self$`item_super`
)
},
if (!is.null(self$`123_number`)) {
sprintf(
'"123_number":
"%s"
',
self$`123_number`
)},
sprintf(
'"123_number":
"%s"
',
self$`123_number`
)
},
if (!is.null(self$`array[test]`)) {
sprintf(
'"array[test]":
"%s"
',
self$`array[test]`
)},
sprintf(
'"array[test]":
"%s"
',
self$`array[test]`
)
},
if (!is.null(self$`empty_string`)) {
sprintf(
'"empty_string":
"%s"
',
self$`empty_string`
)}
sprintf(
'"empty_string":
"%s"
',
self$`empty_string`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Special
#'

View File

@ -119,7 +119,7 @@
#' #################### DeleteOrder ####################
#'
#' library(petstore)
#' var.order_id <- 'order_id_example' # character | ID of the order that needs to be deleted
#' var.order_id <- "order_id_example" # character | ID of the order that needs to be deleted
#'
#' #Delete purchase order by ID
#' api.instance <- StoreApi$new()
@ -235,8 +235,7 @@ StoreApi <- R6::R6Class(
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
}
else {
} else {
self$api_client <- ApiClient$new()
}
},
@ -277,7 +276,10 @@ StoreApi <- R6::R6Class(
header_params <- c()
if (missing(`order_id`)) {
rlang::abort(message = "Missing required parameter `order_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order_id`."))
rlang::abort(message = "Missing required parameter `order_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `order_id`."))
}
body <- NULL
@ -298,22 +300,28 @@ StoreApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Returns pet inventories by status
@ -325,7 +333,7 @@ StoreApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return map(integer)
#' @export
GetInventory = function(data_file=NULL, ...) {
GetInventory = function(data_file = NULL, ...) {
api_response <- self$GetInventoryWithHttpInfo(data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -375,28 +383,36 @@ StoreApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "map(integer)", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Find purchase order by ID
@ -409,7 +425,7 @@ StoreApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Order
#' @export
GetOrderById = function(order_id, data_file=NULL, ...) {
GetOrderById = function(order_id, data_file = NULL, ...) {
api_response <- self$GetOrderByIdWithHttpInfo(order_id, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -438,7 +454,10 @@ StoreApi <- R6::R6Class(
header_params <- c()
if (missing(`order_id`)) {
rlang::abort(message = "Missing required parameter `order_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order_id`."))
rlang::abort(message = "Missing required parameter `order_id`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `order_id`."))
}
body <- NULL
@ -464,28 +483,36 @@ StoreApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Place an order for a pet
@ -498,7 +525,7 @@ StoreApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return Order
#' @export
PlaceOrder = function(order, data_file=NULL, ...) {
PlaceOrder = function(order, data_file = NULL, ...) {
api_response <- self$PlaceOrderWithHttpInfo(order, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -527,7 +554,10 @@ StoreApi <- R6::R6Class(
header_params <- c()
if (missing(`order`)) {
rlang::abort(message = "Missing required parameter `order`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order`."))
rlang::abort(message = "Missing required parameter `order`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `order`."))
}
if (!missing(`order`)) {
@ -554,28 +584,36 @@ StoreApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
}
)

View File

@ -16,7 +16,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
Tag <- R6::R6Class(
'Tag',
"Tag",
public = list(
`id` = NULL,
`name` = NULL,
@ -30,7 +30,7 @@ Tag <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id`=NULL, `name`=NULL, ...
`id` = NULL, `name` = NULL, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
@ -51,11 +51,11 @@ Tag <- R6::R6Class(
toJSON = function() {
TagObject <- list()
if (!is.null(self$`id`)) {
TagObject[['id']] <-
TagObject[["id"]] <-
self$`id`
}
if (!is.null(self$`name`)) {
TagObject[['name']] <-
TagObject[["name"]] <-
self$`name`
}
@ -89,22 +89,24 @@ Tag <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)}
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of Tag
#'

View File

@ -16,7 +16,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
UpdatePetRequest <- R6::R6Class(
'UpdatePetRequest',
"UpdatePetRequest",
public = list(
`jsonData` = NULL,
`binaryDataN2Information` = NULL,
@ -30,7 +30,7 @@ UpdatePetRequest <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`jsonData`=NULL, `binaryDataN2Information`=NULL, ...
`jsonData` = NULL, `binaryDataN2Information` = NULL, ...
) {
if (!is.null(`jsonData`)) {
stopifnot(R6::is.R6(`jsonData`))
@ -50,11 +50,11 @@ UpdatePetRequest <- R6::R6Class(
toJSON = function() {
UpdatePetRequestObject <- list()
if (!is.null(self$`jsonData`)) {
UpdatePetRequestObject[['jsonData']] <-
UpdatePetRequestObject[["jsonData"]] <-
self$`jsonData`$toJSON()
}
if (!is.null(self$`binaryDataN2Information`)) {
UpdatePetRequestObject[['binaryDataN2Information']] <-
UpdatePetRequestObject[["binaryDataN2Information"]] <-
self$`binaryDataN2Information`
}
@ -90,22 +90,24 @@ UpdatePetRequest <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`jsonData`)) {
sprintf(
'"jsonData":
%s
',
jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox=TRUE, digits = NA)
)},
sprintf(
'"jsonData":
%s
',
jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox=TRUE, digits = NA)
)
},
if (!is.null(self$`binaryDataN2Information`)) {
sprintf(
'"binaryDataN2Information":
"%s"
',
self$`binaryDataN2Information`
)}
sprintf(
'"binaryDataN2Information":
"%s"
',
self$`binaryDataN2Information`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of UpdatePetRequest
#'

View File

@ -22,7 +22,7 @@
#' @importFrom jsonlite fromJSON toJSON
#' @export
User <- R6::R6Class(
'User',
"User",
public = list(
`id` = NULL,
`username` = NULL,
@ -48,7 +48,7 @@ User <- R6::R6Class(
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id`=NULL, `username`=NULL, `firstName`=NULL, `lastName`=NULL, `email`=NULL, `password`=NULL, `phone`=NULL, `userStatus`=NULL, ...
`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
@ -93,35 +93,35 @@ User <- R6::R6Class(
toJSON = function() {
UserObject <- list()
if (!is.null(self$`id`)) {
UserObject[['id']] <-
UserObject[["id"]] <-
self$`id`
}
if (!is.null(self$`username`)) {
UserObject[['username']] <-
UserObject[["username"]] <-
self$`username`
}
if (!is.null(self$`firstName`)) {
UserObject[['firstName']] <-
UserObject[["firstName"]] <-
self$`firstName`
}
if (!is.null(self$`lastName`)) {
UserObject[['lastName']] <-
UserObject[["lastName"]] <-
self$`lastName`
}
if (!is.null(self$`email`)) {
UserObject[['email']] <-
UserObject[["email"]] <-
self$`email`
}
if (!is.null(self$`password`)) {
UserObject[['password']] <-
UserObject[["password"]] <-
self$`password`
}
if (!is.null(self$`phone`)) {
UserObject[['phone']] <-
UserObject[["phone"]] <-
self$`phone`
}
if (!is.null(self$`userStatus`)) {
UserObject[['userStatus']] <-
UserObject[["userStatus"]] <-
self$`userStatus`
}
@ -173,64 +173,72 @@ User <- R6::R6Class(
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)},
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`username`)) {
sprintf(
'"username":
"%s"
',
self$`username`
)},
sprintf(
'"username":
"%s"
',
self$`username`
)
},
if (!is.null(self$`firstName`)) {
sprintf(
'"firstName":
"%s"
',
self$`firstName`
)},
sprintf(
'"firstName":
"%s"
',
self$`firstName`
)
},
if (!is.null(self$`lastName`)) {
sprintf(
'"lastName":
"%s"
',
self$`lastName`
)},
sprintf(
'"lastName":
"%s"
',
self$`lastName`
)
},
if (!is.null(self$`email`)) {
sprintf(
'"email":
"%s"
',
self$`email`
)},
sprintf(
'"email":
"%s"
',
self$`email`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)},
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`phone`)) {
sprintf(
'"phone":
"%s"
',
self$`phone`
)},
sprintf(
'"phone":
"%s"
',
self$`phone`
)
},
if (!is.null(self$`userStatus`)) {
sprintf(
'"userStatus":
%d
',
self$`userStatus`
)}
sprintf(
'"userStatus":
%d
',
self$`userStatus`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste('{', jsoncontent, '}', sep = "")))
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of User
#'

View File

@ -276,7 +276,7 @@
#' #################### DeleteUser ####################
#'
#' library(petstore)
#' var.username <- 'username_example' # character | The name that needs to be deleted
#' var.username <- "username_example" # character | The name that needs to be deleted
#'
#' #Delete user
#' api.instance <- UserApi$new()
@ -302,7 +302,7 @@
#' #################### GetUserByName ####################
#'
#' library(petstore)
#' var.username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing.
#' var.username <- "username_example" # character | The name that needs to be fetched. Use user1 for testing.
#'
#' #Get user by user name
#' api.instance <- UserApi$new()
@ -327,8 +327,8 @@
#' #################### LoginUser ####################
#'
#' library(petstore)
#' var.username <- 'username_example' # character | The user name for login
#' var.password <- 'password_example' # character | The password for login in clear text
#' var.username <- "username_example" # character | The user name for login
#' var.password <- "password_example" # character | The password for login in clear text
#'
#' #Logs user into the system
#' api.instance <- UserApi$new()
@ -378,7 +378,7 @@
#' #################### UpdateUser ####################
#'
#' library(petstore)
#' var.username <- 'username_example' # character | name that need to be deleted
#' var.username <- "username_example" # character | name that need to be deleted
#' var.user <- User$new() # User | Updated user object
#'
#' #Updated user
@ -421,8 +421,7 @@ UserApi <- R6::R6Class(
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
}
else {
} else {
self$api_client <- ApiClient$new()
}
},
@ -463,7 +462,10 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`user`)) {
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
rlang::abort(message = "Missing required parameter `user`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `user`."))
}
if (!missing(`user`)) {
@ -489,22 +491,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Creates list of users with given input array
@ -544,7 +552,10 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`user`)) {
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
rlang::abort(message = "Missing required parameter `user`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `user`."))
}
if (!missing(`user`)) {
@ -571,22 +582,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Creates list of users with given input array
@ -626,7 +643,10 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`user`)) {
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
rlang::abort(message = "Missing required parameter `user`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `user`."))
}
if (!missing(`user`)) {
@ -653,22 +673,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Delete user
@ -708,7 +734,10 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`username`)) {
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
rlang::abort(message = "Missing required parameter `username`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `username`."))
}
body <- NULL
@ -733,22 +762,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Get user by user name
@ -761,7 +796,7 @@ UserApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return User
#' @export
GetUserByName = function(username, data_file=NULL, ...) {
GetUserByName = function(username, data_file = NULL, ...) {
api_response <- self$GetUserByNameWithHttpInfo(username, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -790,7 +825,10 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`username`)) {
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
rlang::abort(message = "Missing required parameter `username`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `username`."))
}
body <- NULL
@ -816,28 +854,36 @@ UserApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Logs user into the system
@ -851,7 +897,7 @@ UserApi <- R6::R6Class(
#' @param ... Other optional arguments
#' @return character
#' @export
LoginUser = function(username, password, data_file=NULL, ...) {
LoginUser = function(username, password, data_file = NULL, ...) {
api_response <- self$LoginUserWithHttpInfo(username, password, data_file = data_file, ...)
resp <- api_response$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
@ -881,11 +927,17 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`username`)) {
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
rlang::abort(message = "Missing required parameter `username`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `username`."))
}
if (missing(`password`)) {
rlang::abort(message = "Missing required parameter `password`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `password`."))
rlang::abort(message = "Missing required parameter `password`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `password`."))
}
body <- NULL
@ -907,28 +959,36 @@ UserApi <- R6::R6Class(
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(resp, "character", loadNamespace("petstore")),
error = function(e) {
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = "Failed to deserialize response",
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
)
ApiResponse$new(deserialized_resp_obj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Logs out current logged in user session
@ -983,22 +1043,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
},
#' Updated user
@ -1040,11 +1106,17 @@ UserApi <- R6::R6Class(
header_params <- c()
if (missing(`username`)) {
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
rlang::abort(message = "Missing required parameter `username`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `username`."))
}
if (missing(`user`)) {
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
rlang::abort(message = "Missing required parameter `user`.",
.subclass = "ApiException",
ApiException = ApiException$new(status = 0,
reason = "Missing required parameter `user`."))
}
if (!missing(`user`)) {
@ -1074,22 +1146,28 @@ UserApi <- R6::R6Class(
ApiResponse$new(NULL, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
error_msg <- toString(content(resp))
if(error_msg == "") {
if (error_msg == "") {
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api client exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
error_msg <- toString(content(resp))
if(error_msg == "") {
error_msg <- "Api server exception encountered."
}
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
rlang::abort(message = error_msg,
.subclass = "ApiException",
ApiException = ApiException$new(http_response = resp))
}
}
)

View File

@ -5,6 +5,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **character** | |
**color** | **character** | | [optional] [default to &#39;red&#39;]
**color** | **character** | | [optional] [default to &quot;red&quot;]

View File

@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **character** | |
**color** | **character** | | [optional] [default to &#39;red&#39;]
**color** | **character** | | [optional] [default to &quot;red&quot;]
**declawed** | **character** | | [optional]

View File

@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **character** | |
**color** | **character** | | [optional] [default to &#39;red&#39;]
**color** | **character** | | [optional] [default to &quot;red&quot;]
**breed** | **character** | | [optional]

View File

@ -18,8 +18,8 @@ test data_file to ensure it's escaped correctly
```R
library(petstore)
var_dummy <- 'dummy_example' # character | dummy required parameter
var_var_data_file <- 'var_data_file_example' # character | header data file
var_dummy <- "dummy_example" # character | dummy required parameter
var_var_data_file <- "var_data_file_example" # character | header data file
#test data_file to ensure it's escaped correctly
api_instance <- FakeApi$new()

View File

@ -88,7 +88,7 @@ Deletes a pet
library(petstore)
var_pet_id <- 56 # integer | Pet id to delete
var_api_key <- 'api_key_example' # character |
var_api_key <- "api_key_example" # character |
#Deletes a pet
api_instance <- PetApi$new()
@ -457,8 +457,8 @@ Updates a pet in the store with form data
library(petstore)
var_pet_id <- 56 # integer | ID of pet that needs to be updated
var_name <- 'name_example' # character | Updated name of the pet
var_status <- 'status_example' # character | Updated status of the pet
var_name <- "name_example" # character | Updated name of the pet
var_status <- "status_example" # character | Updated status of the pet
#Updates a pet in the store with form data
api_instance <- PetApi$new()
@ -517,7 +517,7 @@ uploads an image
library(petstore)
var_pet_id <- 56 # integer | ID of pet to update
var_additional_metadata <- 'additional_metadata_example' # character | Additional data to pass to server
var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server
var_file <- File.new('/path/to/file') # data.frame | file to upload
#uploads an image

View File

@ -21,7 +21,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
```R
library(petstore)
var_order_id <- 'order_id_example' # character | ID of the order that needs to be deleted
var_order_id <- "order_id_example" # character | ID of the order that needs to be deleted
#Delete purchase order by ID
api_instance <- StoreApi$new()

View File

@ -193,7 +193,7 @@ This can only be done by the logged in user.
```R
library(petstore)
var_username <- 'username_example' # character | The name that needs to be deleted
var_username <- "username_example" # character | The name that needs to be deleted
#Delete user
api_instance <- UserApi$new()
@ -250,7 +250,7 @@ Get user by user name
```R
library(petstore)
var_username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing.
var_username <- "username_example" # character | The name that needs to be fetched. Use user1 for testing.
#Get user by user name
api_instance <- UserApi$new()
@ -310,8 +310,8 @@ Logs user into the system
```R
library(petstore)
var_username <- 'username_example' # character | The user name for login
var_password <- 'password_example' # character | The password for login in clear text
var_username <- "username_example" # character | The user name for login
var_password <- "password_example" # character | The password for login in clear text
#Logs user into the system
api_instance <- UserApi$new()
@ -423,7 +423,7 @@ This can only be done by the logged in user.
```R
library(petstore)
var_username <- 'username_example' # character | name that need to be deleted
var_username <- "username_example" # character | name that need to be deleted
var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
#Updated user