add documentations to r oneof, anyof (#12638)

This commit is contained in:
William Cheng 2022-06-19 23:19:55 +08:00 committed by GitHub
parent 0140f84f80
commit c26ac3f8a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 311 additions and 151 deletions

2
.gitignore vendored
View File

@ -222,6 +222,8 @@ samples/server/petstore/haskell-yesod/stack.yaml.lock
.Rproj.user
samples/client/petstore/R/**/petstore.Rcheck/
samples/client/petstore/R/**/*.tar.gz
samples/client/petstore/R/R.Rproj
samples/client/petstore/R/man/
# elixir
samples/client/petstore/elixir/_build/

View File

@ -11,14 +11,31 @@
{{classname}} <- R6::R6Class(
'{{classname}}',
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
#' @field actual_type the type of the object stored in this instance.
actual_type = NULL,
#' @field any_of a list of object types defined in the anyOf schema.
any_of = list({{#anyOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/anyOf}}),
#' Initialize a new {{{classname}}}.
#'
#' @description
#' Initialize a new {{{classname}}}.
#'
#' @export
#' @md
initialize = function(
{{#requiredVars}}`{{baseName}}`, {{/requiredVars}}{{#optionalVars}}`{{baseName}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
) {
local_optional_var <- list(...)
},
#' Deserialize JSON string into an instance of {{{classname}}}.
#'
#' @description
#' Deserialize JSON string into an instance of {{{classname}}}.
#'
#' @param input The input JSON.
#' @return An instance of {{{classname}}}.
#' @export
#' @md
fromJSON = function(input) {
error_messages <- list()
@ -41,6 +58,14 @@
# no match
stop(paste("No match found when deserializing the payload into {{{classname}}} with anyOf schemas {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Details: ", paste(error_messages, collapse = ', ')))
},
#' Serialize {{{classname}}} to JSON string.
#'
#' @description
#' Serialize {{{classname}}} to JSON string.
#'
#' @return JSON string reprenation of the {{{classname}}}.
#' @export
#' @md
toJSON = function() {
if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString()
@ -48,6 +73,15 @@
NULL
}
},
#' Validate the input JSON with respect to {{{classname}}}.
#'
#' @description
#' Validate the input JSON with respect to {{{classname}}} and
#' throw exception if invalid.
#'
#' @param input The input JSON.
#' @export
#' @md
validateJSON = function(input) {
# backup current values
actual_instance_bak <- self$actual_instance

View File

@ -11,14 +11,30 @@
{{classname}} <- R6::R6Class(
'{{classname}}',
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
#' @field actual_type the type of the object stored in this instance.
actual_type = NULL,
#' @field one_of a list of object types defined in the oneOf schema.
one_of = list({{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}}),
initialize = function(
{{#requiredVars}}`{{baseName}}`, {{/requiredVars}}{{#optionalVars}}`{{baseName}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
) {
local_optional_var <- list(...)
#' Initialize a new {{{classname}}}.
#'
#' @description
#' Initialize a new {{{classname}}}.
#'
#' @export
#' @md
initialize = function() {
},
#' Deserialize JSON string into an instance of {{{classname}}}.
#'
#' @description
#' Deserialize JSON string into an instance of {{{classname}}}.
#'
#' @param input The input JSON.
#' @return An instance of {{{classname}}}.
#' @export
#' @md
fromJSON = function(input) {
matched <- 0 # match counter
matched_schemas <- list() #names of matched schemas
@ -56,6 +72,14 @@
self
},
#' Serialize {{{classname}}} to JSON string.
#'
#' @description
#' Serialize {{{classname}}} to JSON string.
#'
#' @return JSON string reprenation of the {{{classname}}}.
#' @export
#' @md
toJSON = function() {
if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString()
@ -63,6 +87,15 @@
NULL
}
},
#' Validate the input JSON with respect to {{{classname}}}.
#'
#' @description
#' Validate the input JSON with respect to {{{classname}}} and
#' throw exception if invalid.
#'
#' @param input The input JSON.
#' @export
#' @md
validateJSON = function(input) {
# backup current values
actual_instance_bak <- self$actual_instance

View File

@ -1,15 +1,16 @@
{{#appName}}
# {{{.}}}
#
#' {{{.}}}
#'
{{/appName}}
{{#appDescription}}
# {{{.}}}
#
#' {{{.}}}
#'
{{/appDescription}}
{{#version}}
# The version of the OpenAPI document: {{{.}}}
#' The version of the OpenAPI document: {{{.}}}
{{/version}}
{{#infoEmail}}
# Contact: {{{.}}}
#' Contact: {{{.}}}
{{/infoEmail}}
# Generated by: https://openapi-generator.tech
#' Generated by: https://openapi-generator.tech
#'

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title AllofTagApiResponse

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Animal

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title AnyOfPig
@ -18,14 +19,31 @@
AnyOfPig <- R6::R6Class(
'AnyOfPig',
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
#' @field actual_type the type of the object stored in this instance.
actual_type = NULL,
#' @field any_of a list of object types defined in the anyOf schema.
any_of = list("BasquePig", "DanishPig"),
#' Initialize a new AnyOfPig.
#'
#' @description
#' Initialize a new AnyOfPig.
#'
#' @export
#' @md
initialize = function(
`className`, `color`, `size`, ...
) {
local_optional_var <- list(...)
},
#' Deserialize JSON string into an instance of AnyOfPig.
#'
#' @description
#' Deserialize JSON string into an instance of AnyOfPig.
#'
#' @param input The input JSON.
#' @return An instance of AnyOfPig.
#' @export
#' @md
fromJSON = function(input) {
error_messages <- list()
@ -60,6 +78,14 @@ AnyOfPig <- R6::R6Class(
# no match
stop(paste("No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: ", paste(error_messages, collapse = ', ')))
},
#' Serialize AnyOfPig to JSON string.
#'
#' @description
#' Serialize AnyOfPig to JSON string.
#'
#' @return JSON string reprenation of the AnyOfPig.
#' @export
#' @md
toJSON = function() {
if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString()
@ -67,6 +93,15 @@ AnyOfPig <- R6::R6Class(
NULL
}
},
#' Validate the input JSON with respect to AnyOfPig.
#'
#' @description
#' Validate the input JSON with respect to AnyOfPig and
#' throw exception if invalid.
#'
#' @param input The input JSON.
#' @export
#' @md
validateJSON = function(input) {
# backup current values
actual_instance_bak <- self$actual_instance

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' ApiClient Class

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title BasquePig

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Cat

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title CatAllOf

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Category

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title DanishPig

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Dog

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title DogAllOf

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Fake operations

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title ModelApiResponse

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Order

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Pet

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Pet operations

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Pig
@ -18,14 +19,30 @@
Pig <- R6::R6Class(
'Pig',
public = list(
#' @field actual_instance the object stored in this instance.
actual_instance = NULL,
#' @field actual_type the type of the object stored in this instance.
actual_type = NULL,
#' @field one_of a list of object types defined in the oneOf schema.
one_of = list("BasquePig", "DanishPig"),
initialize = function(
`className`, `color`, `size`, ...
) {
local_optional_var <- list(...)
#' Initialize a new Pig.
#'
#' @description
#' Initialize a new Pig.
#'
#' @export
#' @md
initialize = function() {
},
#' Deserialize JSON string into an instance of Pig.
#'
#' @description
#' Deserialize JSON string into an instance of Pig.
#'
#' @param input The input JSON.
#' @return An instance of Pig.
#' @export
#' @md
fromJSON = function(input) {
matched <- 0 # match counter
matched_schemas <- list() #names of matched schemas
@ -76,6 +93,14 @@ Pig <- R6::R6Class(
self
},
#' Serialize Pig to JSON string.
#'
#' @description
#' Serialize Pig to JSON string.
#'
#' @return JSON string reprenation of the Pig.
#' @export
#' @md
toJSON = function() {
if (!is.null(self$actual_instance)) {
self$actual_instance$toJSONString()
@ -83,6 +108,15 @@ Pig <- R6::R6Class(
NULL
}
},
#' Validate the input JSON with respect to Pig.
#'
#' @description
#' Validate the input JSON with respect to Pig and
#' throw exception if invalid.
#'
#' @param input The input JSON.
#' @export
#' @md
validateJSON = function(input) {
# backup current values
actual_instance_bak <- self$actual_instance

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Store operations

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Tag

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title UpdatePetRequest

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title User

View File

@ -1,9 +1,10 @@
# OpenAPI Petstore
#
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#
# The version of the OpenAPI document: 1.0.0
# Generated by: https://openapi-generator.tech
#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title User operations

View File

@ -17,6 +17,7 @@ Rscript -e "install.packages('R6', repos='$REPO', lib='$R_LIBS_USER')"
Rscript -e "install.packages('base64enc', repos='$REPO', lib='$R_LIBS_USER')"
Rscript -e "install.packages('rlang', repos='$REPO', lib='$R_LIBS_USER')"
Rscript -e "install.packages('rjson', repos='$REPO', lib='$R_LIBS_USER')"
Rscript -e "install.packages('devtools', repos='$REPO', lib='$R_LIBS_USER')"
rm petstore_1.0.0.tar.gz || true