[BUG][R] use loadNamespace instead of package:pkgName string (#4614)

* use loadNamespace instead of package:pkgName string

* update R package code
This commit is contained in:
Marcel Ramos 2019-11-28 21:14:47 -05:00 committed by William Cheng
parent 52554af454
commit 18b950cdc3
6 changed files with 16 additions and 16 deletions

View File

@ -276,7 +276,7 @@
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "{{returnType}}", "package:{{packageName}}"), self$apiClient$deserialize(resp, "{{returnType}}", loadNamespace("{{packageName}}")),
error = function(e){ error = function(e){
{{#useDefaultExceptionHandling}} {{#useDefaultExceptionHandling}}
stop("Failed to deserialize response") stop("Failed to deserialize response")

View File

@ -145,7 +145,7 @@
{{#vars}} {{#vars}}
if (!is.null({{classname}}Object$`{{baseName}}`)) { if (!is.null({{classname}}Object$`{{baseName}}`)) {
{{#isContainer}} {{#isContainer}}
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", "package:{{packageName}}") self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
@ -226,7 +226,7 @@
{{#vars}} {{#vars}}
{{! AAPI - added condition for handling container type of parameters, map and array}} {{! AAPI - added condition for handling container type of parameters, map and array}}
{{#isContainer}} {{#isContainer}}
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}","package:{{packageName}}") self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
{{#isPrimitiveType}} {{#isPrimitiveType}}

View File

@ -107,10 +107,10 @@ Pet <- R6::R6Class(
self$`name` <- PetObject$`name` self$`name` <- PetObject$`name`
} }
if (!is.null(PetObject$`photoUrls`)) { if (!is.null(PetObject$`photoUrls`)) {
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", "package:petstore") self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", loadNamespace("petstore"))
} }
if (!is.null(PetObject$`tags`)) { if (!is.null(PetObject$`tags`)) {
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", "package:petstore") self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", loadNamespace("petstore"))
} }
if (!is.null(PetObject$`status`)) { if (!is.null(PetObject$`status`)) {
self$`status` <- PetObject$`status` self$`status` <- PetObject$`status`
@ -169,8 +169,8 @@ Pet <- R6::R6Class(
self$`id` <- PetObject$`id` self$`id` <- PetObject$`id`
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE, digits = NA)) self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE, digits = NA))
self$`name` <- PetObject$`name` self$`name` <- PetObject$`name`
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]","package:petstore") self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", loadNamespace("petstore"))
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]","package:petstore") self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", loadNamespace("petstore"))
self$`status` <- PetObject$`status` self$`status` <- PetObject$`status`
self self
} }

View File

@ -469,7 +469,7 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[Pet]", "package:petstore"), self$apiClient$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -521,7 +521,7 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[Pet]", "package:petstore"), self$apiClient$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -577,7 +577,7 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "Pet", "package:petstore"), self$apiClient$deserialize(resp, "Pet", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -739,7 +739,7 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "ModelApiResponse", "package:petstore"), self$apiClient$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }

View File

@ -254,7 +254,7 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "map(integer)", "package:petstore"), self$apiClient$deserialize(resp, "map(integer)", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -306,7 +306,7 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "Order", "package:petstore"), self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -360,7 +360,7 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "Order", "package:petstore"), self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }

View File

@ -521,7 +521,7 @@ UserApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "User", "package:petstore"), self$apiClient$deserialize(resp, "User", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }
@ -577,7 +577,7 @@ UserApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch( deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "character", "package:petstore"), self$apiClient$deserialize(resp, "character", loadNamespace("petstore")),
error = function(e){ error = function(e){
stop("Failed to deserialize response") stop("Failed to deserialize response")
} }