mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
R echo client tests (#17629)
* add r echo api client sample * add r workflow * fix * add env * set r version * install curl * install dep * fix * comment out installation
This commit is contained in:
391
samples/client/echo_api/r/R/api_client.R
Normal file
391
samples/client/echo_api/r/R/api_client.R
Normal file
@@ -0,0 +1,391 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' ApiClient Class
|
||||
#'
|
||||
#' Generic API client for OpenAPI client library builds.
|
||||
#' OpenAPI generic API client. This client handles the client-
|
||||
#' server communication, and is invariant across implementations. Specifics of
|
||||
#' the methods and models for each application are generated from the OpenAPI Generator
|
||||
#' templates.
|
||||
#'
|
||||
#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
#' Ref: https://openapi-generator.tech
|
||||
#' Do not edit the class manually.
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title ApiClient
|
||||
#' @description ApiClient Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field base_path Base url
|
||||
#' @field user_agent Default user agent
|
||||
#' @field default_headers Default headers
|
||||
#' @field username Username for HTTP basic authentication
|
||||
#' @field password Password for HTTP basic authentication
|
||||
#' @field api_keys API keys
|
||||
#' @field bearer_token Bearer token
|
||||
#' @field timeout Default timeout in seconds
|
||||
#' @field retry_status_codes vector of status codes to retry
|
||||
#' @field max_retry_attempts maximum number of retries for the status codes
|
||||
#' @importFrom httr add_headers accept timeout content
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
"ApiClient",
|
||||
public = list(
|
||||
# base path of all requests
|
||||
base_path = "http://localhost:3000",
|
||||
# user agent in the HTTP request
|
||||
user_agent = "OpenAPI-Generator/1.0.0/r",
|
||||
# default headers in the HTTP request
|
||||
default_headers = NULL,
|
||||
# username (HTTP basic authentication)
|
||||
username = NULL,
|
||||
# password (HTTP basic authentication)
|
||||
password = NULL,
|
||||
# API keys
|
||||
api_keys = NULL,
|
||||
# Bearer token
|
||||
bearer_token = NULL,
|
||||
# Time Out (seconds)
|
||||
timeout = NULL,
|
||||
# Vector of status codes to retry
|
||||
retry_status_codes = NULL,
|
||||
# Maximum number of retry attempts for the retry status codes
|
||||
max_retry_attempts = NULL,
|
||||
#' Initialize a new ApiClient.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new ApiClient.
|
||||
#'
|
||||
#' @param base_path Base path.
|
||||
#' @param user_agent User agent.
|
||||
#' @param default_headers Default headers.
|
||||
#' @param username User name.
|
||||
#' @param password Password.
|
||||
#' @param api_keys API keys.
|
||||
#' @param access_token Access token.
|
||||
#' @param bearer_token Bearer token.
|
||||
#' @param timeout Timeout.
|
||||
#' @param retry_status_codes Status codes for retry.
|
||||
#' @param max_retry_attempts Maxmium number of retry.
|
||||
#' @export
|
||||
initialize = function(base_path = NULL, user_agent = NULL,
|
||||
default_headers = NULL,
|
||||
username = NULL, password = NULL, api_keys = NULL,
|
||||
access_token = NULL, bearer_token = NULL, timeout = NULL,
|
||||
retry_status_codes = NULL, max_retry_attempts = NULL) {
|
||||
if (!is.null(base_path)) {
|
||||
self$base_path <- base_path
|
||||
}
|
||||
|
||||
if (!is.null(default_headers)) {
|
||||
self$default_headers <- default_headers
|
||||
}
|
||||
|
||||
if (!is.null(username)) {
|
||||
self$username <- username
|
||||
}
|
||||
|
||||
if (!is.null(password)) {
|
||||
self$password <- password
|
||||
}
|
||||
|
||||
if (!is.null(access_token)) {
|
||||
self$access_token <- access_token
|
||||
}
|
||||
|
||||
if (!is.null(bearer_token)) {
|
||||
self$bearer_token <- bearer_token
|
||||
}
|
||||
|
||||
if (!is.null(api_keys)) {
|
||||
self$api_keys <- api_keys
|
||||
} else {
|
||||
self$api_keys <- list()
|
||||
}
|
||||
|
||||
if (!is.null(user_agent)) {
|
||||
self$`user_agent` <- user_agent
|
||||
}
|
||||
|
||||
if (!is.null(timeout)) {
|
||||
self$timeout <- timeout
|
||||
}
|
||||
|
||||
if (!is.null(retry_status_codes)) {
|
||||
self$retry_status_codes <- retry_status_codes
|
||||
}
|
||||
|
||||
if (!is.null(max_retry_attempts)) {
|
||||
self$max_retry_attempts <- max_retry_attempts
|
||||
}
|
||||
},
|
||||
#' Prepare to make an API call with the retry logic.
|
||||
#'
|
||||
#' @description
|
||||
#' Prepare to make an API call with the retry logic.
|
||||
#'
|
||||
#' @param url URL.
|
||||
#' @param method HTTP method.
|
||||
#' @param query_params The query parameters.
|
||||
#' @param header_params The header parameters.
|
||||
#' @param form_params The form parameters.
|
||||
#' @param file_params The form parameters for uploading files.
|
||||
#' @param accepts The list of Accept headers.
|
||||
#' @param content_types The list of Content-Type headers.
|
||||
#' @param body The HTTP request body.
|
||||
#' @param stream_callback Callback function to process the data stream
|
||||
#' @param ... Other optional arguments.
|
||||
#' @return HTTP response
|
||||
#' @export
|
||||
CallApi = function(url, method, query_params, header_params, form_params,
|
||||
file_params, accepts, content_types,
|
||||
body, stream_callback = NULL, ...) {
|
||||
|
||||
resp <- self$Execute(url, method, query_params, header_params,
|
||||
form_params, file_params,
|
||||
accepts, content_types,
|
||||
body, stream_callback = stream_callback, ...)
|
||||
|
||||
if (is.null(self$max_retry_attempts)) {
|
||||
self$max_retry_attempts <- 3
|
||||
}
|
||||
|
||||
if (!is.null(self$retry_status_codes)) {
|
||||
|
||||
for (i in 1 : self$max_retry_attempts) {
|
||||
if (resp$status_code %in% self$retry_status_codes) {
|
||||
Sys.sleep((2 ^ i) + stats::runif(n = 1, min = 0, max = 1))
|
||||
resp <- self$Execute(url, method, query_params, header_params,
|
||||
form_params, file_params, accepts, content_types,
|
||||
body, stream_callback = stream_callback, ...)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resp
|
||||
},
|
||||
#' Make an API call
|
||||
#'
|
||||
#' @description
|
||||
#' Make an API call
|
||||
#'
|
||||
#' @param url URL.
|
||||
#' @param method HTTP method.
|
||||
#' @param query_params The query parameters.
|
||||
#' @param header_params The header parameters.
|
||||
#' @param form_params The form parameters.
|
||||
#' @param file_params The form parameters for uploading files.
|
||||
#' @param accepts The list of Accept headers
|
||||
#' @param content_types The list of Content-Type headers
|
||||
#' @param body The HTTP request body.
|
||||
#' @param stream_callback Callback function to process data stream
|
||||
#' @param ... Other optional arguments.
|
||||
#' @return HTTP response
|
||||
#' @export
|
||||
Execute = function(url, method, query_params, header_params,
|
||||
form_params, file_params,
|
||||
accepts, content_types,
|
||||
body, stream_callback = NULL, ...) {
|
||||
headers <- httr::add_headers(c(header_params, self$default_headers))
|
||||
|
||||
http_timeout <- NULL
|
||||
if (!is.null(self$timeout)) {
|
||||
http_timeout <- httr::timeout(self$timeout)
|
||||
}
|
||||
|
||||
# set HTTP accept header
|
||||
accept = self$select_header(accepts)
|
||||
if (!is.null(accept)) {
|
||||
headers['Accept'] = accept
|
||||
}
|
||||
|
||||
# set HTTP content-type header
|
||||
content_type = self$select_header(content_types)
|
||||
if (!is.null(content_type)) {
|
||||
headers['Content-Type'] = content_type
|
||||
}
|
||||
|
||||
if (typeof(stream_callback) == "closure") { # stream data
|
||||
if (method == "GET") {
|
||||
httr::GET(url, query = query_params, headers, http_timeout,
|
||||
httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
|
||||
} else if (method == "POST") {
|
||||
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 if (method == "PUT") {
|
||||
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 if (method == "PATCH") {
|
||||
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 if (method == "HEAD") {
|
||||
httr::HEAD(url, query = query_params, headers, http_timeout,
|
||||
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = query_params, headers, http_timeout,
|
||||
http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...)
|
||||
} else {
|
||||
err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
stop(err_msg)
|
||||
}
|
||||
} else { # no streaming
|
||||
if (method == "GET") {
|
||||
httr_response <- httr::GET(url, query = query_params, headers, http_timeout,
|
||||
httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "POST") {
|
||||
httr_response <- 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") {
|
||||
httr_response <- 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") {
|
||||
httr_response <- 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") {
|
||||
httr_response <- httr::HEAD(url, query = query_params, headers, http_timeout,
|
||||
http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr_response <- 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`."
|
||||
stop(err_msg)
|
||||
}
|
||||
|
||||
# return ApiResponse
|
||||
api_response <- ApiResponse$new()
|
||||
api_response$status_code <- httr::status_code(httr_response)
|
||||
api_response$status_code_desc <- httr::http_status(httr_response)$reason
|
||||
api_response$response <- httr::content(httr_response, "text", encoding = "UTF-8")
|
||||
api_response$headers <- httr::headers(httr_response)
|
||||
|
||||
api_response
|
||||
}
|
||||
},
|
||||
#' Deserialize the content of API response to the given type.
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize the content of API response to the given type.
|
||||
#'
|
||||
#' @param raw_response Raw response.
|
||||
#' @param return_type R return type.
|
||||
#' @param pkg_env Package environment.
|
||||
#' @return Deserialized object.
|
||||
#' @export
|
||||
deserialize = function(raw_response, return_type, pkg_env) {
|
||||
resp_obj <- jsonlite::fromJSON(raw_response)
|
||||
self$deserializeObj(resp_obj, return_type, pkg_env)
|
||||
},
|
||||
#' Deserialize the response from jsonlite object based on the given type
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize the response from jsonlite object based on the given type
|
||||
#' by handling complex and nested types by iterating recursively
|
||||
#' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
#'
|
||||
#' @param obj Response object.
|
||||
#' @param return_type R return type.
|
||||
#' @param pkg_env Package environment.
|
||||
#' @return Deserialized object.
|
||||
#' @export
|
||||
deserializeObj = function(obj, return_type, pkg_env) {
|
||||
return_obj <- NULL
|
||||
primitive_types <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
# To handle the "map" type
|
||||
if (startsWith(return_type, "map(")) {
|
||||
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)
|
||||
} 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) {
|
||||
for (row in 1:length(obj)) {
|
||||
return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!is.null(nrow(obj))) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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()
|
||||
# check if discriminator is defined
|
||||
if (!is.null(return_obj$`_discriminator_property_name`)) {
|
||||
data_type <- return_obj$`_discriminator_property_name`
|
||||
# use discriminator mapping if provided
|
||||
if (!is.null(return_obj$`_discriminator_mapping_name`)) {
|
||||
data_type <- (return_obj$`_discriminator_mapping_name`)[[obj[[data_type]]]]
|
||||
} else {
|
||||
# no mapping provided, use the value directly
|
||||
data_type <- obj[[data_type]]
|
||||
}
|
||||
# create an object of the mapped type (e.g. Cat)
|
||||
return_type <- get(data_type, envir = as.environment(pkg_env))
|
||||
return_obj <- return_type$new()
|
||||
}
|
||||
return_obj$fromJSON(
|
||||
jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE)
|
||||
)
|
||||
} else {
|
||||
# To handle primitive type
|
||||
return_obj <- obj
|
||||
}
|
||||
return_obj
|
||||
},
|
||||
#' Return a property header (for accept or content-type).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a property header (for accept or content-type). If JSON-related MIME is found,
|
||||
#' return it. Otherwise, return the first one, if any.
|
||||
#'
|
||||
#' @param headers A list of headers
|
||||
#' @return A header (e.g. 'application/json')
|
||||
#' @export
|
||||
select_header = function(headers) {
|
||||
if (length(headers) == 0) {
|
||||
return(invisible(NULL))
|
||||
} else {
|
||||
for (header in headers) {
|
||||
if (str_detect(header, "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$")) {
|
||||
# return JSON-related MIME
|
||||
return(header)
|
||||
}
|
||||
}
|
||||
|
||||
# not json mime type, simply return the first one
|
||||
return(headers[1])
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
50
samples/client/echo_api/r/R/api_response.R
Normal file
50
samples/client/echo_api/r/R/api_response.R
Normal file
@@ -0,0 +1,50 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title ApiResponse
|
||||
#' @description ApiResponse Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field content The deserialized response body.
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @field status_code The HTTP response status code.
|
||||
#' @field status_code_desc The brief description of the HTTP response status code.
|
||||
#' @field headers The HTTP response headers.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
"ApiResponse",
|
||||
public = list(
|
||||
content = NULL,
|
||||
response = NULL,
|
||||
status_code = NULL,
|
||||
status_code_desc = NULL,
|
||||
headers = NULL,
|
||||
#' Initialize a new ApiResponse class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new ApiResponse class.
|
||||
#'
|
||||
#' @param content The deserialized response body.
|
||||
#' @param response The raw response from the endpoint.
|
||||
#' @param status_code The HTTP response status code.
|
||||
#' @param status_code_desc The brief description of the HTTP response status code.
|
||||
#' @param headers The HTTP response headers.
|
||||
#' @export
|
||||
initialize = function(content = NULL,
|
||||
response = NULL,
|
||||
status_code = NULL,
|
||||
status_code_desc = NULL,
|
||||
headers = NULL) {
|
||||
self$content <- content
|
||||
self$response <- response
|
||||
self$status_code <- status_code
|
||||
self$status_code_desc <- status_code_desc
|
||||
self$headers <- headers
|
||||
}
|
||||
)
|
||||
)
|
||||
288
samples/client/echo_api/r/R/auth_api.R
Normal file
288
samples/client/echo_api/r/R/auth_api.R
Normal file
@@ -0,0 +1,288 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Auth operations
|
||||
#' @description AuthApi
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#' \strong{ TestAuthHttpBasic } \emph{ To test HTTP basic authentication }
|
||||
#' To test HTTP basic authentication
|
||||
#'
|
||||
#' \itemize{
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' \strong{ TestAuthHttpBearer } \emph{ To test HTTP bearer authentication }
|
||||
#' To test HTTP bearer authentication
|
||||
#'
|
||||
#' \itemize{
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' #################### TestAuthHttpBasic ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#'
|
||||
#' #To test HTTP basic authentication
|
||||
#' api_instance <- AuthApi$new()
|
||||
#'
|
||||
#' # Configure HTTP basic authorization: http_auth
|
||||
#' api_instance$api_client$username <- Sys.getenv("USERNAME")
|
||||
#' api_instance$api_client$password <- Sys.getenv("PASSWORD")
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestAuthHttpBasic(data_file = "result.txt")
|
||||
#' result <- api_instance$TestAuthHttpBasic()
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' #################### TestAuthHttpBearer ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#'
|
||||
#' #To test HTTP bearer authentication
|
||||
#' api_instance <- AuthApi$new()
|
||||
#'
|
||||
#' # Configure HTTP bearer authorization: http_bearer_auth
|
||||
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestAuthHttpBearer(data_file = "result.txt")
|
||||
#' result <- api_instance$TestAuthHttpBearer()
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
AuthApi <- R6::R6Class(
|
||||
"AuthApi",
|
||||
public = list(
|
||||
api_client = NULL,
|
||||
#' Initialize a new AuthApi.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new AuthApi.
|
||||
#'
|
||||
#' @param api_client An instance of API client.
|
||||
#' @export
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
} else {
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
#' To test HTTP basic authentication
|
||||
#'
|
||||
#' @description
|
||||
#' To test HTTP basic authentication
|
||||
#'
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestAuthHttpBasic = function(data_file = NULL, ...) {
|
||||
local_var_response <- self$TestAuthHttpBasicWithHttpInfo(data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' To test HTTP basic authentication
|
||||
#'
|
||||
#' @description
|
||||
#' To test HTTP basic authentication
|
||||
#'
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestAuthHttpBasicWithHttpInfo = function(data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
local_var_url_path <- "/auth/http/basic"
|
||||
# HTTP basic auth
|
||||
if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) {
|
||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||
}
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list()
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "POST",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
},
|
||||
#' To test HTTP bearer authentication
|
||||
#'
|
||||
#' @description
|
||||
#' To test HTTP bearer authentication
|
||||
#'
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestAuthHttpBearer = function(data_file = NULL, ...) {
|
||||
local_var_response <- self$TestAuthHttpBearerWithHttpInfo(data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' To test HTTP bearer authentication
|
||||
#'
|
||||
#' @description
|
||||
#' To test HTTP bearer authentication
|
||||
#'
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestAuthHttpBearerWithHttpInfo = function(data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
local_var_url_path <- "/auth/http/bearer"
|
||||
# Bearer token
|
||||
if (!is.null(self$api_client$bearer_token)) {
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
|
||||
}
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list()
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "POST",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
188
samples/client/echo_api/r/R/bird.R
Normal file
188
samples/client/echo_api/r/R/bird.R
Normal file
@@ -0,0 +1,188 @@
|
||||
#' Create a new Bird
|
||||
#'
|
||||
#' @description
|
||||
#' Bird Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Bird
|
||||
#' @description Bird Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field size character [optional]
|
||||
#' @field color character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Bird <- R6::R6Class(
|
||||
"Bird",
|
||||
public = list(
|
||||
`size` = NULL,
|
||||
`color` = NULL,
|
||||
#' Initialize a new Bird class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new Bird class.
|
||||
#'
|
||||
#' @param size size
|
||||
#' @param color color
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`size` = NULL, `color` = NULL, ...) {
|
||||
if (!is.null(`size`)) {
|
||||
if (!(is.character(`size`) && length(`size`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `size`. Must be a string:", `size`))
|
||||
}
|
||||
self$`size` <- `size`
|
||||
}
|
||||
if (!is.null(`color`)) {
|
||||
if (!(is.character(`color`) && length(`color`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
|
||||
}
|
||||
self$`color` <- `color`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Bird in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
BirdObject <- list()
|
||||
if (!is.null(self$`size`)) {
|
||||
BirdObject[["size"]] <-
|
||||
self$`size`
|
||||
}
|
||||
if (!is.null(self$`color`)) {
|
||||
BirdObject[["color"]] <-
|
||||
self$`color`
|
||||
}
|
||||
BirdObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Bird
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Bird
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Bird
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`size`)) {
|
||||
self$`size` <- this_object$`size`
|
||||
}
|
||||
if (!is.null(this_object$`color`)) {
|
||||
self$`color` <- this_object$`color`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Bird in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`size`)) {
|
||||
sprintf(
|
||||
'"size":
|
||||
"%s"
|
||||
',
|
||||
self$`size`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`color`)) {
|
||||
sprintf(
|
||||
'"color":
|
||||
"%s"
|
||||
',
|
||||
self$`color`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Bird
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Bird
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Bird
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`size` <- this_object$`size`
|
||||
self$`color` <- this_object$`color`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to Bird
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to Bird and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of Bird
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# Bird$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# Bird$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# Bird$lock()
|
||||
|
||||
1155
samples/client/echo_api/r/R/body_api.R
Normal file
1155
samples/client/echo_api/r/R/body_api.R
Normal file
File diff suppressed because it is too large
Load Diff
188
samples/client/echo_api/r/R/category.R
Normal file
188
samples/client/echo_api/r/R/category.R
Normal file
@@ -0,0 +1,188 @@
|
||||
#' Create a new Category
|
||||
#'
|
||||
#' @description
|
||||
#' Category Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Category
|
||||
#' @description Category Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field id integer [optional]
|
||||
#' @field name character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Category <- R6::R6Class(
|
||||
"Category",
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
#' Initialize a new Category class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new Category class.
|
||||
#'
|
||||
#' @param id id
|
||||
#' @param name name
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`id` = NULL, `name` = NULL, ...) {
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`name`)) {
|
||||
if (!(is.character(`name`) && length(`name`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
|
||||
}
|
||||
self$`name` <- `name`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Category in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
CategoryObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
CategoryObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
CategoryObject[["name"]] <-
|
||||
self$`name`
|
||||
}
|
||||
CategoryObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Category
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Category
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Category
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`name`)) {
|
||||
self$`name` <- this_object$`name`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Category in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`name`)) {
|
||||
sprintf(
|
||||
'"name":
|
||||
"%s"
|
||||
',
|
||||
self$`name`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Category
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Category
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Category
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`id` <- this_object$`id`
|
||||
self$`name` <- this_object$`name`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to Category
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to Category and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of Category
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# Category$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# Category$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# Category$lock()
|
||||
|
||||
263
samples/client/echo_api/r/R/data_query.R
Normal file
263
samples/client/echo_api/r/R/data_query.R
Normal file
@@ -0,0 +1,263 @@
|
||||
#' Create a new DataQuery
|
||||
#'
|
||||
#' @description
|
||||
#' DataQuery Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title DataQuery
|
||||
#' @description DataQuery Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field id Query integer [optional]
|
||||
#' @field outcomes list(character) [optional]
|
||||
#' @field suffix test suffix character [optional]
|
||||
#' @field text Some text containing white spaces character [optional]
|
||||
#' @field date A date character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
DataQuery <- R6::R6Class(
|
||||
"DataQuery",
|
||||
inherit = Query,
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`outcomes` = NULL,
|
||||
`suffix` = NULL,
|
||||
`text` = NULL,
|
||||
`date` = NULL,
|
||||
#' Initialize a new DataQuery class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new DataQuery class.
|
||||
#'
|
||||
#' @param id Query
|
||||
#' @param outcomes outcomes. Default to [SUCCESS, FAILURE].
|
||||
#' @param suffix test suffix
|
||||
#' @param text Some text containing white spaces
|
||||
#' @param date A date
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`id` = NULL, `outcomes` = [SUCCESS, FAILURE], `suffix` = NULL, `text` = NULL, `date` = NULL, ...) {
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`outcomes`)) {
|
||||
stopifnot(is.vector(`outcomes`), length(`outcomes`) != 0)
|
||||
sapply(`outcomes`, function(x) stopifnot(is.character(x)))
|
||||
self$`outcomes` <- `outcomes`
|
||||
}
|
||||
if (!is.null(`suffix`)) {
|
||||
if (!(is.character(`suffix`) && length(`suffix`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `suffix`. Must be a string:", `suffix`))
|
||||
}
|
||||
self$`suffix` <- `suffix`
|
||||
}
|
||||
if (!is.null(`text`)) {
|
||||
if (!(is.character(`text`) && length(`text`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `text`. Must be a string:", `text`))
|
||||
}
|
||||
self$`text` <- `text`
|
||||
}
|
||||
if (!is.null(`date`)) {
|
||||
if (!is.character(`date`)) {
|
||||
stop(paste("Error! Invalid data for `date`. Must be a string:", `date`))
|
||||
}
|
||||
self$`date` <- `date`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return DataQuery in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
DataQueryObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
DataQueryObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`outcomes`)) {
|
||||
DataQueryObject[["outcomes"]] <-
|
||||
self$`outcomes`
|
||||
}
|
||||
if (!is.null(self$`suffix`)) {
|
||||
DataQueryObject[["suffix"]] <-
|
||||
self$`suffix`
|
||||
}
|
||||
if (!is.null(self$`text`)) {
|
||||
DataQueryObject[["text"]] <-
|
||||
self$`text`
|
||||
}
|
||||
if (!is.null(self$`date`)) {
|
||||
DataQueryObject[["date"]] <-
|
||||
self$`date`
|
||||
}
|
||||
DataQueryObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of DataQuery
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of DataQuery
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of DataQuery
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`outcomes`)) {
|
||||
self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`suffix`)) {
|
||||
self$`suffix` <- this_object$`suffix`
|
||||
}
|
||||
if (!is.null(this_object$`text`)) {
|
||||
self$`text` <- this_object$`text`
|
||||
}
|
||||
if (!is.null(this_object$`date`)) {
|
||||
self$`date` <- this_object$`date`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return DataQuery in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`outcomes`)) {
|
||||
sprintf(
|
||||
'"outcomes":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`suffix`)) {
|
||||
sprintf(
|
||||
'"suffix":
|
||||
"%s"
|
||||
',
|
||||
self$`suffix`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`text`)) {
|
||||
sprintf(
|
||||
'"text":
|
||||
"%s"
|
||||
',
|
||||
self$`text`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`date`)) {
|
||||
sprintf(
|
||||
'"date":
|
||||
"%s"
|
||||
',
|
||||
self$`date`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of DataQuery
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of DataQuery
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of DataQuery
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`id` <- this_object$`id`
|
||||
self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi"))
|
||||
self$`suffix` <- this_object$`suffix`
|
||||
self$`text` <- this_object$`text`
|
||||
self$`date` <- this_object$`date`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to DataQuery
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to DataQuery and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of DataQuery
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# DataQuery$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# DataQuery$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# DataQuery$lock()
|
||||
|
||||
331
samples/client/echo_api/r/R/default_value.R
Normal file
331
samples/client/echo_api/r/R/default_value.R
Normal file
@@ -0,0 +1,331 @@
|
||||
#' Create a new DefaultValue
|
||||
#'
|
||||
#' @description
|
||||
#' to test the default value of properties
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title DefaultValue
|
||||
#' @description DefaultValue Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field array_string_enum_ref_default list(\link{StringEnumRef}) [optional]
|
||||
#' @field array_string_enum_default list(character) [optional]
|
||||
#' @field array_string_default list(character) [optional]
|
||||
#' @field array_integer_default list(integer) [optional]
|
||||
#' @field array_string list(character) [optional]
|
||||
#' @field array_string_nullable list(character) [optional]
|
||||
#' @field array_string_extension_nullable list(character) [optional]
|
||||
#' @field string_nullable character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
DefaultValue <- R6::R6Class(
|
||||
"DefaultValue",
|
||||
public = list(
|
||||
`array_string_enum_ref_default` = NULL,
|
||||
`array_string_enum_default` = NULL,
|
||||
`array_string_default` = NULL,
|
||||
`array_integer_default` = NULL,
|
||||
`array_string` = NULL,
|
||||
`array_string_nullable` = NULL,
|
||||
`array_string_extension_nullable` = NULL,
|
||||
`string_nullable` = NULL,
|
||||
#' Initialize a new DefaultValue class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new DefaultValue class.
|
||||
#'
|
||||
#' @param array_string_enum_ref_default array_string_enum_ref_default. Default to ["success","failure"].
|
||||
#' @param array_string_enum_default array_string_enum_default. Default to ["success","failure"].
|
||||
#' @param array_string_default array_string_default. Default to ["failure","skipped"].
|
||||
#' @param array_integer_default array_integer_default. Default to [1,3].
|
||||
#' @param array_string array_string
|
||||
#' @param array_string_nullable array_string_nullable
|
||||
#' @param array_string_extension_nullable array_string_extension_nullable
|
||||
#' @param string_nullable string_nullable
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`array_string_enum_ref_default` = ["success","failure"], `array_string_enum_default` = ["success","failure"], `array_string_default` = ["failure","skipped"], `array_integer_default` = [1,3], `array_string` = NULL, `array_string_nullable` = NULL, `array_string_extension_nullable` = NULL, `string_nullable` = NULL, ...) {
|
||||
if (!is.null(`array_string_enum_ref_default`)) {
|
||||
stopifnot(is.vector(`array_string_enum_ref_default`), length(`array_string_enum_ref_default`) != 0)
|
||||
sapply(`array_string_enum_ref_default`, function(x) stopifnot(R6::is.R6(x)))
|
||||
self$`array_string_enum_ref_default` <- `array_string_enum_ref_default`
|
||||
}
|
||||
if (!is.null(`array_string_enum_default`)) {
|
||||
stopifnot(is.vector(`array_string_enum_default`), length(`array_string_enum_default`) != 0)
|
||||
sapply(`array_string_enum_default`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_string_enum_default` <- `array_string_enum_default`
|
||||
}
|
||||
if (!is.null(`array_string_default`)) {
|
||||
stopifnot(is.vector(`array_string_default`), length(`array_string_default`) != 0)
|
||||
sapply(`array_string_default`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_string_default` <- `array_string_default`
|
||||
}
|
||||
if (!is.null(`array_integer_default`)) {
|
||||
stopifnot(is.vector(`array_integer_default`), length(`array_integer_default`) != 0)
|
||||
sapply(`array_integer_default`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_integer_default` <- `array_integer_default`
|
||||
}
|
||||
if (!is.null(`array_string`)) {
|
||||
stopifnot(is.vector(`array_string`), length(`array_string`) != 0)
|
||||
sapply(`array_string`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_string` <- `array_string`
|
||||
}
|
||||
if (!is.null(`array_string_nullable`)) {
|
||||
stopifnot(is.vector(`array_string_nullable`), length(`array_string_nullable`) != 0)
|
||||
sapply(`array_string_nullable`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_string_nullable` <- `array_string_nullable`
|
||||
}
|
||||
if (!is.null(`array_string_extension_nullable`)) {
|
||||
stopifnot(is.vector(`array_string_extension_nullable`), length(`array_string_extension_nullable`) != 0)
|
||||
sapply(`array_string_extension_nullable`, function(x) stopifnot(is.character(x)))
|
||||
self$`array_string_extension_nullable` <- `array_string_extension_nullable`
|
||||
}
|
||||
if (!is.null(`string_nullable`)) {
|
||||
if (!(is.character(`string_nullable`) && length(`string_nullable`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `string_nullable`. Must be a string:", `string_nullable`))
|
||||
}
|
||||
self$`string_nullable` <- `string_nullable`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return DefaultValue in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
DefaultValueObject <- list()
|
||||
if (!is.null(self$`array_string_enum_ref_default`)) {
|
||||
DefaultValueObject[["array_string_enum_ref_default"]] <-
|
||||
lapply(self$`array_string_enum_ref_default`, function(x) x$toJSON())
|
||||
}
|
||||
if (!is.null(self$`array_string_enum_default`)) {
|
||||
DefaultValueObject[["array_string_enum_default"]] <-
|
||||
self$`array_string_enum_default`
|
||||
}
|
||||
if (!is.null(self$`array_string_default`)) {
|
||||
DefaultValueObject[["array_string_default"]] <-
|
||||
self$`array_string_default`
|
||||
}
|
||||
if (!is.null(self$`array_integer_default`)) {
|
||||
DefaultValueObject[["array_integer_default"]] <-
|
||||
self$`array_integer_default`
|
||||
}
|
||||
if (!is.null(self$`array_string`)) {
|
||||
DefaultValueObject[["array_string"]] <-
|
||||
self$`array_string`
|
||||
}
|
||||
if (!is.null(self$`array_string_nullable`)) {
|
||||
DefaultValueObject[["array_string_nullable"]] <-
|
||||
self$`array_string_nullable`
|
||||
}
|
||||
if (!is.null(self$`array_string_extension_nullable`)) {
|
||||
DefaultValueObject[["array_string_extension_nullable"]] <-
|
||||
self$`array_string_extension_nullable`
|
||||
}
|
||||
if (!is.null(self$`string_nullable`)) {
|
||||
DefaultValueObject[["string_nullable"]] <-
|
||||
self$`string_nullable`
|
||||
}
|
||||
DefaultValueObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of DefaultValue
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of DefaultValue
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of DefaultValue
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`array_string_enum_ref_default`)) {
|
||||
self$`array_string_enum_ref_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_ref_default`, "array[StringEnumRef]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_string_enum_default`)) {
|
||||
self$`array_string_enum_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_default`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_string_default`)) {
|
||||
self$`array_string_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_default`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_integer_default`)) {
|
||||
self$`array_integer_default` <- ApiClient$new()$deserializeObj(this_object$`array_integer_default`, "array[integer]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_string`)) {
|
||||
self$`array_string` <- ApiClient$new()$deserializeObj(this_object$`array_string`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_string_nullable`)) {
|
||||
self$`array_string_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_nullable`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`array_string_extension_nullable`)) {
|
||||
self$`array_string_extension_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_extension_nullable`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`string_nullable`)) {
|
||||
self$`string_nullable` <- this_object$`string_nullable`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return DefaultValue in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`array_string_enum_ref_default`)) {
|
||||
sprintf(
|
||||
'"array_string_enum_ref_default":
|
||||
[%s]
|
||||
',
|
||||
paste(sapply(self$`array_string_enum_ref_default`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_string_enum_default`)) {
|
||||
sprintf(
|
||||
'"array_string_enum_default":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_string_enum_default`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_string_default`)) {
|
||||
sprintf(
|
||||
'"array_string_default":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_string_default`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_integer_default`)) {
|
||||
sprintf(
|
||||
'"array_integer_default":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_integer_default`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_string`)) {
|
||||
sprintf(
|
||||
'"array_string":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_string`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_string_nullable`)) {
|
||||
sprintf(
|
||||
'"array_string_nullable":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_string_nullable`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`array_string_extension_nullable`)) {
|
||||
sprintf(
|
||||
'"array_string_extension_nullable":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`array_string_extension_nullable`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`string_nullable`)) {
|
||||
sprintf(
|
||||
'"string_nullable":
|
||||
"%s"
|
||||
',
|
||||
self$`string_nullable`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of DefaultValue
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of DefaultValue
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of DefaultValue
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`array_string_enum_ref_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_ref_default`, "array[StringEnumRef]", loadNamespace("openapi"))
|
||||
self$`array_string_enum_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_default`, "array[character]", loadNamespace("openapi"))
|
||||
self$`array_string_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_default`, "array[character]", loadNamespace("openapi"))
|
||||
self$`array_integer_default` <- ApiClient$new()$deserializeObj(this_object$`array_integer_default`, "array[integer]", loadNamespace("openapi"))
|
||||
self$`array_string` <- ApiClient$new()$deserializeObj(this_object$`array_string`, "array[character]", loadNamespace("openapi"))
|
||||
self$`array_string_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_nullable`, "array[character]", loadNamespace("openapi"))
|
||||
self$`array_string_extension_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_extension_nullable`, "array[character]", loadNamespace("openapi"))
|
||||
self$`string_nullable` <- this_object$`string_nullable`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to DefaultValue
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to DefaultValue and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of DefaultValue
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# DefaultValue$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# DefaultValue$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# DefaultValue$lock()
|
||||
|
||||
327
samples/client/echo_api/r/R/form_api.R
Normal file
327
samples/client/echo_api/r/R/form_api.R
Normal file
@@ -0,0 +1,327 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Form operations
|
||||
#' @description FormApi
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#' \strong{ TestFormIntegerBooleanString } \emph{ Test form parameter(s) }
|
||||
#' Test form parameter(s)
|
||||
#'
|
||||
#' \itemize{
|
||||
#' \item \emph{ @param } integer_form integer
|
||||
#' \item \emph{ @param } boolean_form character
|
||||
#' \item \emph{ @param } string_form character
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' \strong{ TestFormOneof } \emph{ Test form parameter(s) for oneOf schema }
|
||||
#' Test form parameter(s) for oneOf schema
|
||||
#'
|
||||
#' \itemize{
|
||||
#' \item \emph{ @param } form1 character
|
||||
#' \item \emph{ @param } form2 integer
|
||||
#' \item \emph{ @param } form3 character
|
||||
#' \item \emph{ @param } form4 character
|
||||
#' \item \emph{ @param } id integer
|
||||
#' \item \emph{ @param } name character
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' #################### TestFormIntegerBooleanString ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#' var_integer_form <- 56 # integer | (Optional)
|
||||
#' var_boolean_form <- "boolean_form_example" # character | (Optional)
|
||||
#' var_string_form <- "string_form_example" # character | (Optional)
|
||||
#'
|
||||
#' #Test form parameter(s)
|
||||
#' api_instance <- FormApi$new()
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_formdata_file = "result.txt")
|
||||
#' result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_form)
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' #################### TestFormOneof ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#' var_form1 <- "form1_example" # character | (Optional)
|
||||
#' var_form2 <- 56 # integer | (Optional)
|
||||
#' var_form3 <- "form3_example" # character | (Optional)
|
||||
#' var_form4 <- "form4_example" # character | (Optional)
|
||||
#' var_id <- 56 # integer | (Optional)
|
||||
#' var_name <- "name_example" # character | (Optional)
|
||||
#'
|
||||
#' #Test form parameter(s) for oneOf schema
|
||||
#' api_instance <- FormApi$new()
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_namedata_file = "result.txt")
|
||||
#' result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_name)
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
FormApi <- R6::R6Class(
|
||||
"FormApi",
|
||||
public = list(
|
||||
api_client = NULL,
|
||||
#' Initialize a new FormApi.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new FormApi.
|
||||
#'
|
||||
#' @param api_client An instance of API client.
|
||||
#' @export
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
} else {
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
#' Test form parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test form parameter(s)
|
||||
#'
|
||||
#' @param integer_form (optional) No description
|
||||
#' @param boolean_form (optional) No description
|
||||
#' @param string_form (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestFormIntegerBooleanString = function(integer_form = NULL, boolean_form = NULL, string_form = NULL, data_file = NULL, ...) {
|
||||
local_var_response <- self$TestFormIntegerBooleanStringWithHttpInfo(integer_form, boolean_form, string_form, data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' Test form parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test form parameter(s)
|
||||
#'
|
||||
#' @param integer_form (optional) No description
|
||||
#' @param boolean_form (optional) No description
|
||||
#' @param string_form (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestFormIntegerBooleanStringWithHttpInfo = function(integer_form = NULL, boolean_form = NULL, string_form = NULL, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
|
||||
|
||||
|
||||
form_params["integer_form"] <- `integer_form`
|
||||
form_params["boolean_form"] <- `boolean_form`
|
||||
form_params["string_form"] <- `string_form`
|
||||
local_var_url_path <- "/form/integer/boolean/string"
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list("application/x-www-form-urlencoded")
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "POST",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
},
|
||||
#' Test form parameter(s) for oneOf schema
|
||||
#'
|
||||
#' @description
|
||||
#' Test form parameter(s) for oneOf schema
|
||||
#'
|
||||
#' @param form1 (optional) No description
|
||||
#' @param form2 (optional) No description
|
||||
#' @param form3 (optional) No description
|
||||
#' @param form4 (optional) No description
|
||||
#' @param id (optional) No description
|
||||
#' @param name (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestFormOneof = function(form1 = NULL, form2 = NULL, form3 = NULL, form4 = NULL, id = NULL, name = NULL, data_file = NULL, ...) {
|
||||
local_var_response <- self$TestFormOneofWithHttpInfo(form1, form2, form3, form4, id, name, data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' Test form parameter(s) for oneOf schema
|
||||
#'
|
||||
#' @description
|
||||
#' Test form parameter(s) for oneOf schema
|
||||
#'
|
||||
#' @param form1 (optional) No description
|
||||
#' @param form2 (optional) No description
|
||||
#' @param form3 (optional) No description
|
||||
#' @param form4 (optional) No description
|
||||
#' @param id (optional) No description
|
||||
#' @param name (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestFormOneofWithHttpInfo = function(form1 = NULL, form2 = NULL, form3 = NULL, form4 = NULL, id = NULL, name = NULL, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
form_params["form1"] <- `form1`
|
||||
form_params["form2"] <- `form2`
|
||||
form_params["form3"] <- `form3`
|
||||
form_params["form4"] <- `form4`
|
||||
form_params["id"] <- `id`
|
||||
form_params["name"] <- `name`
|
||||
local_var_url_path <- "/form/oneof"
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list("application/x-www-form-urlencoded")
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "POST",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
194
samples/client/echo_api/r/R/header_api.R
Normal file
194
samples/client/echo_api/r/R/header_api.R
Normal file
@@ -0,0 +1,194 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Header operations
|
||||
#' @description HeaderApi
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#' \strong{ TestHeaderIntegerBooleanStringEnums } \emph{ Test header parameter(s) }
|
||||
#' Test header parameter(s)
|
||||
#'
|
||||
#' \itemize{
|
||||
#' \item \emph{ @param } integer_header integer
|
||||
#' \item \emph{ @param } boolean_header character
|
||||
#' \item \emph{ @param } string_header character
|
||||
#' \item \emph{ @param } enum_nonref_string_header Enum < [success, failure, unclassified] >
|
||||
#' \item \emph{ @param } enum_ref_string_header \link{StringEnumRef}
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' #################### TestHeaderIntegerBooleanStringEnums ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#' var_integer_header <- 56 # integer | (Optional)
|
||||
#' var_boolean_header <- "boolean_header_example" # character | (Optional)
|
||||
#' var_string_header <- "string_header_example" # character | (Optional)
|
||||
#' var_enum_nonref_string_header <- "enum_nonref_string_header_example" # character | (Optional)
|
||||
#' var_enum_ref_string_header <- StringEnumRef$new() # StringEnumRef | (Optional)
|
||||
#'
|
||||
#' #Test header parameter(s)
|
||||
#' api_instance <- HeaderApi$new()
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_headerdata_file = "result.txt")
|
||||
#' result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_header)
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
HeaderApi <- R6::R6Class(
|
||||
"HeaderApi",
|
||||
public = list(
|
||||
api_client = NULL,
|
||||
#' Initialize a new HeaderApi.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new HeaderApi.
|
||||
#'
|
||||
#' @param api_client An instance of API client.
|
||||
#' @export
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
} else {
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
#' Test header parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test header parameter(s)
|
||||
#'
|
||||
#' @param integer_header (optional) No description
|
||||
#' @param boolean_header (optional) No description
|
||||
#' @param string_header (optional) No description
|
||||
#' @param enum_nonref_string_header (optional) No description
|
||||
#' @param enum_ref_string_header (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestHeaderIntegerBooleanStringEnums = function(integer_header = NULL, boolean_header = NULL, string_header = NULL, enum_nonref_string_header = NULL, enum_ref_string_header = NULL, data_file = NULL, ...) {
|
||||
local_var_response <- self$TestHeaderIntegerBooleanStringEnumsWithHttpInfo(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' Test header parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test header parameter(s)
|
||||
#'
|
||||
#' @param integer_header (optional) No description
|
||||
#' @param boolean_header (optional) No description
|
||||
#' @param string_header (optional) No description
|
||||
#' @param enum_nonref_string_header (optional) No description
|
||||
#' @param enum_ref_string_header (optional) No description
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestHeaderIntegerBooleanStringEnumsWithHttpInfo = function(integer_header = NULL, boolean_header = NULL, string_header = NULL, enum_nonref_string_header = NULL, enum_ref_string_header = NULL, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
header_params["integer_header"] <- `integer_header`
|
||||
|
||||
header_params["boolean_header"] <- `boolean_header`
|
||||
|
||||
header_params["string_header"] <- `string_header`
|
||||
|
||||
header_params["enum_nonref_string_header"] <- `enum_nonref_string_header`
|
||||
|
||||
header_params["enum_ref_string_header"] <- `enum_ref_string_header`
|
||||
|
||||
local_var_url_path <- "/header/integer/boolean/string/enums"
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list()
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "GET",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
224
samples/client/echo_api/r/R/number_properties_only.R
Normal file
224
samples/client/echo_api/r/R/number_properties_only.R
Normal file
@@ -0,0 +1,224 @@
|
||||
#' Create a new NumberPropertiesOnly
|
||||
#'
|
||||
#' @description
|
||||
#' NumberPropertiesOnly Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title NumberPropertiesOnly
|
||||
#' @description NumberPropertiesOnly Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field number numeric [optional]
|
||||
#' @field float numeric [optional]
|
||||
#' @field double numeric [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
NumberPropertiesOnly <- R6::R6Class(
|
||||
"NumberPropertiesOnly",
|
||||
public = list(
|
||||
`number` = NULL,
|
||||
`float` = NULL,
|
||||
`double` = NULL,
|
||||
#' Initialize a new NumberPropertiesOnly class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new NumberPropertiesOnly class.
|
||||
#'
|
||||
#' @param number number
|
||||
#' @param float float
|
||||
#' @param double double
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`number` = NULL, `float` = NULL, `double` = NULL, ...) {
|
||||
if (!is.null(`number`)) {
|
||||
self$`number` <- `number`
|
||||
}
|
||||
if (!is.null(`float`)) {
|
||||
if (!(is.numeric(`float`) && length(`float`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `float`. Must be a number:", `float`))
|
||||
}
|
||||
self$`float` <- `float`
|
||||
}
|
||||
if (!is.null(`double`)) {
|
||||
if (!(is.numeric(`double`) && length(`double`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `double`. Must be a number:", `double`))
|
||||
}
|
||||
self$`double` <- `double`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return NumberPropertiesOnly in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
NumberPropertiesOnlyObject <- list()
|
||||
if (!is.null(self$`number`)) {
|
||||
NumberPropertiesOnlyObject[["number"]] <-
|
||||
self$`number`
|
||||
}
|
||||
if (!is.null(self$`float`)) {
|
||||
NumberPropertiesOnlyObject[["float"]] <-
|
||||
self$`float`
|
||||
}
|
||||
if (!is.null(self$`double`)) {
|
||||
NumberPropertiesOnlyObject[["double"]] <-
|
||||
self$`double`
|
||||
}
|
||||
NumberPropertiesOnlyObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of NumberPropertiesOnly
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of NumberPropertiesOnly
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of NumberPropertiesOnly
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`number`)) {
|
||||
self$`number` <- this_object$`number`
|
||||
}
|
||||
if (!is.null(this_object$`float`)) {
|
||||
self$`float` <- this_object$`float`
|
||||
}
|
||||
if (!is.null(this_object$`double`)) {
|
||||
self$`double` <- this_object$`double`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return NumberPropertiesOnly in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`number`)) {
|
||||
sprintf(
|
||||
'"number":
|
||||
%d
|
||||
',
|
||||
self$`number`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`float`)) {
|
||||
sprintf(
|
||||
'"float":
|
||||
%d
|
||||
',
|
||||
self$`float`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`double`)) {
|
||||
sprintf(
|
||||
'"double":
|
||||
%d
|
||||
',
|
||||
self$`double`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of NumberPropertiesOnly
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of NumberPropertiesOnly
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of NumberPropertiesOnly
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`number` <- this_object$`number`
|
||||
self$`float` <- this_object$`float`
|
||||
self$`double` <- this_object$`double`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to NumberPropertiesOnly
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to NumberPropertiesOnly and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of NumberPropertiesOnly
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
if (self$`double` > 50.2) {
|
||||
return(FALSE)
|
||||
}
|
||||
if (self$`double` < 0.8) {
|
||||
return(FALSE)
|
||||
}
|
||||
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
if (self$`double` > 50.2) {
|
||||
invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 50.2."
|
||||
}
|
||||
if (self$`double` < 0.8) {
|
||||
invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 0.8."
|
||||
}
|
||||
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# NumberPropertiesOnly$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# NumberPropertiesOnly$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# NumberPropertiesOnly$lock()
|
||||
|
||||
211
samples/client/echo_api/r/R/path_api.R
Normal file
211
samples/client/echo_api/r/R/path_api.R
Normal file
@@ -0,0 +1,211 @@
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' Echo Server API
|
||||
#'
|
||||
#' The version of the OpenAPI document: 0.1.0
|
||||
#' Contact: team@openapitools.org
|
||||
#' Generated by: https://openapi-generator.tech
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Path operations
|
||||
#' @description PathApi
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#' \strong{ TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath } \emph{ Test path parameter(s) }
|
||||
#' Test path parameter(s)
|
||||
#'
|
||||
#' \itemize{
|
||||
#' \item \emph{ @param } path_string character
|
||||
#' \item \emph{ @param } path_integer integer
|
||||
#' \item \emph{ @param } enum_nonref_string_path Enum < [success, failure, unclassified] >
|
||||
#' \item \emph{ @param } enum_ref_string_path \link{StringEnumRef}
|
||||
#'
|
||||
#'
|
||||
#' \item status code : 200 | Successful operation
|
||||
#'
|
||||
#' \item return type : character
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' #################### TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath ####################
|
||||
#'
|
||||
#' library(openapi)
|
||||
#' var_path_string <- "path_string_example" # character |
|
||||
#' var_path_integer <- 56 # integer |
|
||||
#' var_enum_nonref_string_path <- "enum_nonref_string_path_example" # character |
|
||||
#' var_enum_ref_string_path <- StringEnumRef$new() # StringEnumRef |
|
||||
#'
|
||||
#' #Test path parameter(s)
|
||||
#' api_instance <- PathApi$new()
|
||||
#'
|
||||
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
|
||||
#' # result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_pathdata_file = "result.txt")
|
||||
#' result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_path)
|
||||
#' dput(result)
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
PathApi <- R6::R6Class(
|
||||
"PathApi",
|
||||
public = list(
|
||||
api_client = NULL,
|
||||
#' Initialize a new PathApi.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new PathApi.
|
||||
#'
|
||||
#' @param api_client An instance of API client.
|
||||
#' @export
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
} else {
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
#' Test path parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test path parameter(s)
|
||||
#'
|
||||
#' @param path_string
|
||||
#' @param path_integer
|
||||
#' @param enum_nonref_string_path
|
||||
#' @param enum_ref_string_path
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return character
|
||||
#' @export
|
||||
TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath = function(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = NULL, ...) {
|
||||
local_var_response <- self$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = data_file, ...)
|
||||
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
|
||||
local_var_response$content
|
||||
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
|
||||
local_var_response
|
||||
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
|
||||
local_var_response
|
||||
}
|
||||
},
|
||||
#' Test path parameter(s)
|
||||
#'
|
||||
#' @description
|
||||
#' Test path parameter(s)
|
||||
#'
|
||||
#' @param path_string
|
||||
#' @param path_integer
|
||||
#' @param enum_nonref_string_path
|
||||
#' @param enum_ref_string_path
|
||||
#' @param data_file (optional) name of the data file to save the result
|
||||
#' @param ... Other optional arguments
|
||||
#' @return API response (character) with additional information such as HTTP status code, headers
|
||||
#' @export
|
||||
TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo = function(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
form_params <- list()
|
||||
file_params <- list()
|
||||
local_var_body <- NULL
|
||||
oauth_scopes <- NULL
|
||||
is_oauth <- FALSE
|
||||
|
||||
if (missing(`path_string`)) {
|
||||
stop("Missing required parameter `path_string`.")
|
||||
}
|
||||
|
||||
if (missing(`path_integer`)) {
|
||||
stop("Missing required parameter `path_integer`.")
|
||||
}
|
||||
|
||||
if (missing(`enum_nonref_string_path`)) {
|
||||
stop("Missing required parameter `enum_nonref_string_path`.")
|
||||
}
|
||||
|
||||
if (missing(`enum_ref_string_path`)) {
|
||||
stop("Missing required parameter `enum_ref_string_path`.")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local_var_url_path <- "/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}"
|
||||
if (!missing(`path_string`)) {
|
||||
local_var_url_path <- gsub("\\{path_string\\}", URLencode(as.character(`path_string`), reserved = TRUE), local_var_url_path)
|
||||
}
|
||||
|
||||
if (!missing(`path_integer`)) {
|
||||
local_var_url_path <- gsub("\\{path_integer\\}", URLencode(as.character(`path_integer`), reserved = TRUE), local_var_url_path)
|
||||
}
|
||||
|
||||
if (!missing(`enum_nonref_string_path`)) {
|
||||
local_var_url_path <- gsub("\\{enum_nonref_string_path\\}", URLencode(as.character(`enum_nonref_string_path`), reserved = TRUE), local_var_url_path)
|
||||
}
|
||||
|
||||
if (!missing(`enum_ref_string_path`)) {
|
||||
local_var_url_path <- gsub("\\{enum_ref_string_path\\}", URLencode(as.character(`enum_ref_string_path`), reserved = TRUE), local_var_url_path)
|
||||
}
|
||||
|
||||
|
||||
# The Accept request HTTP header
|
||||
local_var_accepts <- list("text/plain")
|
||||
|
||||
# The Content-Type representation header
|
||||
local_var_content_types <- list()
|
||||
|
||||
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
|
||||
method = "GET",
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
form_params = form_params,
|
||||
file_params = file_params,
|
||||
accepts = local_var_accepts,
|
||||
content_types = local_var_content_types,
|
||||
body = local_var_body,
|
||||
is_oauth = is_oauth,
|
||||
oauth_scopes = oauth_scopes,
|
||||
...)
|
||||
|
||||
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
|
||||
# save response in a file
|
||||
if (!is.null(data_file)) {
|
||||
write(local_var_resp$response, data_file)
|
||||
}
|
||||
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
local_var_resp$content <- deserialized_resp_obj
|
||||
local_var_resp
|
||||
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
|
||||
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
|
||||
ApiResponse$new("API client error", local_var_resp)
|
||||
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
|
||||
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
|
||||
local_var_resp$response <- "API server error"
|
||||
}
|
||||
local_var_resp
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
330
samples/client/echo_api/r/R/pet.R
Normal file
330
samples/client/echo_api/r/R/pet.R
Normal file
@@ -0,0 +1,330 @@
|
||||
#' Create a new Pet
|
||||
#'
|
||||
#' @description
|
||||
#' Pet Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Pet
|
||||
#' @description Pet Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field id integer [optional]
|
||||
#' @field name character
|
||||
#' @field category \link{Category} [optional]
|
||||
#' @field photoUrls list(character)
|
||||
#' @field tags list(\link{Tag}) [optional]
|
||||
#' @field status pet status in the store character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Pet <- R6::R6Class(
|
||||
"Pet",
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
`category` = NULL,
|
||||
`photoUrls` = NULL,
|
||||
`tags` = NULL,
|
||||
`status` = NULL,
|
||||
#' Initialize a new Pet class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new Pet class.
|
||||
#'
|
||||
#' @param name name
|
||||
#' @param photoUrls photoUrls
|
||||
#' @param id id
|
||||
#' @param category category
|
||||
#' @param tags tags
|
||||
#' @param status pet status in the store
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ...) {
|
||||
if (!missing(`name`)) {
|
||||
if (!(is.character(`name`) && length(`name`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
|
||||
}
|
||||
self$`name` <- `name`
|
||||
}
|
||||
if (!missing(`photoUrls`)) {
|
||||
stopifnot(is.vector(`photoUrls`), length(`photoUrls`) != 0)
|
||||
sapply(`photoUrls`, function(x) stopifnot(is.character(x)))
|
||||
self$`photoUrls` <- `photoUrls`
|
||||
}
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`category`)) {
|
||||
stopifnot(R6::is.R6(`category`))
|
||||
self$`category` <- `category`
|
||||
}
|
||||
if (!is.null(`tags`)) {
|
||||
stopifnot(is.vector(`tags`), length(`tags`) != 0)
|
||||
sapply(`tags`, function(x) stopifnot(R6::is.R6(x)))
|
||||
self$`tags` <- `tags`
|
||||
}
|
||||
if (!is.null(`status`)) {
|
||||
if (!(`status` %in% c("available", "pending", "sold"))) {
|
||||
stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
|
||||
}
|
||||
if (!(is.character(`status`) && length(`status`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `status`. Must be a string:", `status`))
|
||||
}
|
||||
self$`status` <- `status`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Pet in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
PetObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
PetObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
PetObject[["name"]] <-
|
||||
self$`name`
|
||||
}
|
||||
if (!is.null(self$`category`)) {
|
||||
PetObject[["category"]] <-
|
||||
self$`category`$toJSON()
|
||||
}
|
||||
if (!is.null(self$`photoUrls`)) {
|
||||
PetObject[["photoUrls"]] <-
|
||||
self$`photoUrls`
|
||||
}
|
||||
if (!is.null(self$`tags`)) {
|
||||
PetObject[["tags"]] <-
|
||||
lapply(self$`tags`, function(x) x$toJSON())
|
||||
}
|
||||
if (!is.null(self$`status`)) {
|
||||
PetObject[["status"]] <-
|
||||
self$`status`
|
||||
}
|
||||
PetObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Pet
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Pet
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Pet
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`name`)) {
|
||||
self$`name` <- this_object$`name`
|
||||
}
|
||||
if (!is.null(this_object$`category`)) {
|
||||
`category_object` <- Category$new()
|
||||
`category_object`$fromJSON(jsonlite::toJSON(this_object$`category`, auto_unbox = TRUE, digits = NA))
|
||||
self$`category` <- `category_object`
|
||||
}
|
||||
if (!is.null(this_object$`photoUrls`)) {
|
||||
self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`tags`)) {
|
||||
self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("openapi"))
|
||||
}
|
||||
if (!is.null(this_object$`status`)) {
|
||||
if (!is.null(this_object$`status`) && !(this_object$`status` %in% c("available", "pending", "sold"))) {
|
||||
stop(paste("Error! \"", this_object$`status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
|
||||
}
|
||||
self$`status` <- this_object$`status`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Pet in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`name`)) {
|
||||
sprintf(
|
||||
'"name":
|
||||
"%s"
|
||||
',
|
||||
self$`name`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`category`)) {
|
||||
sprintf(
|
||||
'"category":
|
||||
%s
|
||||
',
|
||||
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA)
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`photoUrls`)) {
|
||||
sprintf(
|
||||
'"photoUrls":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`tags`)) {
|
||||
sprintf(
|
||||
'"tags":
|
||||
[%s]
|
||||
',
|
||||
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`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Pet
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Pet
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Pet
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`id` <- this_object$`id`
|
||||
self$`name` <- this_object$`name`
|
||||
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(this_object$`category`, auto_unbox = TRUE, digits = NA))
|
||||
self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("openapi"))
|
||||
self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("openapi"))
|
||||
if (!is.null(this_object$`status`) && !(this_object$`status` %in% c("available", "pending", "sold"))) {
|
||||
stop(paste("Error! \"", this_object$`status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = ""))
|
||||
}
|
||||
self$`status` <- this_object$`status`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to Pet
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to Pet and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
# check the required field `name`
|
||||
if (!is.null(input_json$`name`)) {
|
||||
if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`))
|
||||
}
|
||||
} else {
|
||||
stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing."))
|
||||
}
|
||||
# check the required field `photoUrls`
|
||||
if (!is.null(input_json$`photoUrls`)) {
|
||||
stopifnot(is.vector(input_json$`photoUrls`), length(input_json$`photoUrls`) != 0)
|
||||
tmp <- sapply(input_json$`photoUrls`, function(x) stopifnot(is.character(x)))
|
||||
} else {
|
||||
stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `photoUrls` is missing."))
|
||||
}
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of Pet
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
# check if the required `name` is null
|
||||
if (is.null(self$`name`)) {
|
||||
return(FALSE)
|
||||
}
|
||||
|
||||
# check if the required `photoUrls` is null
|
||||
if (is.null(self$`photoUrls`)) {
|
||||
return(FALSE)
|
||||
}
|
||||
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
# check if the required `name` is null
|
||||
if (is.null(self$`name`)) {
|
||||
invalid_fields["name"] <- "Non-nullable required field `name` cannot be null."
|
||||
}
|
||||
|
||||
# check if the required `photoUrls` is null
|
||||
if (is.null(self$`photoUrls`)) {
|
||||
invalid_fields["photoUrls"] <- "Non-nullable required field `photoUrls` cannot be null."
|
||||
}
|
||||
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# Pet$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# Pet$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# Pet$lock()
|
||||
|
||||
187
samples/client/echo_api/r/R/query.R
Normal file
187
samples/client/echo_api/r/R/query.R
Normal file
@@ -0,0 +1,187 @@
|
||||
#' Create a new Query
|
||||
#'
|
||||
#' @description
|
||||
#' Query Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Query
|
||||
#' @description Query Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field id Query integer [optional]
|
||||
#' @field outcomes list(character) [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Query <- R6::R6Class(
|
||||
"Query",
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`outcomes` = NULL,
|
||||
#' Initialize a new Query class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new Query class.
|
||||
#'
|
||||
#' @param id Query
|
||||
#' @param outcomes outcomes. Default to ["SUCCESS","FAILURE"].
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`id` = NULL, `outcomes` = ["SUCCESS","FAILURE"], ...) {
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`outcomes`)) {
|
||||
stopifnot(is.vector(`outcomes`), length(`outcomes`) != 0)
|
||||
sapply(`outcomes`, function(x) stopifnot(is.character(x)))
|
||||
self$`outcomes` <- `outcomes`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Query in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
QueryObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
QueryObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`outcomes`)) {
|
||||
QueryObject[["outcomes"]] <-
|
||||
self$`outcomes`
|
||||
}
|
||||
QueryObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Query
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Query
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Query
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`outcomes`)) {
|
||||
self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Query in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`outcomes`)) {
|
||||
sprintf(
|
||||
'"outcomes":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Query
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Query
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Query
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`id` <- this_object$`id`
|
||||
self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi"))
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to Query
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to Query and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of Query
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# Query$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# Query$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# Query$lock()
|
||||
|
||||
1051
samples/client/echo_api/r/R/query_api.R
Normal file
1051
samples/client/echo_api/r/R/query_api.R
Normal file
File diff suppressed because it is too large
Load Diff
88
samples/client/echo_api/r/R/string_enum_ref.R
Normal file
88
samples/client/echo_api/r/R/string_enum_ref.R
Normal file
@@ -0,0 +1,88 @@
|
||||
#' @docType class
|
||||
#' @title StringEnumRef
|
||||
#' @description StringEnumRef Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
StringEnumRef <- R6::R6Class(
|
||||
"StringEnumRef",
|
||||
public = list(
|
||||
#' Initialize a new StringEnumRef class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new StringEnumRef class.
|
||||
#'
|
||||
#' @param ... Optional arguments.
|
||||
#' @export
|
||||
initialize = function(...) {
|
||||
local.optional.var <- list(...)
|
||||
val <- unlist(local.optional.var)
|
||||
enumvec <- .parse_StringEnumRef()
|
||||
|
||||
stopifnot(length(val) == 1L)
|
||||
|
||||
if (!val %in% enumvec)
|
||||
stop("Use one of the valid values: ",
|
||||
paste0(enumvec, collapse = ", "))
|
||||
private$value <- val
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return StringEnumRef in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
jsonlite::toJSON(private$value, auto_unbox = TRUE)
|
||||
},
|
||||
#' Deserialize JSON string into an instance of StringEnumRef
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of StringEnumRef
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of StringEnumRef
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
private$value <- jsonlite::fromJSON(input_json,
|
||||
simplifyVector = FALSE)
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return StringEnumRef in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
as.character(jsonlite::toJSON(private$value,
|
||||
auto_unbox = TRUE))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of StringEnumRef
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of StringEnumRef
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of StringEnumRef
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
private$value <- jsonlite::fromJSON(input_json,
|
||||
simplifyVector = FALSE)
|
||||
self
|
||||
}
|
||||
),
|
||||
private = list(
|
||||
value = NULL
|
||||
)
|
||||
)
|
||||
|
||||
# add to utils.R
|
||||
.parse_StringEnumRef <- function(vals) {
|
||||
res <- gsub("^\\[|\\]$", "", "[success, failure, unclassified]")
|
||||
unlist(strsplit(res, ", "))
|
||||
}
|
||||
|
||||
188
samples/client/echo_api/r/R/tag.R
Normal file
188
samples/client/echo_api/r/R/tag.R
Normal file
@@ -0,0 +1,188 @@
|
||||
#' Create a new Tag
|
||||
#'
|
||||
#' @description
|
||||
#' Tag Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title Tag
|
||||
#' @description Tag Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field id integer [optional]
|
||||
#' @field name character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Tag <- R6::R6Class(
|
||||
"Tag",
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
#' Initialize a new Tag class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new Tag class.
|
||||
#'
|
||||
#' @param id id
|
||||
#' @param name name
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`id` = NULL, `name` = NULL, ...) {
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`name`)) {
|
||||
if (!(is.character(`name`) && length(`name`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
|
||||
}
|
||||
self$`name` <- `name`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Tag in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
TagObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
TagObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
TagObject[["name"]] <-
|
||||
self$`name`
|
||||
}
|
||||
TagObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Tag
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Tag
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Tag
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`name`)) {
|
||||
self$`name` <- this_object$`name`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return Tag in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`name`)) {
|
||||
sprintf(
|
||||
'"name":
|
||||
"%s"
|
||||
',
|
||||
self$`name`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of Tag
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of Tag
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of Tag
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`id` <- this_object$`id`
|
||||
self$`name` <- this_object$`name`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to Tag
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to Tag and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of Tag
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# Tag$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# Tag$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# Tag$lock()
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
#' Create a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#' @description TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field size character [optional]
|
||||
#' @field color character [optional]
|
||||
#' @field id integer [optional]
|
||||
#' @field name character [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Class(
|
||||
"TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter",
|
||||
public = list(
|
||||
`size` = NULL,
|
||||
`color` = NULL,
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
#' Initialize a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter class.
|
||||
#'
|
||||
#' @param size size
|
||||
#' @param color color
|
||||
#' @param id id
|
||||
#' @param name name
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`size` = NULL, `color` = NULL, `id` = NULL, `name` = NULL, ...) {
|
||||
if (!is.null(`size`)) {
|
||||
if (!(is.character(`size`) && length(`size`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `size`. Must be a string:", `size`))
|
||||
}
|
||||
self$`size` <- `size`
|
||||
}
|
||||
if (!is.null(`color`)) {
|
||||
if (!(is.character(`color`) && length(`color`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `color`. Must be a string:", `color`))
|
||||
}
|
||||
self$`color` <- `color`
|
||||
}
|
||||
if (!is.null(`id`)) {
|
||||
if (!(is.numeric(`id`) && length(`id`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
|
||||
}
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`name`)) {
|
||||
if (!(is.character(`name`) && length(`name`) == 1)) {
|
||||
stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
|
||||
}
|
||||
self$`name` <- `name`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject <- list()
|
||||
if (!is.null(self$`size`)) {
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["size"]] <-
|
||||
self$`size`
|
||||
}
|
||||
if (!is.null(self$`color`)) {
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["color"]] <-
|
||||
self$`color`
|
||||
}
|
||||
if (!is.null(self$`id`)) {
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["id"]] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["name"]] <-
|
||||
self$`name`
|
||||
}
|
||||
TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`size`)) {
|
||||
self$`size` <- this_object$`size`
|
||||
}
|
||||
if (!is.null(this_object$`color`)) {
|
||||
self$`color` <- this_object$`color`
|
||||
}
|
||||
if (!is.null(this_object$`id`)) {
|
||||
self$`id` <- this_object$`id`
|
||||
}
|
||||
if (!is.null(this_object$`name`)) {
|
||||
self$`name` <- this_object$`name`
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`size`)) {
|
||||
sprintf(
|
||||
'"size":
|
||||
"%s"
|
||||
',
|
||||
self$`size`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`color`)) {
|
||||
sprintf(
|
||||
'"color":
|
||||
"%s"
|
||||
',
|
||||
self$`color`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)
|
||||
},
|
||||
if (!is.null(self$`name`)) {
|
||||
sprintf(
|
||||
'"name":
|
||||
"%s"
|
||||
',
|
||||
self$`name`
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`size` <- this_object$`size`
|
||||
self$`color` <- this_object$`color`
|
||||
self$`id` <- this_object$`id`
|
||||
self$`name` <- this_object$`name`
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$lock()
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
#' Create a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#' @description TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field values list(character) [optional]
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class(
|
||||
"TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter",
|
||||
public = list(
|
||||
`values` = NULL,
|
||||
#' Initialize a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter class.
|
||||
#'
|
||||
#' @description
|
||||
#' Initialize a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter class.
|
||||
#'
|
||||
#' @param values values
|
||||
#' @param ... Other optional arguments.
|
||||
#' @export
|
||||
initialize = function(`values` = NULL, ...) {
|
||||
if (!is.null(`values`)) {
|
||||
stopifnot(is.vector(`values`), length(`values`) != 0)
|
||||
sapply(`values`, function(x) stopifnot(is.character(x)))
|
||||
self$`values` <- `values`
|
||||
}
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
|
||||
#' @export
|
||||
toJSON = function() {
|
||||
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject <- list()
|
||||
if (!is.null(self$`values`)) {
|
||||
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject[["values"]] <-
|
||||
self$`values`
|
||||
}
|
||||
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject
|
||||
},
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#' @export
|
||||
fromJSON = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
if (!is.null(this_object$`values`)) {
|
||||
self$`values` <- ApiClient$new()$deserializeObj(this_object$`values`, "array[character]", loadNamespace("openapi"))
|
||||
}
|
||||
self
|
||||
},
|
||||
#' To JSON string
|
||||
#'
|
||||
#' @description
|
||||
#' To JSON String
|
||||
#'
|
||||
#' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format
|
||||
#' @export
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`values`)) {
|
||||
sprintf(
|
||||
'"values":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`values`, function(x) paste0('"', x, '"'))), collapse = ",")
|
||||
)
|
||||
}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||
},
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @param input_json the JSON input
|
||||
#' @return the instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#' @export
|
||||
fromJSONString = function(input_json) {
|
||||
this_object <- jsonlite::fromJSON(input_json)
|
||||
self$`values` <- ApiClient$new()$deserializeObj(this_object$`values`, "array[character]", loadNamespace("openapi"))
|
||||
self
|
||||
},
|
||||
#' Validate JSON input with respect to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#'
|
||||
#' @description
|
||||
#' Validate JSON input with respect to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter and throw an exception if invalid
|
||||
#'
|
||||
#' @param input the JSON input
|
||||
#' @export
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
},
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @description
|
||||
#' To string (JSON format)
|
||||
#'
|
||||
#' @return String representation of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
||||
#' @export
|
||||
toString = function() {
|
||||
self$toJSONString()
|
||||
},
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @description
|
||||
#' Return true if the values in all fields are valid.
|
||||
#'
|
||||
#' @return true if the values in all fields are valid.
|
||||
#' @export
|
||||
isValid = function() {
|
||||
TRUE
|
||||
},
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @description
|
||||
#' Return a list of invalid fields (if any).
|
||||
#'
|
||||
#' @return A list of invalid fields (if any).
|
||||
#' @export
|
||||
getInvalidFields = function() {
|
||||
invalid_fields <- list()
|
||||
invalid_fields
|
||||
},
|
||||
#' Print the object
|
||||
#'
|
||||
#' @description
|
||||
#' Print the object
|
||||
#'
|
||||
#' @export
|
||||
print = function() {
|
||||
print(jsonlite::prettify(self$toJSONString()))
|
||||
invisible(self)
|
||||
}
|
||||
),
|
||||
# Lock the class to prevent modifications to the method or field
|
||||
lock_class = TRUE
|
||||
)
|
||||
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||
# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$unlock()
|
||||
#
|
||||
## Below is an example to define the print function
|
||||
# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$set("public", "print", function(...) {
|
||||
# print(jsonlite::prettify(self$toJSONString()))
|
||||
# invisible(self)
|
||||
# })
|
||||
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||
# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$lock()
|
||||
|
||||
Reference in New Issue
Block a user