Skip to content

Commit 18b950c

Browse files
LiNk-NYwing328
authored andcommitted
[BUG][R] use loadNamespace instead of package:pkgName string (#4614)
* use loadNamespace instead of package:pkgName string * update R package code
1 parent 52554af commit 18b950c

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

modules/openapi-generator/src/main/resources/r/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
{{/isPrimitiveType}}
277277
{{^isPrimitiveType}}
278278
deserializedRespObj <- tryCatch(
279-
self$apiClient$deserialize(resp, "{{returnType}}", "package:{{packageName}}"),
279+
self$apiClient$deserialize(resp, "{{returnType}}", loadNamespace("{{packageName}}")),
280280
error = function(e){
281281
{{#useDefaultExceptionHandling}}
282282
stop("Failed to deserialize response")

modules/openapi-generator/src/main/resources/r/model.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
{{#vars}}
146146
if (!is.null({{classname}}Object$`{{baseName}}`)) {
147147
{{#isContainer}}
148-
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", "package:{{packageName}}")
148+
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
149149
{{/isContainer}}
150150
{{^isContainer}}
151151
{{#isPrimitiveType}}
@@ -226,7 +226,7 @@
226226
{{#vars}}
227227
{{! AAPI - added condition for handling container type of parameters, map and array}}
228228
{{#isContainer}}
229-
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}","package:{{packageName}}")
229+
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
230230
{{/isContainer}}
231231
{{^isContainer}}
232232
{{#isPrimitiveType}}

samples/client/petstore/R/R/pet.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ Pet <- R6::R6Class(
107107
self$`name` <- PetObject$`name`
108108
}
109109
if (!is.null(PetObject$`photoUrls`)) {
110-
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", "package:petstore")
110+
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", loadNamespace("petstore"))
111111
}
112112
if (!is.null(PetObject$`tags`)) {
113-
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", "package:petstore")
113+
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", loadNamespace("petstore"))
114114
}
115115
if (!is.null(PetObject$`status`)) {
116116
self$`status` <- PetObject$`status`
@@ -169,8 +169,8 @@ Pet <- R6::R6Class(
169169
self$`id` <- PetObject$`id`
170170
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE, digits = NA))
171171
self$`name` <- PetObject$`name`
172-
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]","package:petstore")
173-
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]","package:petstore")
172+
self$`photoUrls` <- ApiClient$new()$deserializeObj(PetObject$`photoUrls`, "array[character]", loadNamespace("petstore"))
173+
self$`tags` <- ApiClient$new()$deserializeObj(PetObject$`tags`, "array[Tag]", loadNamespace("petstore"))
174174
self$`status` <- PetObject$`status`
175175
self
176176
}

samples/client/petstore/R/R/pet_api.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ PetApi <- R6::R6Class(
469469

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

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

578578
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
579579
deserializedRespObj <- tryCatch(
580-
self$apiClient$deserialize(resp, "Pet", "package:petstore"),
580+
self$apiClient$deserialize(resp, "Pet", loadNamespace("petstore")),
581581
error = function(e){
582582
stop("Failed to deserialize response")
583583
}
@@ -739,7 +739,7 @@ PetApi <- R6::R6Class(
739739

740740
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
741741
deserializedRespObj <- tryCatch(
742-
self$apiClient$deserialize(resp, "ModelApiResponse", "package:petstore"),
742+
self$apiClient$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
743743
error = function(e){
744744
stop("Failed to deserialize response")
745745
}

samples/client/petstore/R/R/store_api.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ StoreApi <- R6::R6Class(
254254

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

307307
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
308308
deserializedRespObj <- tryCatch(
309-
self$apiClient$deserialize(resp, "Order", "package:petstore"),
309+
self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
310310
error = function(e){
311311
stop("Failed to deserialize response")
312312
}
@@ -360,7 +360,7 @@ StoreApi <- R6::R6Class(
360360

361361
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
362362
deserializedRespObj <- tryCatch(
363-
self$apiClient$deserialize(resp, "Order", "package:petstore"),
363+
self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
364364
error = function(e){
365365
stop("Failed to deserialize response")
366366
}

samples/client/petstore/R/R/user_api.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ UserApi <- R6::R6Class(
521521

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

578578
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
579579
deserializedRespObj <- tryCatch(
580-
self$apiClient$deserialize(resp, "character", "package:petstore"),
580+
self$apiClient$deserialize(resp, "character", loadNamespace("petstore")),
581581
error = function(e){
582582
stop("Failed to deserialize response")
583583
}

0 commit comments

Comments
 (0)