Skip to content

Commit 9522f6d

Browse files
authored
add toString method in models (#12706)
1 parent 229b2dc commit 9522f6d

18 files changed

Lines changed: 172 additions & 18 deletions

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,17 @@
349349
stop(paste("The JSON input `", input, "` is invalid for {{classname}}: the required field `{{name}}` is missing."))
350350
}
351351
{{/requiredVars}}
352+
},
353+
#' To string (JSON format)
354+
#'
355+
#' @description
356+
#' To string (JSON format)
357+
#'
358+
#' @return String representation of {{{classname}}}
359+
#' @export
360+
toString = function() {
361+
self$toJSONString()
352362
}
353-
354363
)
355364
)
356365
{{/isEnum}}

samples/client/petstore/R/R/allof_tag_api_response.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,17 @@ AllofTagApiResponse <- R6::R6Class(
195195
#' @export
196196
validateJSON = function(input) {
197197
input_json <- jsonlite::fromJSON(input)
198+
},
199+
#' To string (JSON format)
200+
#'
201+
#' @description
202+
#' To string (JSON format)
203+
#'
204+
#' @return String representation of AllofTagApiResponse
205+
#' @export
206+
toString = function() {
207+
self$toJSONString()
198208
}
199-
200209
)
201210
)
202211

samples/client/petstore/R/R/animal.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,17 @@ Animal <- R6::R6Class(
135135
} else {
136136
stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing."))
137137
}
138+
},
139+
#' To string (JSON format)
140+
#'
141+
#' @description
142+
#' To string (JSON format)
143+
#'
144+
#' @return String representation of Animal
145+
#' @export
146+
toString = function() {
147+
self$toJSONString()
138148
}
139-
140149
)
141150
)
142151

samples/client/petstore/R/R/basque_pig.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,17 @@ BasquePig <- R6::R6Class(
141141
} else {
142142
stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing."))
143143
}
144+
},
145+
#' To string (JSON format)
146+
#'
147+
#' @description
148+
#' To string (JSON format)
149+
#'
150+
#' @return String representation of BasquePig
151+
#' @export
152+
toString = function() {
153+
self$toJSONString()
144154
}
145-
146155
)
147156
)
148157

samples/client/petstore/R/R/cat.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,17 @@ Cat <- R6::R6Class(
158158
} else {
159159
stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing."))
160160
}
161+
},
162+
#' To string (JSON format)
163+
#'
164+
#' @description
165+
#' To string (JSON format)
166+
#'
167+
#' @return String representation of Cat
168+
#' @export
169+
toString = function() {
170+
self$toJSONString()
161171
}
162-
163172
)
164173
)
165174

samples/client/petstore/R/R/cat_all_of.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,17 @@ CatAllOf <- R6::R6Class(
107107
#' @export
108108
validateJSON = function(input) {
109109
input_json <- jsonlite::fromJSON(input)
110+
},
111+
#' To string (JSON format)
112+
#'
113+
#' @description
114+
#' To string (JSON format)
115+
#'
116+
#' @return String representation of CatAllOf
117+
#' @export
118+
toString = function() {
119+
self$toJSONString()
110120
}
111-
112121
)
113122
)
114123

samples/client/petstore/R/R/category.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,17 @@ Category <- R6::R6Class(
129129
#' @export
130130
validateJSON = function(input) {
131131
input_json <- jsonlite::fromJSON(input)
132+
},
133+
#' To string (JSON format)
134+
#'
135+
#' @description
136+
#' To string (JSON format)
137+
#'
138+
#' @return String representation of Category
139+
#' @export
140+
toString = function() {
141+
self$toJSONString()
132142
}
133-
134143
)
135144
)
136145

samples/client/petstore/R/R/danish_pig.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,17 @@ DanishPig <- R6::R6Class(
141141
} else {
142142
stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing."))
143143
}
144+
},
145+
#' To string (JSON format)
146+
#'
147+
#' @description
148+
#' To string (JSON format)
149+
#'
150+
#' @return String representation of DanishPig
151+
#' @export
152+
toString = function() {
153+
self$toJSONString()
144154
}
145-
146155
)
147156
)
148157

samples/client/petstore/R/R/dog.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,17 @@ Dog <- R6::R6Class(
158158
} else {
159159
stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing."))
160160
}
161+
},
162+
#' To string (JSON format)
163+
#'
164+
#' @description
165+
#' To string (JSON format)
166+
#'
167+
#' @return String representation of Dog
168+
#' @export
169+
toString = function() {
170+
self$toJSONString()
161171
}
162-
163172
)
164173
)
165174

samples/client/petstore/R/R/dog_all_of.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,17 @@ DogAllOf <- R6::R6Class(
107107
#' @export
108108
validateJSON = function(input) {
109109
input_json <- jsonlite::fromJSON(input)
110+
},
111+
#' To string (JSON format)
112+
#'
113+
#' @description
114+
#' To string (JSON format)
115+
#'
116+
#' @return String representation of DogAllOf
117+
#' @export
118+
toString = function() {
119+
self$toJSONString()
110120
}
111-
112121
)
113122
)
114123

0 commit comments

Comments
 (0)