forked from loafle/openapi-generator-original
[R] feat(r) : Alternate PR for serialization fixes along with WithHttpInfo method enhancement (#3099)
* feat(r): fixing serialization and deserialization issues
* feat(r): pet store file generated with serialization fixes
* fix(r): updated the query params with keyname in get request
* fix(r):fix issue with package name and other minor
* fix(r): fixing unit tests
* feat(r): adding api calls WithHttpInfo method
* fix(r): reverting unit test changes
* feat(r): saving changes for reference
* Revert "feat(r): saving changes for reference"
This reverts commit 0d091b5c20.
* feat(r): minor refactor of method position
* fix(r): fixing bug in withhttpinfo method args passing
* fix(r): generated petstore with fix
This commit is contained in:
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g r -o samples\client\petstore\R
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g r -o samples\client\petstore\R --additional-properties packageName=petstore
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
+5
-3
@@ -103,8 +103,10 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("file", "data.frame");
|
||||
typeMapping.put("binary", "data.frame");
|
||||
typeMapping.put("ByteArray", "character");
|
||||
typeMapping.put("map", "object");
|
||||
typeMapping.put("map", "map");
|
||||
typeMapping.put("object", "object");
|
||||
|
||||
importMapping.clear();
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "R package name (convention: lowercase).")
|
||||
.defaultValue("openapi"));
|
||||
@@ -288,10 +290,10 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner);
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner)+ "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getTypeDeclaration(inner);
|
||||
return getSchemaType(p) + "(" + getTypeDeclaration(inner) + ")";
|
||||
}
|
||||
|
||||
// Not using the supertype invocation, because we want to UpperCamelize
|
||||
|
||||
+18
-4
@@ -33,6 +33,18 @@
|
||||
},
|
||||
{{#operation}}
|
||||
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{#defaultValue}}{{{.}}}{{/defaultValue}}, {{/optionalParams}}...){
|
||||
apiResponse <- self${{{operationId}}}WithHttpInfo({{#allParams}}{{paramName}}, {{/allParams}}...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
{{{operationId}}}WithHttpInfo = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{#defaultValue}}{{{.}}}{{/defaultValue}}, {{/optionalParams}}...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -119,21 +131,23 @@
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
{{#returnType}}
|
||||
{{#isPrimitiveType}}
|
||||
httr::content(resp, "text", encoding = "UTF-8"
|
||||
content <- httr::content(resp, "text", encoding = "UTF-8")
|
||||
ApiResponse$new(content,resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{returnType}}$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "{{returnType}}", "package:{{packageName}}")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
# void response, no need to return anything
|
||||
{{! Returning the ApiResponse object with NULL object when the endpoint doesn't return anything}}
|
||||
ApiResponse$new(NULL, resp)
|
||||
{{/returnType}}
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}{{#hasMore}},{{/hasMore}}
|
||||
{{/operation}}
|
||||
)
|
||||
|
||||
@@ -74,7 +74,7 @@ ApiClient <- R6::R6Class(
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
httr::GET(url, query = queryParams, headers, ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PUT") {
|
||||
@@ -88,6 +88,48 @@ ApiClient <- R6::R6Class(
|
||||
} else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
},
|
||||
|
||||
deserialize = function(resp, returnType, pkgEnv) {
|
||||
respObj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(respObj, returnType, pkgEnv)
|
||||
},
|
||||
|
||||
deserializeObj = function(obj, returnType, pkgEnv) {
|
||||
returnObj <- NULL
|
||||
primitiveTypes <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
if (startsWith(returnType, "map(")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "map\\((.*)\\)", returnType))[[1]][2]
|
||||
returnObj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], innerReturnType, pkgEnv)
|
||||
})
|
||||
names(returnObj) <- names(obj)
|
||||
} else if (startsWith(returnType, "array[")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "array\\[(.*)\\]", returnType))[[1]][2]
|
||||
if (c(innerReturnType) %in% primitiveTypes) {
|
||||
returnObj <- vector("list", length = length(obj))
|
||||
if (length(obj) > 0) {
|
||||
for (row in 1:length(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row], innerReturnType, pkgEnv)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
returnObj <- vector("list", length = nrow(obj))
|
||||
if (nrow(obj) > 0) {
|
||||
for (row in 1:nrow(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
returnType <- get(returnType, envir = as.environment(pkgEnv))
|
||||
returnObj <- returnType$new()
|
||||
returnObj$fromJSON(jsonlite::toJSON(obj, digits = NA))
|
||||
} else {
|
||||
returnObj <- obj
|
||||
}
|
||||
returnObj
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
+40
-60
@@ -132,99 +132,79 @@
|
||||
{{classname}}Object <- jsonlite::fromJSON({{classname}}Json)
|
||||
{{#vars}}
|
||||
if (!is.null({{classname}}Object$`{{baseName}}`)) {
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- sapply({{classname}}Object$`{{baseName}}`, function(x) {
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
{{baseName}}Object
|
||||
})
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isContainer}}
|
||||
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", "package:{{packageName}}")
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE, digits = NA))
|
||||
self$`{{baseName}}` <- {{baseName}}Object
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/isContainer}}
|
||||
}
|
||||
{{/vars}}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
{{#vars}}
|
||||
"{{baseName}}":
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
[%s]{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
%s{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/vars}}
|
||||
}',
|
||||
{{#vars}}
|
||||
jsoncontent <- c(
|
||||
{{#vars}}
|
||||
if (!is.null(self$`{{baseName}}`)) {
|
||||
sprintf(
|
||||
'"{{baseName}}":
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) paste0('"', x, '"'))), collapse=","){{#hasMore}},{{/hasMore}}
|
||||
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE))), collapse=","){{#hasMore}},{{/hasMore}}
|
||||
{{^isPrimitiveType}}[%s]
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`{{#hasMore}},{{/hasMore}}
|
||||
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}%s
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}',
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) paste0('"', x, '"'))), collapse=",")
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE){{#hasMore}},{{/hasMore}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA))), collapse=",")
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE, digits = NA)
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
)}{{#hasMore}},{{/hasMore}}
|
||||
{{/vars}}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function({{classname}}Json) {
|
||||
{{classname}}Object <- jsonlite::fromJSON({{classname}}Json)
|
||||
{{#vars}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- lapply({{classname}}Object$`{{baseName}}`, function (x) x)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
data.frame <- {{classname}}Object$`{{baseName}}`
|
||||
self$`{{baseName}}` <- vector("list", length = nrow(data.frame))
|
||||
for (row in 1:nrow(data.frame)) {
|
||||
{{baseName}}.node <- {{dataType}}$new()
|
||||
{{baseName}}.node$fromJSON(jsonlite::toJSON(data.frame[row,,drop = TRUE], auto_unbox = TRUE))
|
||||
self$`{{baseName}}`[[row]] <- {{baseName}}.node
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{! AAPI - added condition for handling container type of parameters, map and array}}
|
||||
{{#isContainer}}
|
||||
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}","package:{{packageName}}")
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{dataType}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
self$`{{baseName}}` <- {{dataType}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE, digits = NA))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/isContainer}}
|
||||
{{/vars}}
|
||||
self
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ ApiClient <- R6::R6Class(
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
httr::GET(url, query = queryParams, headers, ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PUT") {
|
||||
@@ -95,6 +95,48 @@ ApiClient <- R6::R6Class(
|
||||
} else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
},
|
||||
|
||||
deserialize = function(resp, returnType, pkgEnv) {
|
||||
respObj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(respObj, returnType, pkgEnv)
|
||||
},
|
||||
|
||||
deserializeObj = function(obj, returnType, pkgEnv) {
|
||||
returnObj <- NULL
|
||||
primitiveTypes <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
if (startsWith(returnType, "map(")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "map\\((.*)\\)", returnType))[[1]][2]
|
||||
returnObj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], innerReturnType, pkgEnv)
|
||||
})
|
||||
names(returnObj) <- names(obj)
|
||||
} else if (startsWith(returnType, "array[")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "array\\[(.*)\\]", returnType))[[1]][2]
|
||||
if (c(innerReturnType) %in% primitiveTypes) {
|
||||
returnObj <- vector("list", length = length(obj))
|
||||
if (length(obj) > 0) {
|
||||
for (row in 1:length(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row], innerReturnType, pkgEnv)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
returnObj <- vector("list", length = nrow(obj))
|
||||
if (nrow(obj) > 0) {
|
||||
for (row in 1:nrow(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
returnType <- get(returnType, envir = as.environment(pkgEnv))
|
||||
returnObj <- returnType$new()
|
||||
returnObj$fromJSON(jsonlite::toJSON(obj, digits = NA))
|
||||
} else {
|
||||
returnObj <- obj
|
||||
}
|
||||
returnObj
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -54,16 +54,24 @@ Category <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"name":
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
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 = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(CategoryJson) {
|
||||
CategoryObject <- jsonlite::fromJSON(CategoryJson)
|
||||
|
||||
@@ -67,19 +67,31 @@ ModelApiResponse <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"code":
|
||||
%d,
|
||||
"type":
|
||||
"%s",
|
||||
"message":
|
||||
"%s"
|
||||
}',
|
||||
self$`code`,
|
||||
self$`type`,
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`code`)) {
|
||||
sprintf(
|
||||
'"code":
|
||||
%d
|
||||
',
|
||||
self$`code`
|
||||
)},
|
||||
if (!is.null(self$`type`)) {
|
||||
sprintf(
|
||||
'"type":
|
||||
"%s"
|
||||
',
|
||||
self$`type`
|
||||
)},
|
||||
if (!is.null(self$`message`)) {
|
||||
sprintf(
|
||||
'"message":
|
||||
"%s"
|
||||
',
|
||||
self$`message`
|
||||
)}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(ModelApiResponseJson) {
|
||||
ModelApiResponseObject <- jsonlite::fromJSON(ModelApiResponseJson)
|
||||
|
||||
@@ -105,28 +105,52 @@ Order <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"petId":
|
||||
%d,
|
||||
"quantity":
|
||||
%d,
|
||||
"shipDate":
|
||||
"%s",
|
||||
"status":
|
||||
"%s",
|
||||
"complete":
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
self$`petId`,
|
||||
self$`quantity`,
|
||||
self$`shipDate`,
|
||||
self$`status`,
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)},
|
||||
if (!is.null(self$`petId`)) {
|
||||
sprintf(
|
||||
'"petId":
|
||||
%d
|
||||
',
|
||||
self$`petId`
|
||||
)},
|
||||
if (!is.null(self$`quantity`)) {
|
||||
sprintf(
|
||||
'"quantity":
|
||||
%d
|
||||
',
|
||||
self$`quantity`
|
||||
)},
|
||||
if (!is.null(self$`shipDate`)) {
|
||||
sprintf(
|
||||
'"shipDate":
|
||||
"%s"
|
||||
',
|
||||
self$`shipDate`
|
||||
)},
|
||||
if (!is.null(self$`status`)) {
|
||||
sprintf(
|
||||
'"status":
|
||||
"%s"
|
||||
',
|
||||
self$`status`
|
||||
)},
|
||||
if (!is.null(self$`complete`)) {
|
||||
sprintf(
|
||||
'"complete":
|
||||
"%s"
|
||||
',
|
||||
self$`complete`
|
||||
)}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(OrderJson) {
|
||||
OrderObject <- jsonlite::fromJSON(OrderJson)
|
||||
|
||||
@@ -93,63 +93,77 @@ Pet <- R6::R6Class(
|
||||
}
|
||||
if (!is.null(PetObject$`category`)) {
|
||||
categoryObject <- Category$new()
|
||||
categoryObject$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
categoryObject$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE, digits = NA))
|
||||
self$`category` <- categoryObject
|
||||
}
|
||||
if (!is.null(PetObject$`name`)) {
|
||||
self$`name` <- PetObject$`name`
|
||||
}
|
||||
if (!is.null(PetObject$`photoUrls`)) {
|
||||
self$`photoUrls` <- PetObject$`photoUrls`
|
||||
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", "package:petstore")
|
||||
}
|
||||
if (!is.null(PetObject$`tags`)) {
|
||||
self$`tags` <- sapply(PetObject$`tags`, function(x) {
|
||||
tagsObject <- Tag$new()
|
||||
tagsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
tagsObject
|
||||
})
|
||||
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", "package:petstore")
|
||||
}
|
||||
if (!is.null(PetObject$`status`)) {
|
||||
self$`status` <- PetObject$`status`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"category":
|
||||
%s,
|
||||
"name":
|
||||
"%s",
|
||||
"photoUrls":
|
||||
[%s],
|
||||
"tags":
|
||||
[%s],
|
||||
"status":
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox=TRUE),
|
||||
self$`name`,
|
||||
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse=","),
|
||||
paste(unlist(lapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE))), collapse=","),
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)},
|
||||
if (!is.null(self$`category`)) {
|
||||
sprintf(
|
||||
'"category":
|
||||
%s
|
||||
',
|
||||
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox=TRUE, digits = NA)
|
||||
)},
|
||||
if (!is.null(self$`name`)) {
|
||||
sprintf(
|
||||
'"name":
|
||||
"%s"
|
||||
',
|
||||
self$`name`
|
||||
)},
|
||||
if (!is.null(self$`photoUrls`)) {
|
||||
sprintf(
|
||||
'"photoUrls":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse=",")
|
||||
)},
|
||||
if (!is.null(self$`tags`)) {
|
||||
sprintf(
|
||||
'"tags":
|
||||
[%s]
|
||||
',
|
||||
paste(unlist(lapply(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 = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(PetJson) {
|
||||
PetObject <- jsonlite::fromJSON(PetJson)
|
||||
self$`id` <- PetObject$`id`
|
||||
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE, digits = NA))
|
||||
self$`name` <- PetObject$`name`
|
||||
self$`photoUrls` <- lapply(PetObject$`photoUrls`, function (x) x)
|
||||
data.frame <- PetObject$`tags`
|
||||
self$`tags` <- vector("list", length = nrow(data.frame))
|
||||
for (row in 1:nrow(data.frame)) {
|
||||
tags.node <- Tag$new()
|
||||
tags.node$fromJSON(jsonlite::toJSON(data.frame[row,,drop = TRUE], auto_unbox = TRUE))
|
||||
self$`tags`[[row]] <- tags.node
|
||||
}
|
||||
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]","package:petstore")
|
||||
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]","package:petstore")
|
||||
self$`status` <- PetObject$`status`
|
||||
self
|
||||
}
|
||||
|
||||
@@ -57,6 +57,18 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
AddPet = function(body, ...){
|
||||
apiResponse <- self$AddPetWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
AddPetWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -83,15 +95,26 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
DeletePet = function(pet.id, api.key=NULL, ...){
|
||||
apiResponse <- self$DeletePetWithHttpInfo(pet.id, api.key, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
DeletePetWithHttpInfo = function(pet.id, api.key=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -118,15 +141,26 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
FindPetsByStatus = function(status, ...){
|
||||
apiResponse <- self$FindPetsByStatusWithHttpInfo(status, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
FindPetsByStatusWithHttpInfo = function(status, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -149,15 +183,27 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "array[Pet]", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
FindPetsByTags = function(tags, ...){
|
||||
apiResponse <- self$FindPetsByTagsWithHttpInfo(tags, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
FindPetsByTagsWithHttpInfo = function(tags, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -180,15 +226,27 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "array[Pet]", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
GetPetById = function(pet.id, ...){
|
||||
apiResponse <- self$GetPetByIdWithHttpInfo(pet.id, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
GetPetByIdWithHttpInfo = function(pet.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -215,15 +273,27 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "Pet", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
UpdatePet = function(body, ...){
|
||||
apiResponse <- self$UpdatePetWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
UpdatePetWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -250,15 +320,26 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
UpdatePetWithForm = function(pet.id, name=NULL, status=NULL, ...){
|
||||
apiResponse <- self$UpdatePetWithFormWithHttpInfo(pet.id, name, status, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
UpdatePetWithFormWithHttpInfo = function(pet.id, name=NULL, status=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -288,15 +369,26 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
UploadFile = function(pet.id, additional.metadata=NULL, file=NULL, ...){
|
||||
apiResponse <- self$UploadFileWithHttpInfo(pet.id, additional.metadata, file, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
UploadFileWithHttpInfo = function(pet.id, additional.metadata=NULL, file=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -326,13 +418,13 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ModelApiResponse$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "ModelApiResponse", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -45,6 +45,18 @@ StoreApi <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
DeleteOrder = function(order.id, ...){
|
||||
apiResponse <- self$DeleteOrderWithHttpInfo(order.id, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
DeleteOrderWithHttpInfo = function(order.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -67,15 +79,26 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
GetInventory = function(...){
|
||||
apiResponse <- self$GetInventoryWithHttpInfo(...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
GetInventoryWithHttpInfo = function(...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -94,15 +117,27 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
integer$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "map(integer)", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
GetOrderById = function(order.id, ...){
|
||||
apiResponse <- self$GetOrderByIdWithHttpInfo(order.id, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
GetOrderByIdWithHttpInfo = function(order.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -125,15 +160,27 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "Order", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
PlaceOrder = function(body, ...){
|
||||
apiResponse <- self$PlaceOrderWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
PlaceOrderWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -158,13 +205,13 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "Order", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -54,16 +54,24 @@ Tag <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"name":
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
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 = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(TagJson) {
|
||||
TagObject <- jsonlite::fromJSON(TagJson)
|
||||
|
||||
@@ -132,34 +132,66 @@ User <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"username":
|
||||
"%s",
|
||||
"firstName":
|
||||
"%s",
|
||||
"lastName":
|
||||
"%s",
|
||||
"email":
|
||||
"%s",
|
||||
"password":
|
||||
"%s",
|
||||
"phone":
|
||||
"%s",
|
||||
"userStatus":
|
||||
%d
|
||||
}',
|
||||
self$`id`,
|
||||
self$`username`,
|
||||
self$`firstName`,
|
||||
self$`lastName`,
|
||||
self$`email`,
|
||||
self$`password`,
|
||||
self$`phone`,
|
||||
jsoncontent <- c(
|
||||
if (!is.null(self$`id`)) {
|
||||
sprintf(
|
||||
'"id":
|
||||
%d
|
||||
',
|
||||
self$`id`
|
||||
)},
|
||||
if (!is.null(self$`username`)) {
|
||||
sprintf(
|
||||
'"username":
|
||||
"%s"
|
||||
',
|
||||
self$`username`
|
||||
)},
|
||||
if (!is.null(self$`firstName`)) {
|
||||
sprintf(
|
||||
'"firstName":
|
||||
"%s"
|
||||
',
|
||||
self$`firstName`
|
||||
)},
|
||||
if (!is.null(self$`lastName`)) {
|
||||
sprintf(
|
||||
'"lastName":
|
||||
"%s"
|
||||
',
|
||||
self$`lastName`
|
||||
)},
|
||||
if (!is.null(self$`email`)) {
|
||||
sprintf(
|
||||
'"email":
|
||||
"%s"
|
||||
',
|
||||
self$`email`
|
||||
)},
|
||||
if (!is.null(self$`password`)) {
|
||||
sprintf(
|
||||
'"password":
|
||||
"%s"
|
||||
',
|
||||
self$`password`
|
||||
)},
|
||||
if (!is.null(self$`phone`)) {
|
||||
sprintf(
|
||||
'"phone":
|
||||
"%s"
|
||||
',
|
||||
self$`phone`
|
||||
)},
|
||||
if (!is.null(self$`userStatus`)) {
|
||||
sprintf(
|
||||
'"userStatus":
|
||||
%d
|
||||
',
|
||||
self$`userStatus`
|
||||
)}
|
||||
)
|
||||
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||
paste('{', jsoncontent, '}', sep = "")
|
||||
},
|
||||
fromJSONString = function(UserJson) {
|
||||
UserObject <- jsonlite::fromJSON(UserJson)
|
||||
|
||||
@@ -57,6 +57,18 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
},
|
||||
CreateUser = function(body, ...){
|
||||
apiResponse <- self$CreateUserWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
CreateUserWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -81,15 +93,26 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
CreateUsersWithArrayInput = function(body, ...){
|
||||
apiResponse <- self$CreateUsersWithArrayInputWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
CreateUsersWithArrayInputWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -114,15 +137,26 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
CreateUsersWithListInput = function(body, ...){
|
||||
apiResponse <- self$CreateUsersWithListInputWithHttpInfo(body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
CreateUsersWithListInputWithHttpInfo = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -147,15 +181,26 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
DeleteUser = function(username, ...){
|
||||
apiResponse <- self$DeleteUserWithHttpInfo(username, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
DeleteUserWithHttpInfo = function(username, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -178,15 +223,26 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
GetUserByName = function(username, ...){
|
||||
apiResponse <- self$GetUserByNameWithHttpInfo(username, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
GetUserByNameWithHttpInfo = function(username, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -209,15 +265,27 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
User$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "User", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
LoginUser = function(username, password, ...){
|
||||
apiResponse <- self$LoginUserWithHttpInfo(username, password, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
LoginUserWithHttpInfo = function(username, password, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -244,15 +312,27 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
character$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "character", "package:petstore")
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
LogoutUser = function(...){
|
||||
apiResponse <- self$LogoutUserWithHttpInfo(...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
LogoutUserWithHttpInfo = function(...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -267,15 +347,26 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
UpdateUser = function(username, body, ...){
|
||||
apiResponse <- self$UpdateUserWithHttpInfo(username, body, ...)
|
||||
resp <- apiResponse$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
}
|
||||
},
|
||||
|
||||
UpdateUserWithHttpInfo = function(username, body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
@@ -308,13 +399,12 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -6,8 +6,8 @@ Name | Type | Description | Notes
|
||||
**id** | **integer** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**name** | **character** | |
|
||||
**photoUrls** | **character** | |
|
||||
**tags** | [**Tag**](Tag.md) | | [optional]
|
||||
**photoUrls** | **array[character]** | |
|
||||
**tags** | [**array[Tag]**](Tag.md) | | [optional]
|
||||
**status** | **character** | pet status in the store | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ void (empty response body)
|
||||
|
||||
|
||||
# **FindPetsByStatus**
|
||||
> Pet FindPetsByStatus(status)
|
||||
> array[Pet] FindPetsByStatus(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
@@ -105,7 +105,7 @@ Multiple status values can be provided with comma separated strings
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.status <- list("status_example") # character | Status values that need to be considered for filter
|
||||
var.status <- list("status_example") # array[character] | Status values that need to be considered for filter
|
||||
|
||||
#Finds Pets by status
|
||||
api.instance <- PetApi$new()
|
||||
@@ -119,11 +119,11 @@ dput(result)
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**character**](character.md)| Status values that need to be considered for filter |
|
||||
**status** | [**array[character]**](character.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
[**array[Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -137,7 +137,7 @@ Name | Type | Description | Notes
|
||||
|
||||
|
||||
# **FindPetsByTags**
|
||||
> Pet FindPetsByTags(tags)
|
||||
> array[Pet] FindPetsByTags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
@@ -147,7 +147,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.tags <- list("inner_example") # character | Tags to filter by
|
||||
var.tags <- list("inner_example") # array[character] | Tags to filter by
|
||||
|
||||
#Finds Pets by tags
|
||||
api.instance <- PetApi$new()
|
||||
@@ -161,11 +161,11 @@ dput(result)
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**character**](character.md)| Tags to filter by |
|
||||
**tags** | [**array[character]**](character.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
[**array[Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ No authorization required
|
||||
|
||||
|
||||
# **GetInventory**
|
||||
> integer GetInventory()
|
||||
> map(integer) GetInventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
@@ -74,7 +74,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**integer**
|
||||
**map(integer)**
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ Creates list of users with given input array
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # User | List of user object
|
||||
var.body <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
||||
|
||||
#Creates list of users with given input array
|
||||
api.instance <- UserApi$new()
|
||||
@@ -73,7 +73,7 @@ api.instance$CreateUsersWithArrayInput(var.body)
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](User.md)| List of user object |
|
||||
**body** | [**array[User]**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -99,7 +99,7 @@ Creates list of users with given input array
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # User | List of user object
|
||||
var.body <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
||||
|
||||
#Creates list of users with given input array
|
||||
api.instance <- UserApi$new()
|
||||
@@ -110,7 +110,7 @@ api.instance$CreateUsersWithListInput(var.body)
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](User.md)| List of user object |
|
||||
**body** | [**array[User]**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user