Fix/r/serialization fix and minor 3xx resp fix (#3817)

* fix(qlik): fix for minor serialization bug

* fix(r): add petsore generated classes

* fix(r): indendation fixes
This commit is contained in:
Ramanth Addala
2019-09-10 13:16:55 +05:30
committed by William Cheng
parent 8d67acc3ed
commit e18f361534
6 changed files with 99 additions and 28 deletions

View File

@@ -164,6 +164,8 @@
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {

View File

@@ -23,7 +23,7 @@
local.optional.var <- list(...)
{{#requiredVars}}
if (!missing(`{{baseName}}`)) {
{{^isListContainer}}
{{^isContainer}}
{{#isInteger}}
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
{{/isInteger}}
@@ -48,8 +48,8 @@
{{^isPrimitiveType}}
stopifnot(R6::is.R6(`{{baseName}}`))
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isListContainer}}
{{/isContainer}}
{{#isContainer}}
{{#isPrimitiveType}}
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
@@ -58,13 +58,13 @@
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
{{/isPrimitiveType}}
{{/isListContainer}}
{{/isContainer}}
self$`{{baseName}}` <- `{{baseName}}`
}
{{/requiredVars}}
{{#optionalVars}}
if (!is.null(`{{baseName}}`)) {
{{^isListContainer}}
{{^isContainer}}
{{#isInteger}}
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
{{/isInteger}}
@@ -89,8 +89,8 @@
{{^isPrimitiveType}}
stopifnot(R6::is.R6(`{{baseName}}`))
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isListContainer}}
{{/isContainer}}
{{#isContainer}}
{{#isPrimitiveType}}
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
@@ -99,7 +99,7 @@
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
{{/isPrimitiveType}}
{{/isListContainer}}
{{/isContainer}}
self$`{{baseName}}` <- `{{baseName}}`
}
{{/optionalVars}}
@@ -109,22 +109,32 @@
{{#vars}}
if (!is.null(self$`{{baseName}}`)) {
{{classname}}Object[['{{baseName}}']] <-
{{#isListContainer}}
{{#isPrimitiveType}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
self$`{{baseName}}`
{{/isPrimitiveType}}
{{^isPrimitiveType}}
lapply(self$`{{baseName}}`, function(x) x$toJSON())
{{/isPrimitiveType}}
{{^isPrimitiveType}}
sapply(self$`{{baseName}}`, function(x) x$toJSON())
{{/isPrimitiveType}}
{{/isListContainer}}
{{^isListContainer}}
{{#isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
{{#isPrimitiveType}}
self$`{{baseName}}`
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
lapply(self$`{{baseName}}`, function(x) x$toJSON())
{{/isPrimitiveType}}
{{/isMapContainer}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
self$`{{baseName}}`
{{/isPrimitiveType}}
{{^isPrimitiveType}}
self$`{{baseName}}`$toJSON()
{{/isPrimitiveType}}
{{/isListContainer}}
{{/isPrimitiveType}}
{{/isContainer}}
}
{{/vars}}
@@ -156,6 +166,7 @@
if (!is.null(self$`{{baseName}}`)) {
sprintf(
'"{{baseName}}":
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}
@@ -163,31 +174,49 @@
{{^isPrimitiveType}}[%s]
{{/isPrimitiveType}}
{{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isListContainer}}',
{{/isMapContainer}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}%s
{{/isPrimitiveType}}
{{/isContainer}}',
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) paste0('"', x, '"'))), collapse=",")
{{/isPrimitiveType}}
{{^isPrimitiveType}}
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA))), collapse=",")
paste(sapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
{{/isPrimitiveType}}
{{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
{{#isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{baseName}}}`, function(x){ x }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(lapply(self$`{{{baseName}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
{{/isPrimitiveType}}
{{/isMapContainer}}
{{/isContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
self$`{{baseName}}`
{{/isPrimitiveType}}
{{^isPrimitiveType}}
jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE, digits = NA)
{{/isPrimitiveType}}
{{/isListContainer}}
{{/isContainer}}
)}{{#hasMore}},{{/hasMore}}
{{/vars}}
{{/vars}}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
paste('{', jsoncontent, '}', sep = "")

View File

@@ -84,7 +84,7 @@ Pet <- R6::R6Class(
}
if (!is.null(self$`tags`)) {
PetObject[['tags']] <-
sapply(self$`tags`, function(x) x$toJSON())
lapply(self$`tags`, function(x) x$toJSON())
}
if (!is.null(self$`status`)) {
PetObject[['status']] <-
@@ -151,7 +151,7 @@ Pet <- R6::R6Class(
'"tags":
[%s]
',
paste(unlist(lapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA))), collapse=",")
paste(sapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
)},
if (!is.null(self$`status`)) {
sprintf(

View File

@@ -336,6 +336,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -384,6 +386,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -432,6 +436,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -482,6 +488,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -532,6 +540,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -586,6 +596,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -634,6 +646,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -685,6 +699,8 @@ PetApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {

View File

@@ -179,6 +179,8 @@ StoreApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -223,6 +225,8 @@ StoreApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -269,6 +273,8 @@ StoreApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -319,6 +325,8 @@ StoreApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {

View File

@@ -296,6 +296,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -342,6 +344,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -389,6 +393,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -436,6 +442,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -480,6 +488,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -530,6 +540,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -584,6 +596,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {
@@ -620,6 +634,8 @@ UserApi <- R6::R6Class(
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} 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) {