forked from loafle/openapi-generator-original
R client refactoring (#2215)
* [R] fix namespace, use 2-space indentation (#2105) * fix namespace, indentation * use 2-space indentation in model files * update gitignore * use PascalCase for function naming (#2106) * [R] improve .travis.yml, .Rbuildignore (#2109) * update travis * enhance travis.yml * update travis, .Rbuildignore * [R] Add auto-generated documentations, change parameter naming (#2114) * add auto-generated doc for r client * remove module name * replace nil with void * [R] fix object serialization to JSON (#2129) * fix object serialization * fix array property seriziation * fix deserializing array of string * fix array of object deserialization * [R] Fix return type (#2140) * fix return type * update r petstore sample * add auto-generated tests (#2141) * rename file to conform to style guide (#2142) * add authenticaiton support to R (#2153) [R] Add authentication support, minor ApiClient refactor * rename test files * [R] various improvements and bug fixes (#2162) * fix api keys in headers * use optional parameter in function signature * fix property naming * fix doc assignment operator * [R] fix base64 encode (#2171) * fix base64 encode * fix basic http auth * fix typo, update instruction (#2203) * rename test files to conform to style guide (#2206) * [R] improve class constructor (#2208) * update constructor with optional parameter, default value * update r petstore sample * clean up files * regenerate files * Revert "rename test files to conform to style guide (#2206)" This reverts commit 90a6302a6565d208a6ab298fda41a47836a63d9c. * fix query parameter in api client (#2214)
This commit is contained in:
parent
7486438491
commit
e6658278ad
2
.gitignore
vendored
2
.gitignore
vendored
@ -193,6 +193,8 @@ samples/client/petstore/haskell-http-client/docs/quick-jump.css
|
||||
|
||||
# R
|
||||
.Rproj.user
|
||||
samples/client/petstore/R/**/petstore.Rcheck/
|
||||
samples/client/petstore/R/**/*.tar.gz
|
||||
|
||||
# elixir
|
||||
samples/client/petstore/elixir/_build/
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@ -27,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
@ -38,6 +41,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
protected String testFolder = "tests/testthat";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
@ -54,8 +58,8 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public RClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/r";
|
||||
modelTemplateFiles.put("model.mustache", ".r");
|
||||
apiTemplateFiles.put("api.mustache", ".r");
|
||||
modelTemplateFiles.put("model.mustache", ".R");
|
||||
apiTemplateFiles.put("api.mustache", ".R");
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
@ -70,7 +74,9 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// reserved words: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html
|
||||
"if", "else", "repeat", "while", "function", "for", "in",
|
||||
"next", "break", "TRUE", "FALSE", "NULL", "Inf", "NaN",
|
||||
"NA", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_"
|
||||
"NA", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_",
|
||||
// reserved words in API client
|
||||
"ApiResponse"
|
||||
)
|
||||
);
|
||||
|
||||
@ -130,11 +136,11 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
apiTestTemplateFiles.clear(); // TODO: add api test template
|
||||
modelTestTemplateFiles.clear(); // TODO: add model test template
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".R");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".R");
|
||||
|
||||
apiDocTemplateFiles.clear(); // TODO: add api doc template
|
||||
modelDocTemplateFiles.clear(); // TODO: add model doc template
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
modelPackage = packageName;
|
||||
apiPackage = packageName;
|
||||
@ -145,10 +151,11 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("description.mustache", "", "DESCRIPTION"));
|
||||
supportingFiles.add(new SupportingFile("Rbuildignore.mustache", "", ".Rbuildignore"));
|
||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile("response.mustache", "/R", "Response.r"));
|
||||
supportingFiles.add(new SupportingFile("element.mustache", "/R", "Element.r"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", "/R", "ApiClient.r"));
|
||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", File.separator + "R", "api_response.R"));
|
||||
//supportingFiles.add(new SupportingFile("element.mustache", File.separator + "R", "Element.R"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", File.separator + "R", "api_client.R"));
|
||||
supportingFiles.add(new SupportingFile("NAMESPACE.mustache", "", "NAMESPACE"));
|
||||
supportingFiles.add(new SupportingFile("testthat.mustache", File.separator + "tests", "testthat.R"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,7 +187,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
public String toParamName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
|
||||
@ -200,21 +207,22 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (name.matches("^\\d.*"))
|
||||
name = "Var" + name;
|
||||
|
||||
return name.replace("_", ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// don't do anything as we'll put property name inside ` `, e.g. `date-time`
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
return toVarName(name);
|
||||
public String toModelFilename(String name) {
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
return toModelFilename(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
@ -246,7 +254,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.r => pet_api.r
|
||||
return camelize(name + "_api");
|
||||
return underscore(name + "_api");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -327,7 +335,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return underscore(sanitizedOperationId);
|
||||
return camelize(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -450,4 +458,179 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return enumName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameterExampleValue(CodegenParameter p) {
|
||||
String example;
|
||||
|
||||
if (p.defaultValue == null) {
|
||||
example = p.example;
|
||||
} else {
|
||||
p.example = p.defaultValue;
|
||||
return;
|
||||
}
|
||||
|
||||
String type = p.baseType;
|
||||
if (type == null) {
|
||||
type = p.dataType;
|
||||
}
|
||||
|
||||
if ("character".equals(type)) {
|
||||
if (example == null) {
|
||||
example = p.paramName + "_example";
|
||||
}
|
||||
example = "'" + escapeText(example) + "'";
|
||||
} else if ("integer".equals(type)) {
|
||||
if (example == null) {
|
||||
example = "56";
|
||||
}
|
||||
} else if ("numeric".equals(type)) {
|
||||
if (example == null) {
|
||||
example = "3.4";
|
||||
}
|
||||
} else if ("data.frame".equals(type)) {
|
||||
if (example == null) {
|
||||
example = "/path/to/file";
|
||||
}
|
||||
example = "File.new('" + escapeText(example) + "')";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
example = type + "$new()";
|
||||
}
|
||||
|
||||
if (example == null) {
|
||||
example = "NULL";
|
||||
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
example = "[" + example + "]";
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
example = "{'key' => " + example + "}";
|
||||
}
|
||||
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the parameter. Overrides the
|
||||
* setParameterExampleValue(CodegenParameter, Parameter) method in
|
||||
* DefaultCodegen to always call setParameterExampleValue(CodegenParameter)
|
||||
* in this class, which adds single quotes around strings from the
|
||||
* x-example property.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param parameter Parameter
|
||||
*/
|
||||
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
||||
if (parameter.getExample() != null) {
|
||||
codegenParameter.example = parameter.getExample().toString();
|
||||
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
|
||||
Example example = parameter.getExamples().values().iterator().next();
|
||||
if (example.getValue() != null) {
|
||||
codegenParameter.example = example.getValue().toString();
|
||||
}
|
||||
} else {
|
||||
Schema schema = parameter.getSchema();
|
||||
if (schema != null && schema.getExample() != null) {
|
||||
codegenParameter.example = schema.getExample().toString();
|
||||
}
|
||||
}
|
||||
|
||||
setParameterExampleValue(codegenParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
* @param p OpenAPI property object
|
||||
* @return string presentation of the default value of the property
|
||||
*/
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isBooleanSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Boolean.valueOf(p.getDefault().toString()) == false)
|
||||
return "FALSE";
|
||||
else
|
||||
return "TRUE";
|
||||
}
|
||||
// include fallback to example, default defined as server only
|
||||
// example is not defined as server only
|
||||
if (p.getExample() != null) {
|
||||
if (Boolean.valueOf(p.getExample().toString()) == false)
|
||||
return "FALSE";
|
||||
else
|
||||
return "TRUE";
|
||||
}
|
||||
} else if (ModelUtils.isDateSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
// TODO
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
// default numbers are not yet returned by v2 spec openAPI results
|
||||
// https://github.com/swagger-api/swagger-parser/issues/971
|
||||
// include fallback to example, default defined as server only
|
||||
// example is not defined as server only
|
||||
if (p.getExample() != null) {
|
||||
return p.getExample().toString();
|
||||
}
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
// default integers are not yet returned by v2 spec openAPI results
|
||||
// https://github.com/swagger-api/swagger-parser/issues/971
|
||||
// include fallback to example, default defined as server only
|
||||
// example is not defined as server only
|
||||
if (p.getExample() != null) {
|
||||
return p.getExample().toString();
|
||||
}
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
|
||||
return "'''" + p.getDefault() + "'''";
|
||||
else
|
||||
return "'" + p.getDefault() + "'";
|
||||
}
|
||||
// include fallback to example, default defined as server only
|
||||
// example is not defined as server only
|
||||
if (p.getExample() != null) {
|
||||
if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getExample()).find())
|
||||
return "'''" + p.getExample() + "'''";
|
||||
else
|
||||
return "'" + p.getExample() + "'";
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString();
|
||||
}
|
||||
// include fallback to example, default defined as server only
|
||||
// example is not defined as server only
|
||||
if (p.getExample() != null) {
|
||||
return p.getExample().toString();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return outputFolder + File.separator + testFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return outputFolder + File.separator + testFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return "test_" + toApiFilename(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return "test_" + toModelFilename(name);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,15 @@
|
||||
# ref: https://docs.travis-ci.com/user/languages/r/
|
||||
language: r
|
||||
cache: packages
|
||||
cache:
|
||||
directories:
|
||||
- /home/travis/R/Library
|
||||
r_packages:
|
||||
- jsonlite
|
||||
- httr
|
||||
# uncomment below to install deps with devtools
|
||||
#install:
|
||||
#- R -e 'devtools::install_deps(dep = T)'
|
||||
script:
|
||||
- R CMD build .
|
||||
- R CMD check *tar.gz
|
||||
- R CMD INSTALL *tar.gz
|
||||
|
@ -1,9 +1,9 @@
|
||||
#' Response Class
|
||||
#' ApiResponse Class
|
||||
#'
|
||||
#' Response Class
|
||||
#' ApiResponse Class
|
||||
#' @export
|
||||
Response <- R6::R6Class(
|
||||
'Response',
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
public = list(
|
||||
content = NULL,
|
||||
response = NULL,
|
@ -1,8 +1,26 @@
|
||||
# Generated by openapi-generator: https://openapi-generator.tech
|
||||
# Do not edit by hand
|
||||
|
||||
# Core
|
||||
export(ApiClient)
|
||||
export(ApiResponse)
|
||||
|
||||
# Models
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
export({{{classname}}})
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
# APIs
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-first}}
|
||||
export({{{classname}}})
|
||||
{{/-first}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
@ -18,23 +18,83 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Installation
|
||||
You'll need the `devtools` package in order to build the API.
|
||||
Make sure you have a proper CRAN repository from which you can download packages.
|
||||
|
||||
### Prerequisites
|
||||
Install the `devtools` package with the following command.
|
||||
|
||||
Install the dependencies
|
||||
|
||||
```R
|
||||
if(!require(devtools)) { install.packages("devtools") }
|
||||
install.packages("jsonlite")
|
||||
install.packages("httr")
|
||||
install.packages("caTools")
|
||||
```
|
||||
|
||||
### Installation of the API package
|
||||
Make sure you set the working directory to where the API code is located.
|
||||
Then execute
|
||||
```R
|
||||
library(devtools)
|
||||
install(".")
|
||||
### Build the package
|
||||
|
||||
```sh
|
||||
git clone https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}
|
||||
cd {{{gitRepoId}}}
|
||||
R CMD build .
|
||||
R CMD check {{{packageName}}}_{{{packageVersion}}}.tar.gz
|
||||
R CMD INSTALL {{{packageName}}}_{{{packageVersion}}}.tar.gz
|
||||
```
|
||||
|
||||
### Install the package
|
||||
|
||||
```R
|
||||
install.packages("{{{packageName}}}")
|
||||
```
|
||||
|
||||
To install directly from Github, use `devtools`:
|
||||
```R
|
||||
install.packages("devtools")
|
||||
library(devtools)
|
||||
install_github("{{{gitUserId}}}/{{{gitRepoId}}}")
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```R
|
||||
library({{{packageName}}})
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
{{^authMethods}} All endpoints do not require authorization.
|
||||
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||
{{#authMethods}}### {{name}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
- **API key parameter name**: {{keyParamName}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}- **Type**: OAuth
|
||||
- **Flow**: {{flow}}
|
||||
- **Authorization URL**: {{authorizationUrl}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - {{scope}}: {{description}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
||||
|
@ -1,2 +1,5 @@
|
||||
^.*\.Rproj$
|
||||
^\.Rproj\.user$
|
||||
^\.openapi-generator-ignore$
|
||||
^\.travis\.yml$
|
||||
^\.openapi-generator$
|
||||
|
@ -5,7 +5,6 @@
|
||||
#'
|
||||
#' @field path Stores url path of the request.
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field userAgent Set the user agent of the request.
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#'
|
||||
@ -18,11 +17,11 @@
|
||||
{{/operation}}
|
||||
#' }
|
||||
#'
|
||||
#' @importFrom caTools base64encode
|
||||
#' @export
|
||||
{{classname}} <- R6::R6Class(
|
||||
'{{classname}}',
|
||||
public = list(
|
||||
userAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}",
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
@ -33,36 +32,34 @@
|
||||
}
|
||||
},
|
||||
{{#operation}}
|
||||
{{operationId}} = function({{#allParams}}{{paramName}}, {{/allParams}}...){
|
||||
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{#defaultValue}}{{{.}}}{{/defaultValue}}, {{/optionalParams}}...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
{{#hasHeaderParams}}
|
||||
{{#headerParams}}
|
||||
if (!missing(`{{paramName}}`)) {
|
||||
headerParams['{{baseName}}'] <- `{{paramName}}`
|
||||
{{#requiredParams}}
|
||||
if (missing(`{{paramName}}`)) {
|
||||
stop("Missing required parameter `{{{paramName}}}`.")
|
||||
}
|
||||
|
||||
{{/requiredParams}}
|
||||
{{#headerParams}}
|
||||
headerParams['{{baseName}}'] <- `{{paramName}}`
|
||||
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}
|
||||
{{#queryParams}}
|
||||
if (!missing(`{{paramName}}`)) {
|
||||
queryParams['{{baseName}}'] <- {{paramName}}
|
||||
}
|
||||
queryParams['{{baseName}}'] <- {{paramName}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
{{#hasFormParams}}
|
||||
body <- list(
|
||||
{{#formParams}}
|
||||
{{^isFile}}
|
||||
"{{baseName}}" = {{paramName}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isFile}}
|
||||
{{#isFile}}
|
||||
"{{baseName}}" = httr::upload_file({{paramName}}){{#hasMore}},{{/hasMore}}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
"{{baseName}}" = {{paramName}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isFile}}
|
||||
{{#isFile}}
|
||||
"{{baseName}}" = httr::upload_file({{paramName}}){{#hasMore}},{{/hasMore}}
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
)
|
||||
|
||||
@ -86,7 +83,33 @@
|
||||
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
# HTTP basic auth
|
||||
headerParams['Authorization'] <- paste("Basic", caTools::base64encode(paste(self$apiClient$username, self$apiClient$password, sep=":")), sep=" ")
|
||||
{{/isBasicBasic}}
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
# API key authentication
|
||||
{{#isKeyInHeader}}
|
||||
if ("{{{keyParamName}}}" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["{{{keyParamName}}}"]) > 0) {
|
||||
headerParams['{{keyParamName}}'] <- paste(unlist(self$apiClient$apiKeys["{{keyParamName}}"]), collapse='')
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if ("{{{keyParamName}}}" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["{{{keyParamName}}}"]) > 0) {
|
||||
queryParams['{{keyParamName}}'] <- paste(unlist(self$apiClient$apiKeys["{{keyParamName}}"]), collapse='')
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "{{httpMethod}}",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -95,22 +118,20 @@
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
{{#returnType}}
|
||||
{{#isPrimitiveType}}
|
||||
returnObject <- {{returnType}}$new()
|
||||
result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Response$new(returnObject, resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
{{/isPrimitiveType}}
|
||||
{{/returnType}}
|
||||
{{#isPrimitiveType}}
|
||||
httr::content(resp, "text", encoding = "UTF-8"
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{returnType}}$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
{{/isPrimitiveType}}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
# void response, no need to return anything
|
||||
# void response, no need to return anything
|
||||
{{/returnType}}
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}{{#hasMore}},{{/hasMore}}
|
||||
|
@ -12,53 +12,82 @@
|
||||
#' Ref: https://openapi-generator.tech
|
||||
#' Do not edit the class manually.
|
||||
#'
|
||||
#' @field basePath
|
||||
#' @field userAgent
|
||||
#' @field defaultHeaders
|
||||
#' @field username
|
||||
#' @field password
|
||||
#' @field apiKeys
|
||||
#' @field accessToken
|
||||
#' @importFrom httr
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
public = list(
|
||||
# base path of all requests
|
||||
basePath = "{{{basePath}}}",
|
||||
configuration = NULL,
|
||||
userAgent = NULL,
|
||||
# user agent in the HTTP request
|
||||
userAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}",
|
||||
# default headers in the HTTP request
|
||||
defaultHeaders = NULL,
|
||||
initialize = function(basePath, configuration, defaultHeaders){
|
||||
if (!missing(basePath)) {
|
||||
self$basePath <- basePath
|
||||
}
|
||||
# username (HTTP basic authentication)
|
||||
username = NULL,
|
||||
# password (HTTP basic authentication)
|
||||
password = NULL,
|
||||
# API keys
|
||||
apiKeys = NULL,
|
||||
# Access token
|
||||
accessToken = NULL,
|
||||
# constructor
|
||||
initialize = function(basePath=NULL, userAgent=NULL, defaultHeaders=NULL, username=NULL, password=NULL, apiKeys=NULL, accessToken=NULL){
|
||||
if (!is.null(basePath)) {
|
||||
self$basePath <- basePath
|
||||
}
|
||||
|
||||
if (!missing(configuration)) {
|
||||
self$configuration <- configuration
|
||||
}
|
||||
if (!is.null(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
}
|
||||
|
||||
if (!missing(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
}
|
||||
if (!is.null(username)) {
|
||||
self$username <- username
|
||||
}
|
||||
|
||||
self$`userAgent` <- '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}'
|
||||
if (!is.null(password)) {
|
||||
self$password <- password
|
||||
}
|
||||
|
||||
if (!is.null(accessToken)) {
|
||||
self$accessToken <- accessToken
|
||||
}
|
||||
|
||||
if (!is.null(apiKeys)) {
|
||||
self$apiKeys <- apiKeys
|
||||
} else {
|
||||
self$apiKeys <- list()
|
||||
}
|
||||
|
||||
if (!is.null(userAgent)) {
|
||||
self$`userAgent` <- userAgent
|
||||
}
|
||||
},
|
||||
callApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
CallApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
}
|
||||
else if (method == "POST") {
|
||||
httr::POST(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "PUT") {
|
||||
httr::PUT(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "PATCH") {
|
||||
httr::PATCH(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "HEAD") {
|
||||
httr::HEAD(url, queryParams, headers, ...)
|
||||
}
|
||||
else if (method == "DELETE") {
|
||||
httr::DELETE(url, queryParams, headers, ...)
|
||||
}
|
||||
else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PUT") {
|
||||
httr::PUT(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PATCH") {
|
||||
httr::PATCH(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "HEAD") {
|
||||
httr::HEAD(url, query = queryParams, headers, ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = queryParams, headers, ...)
|
||||
} else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# {{invokerPackage}}\{{classname}}{{#description}}
|
||||
# {{classname}}{{#description}}
|
||||
{{description}}{{/description}}
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
@ -10,41 +10,71 @@ Method | HTTP request | Description
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
# **{{{operationId}}}**
|
||||
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#authMethods}}ctx, {{/authMethods}}{{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
|
||||
# **{{operationId}}**
|
||||
> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}{{#defaultValue}}={{{.}}}{{/defaultValue}}{{^defaultValue}}=var.{{{paramName}}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/optionalParams}})
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{notes}}}{{/notes}}
|
||||
|
||||
### Required Parameters
|
||||
### Example
|
||||
```R
|
||||
library({{{packageName}}})
|
||||
|
||||
{{#allParams}}
|
||||
var.{{{paramName}}} <- {{{example}}} # {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
{{#summary}}
|
||||
#{{{.}}}
|
||||
{{/summary}}
|
||||
api.instance <- {{{classname}}}$new()
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
# Configure HTTP basic authorization: {{{name}}}
|
||||
api.instance$apiClient$username <- 'TODO_YOUR_USERNAME';
|
||||
api.instance$apiClient$password <- 'TODO_YOUR_PASSWORD';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
# Configure API key authorization: {{{name}}}
|
||||
api.instance$apiClient$apiKeys['{{{keyParamName}}}'] <- 'TODO_YOUR_API_KEY';
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
{{#returnType}}result <- {{/returnType}}api.instance${{{operationId}}}({{#requiredParams}}var.{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var.{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}})
|
||||
{{#returnType}}
|
||||
dput(result)
|
||||
{{/returnType}}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{#authMethods}}
|
||||
**ctx** | **context.Context** | context containing the authentication | nil if no authentication{{/authMethods}}{{/-last}}{{/allParams}}{{#allParams}}{{#required}}
|
||||
**{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
|
||||
**{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}}
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#requiredParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
{{#optionalParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/optionalParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
29
modules/openapi-generator/src/main/resources/r/api_test.mustache
vendored
Normal file
29
modules/openapi-generator/src/main/resources/r/api_test.mustache
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test {{{classname}}}")
|
||||
|
||||
api.instance <- {{{classname}}}$new()
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
test_that("{{{operationId}}}", {
|
||||
# tests for {{operationId}}
|
||||
# base path: {{{basePath}}}
|
||||
{{#summary}}
|
||||
# {{summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
# {{notes}}
|
||||
{{/notes}}
|
||||
{{#allParams}}
|
||||
# @param {{{dataType}}} {{{paramName}}} {{{description}}} {{^required}} (optional){{/required}}
|
||||
{{/allParams}}
|
||||
# @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -8,5 +8,5 @@ Encoding: UTF-8
|
||||
License: Unlicense
|
||||
LazyData: true
|
||||
Suggests: testthat
|
||||
Imports: jsonlite, httr, R6
|
||||
Imports: jsonlite, httr, R6, caTools
|
||||
RoxygenNote: 6.0.1.9000
|
||||
|
@ -17,48 +17,90 @@
|
||||
{{#vars}}
|
||||
`{{{baseName}}}` = NULL,
|
||||
{{/vars}}
|
||||
initialize = function({{#vars}}`{{baseName}}`{{#hasMore}}, {{/hasMore}}{{/vars}}){
|
||||
{{#vars}}
|
||||
initialize = function({{#requiredVars}}`{{baseName}}`{{#hasMore}}, {{/hasMore}}{{/requiredVars}}{{#optionalVars}}{{#-first}}{{#requiredVars.0}}, {{/requiredVars.0}}{{/-first}}`{{baseName}}`={{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}NULL{{/defaultValue}}{{^-last}}, {{/-last}}{{/optionalVars}}, ...){
|
||||
local.optional.var <- list(...)
|
||||
{{#requiredVars}}
|
||||
if (!missing(`{{baseName}}`)) {
|
||||
{{^isListContainer}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(`{{baseName}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(`{{baseName}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
self$`{{baseName}}` <- `{{baseName}}`
|
||||
}
|
||||
{{/vars}}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
if (!is.null(`{{baseName}}`)) {
|
||||
{{^isListContainer}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(`{{baseName}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
self$`{{baseName}}` <- `{{baseName}}`
|
||||
}
|
||||
{{/optionalVars}}
|
||||
},
|
||||
toJSON = function() {
|
||||
{{classname}}Object <- list()
|
||||
@ -66,20 +108,20 @@
|
||||
if (!is.null(self$`{{baseName}}`)) {
|
||||
{{classname}}Object[['{{baseName}}']] <-
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
sapply(self$`{{baseName}}`, function(x) x$toJSON())
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
sapply(self$`{{baseName}}`, function(x) x$toJSON())
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}`$toJSON()
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}`$toJSON()
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
}
|
||||
{{/vars}}
|
||||
@ -91,94 +133,100 @@
|
||||
{{#vars}}
|
||||
if (!is.null({{classname}}Object$`{{baseName}}`)) {
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- sapply({{classname}}Object$`{{baseName}}`, function(x) {
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
{{baseName}}Object
|
||||
})
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- sapply({{classname}}Object$`{{baseName}}`, function(x) {
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
{{baseName}}Object
|
||||
})
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
self$`{{baseName}}` <- {{baseName}}Object
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
self$`{{baseName}}` <- {{baseName}}Object
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
}
|
||||
{{/vars}}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
sprintf(
|
||||
'{
|
||||
{{#vars}}
|
||||
"{{baseName}}":
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}[%d]{{/isNumeric}}
|
||||
{{^isNumeric}}["%s"]{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}["%s"]{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}%d{{/isNumeric}}
|
||||
{{^isNumeric}}"%s"{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}"%s"{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{#hasMore}},{{/hasMore}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
[%s]{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
%s{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/vars}}
|
||||
}',
|
||||
{{#vars}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
paste0(self$`{{baseName}}`, collapse='","'){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
paste0(sapply(self$`{{baseName}}`, function(x) x$toJSON()), collapse='","'){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) paste0('"', x, '"'))), collapse=","){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE))), collapse=","){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}`$toJSON(){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`{{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE){{#hasMore}},{{/hasMore}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/vars}}
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function({{classname}}Json) {
|
||||
{{classname}}Object <- jsonlite::fromJSON({{classname}}Json)
|
||||
{{#vars}}
|
||||
{{#isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- sapply({{classname}}Object$`{{baseName}}`, function(x) {{dataType}}$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- lapply({{classname}}Object$`{{baseName}}`, function (x) x)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
data.frame <- {{classname}}Object$`{{baseName}}`
|
||||
self$`{{baseName}}` <- vector("list", length = nrow(data.frame))
|
||||
for (row in 1:nrow(data.frame)) {
|
||||
{{baseName}}.node <- {{dataType}}$new()
|
||||
{{baseName}}.node$fromJSON(jsonlite::toJSON(data.frame[row,,drop = TRUE], auto_unbox = TRUE))
|
||||
self$`{{baseName}}`[[row]] <- {{baseName}}.node
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{dataType}}Object <- {{dataType}}$new()
|
||||
self$`{{baseName}}` <- {{dataType}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{dataType}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isListContainer}}
|
||||
{{/vars}}
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -1,11 +1,9 @@
|
||||
{{#models}}{{#model}}# {{classname}}
|
||||
{{#models}}{{#model}}# {{packageName}}::{{classname}}
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}{{/models}}
|
||||
|
23
modules/openapi-generator/src/main/resources/r/model_test.mustache
vendored
Normal file
23
modules/openapi-generator/src/main/resources/r/model_test.mustache
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test {{{classname}}}")
|
||||
|
||||
model.instance <- {{{classname}}}$new()
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#vars}}
|
||||
test_that("{{{name}}}", {
|
||||
# tests for the property `{{{name}}}` ({{dataType}})
|
||||
{{#description}}
|
||||
# {{description}}
|
||||
{{/description}}
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`{{{name}}}`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/models}}
|
4
modules/openapi-generator/src/main/resources/r/testthat.mustache
vendored
Normal file
4
modules/openapi-generator/src/main/resources/r/testthat.mustache
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
library(testthat)
|
||||
library({{{packageName}}})
|
||||
|
||||
test_check("{{{packageName}}}")
|
@ -1,2 +1,5 @@
|
||||
^.*\.Rproj$
|
||||
^\.Rproj\.user$
|
||||
^\.openapi-generator-ignore$
|
||||
^\.travis\.yml$
|
||||
^\.openapi-generator$
|
||||
|
@ -1,3 +1,15 @@
|
||||
# ref: https://docs.travis-ci.com/user/languages/r/
|
||||
language: r
|
||||
cache: packages
|
||||
cache:
|
||||
directories:
|
||||
- /home/travis/R/Library
|
||||
r_packages:
|
||||
- jsonlite
|
||||
- httr
|
||||
# uncomment below to install deps with devtools
|
||||
#install:
|
||||
#- R -e 'devtools::install_deps(dep = T)'
|
||||
script:
|
||||
- R CMD build .
|
||||
- R CMD check *tar.gz
|
||||
- R CMD INSTALL *tar.gz
|
||||
|
@ -8,5 +8,5 @@ Encoding: UTF-8
|
||||
License: Unlicense
|
||||
LazyData: true
|
||||
Suggests: testthat
|
||||
Imports: jsonlite, httr, R6
|
||||
Imports: jsonlite, httr, R6, caTools
|
||||
RoxygenNote: 6.0.1.9000
|
||||
|
@ -1,9 +1,19 @@
|
||||
# Generated by openapi-generator: https://openapi-generator.tech
|
||||
# Do not edit by hand
|
||||
|
||||
# Core
|
||||
export(ApiClient)
|
||||
export(ApiResponse)
|
||||
|
||||
# Models
|
||||
export(Category)
|
||||
export(ModelApiResponse)
|
||||
export(Order)
|
||||
export(Pet)
|
||||
export(Tag)
|
||||
export(User)
|
||||
|
||||
# APIs
|
||||
export(PetApi)
|
||||
export(StoreApi)
|
||||
export(UserApi)
|
||||
|
@ -1,71 +0,0 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' ApiClient Class
|
||||
#'
|
||||
#' Generic API client for OpenAPI client library builds.
|
||||
#' OpenAPI generic API client. This client handles the client-
|
||||
#' server communication, and is invariant across implementations. Specifics of
|
||||
#' the methods and models for each application are generated from the OpenAPI Generator
|
||||
#' templates.
|
||||
#'
|
||||
#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
#' Ref: https://openapi-generator.tech
|
||||
#' Do not edit the class manually.
|
||||
#'
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
public = list(
|
||||
basePath = "http://petstore.swagger.io/v2",
|
||||
configuration = NULL,
|
||||
userAgent = NULL,
|
||||
defaultHeaders = NULL,
|
||||
initialize = function(basePath, configuration, defaultHeaders){
|
||||
if (!missing(basePath)) {
|
||||
self$basePath <- basePath
|
||||
}
|
||||
|
||||
if (!missing(configuration)) {
|
||||
self$configuration <- configuration
|
||||
}
|
||||
|
||||
if (!missing(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
}
|
||||
|
||||
self$`userAgent` <- 'OpenAPI-Generator/1.0.0/r'
|
||||
},
|
||||
callApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
}
|
||||
else if (method == "POST") {
|
||||
httr::POST(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "PUT") {
|
||||
httr::PUT(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "PATCH") {
|
||||
httr::PATCH(url, queryParams, headers, body = body, content_type("application/json"), ...)
|
||||
}
|
||||
else if (method == "HEAD") {
|
||||
httr::HEAD(url, queryParams, headers, ...)
|
||||
}
|
||||
else if (method == "DELETE") {
|
||||
httr::DELETE(url, queryParams, headers, ...)
|
||||
}
|
||||
else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
@ -1,100 +0,0 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' ApiResponse Class
|
||||
#'
|
||||
#' @field code
|
||||
#' @field type
|
||||
#' @field message
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
public = list(
|
||||
`code` = NULL,
|
||||
`type` = NULL,
|
||||
`message` = NULL,
|
||||
initialize = function(`code`, `type`, `message`){
|
||||
if (!missing(`code`)) {
|
||||
stopifnot(is.numeric(`code`), length(`code`) == 1)
|
||||
self$`code` <- `code`
|
||||
}
|
||||
if (!missing(`type`)) {
|
||||
stopifnot(is.character(`type`), length(`type`) == 1)
|
||||
self$`type` <- `type`
|
||||
}
|
||||
if (!missing(`message`)) {
|
||||
stopifnot(is.character(`message`), length(`message`) == 1)
|
||||
self$`message` <- `message`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
ApiResponseObject <- list()
|
||||
if (!is.null(self$`code`)) {
|
||||
ApiResponseObject[['code']] <-
|
||||
self$`code`
|
||||
}
|
||||
if (!is.null(self$`type`)) {
|
||||
ApiResponseObject[['type']] <-
|
||||
self$`type`
|
||||
}
|
||||
if (!is.null(self$`message`)) {
|
||||
ApiResponseObject[['message']] <-
|
||||
self$`message`
|
||||
}
|
||||
|
||||
ApiResponseObject
|
||||
},
|
||||
fromJSON = function(ApiResponseJson) {
|
||||
ApiResponseObject <- jsonlite::fromJSON(ApiResponseJson)
|
||||
if (!is.null(ApiResponseObject$`code`)) {
|
||||
self$`code` <- ApiResponseObject$`code`
|
||||
}
|
||||
if (!is.null(ApiResponseObject$`type`)) {
|
||||
self$`type` <- ApiResponseObject$`type`
|
||||
}
|
||||
if (!is.null(ApiResponseObject$`message`)) {
|
||||
self$`message` <- ApiResponseObject$`message`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
'{
|
||||
"code":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
"type":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"message":
|
||||
|
||||
"%s"
|
||||
|
||||
|
||||
}',
|
||||
self$`code`,
|
||||
self$`type`,
|
||||
self$`message`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(ApiResponseJson) {
|
||||
ApiResponseObject <- jsonlite::fromJSON(ApiResponseJson)
|
||||
self$`code` <- ApiResponseObject$`code`
|
||||
self$`type` <- ApiResponseObject$`type`
|
||||
self$`message` <- ApiResponseObject$`message`
|
||||
}
|
||||
)
|
||||
)
|
@ -1,24 +0,0 @@
|
||||
#' Element Class
|
||||
#'
|
||||
#' Element Class
|
||||
#' @export
|
||||
Element <- R6::R6Class(
|
||||
'Element',
|
||||
public = list(
|
||||
id = NULL,
|
||||
name = NULL,
|
||||
initialize = function(id,name){
|
||||
if (!missing(id)) {
|
||||
stopifnot(is.numeric(id), length(id) == 1)
|
||||
self$id <- id
|
||||
}
|
||||
if (!missing(name)) {
|
||||
stopifnot(is.character(name), length(name) == 1)
|
||||
self$name <- name
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
sprintf('{"id":%d,"name":"%s"}', self$id, self$name)
|
||||
}
|
||||
)
|
||||
)
|
@ -1,159 +0,0 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' Order Class
|
||||
#'
|
||||
#' @field id
|
||||
#' @field petId
|
||||
#' @field quantity
|
||||
#' @field shipDate
|
||||
#' @field status
|
||||
#' @field complete
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Order <- R6::R6Class(
|
||||
'Order',
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`petId` = NULL,
|
||||
`quantity` = NULL,
|
||||
`shipDate` = NULL,
|
||||
`status` = NULL,
|
||||
`complete` = NULL,
|
||||
initialize = function(`id`, `petId`, `quantity`, `shipDate`, `status`, `complete`){
|
||||
if (!missing(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!missing(`petId`)) {
|
||||
stopifnot(is.numeric(`petId`), length(`petId`) == 1)
|
||||
self$`petId` <- `petId`
|
||||
}
|
||||
if (!missing(`quantity`)) {
|
||||
stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
|
||||
self$`quantity` <- `quantity`
|
||||
}
|
||||
if (!missing(`shipDate`)) {
|
||||
stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
|
||||
self$`shipDate` <- `shipDate`
|
||||
}
|
||||
if (!missing(`status`)) {
|
||||
stopifnot(is.character(`status`), length(`status`) == 1)
|
||||
self$`status` <- `status`
|
||||
}
|
||||
if (!missing(`complete`)) {
|
||||
self$`complete` <- `complete`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
OrderObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
OrderObject[['id']] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`petId`)) {
|
||||
OrderObject[['petId']] <-
|
||||
self$`petId`
|
||||
}
|
||||
if (!is.null(self$`quantity`)) {
|
||||
OrderObject[['quantity']] <-
|
||||
self$`quantity`
|
||||
}
|
||||
if (!is.null(self$`shipDate`)) {
|
||||
OrderObject[['shipDate']] <-
|
||||
self$`shipDate`
|
||||
}
|
||||
if (!is.null(self$`status`)) {
|
||||
OrderObject[['status']] <-
|
||||
self$`status`
|
||||
}
|
||||
if (!is.null(self$`complete`)) {
|
||||
OrderObject[['complete']] <-
|
||||
self$`complete`
|
||||
}
|
||||
|
||||
OrderObject
|
||||
},
|
||||
fromJSON = function(OrderJson) {
|
||||
OrderObject <- jsonlite::fromJSON(OrderJson)
|
||||
if (!is.null(OrderObject$`id`)) {
|
||||
self$`id` <- OrderObject$`id`
|
||||
}
|
||||
if (!is.null(OrderObject$`petId`)) {
|
||||
self$`petId` <- OrderObject$`petId`
|
||||
}
|
||||
if (!is.null(OrderObject$`quantity`)) {
|
||||
self$`quantity` <- OrderObject$`quantity`
|
||||
}
|
||||
if (!is.null(OrderObject$`shipDate`)) {
|
||||
self$`shipDate` <- OrderObject$`shipDate`
|
||||
}
|
||||
if (!is.null(OrderObject$`status`)) {
|
||||
self$`status` <- OrderObject$`status`
|
||||
}
|
||||
if (!is.null(OrderObject$`complete`)) {
|
||||
self$`complete` <- OrderObject$`complete`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
"petId":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
"quantity":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
"shipDate":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"status":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"complete":
|
||||
|
||||
"%s"
|
||||
|
||||
|
||||
}',
|
||||
self$`id`,
|
||||
self$`petId`,
|
||||
self$`quantity`,
|
||||
self$`shipDate`,
|
||||
self$`status`,
|
||||
self$`complete`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(OrderJson) {
|
||||
OrderObject <- jsonlite::fromJSON(OrderJson)
|
||||
self$`id` <- OrderObject$`id`
|
||||
self$`petId` <- OrderObject$`petId`
|
||||
self$`quantity` <- OrderObject$`quantity`
|
||||
self$`shipDate` <- OrderObject$`shipDate`
|
||||
self$`status` <- OrderObject$`status`
|
||||
self$`complete` <- OrderObject$`complete`
|
||||
}
|
||||
)
|
||||
)
|
@ -1,200 +0,0 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' User Class
|
||||
#'
|
||||
#' @field id
|
||||
#' @field username
|
||||
#' @field firstName
|
||||
#' @field lastName
|
||||
#' @field email
|
||||
#' @field password
|
||||
#' @field phone
|
||||
#' @field userStatus
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
User <- R6::R6Class(
|
||||
'User',
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`username` = NULL,
|
||||
`firstName` = NULL,
|
||||
`lastName` = NULL,
|
||||
`email` = NULL,
|
||||
`password` = NULL,
|
||||
`phone` = NULL,
|
||||
`userStatus` = NULL,
|
||||
initialize = function(`id`, `username`, `firstName`, `lastName`, `email`, `password`, `phone`, `userStatus`){
|
||||
if (!missing(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!missing(`username`)) {
|
||||
stopifnot(is.character(`username`), length(`username`) == 1)
|
||||
self$`username` <- `username`
|
||||
}
|
||||
if (!missing(`firstName`)) {
|
||||
stopifnot(is.character(`firstName`), length(`firstName`) == 1)
|
||||
self$`firstName` <- `firstName`
|
||||
}
|
||||
if (!missing(`lastName`)) {
|
||||
stopifnot(is.character(`lastName`), length(`lastName`) == 1)
|
||||
self$`lastName` <- `lastName`
|
||||
}
|
||||
if (!missing(`email`)) {
|
||||
stopifnot(is.character(`email`), length(`email`) == 1)
|
||||
self$`email` <- `email`
|
||||
}
|
||||
if (!missing(`password`)) {
|
||||
stopifnot(is.character(`password`), length(`password`) == 1)
|
||||
self$`password` <- `password`
|
||||
}
|
||||
if (!missing(`phone`)) {
|
||||
stopifnot(is.character(`phone`), length(`phone`) == 1)
|
||||
self$`phone` <- `phone`
|
||||
}
|
||||
if (!missing(`userStatus`)) {
|
||||
stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
|
||||
self$`userStatus` <- `userStatus`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
UserObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
UserObject[['id']] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`username`)) {
|
||||
UserObject[['username']] <-
|
||||
self$`username`
|
||||
}
|
||||
if (!is.null(self$`firstName`)) {
|
||||
UserObject[['firstName']] <-
|
||||
self$`firstName`
|
||||
}
|
||||
if (!is.null(self$`lastName`)) {
|
||||
UserObject[['lastName']] <-
|
||||
self$`lastName`
|
||||
}
|
||||
if (!is.null(self$`email`)) {
|
||||
UserObject[['email']] <-
|
||||
self$`email`
|
||||
}
|
||||
if (!is.null(self$`password`)) {
|
||||
UserObject[['password']] <-
|
||||
self$`password`
|
||||
}
|
||||
if (!is.null(self$`phone`)) {
|
||||
UserObject[['phone']] <-
|
||||
self$`phone`
|
||||
}
|
||||
if (!is.null(self$`userStatus`)) {
|
||||
UserObject[['userStatus']] <-
|
||||
self$`userStatus`
|
||||
}
|
||||
|
||||
UserObject
|
||||
},
|
||||
fromJSON = function(UserJson) {
|
||||
UserObject <- jsonlite::fromJSON(UserJson)
|
||||
if (!is.null(UserObject$`id`)) {
|
||||
self$`id` <- UserObject$`id`
|
||||
}
|
||||
if (!is.null(UserObject$`username`)) {
|
||||
self$`username` <- UserObject$`username`
|
||||
}
|
||||
if (!is.null(UserObject$`firstName`)) {
|
||||
self$`firstName` <- UserObject$`firstName`
|
||||
}
|
||||
if (!is.null(UserObject$`lastName`)) {
|
||||
self$`lastName` <- UserObject$`lastName`
|
||||
}
|
||||
if (!is.null(UserObject$`email`)) {
|
||||
self$`email` <- UserObject$`email`
|
||||
}
|
||||
if (!is.null(UserObject$`password`)) {
|
||||
self$`password` <- UserObject$`password`
|
||||
}
|
||||
if (!is.null(UserObject$`phone`)) {
|
||||
self$`phone` <- UserObject$`phone`
|
||||
}
|
||||
if (!is.null(UserObject$`userStatus`)) {
|
||||
self$`userStatus` <- UserObject$`userStatus`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
"username":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"firstName":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"lastName":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"email":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"password":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"phone":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"userStatus":
|
||||
%d
|
||||
|
||||
|
||||
|
||||
}',
|
||||
self$`id`,
|
||||
self$`username`,
|
||||
self$`firstName`,
|
||||
self$`lastName`,
|
||||
self$`email`,
|
||||
self$`password`,
|
||||
self$`phone`,
|
||||
self$`userStatus`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(UserJson) {
|
||||
UserObject <- jsonlite::fromJSON(UserJson)
|
||||
self$`id` <- UserObject$`id`
|
||||
self$`username` <- UserObject$`username`
|
||||
self$`firstName` <- UserObject$`firstName`
|
||||
self$`lastName` <- UserObject$`lastName`
|
||||
self$`email` <- UserObject$`email`
|
||||
self$`password` <- UserObject$`password`
|
||||
self$`phone` <- UserObject$`phone`
|
||||
self$`userStatus` <- UserObject$`userStatus`
|
||||
}
|
||||
)
|
||||
)
|
100
samples/client/petstore/R/R/api_client.R
Normal file
100
samples/client/petstore/R/R/api_client.R
Normal file
@ -0,0 +1,100 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' ApiClient Class
|
||||
#'
|
||||
#' Generic API client for OpenAPI client library builds.
|
||||
#' OpenAPI generic API client. This client handles the client-
|
||||
#' server communication, and is invariant across implementations. Specifics of
|
||||
#' the methods and models for each application are generated from the OpenAPI Generator
|
||||
#' templates.
|
||||
#'
|
||||
#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
#' Ref: https://openapi-generator.tech
|
||||
#' Do not edit the class manually.
|
||||
#'
|
||||
#' @field basePath
|
||||
#' @field userAgent
|
||||
#' @field defaultHeaders
|
||||
#' @field username
|
||||
#' @field password
|
||||
#' @field apiKeys
|
||||
#' @field accessToken
|
||||
#' @importFrom httr
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
public = list(
|
||||
# base path of all requests
|
||||
basePath = "http://petstore.swagger.io/v2",
|
||||
# user agent in the HTTP request
|
||||
userAgent = "OpenAPI-Generator/1.0.0/r",
|
||||
# default headers in the HTTP request
|
||||
defaultHeaders = NULL,
|
||||
# username (HTTP basic authentication)
|
||||
username = NULL,
|
||||
# password (HTTP basic authentication)
|
||||
password = NULL,
|
||||
# API keys
|
||||
apiKeys = NULL,
|
||||
# Access token
|
||||
accessToken = NULL,
|
||||
# constructor
|
||||
initialize = function(basePath=NULL, userAgent=NULL, defaultHeaders=NULL, username=NULL, password=NULL, apiKeys=NULL, accessToken=NULL){
|
||||
if (!is.null(basePath)) {
|
||||
self$basePath <- basePath
|
||||
}
|
||||
|
||||
if (!is.null(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
}
|
||||
|
||||
if (!is.null(username)) {
|
||||
self$username <- username
|
||||
}
|
||||
|
||||
if (!is.null(password)) {
|
||||
self$password <- password
|
||||
}
|
||||
|
||||
if (!is.null(accessToken)) {
|
||||
self$accessToken <- accessToken
|
||||
}
|
||||
|
||||
if (!is.null(apiKeys)) {
|
||||
self$apiKeys <- apiKeys
|
||||
} else {
|
||||
self$apiKeys <- list()
|
||||
}
|
||||
|
||||
if (!is.null(userAgent)) {
|
||||
self$`userAgent` <- userAgent
|
||||
}
|
||||
},
|
||||
CallApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, queryParams, headers, ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PUT") {
|
||||
httr::PUT(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "PATCH") {
|
||||
httr::PATCH(url, query = queryParams, headers, body = body, httr::content_type("application/json"), ...)
|
||||
} else if (method == "HEAD") {
|
||||
httr::HEAD(url, query = queryParams, headers, ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = queryParams, headers, ...)
|
||||
} else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
@ -1,9 +1,9 @@
|
||||
#' Response Class
|
||||
#' ApiResponse Class
|
||||
#'
|
||||
#' Response Class
|
||||
#' ApiResponse Class
|
||||
#' @export
|
||||
Response <- R6::R6Class(
|
||||
'Response',
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
public = list(
|
||||
content = NULL,
|
||||
response = NULL,
|
@ -20,13 +20,14 @@ Category <- R6::R6Class(
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
initialize = function(`id`, `name`){
|
||||
if (!missing(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
initialize = function(`id`=NULL, `name`=NULL, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!is.null(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!missing(`name`)) {
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
if (!is.null(`name`)) {
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
self$`name` <- `name`
|
||||
}
|
||||
},
|
||||
@ -34,11 +35,11 @@ Category <- R6::R6Class(
|
||||
CategoryObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
CategoryObject[['id']] <-
|
||||
self$`id`
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
CategoryObject[['name']] <-
|
||||
self$`name`
|
||||
self$`name`
|
||||
}
|
||||
|
||||
CategoryObject
|
||||
@ -46,35 +47,29 @@ Category <- R6::R6Class(
|
||||
fromJSON = function(CategoryJson) {
|
||||
CategoryObject <- jsonlite::fromJSON(CategoryJson)
|
||||
if (!is.null(CategoryObject$`id`)) {
|
||||
self$`id` <- CategoryObject$`id`
|
||||
self$`id` <- CategoryObject$`id`
|
||||
}
|
||||
if (!is.null(CategoryObject$`name`)) {
|
||||
self$`name` <- CategoryObject$`name`
|
||||
self$`name` <- CategoryObject$`name`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
%d,
|
||||
"name":
|
||||
|
||||
"%s"
|
||||
|
||||
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
self$`name`
|
||||
self$`id`,
|
||||
self$`name`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(CategoryJson) {
|
||||
CategoryObject <- jsonlite::fromJSON(CategoryJson)
|
||||
self$`id` <- CategoryObject$`id`
|
||||
self$`name` <- CategoryObject$`name`
|
||||
self$`id` <- CategoryObject$`id`
|
||||
self$`name` <- CategoryObject$`name`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
92
samples/client/petstore/R/R/model_api_response.R
Normal file
92
samples/client/petstore/R/R/model_api_response.R
Normal file
@ -0,0 +1,92 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' ModelApiResponse Class
|
||||
#'
|
||||
#' @field code
|
||||
#' @field type
|
||||
#' @field message
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
ModelApiResponse <- R6::R6Class(
|
||||
'ModelApiResponse',
|
||||
public = list(
|
||||
`code` = NULL,
|
||||
`type` = NULL,
|
||||
`message` = NULL,
|
||||
initialize = function(`code`=NULL, `type`=NULL, `message`=NULL, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!is.null(`code`)) {
|
||||
stopifnot(is.numeric(`code`), length(`code`) == 1)
|
||||
self$`code` <- `code`
|
||||
}
|
||||
if (!is.null(`type`)) {
|
||||
stopifnot(is.character(`type`), length(`type`) == 1)
|
||||
self$`type` <- `type`
|
||||
}
|
||||
if (!is.null(`message`)) {
|
||||
stopifnot(is.character(`message`), length(`message`) == 1)
|
||||
self$`message` <- `message`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
ModelApiResponseObject <- list()
|
||||
if (!is.null(self$`code`)) {
|
||||
ModelApiResponseObject[['code']] <-
|
||||
self$`code`
|
||||
}
|
||||
if (!is.null(self$`type`)) {
|
||||
ModelApiResponseObject[['type']] <-
|
||||
self$`type`
|
||||
}
|
||||
if (!is.null(self$`message`)) {
|
||||
ModelApiResponseObject[['message']] <-
|
||||
self$`message`
|
||||
}
|
||||
|
||||
ModelApiResponseObject
|
||||
},
|
||||
fromJSON = function(ModelApiResponseJson) {
|
||||
ModelApiResponseObject <- jsonlite::fromJSON(ModelApiResponseJson)
|
||||
if (!is.null(ModelApiResponseObject$`code`)) {
|
||||
self$`code` <- ModelApiResponseObject$`code`
|
||||
}
|
||||
if (!is.null(ModelApiResponseObject$`type`)) {
|
||||
self$`type` <- ModelApiResponseObject$`type`
|
||||
}
|
||||
if (!is.null(ModelApiResponseObject$`message`)) {
|
||||
self$`message` <- ModelApiResponseObject$`message`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"code":
|
||||
%d,
|
||||
"type":
|
||||
"%s",
|
||||
"message":
|
||||
"%s"
|
||||
}',
|
||||
self$`code`,
|
||||
self$`type`,
|
||||
self$`message`
|
||||
)
|
||||
},
|
||||
fromJSONString = function(ModelApiResponseJson) {
|
||||
ModelApiResponseObject <- jsonlite::fromJSON(ModelApiResponseJson)
|
||||
self$`code` <- ModelApiResponseObject$`code`
|
||||
self$`type` <- ModelApiResponseObject$`type`
|
||||
self$`message` <- ModelApiResponseObject$`message`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
142
samples/client/petstore/R/R/order.R
Normal file
142
samples/client/petstore/R/R/order.R
Normal file
@ -0,0 +1,142 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' Order Class
|
||||
#'
|
||||
#' @field id
|
||||
#' @field petId
|
||||
#' @field quantity
|
||||
#' @field shipDate
|
||||
#' @field status
|
||||
#' @field complete
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
Order <- R6::R6Class(
|
||||
'Order',
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`petId` = NULL,
|
||||
`quantity` = NULL,
|
||||
`shipDate` = NULL,
|
||||
`status` = NULL,
|
||||
`complete` = NULL,
|
||||
initialize = function(`id`=NULL, `petId`=NULL, `quantity`=NULL, `shipDate`=NULL, `status`=NULL, `complete`=FALSE, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!is.null(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`petId`)) {
|
||||
stopifnot(is.numeric(`petId`), length(`petId`) == 1)
|
||||
self$`petId` <- `petId`
|
||||
}
|
||||
if (!is.null(`quantity`)) {
|
||||
stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
|
||||
self$`quantity` <- `quantity`
|
||||
}
|
||||
if (!is.null(`shipDate`)) {
|
||||
stopifnot(is.character(`shipDate`), length(`shipDate`) == 1)
|
||||
self$`shipDate` <- `shipDate`
|
||||
}
|
||||
if (!is.null(`status`)) {
|
||||
stopifnot(is.character(`status`), length(`status`) == 1)
|
||||
self$`status` <- `status`
|
||||
}
|
||||
if (!is.null(`complete`)) {
|
||||
self$`complete` <- `complete`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
OrderObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
OrderObject[['id']] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`petId`)) {
|
||||
OrderObject[['petId']] <-
|
||||
self$`petId`
|
||||
}
|
||||
if (!is.null(self$`quantity`)) {
|
||||
OrderObject[['quantity']] <-
|
||||
self$`quantity`
|
||||
}
|
||||
if (!is.null(self$`shipDate`)) {
|
||||
OrderObject[['shipDate']] <-
|
||||
self$`shipDate`
|
||||
}
|
||||
if (!is.null(self$`status`)) {
|
||||
OrderObject[['status']] <-
|
||||
self$`status`
|
||||
}
|
||||
if (!is.null(self$`complete`)) {
|
||||
OrderObject[['complete']] <-
|
||||
self$`complete`
|
||||
}
|
||||
|
||||
OrderObject
|
||||
},
|
||||
fromJSON = function(OrderJson) {
|
||||
OrderObject <- jsonlite::fromJSON(OrderJson)
|
||||
if (!is.null(OrderObject$`id`)) {
|
||||
self$`id` <- OrderObject$`id`
|
||||
}
|
||||
if (!is.null(OrderObject$`petId`)) {
|
||||
self$`petId` <- OrderObject$`petId`
|
||||
}
|
||||
if (!is.null(OrderObject$`quantity`)) {
|
||||
self$`quantity` <- OrderObject$`quantity`
|
||||
}
|
||||
if (!is.null(OrderObject$`shipDate`)) {
|
||||
self$`shipDate` <- OrderObject$`shipDate`
|
||||
}
|
||||
if (!is.null(OrderObject$`status`)) {
|
||||
self$`status` <- OrderObject$`status`
|
||||
}
|
||||
if (!is.null(OrderObject$`complete`)) {
|
||||
self$`complete` <- OrderObject$`complete`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"petId":
|
||||
%d,
|
||||
"quantity":
|
||||
%d,
|
||||
"shipDate":
|
||||
"%s",
|
||||
"status":
|
||||
"%s",
|
||||
"complete":
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
self$`petId`,
|
||||
self$`quantity`,
|
||||
self$`shipDate`,
|
||||
self$`status`,
|
||||
self$`complete`
|
||||
)
|
||||
},
|
||||
fromJSONString = function(OrderJson) {
|
||||
OrderObject <- jsonlite::fromJSON(OrderJson)
|
||||
self$`id` <- OrderObject$`id`
|
||||
self$`petId` <- OrderObject$`petId`
|
||||
self$`quantity` <- OrderObject$`quantity`
|
||||
self$`shipDate` <- OrderObject$`shipDate`
|
||||
self$`status` <- OrderObject$`status`
|
||||
self$`complete` <- OrderObject$`complete`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
@ -28,31 +28,32 @@ Pet <- R6::R6Class(
|
||||
`photoUrls` = NULL,
|
||||
`tags` = NULL,
|
||||
`status` = NULL,
|
||||
initialize = function(`id`, `category`, `name`, `photoUrls`, `tags`, `status`){
|
||||
if (!missing(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!missing(`category`)) {
|
||||
stopifnot(R6::is.R6(`category`))
|
||||
self$`category` <- `category`
|
||||
}
|
||||
initialize = function(`name`, `photoUrls`, `id`=NULL, `category`=NULL, `tags`=NULL, `status`=NULL, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!missing(`name`)) {
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
self$`name` <- `name`
|
||||
}
|
||||
if (!missing(`photoUrls`)) {
|
||||
stopifnot(is.vector(`photoUrls`), length(`photoUrls`) != 0)
|
||||
sapply(`photoUrls`, function(x) stopifnot(is.character(x)))
|
||||
stopifnot(is.vector(`photoUrls`), length(`photoUrls`) != 0)
|
||||
sapply(`photoUrls`, function(x) stopifnot(is.character(x)))
|
||||
self$`photoUrls` <- `photoUrls`
|
||||
}
|
||||
if (!missing(`tags`)) {
|
||||
stopifnot(is.vector(`tags`), length(`tags`) != 0)
|
||||
sapply(`tags`, function(x) stopifnot(R6::is.R6(x)))
|
||||
if (!is.null(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`category`)) {
|
||||
stopifnot(R6::is.R6(`category`))
|
||||
self$`category` <- `category`
|
||||
}
|
||||
if (!is.null(`tags`)) {
|
||||
stopifnot(is.vector(`tags`), length(`tags`) != 0)
|
||||
sapply(`tags`, function(x) stopifnot(R6::is.R6(x)))
|
||||
self$`tags` <- `tags`
|
||||
}
|
||||
if (!missing(`status`)) {
|
||||
stopifnot(is.character(`status`), length(`status`) == 1)
|
||||
if (!is.null(`status`)) {
|
||||
stopifnot(is.character(`status`), length(`status`) == 1)
|
||||
self$`status` <- `status`
|
||||
}
|
||||
},
|
||||
@ -60,27 +61,27 @@ Pet <- R6::R6Class(
|
||||
PetObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
PetObject[['id']] <-
|
||||
self$`id`
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`category`)) {
|
||||
PetObject[['category']] <-
|
||||
self$`category`$toJSON()
|
||||
self$`category`$toJSON()
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
PetObject[['name']] <-
|
||||
self$`name`
|
||||
self$`name`
|
||||
}
|
||||
if (!is.null(self$`photoUrls`)) {
|
||||
PetObject[['photoUrls']] <-
|
||||
self$`photoUrls`
|
||||
self$`photoUrls`
|
||||
}
|
||||
if (!is.null(self$`tags`)) {
|
||||
PetObject[['tags']] <-
|
||||
sapply(self$`tags`, function(x) x$toJSON())
|
||||
sapply(self$`tags`, function(x) x$toJSON())
|
||||
}
|
||||
if (!is.null(self$`status`)) {
|
||||
PetObject[['status']] <-
|
||||
self$`status`
|
||||
self$`status`
|
||||
}
|
||||
|
||||
PetObject
|
||||
@ -88,78 +89,69 @@ Pet <- R6::R6Class(
|
||||
fromJSON = function(PetJson) {
|
||||
PetObject <- jsonlite::fromJSON(PetJson)
|
||||
if (!is.null(PetObject$`id`)) {
|
||||
self$`id` <- PetObject$`id`
|
||||
self$`id` <- PetObject$`id`
|
||||
}
|
||||
if (!is.null(PetObject$`category`)) {
|
||||
categoryObject <- Category$new()
|
||||
categoryObject$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
self$`category` <- categoryObject
|
||||
categoryObject <- Category$new()
|
||||
categoryObject$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
self$`category` <- categoryObject
|
||||
}
|
||||
if (!is.null(PetObject$`name`)) {
|
||||
self$`name` <- PetObject$`name`
|
||||
self$`name` <- PetObject$`name`
|
||||
}
|
||||
if (!is.null(PetObject$`photoUrls`)) {
|
||||
self$`photoUrls` <- PetObject$`photoUrls`
|
||||
self$`photoUrls` <- PetObject$`photoUrls`
|
||||
}
|
||||
if (!is.null(PetObject$`tags`)) {
|
||||
self$`tags` <- sapply(PetObject$`tags`, function(x) {
|
||||
tagsObject <- Tag$new()
|
||||
tagsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
tagsObject
|
||||
})
|
||||
self$`tags` <- sapply(PetObject$`tags`, function(x) {
|
||||
tagsObject <- Tag$new()
|
||||
tagsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
|
||||
tagsObject
|
||||
})
|
||||
}
|
||||
if (!is.null(PetObject$`status`)) {
|
||||
self$`status` <- PetObject$`status`
|
||||
self$`status` <- PetObject$`status`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
%d,
|
||||
"category":
|
||||
"%s"
|
||||
,
|
||||
%s,
|
||||
"name":
|
||||
|
||||
"%s"
|
||||
|
||||
,
|
||||
"%s",
|
||||
"photoUrls":
|
||||
|
||||
["%s"]
|
||||
|
||||
,
|
||||
[%s],
|
||||
"tags":
|
||||
["%s"]
|
||||
,
|
||||
[%s],
|
||||
"status":
|
||||
|
||||
"%s"
|
||||
|
||||
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
self$`category`$toJSON(),
|
||||
self$`name`,
|
||||
paste0(self$`photoUrls`, collapse='","'),
|
||||
paste0(sapply(self$`tags`, function(x) x$toJSON()), collapse='","'),
|
||||
self$`status`
|
||||
self$`id`,
|
||||
jsonlite::toJSON(self$`category`$toJSON(), auto_unbox=TRUE),
|
||||
self$`name`,
|
||||
paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse=","),
|
||||
paste(unlist(lapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE))), collapse=","),
|
||||
self$`status`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(PetJson) {
|
||||
PetObject <- jsonlite::fromJSON(PetJson)
|
||||
self$`id` <- PetObject$`id`
|
||||
CategoryObject <- Category$new()
|
||||
self$`category` <- CategoryObject$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
self$`name` <- PetObject$`name`
|
||||
self$`photoUrls` <- PetObject$`photoUrls`
|
||||
self$`tags` <- sapply(PetObject$`tags`, function(x) Tag$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
|
||||
self$`status` <- PetObject$`status`
|
||||
self$`id` <- PetObject$`id`
|
||||
self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(PetObject$category, auto_unbox = TRUE))
|
||||
self$`name` <- PetObject$`name`
|
||||
self$`photoUrls` <- lapply(PetObject$`photoUrls`, function (x) x)
|
||||
data.frame <- PetObject$`tags`
|
||||
self$`tags` <- vector("list", length = nrow(data.frame))
|
||||
for (row in 1:nrow(data.frame)) {
|
||||
tags.node <- Tag$new()
|
||||
tags.node$fromJSON(jsonlite::toJSON(data.frame[row,,drop = TRUE], auto_unbox = TRUE))
|
||||
self$`tags`[[row]] <- tags.node
|
||||
}
|
||||
self$`status` <- PetObject$`status`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -11,43 +11,42 @@
|
||||
#'
|
||||
#' @field path Stores url path of the request.
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field userAgent Set the user agent of the request.
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#'
|
||||
#' add_pet Add a new pet to the store
|
||||
#' AddPet Add a new pet to the store
|
||||
#'
|
||||
#'
|
||||
#' delete_pet Deletes a pet
|
||||
#' DeletePet Deletes a pet
|
||||
#'
|
||||
#'
|
||||
#' find_pets_by_status Finds Pets by status
|
||||
#' FindPetsByStatus Finds Pets by status
|
||||
#'
|
||||
#'
|
||||
#' find_pets_by_tags Finds Pets by tags
|
||||
#' FindPetsByTags Finds Pets by tags
|
||||
#'
|
||||
#'
|
||||
#' get_pet_by_id Find pet by ID
|
||||
#' GetPetById Find pet by ID
|
||||
#'
|
||||
#'
|
||||
#' update_pet Update an existing pet
|
||||
#' UpdatePet Update an existing pet
|
||||
#'
|
||||
#'
|
||||
#' update_pet_with_form Updates a pet in the store with form data
|
||||
#' UpdatePetWithForm Updates a pet in the store with form data
|
||||
#'
|
||||
#'
|
||||
#' upload_file uploads an image
|
||||
#' UploadFile uploads an image
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' @importFrom caTools base64encode
|
||||
#' @export
|
||||
PetApi <- R6::R6Class(
|
||||
'PetApi',
|
||||
public = list(
|
||||
userAgent = "OpenAPI-Generator/1.0.0/r",
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
@ -57,10 +56,14 @@ PetApi <- R6::R6Class(
|
||||
self$apiClient <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
add_pet = function(body, ...){
|
||||
AddPet = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -69,7 +72,10 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/pet"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -79,27 +85,32 @@ PetApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
delete_pet = function(pet_id, api_key, ...){
|
||||
DeletePet = function(pet.id, api.key=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (!missing(`api_key`)) {
|
||||
headerParams['api_key'] <- `api_key`
|
||||
if (missing(`pet.id`)) {
|
||||
stop("Missing required parameter `pet.id`.")
|
||||
}
|
||||
|
||||
headerParams['api_key'] <- `api.key`
|
||||
|
||||
urlPath <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet_id`, urlPath)
|
||||
if (!missing(`pet.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet.id`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -109,23 +120,28 @@ PetApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
find_pets_by_status = function(status, ...){
|
||||
FindPetsByStatus = function(status, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (!missing(`status`)) {
|
||||
queryParams['status'] <- status
|
||||
if (missing(`status`)) {
|
||||
stop("Missing required parameter `status`.")
|
||||
}
|
||||
|
||||
queryParams['status'] <- status
|
||||
|
||||
urlPath <- "/pet/findByStatus"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -133,25 +149,30 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
find_pets_by_tags = function(tags, ...){
|
||||
FindPetsByTags = function(tags, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (!missing(`tags`)) {
|
||||
queryParams['tags'] <- tags
|
||||
if (missing(`tags`)) {
|
||||
stop("Missing required parameter `tags`.")
|
||||
}
|
||||
|
||||
queryParams['tags'] <- tags
|
||||
|
||||
urlPath <- "/pet/findByTags"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -159,25 +180,34 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
get_pet_by_id = function(pet_id, ...){
|
||||
GetPetById = function(pet.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`pet.id`)) {
|
||||
stop("Missing required parameter `pet.id`.")
|
||||
}
|
||||
|
||||
urlPath <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet_id`, urlPath)
|
||||
if (!missing(`pet.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet.id`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -185,18 +215,22 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
update_pet = function(body, ...){
|
||||
UpdatePet = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -205,7 +239,10 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/pet"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "PUT",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -215,28 +252,35 @@ PetApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
update_pet_with_form = function(pet_id, name, status, ...){
|
||||
UpdatePetWithForm = function(pet.id, name=NULL, status=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`pet.id`)) {
|
||||
stop("Missing required parameter `pet.id`.")
|
||||
}
|
||||
|
||||
body <- list(
|
||||
"name" = name,
|
||||
"status" = status
|
||||
"name" = name,
|
||||
"status" = status
|
||||
)
|
||||
|
||||
urlPath <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet_id`, urlPath)
|
||||
if (!missing(`pet.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet.id`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -246,28 +290,35 @@ PetApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
upload_file = function(pet_id, additional_metadata, file, ...){
|
||||
UploadFile = function(pet.id, additional.metadata=NULL, file=NULL, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`pet.id`)) {
|
||||
stop("Missing required parameter `pet.id`.")
|
||||
}
|
||||
|
||||
body <- list(
|
||||
"additionalMetadata" = additional_metadata,
|
||||
"file" = httr::upload_file(file)
|
||||
"additionalMetadata" = additional.metadata,
|
||||
"file" = httr::upload_file(file)
|
||||
)
|
||||
|
||||
urlPath <- "/pet/{petId}/uploadImage"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet_id`, urlPath)
|
||||
if (!missing(`pet.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), `pet.id`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -275,11 +326,11 @@ PetApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
ModelApiResponse$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
@ -11,31 +11,30 @@
|
||||
#'
|
||||
#' @field path Stores url path of the request.
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field userAgent Set the user agent of the request.
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#'
|
||||
#' delete_order Delete purchase order by ID
|
||||
#' DeleteOrder Delete purchase order by ID
|
||||
#'
|
||||
#'
|
||||
#' get_inventory Returns pet inventories by status
|
||||
#' GetInventory Returns pet inventories by status
|
||||
#'
|
||||
#'
|
||||
#' get_order_by_id Find purchase order by ID
|
||||
#' GetOrderById Find purchase order by ID
|
||||
#'
|
||||
#'
|
||||
#' place_order Place an order for a pet
|
||||
#' PlaceOrder Place an order for a pet
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' @importFrom caTools base64encode
|
||||
#' @export
|
||||
StoreApi <- R6::R6Class(
|
||||
'StoreApi',
|
||||
public = list(
|
||||
userAgent = "OpenAPI-Generator/1.0.0/r",
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
@ -45,17 +44,22 @@ StoreApi <- R6::R6Class(
|
||||
self$apiClient <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
delete_order = function(order_id, ...){
|
||||
DeleteOrder = function(order.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
urlPath <- "/store/order/{orderId}"
|
||||
if (!missing(`order_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), `order_id`, urlPath)
|
||||
if (missing(`order.id`)) {
|
||||
stop("Missing required parameter `order.id`.")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
urlPath <- "/store/order/{orderId}"
|
||||
if (!missing(`order.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), `order.id`, urlPath)
|
||||
}
|
||||
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -65,19 +69,24 @@ StoreApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
get_inventory = function(...){
|
||||
GetInventory = function(...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
urlPath <- "/store/inventory"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -85,25 +94,30 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
integer$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
get_order_by_id = function(order_id, ...){
|
||||
GetOrderById = function(order.id, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`order.id`)) {
|
||||
stop("Missing required parameter `order.id`.")
|
||||
}
|
||||
|
||||
urlPath <- "/store/order/{orderId}"
|
||||
if (!missing(`order_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), `order_id`, urlPath)
|
||||
if (!missing(`order.id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), `order.id`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -111,18 +125,22 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
place_order = function(body, ...){
|
||||
PlaceOrder = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -131,7 +149,8 @@ StoreApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/store/order"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -139,11 +158,11 @@ StoreApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
@ -20,13 +20,14 @@ Tag <- R6::R6Class(
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`name` = NULL,
|
||||
initialize = function(`id`, `name`){
|
||||
if (!missing(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
initialize = function(`id`=NULL, `name`=NULL, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!is.null(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!missing(`name`)) {
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
if (!is.null(`name`)) {
|
||||
stopifnot(is.character(`name`), length(`name`) == 1)
|
||||
self$`name` <- `name`
|
||||
}
|
||||
},
|
||||
@ -34,11 +35,11 @@ Tag <- R6::R6Class(
|
||||
TagObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
TagObject[['id']] <-
|
||||
self$`id`
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`name`)) {
|
||||
TagObject[['name']] <-
|
||||
self$`name`
|
||||
self$`name`
|
||||
}
|
||||
|
||||
TagObject
|
||||
@ -46,35 +47,29 @@ Tag <- R6::R6Class(
|
||||
fromJSON = function(TagJson) {
|
||||
TagObject <- jsonlite::fromJSON(TagJson)
|
||||
if (!is.null(TagObject$`id`)) {
|
||||
self$`id` <- TagObject$`id`
|
||||
self$`id` <- TagObject$`id`
|
||||
}
|
||||
if (!is.null(TagObject$`name`)) {
|
||||
self$`name` <- TagObject$`name`
|
||||
self$`name` <- TagObject$`name`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
outstring <- sprintf(
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d
|
||||
|
||||
|
||||
,
|
||||
%d,
|
||||
"name":
|
||||
|
||||
"%s"
|
||||
|
||||
|
||||
"%s"
|
||||
}',
|
||||
self$`id`,
|
||||
self$`name`
|
||||
self$`id`,
|
||||
self$`name`
|
||||
)
|
||||
gsub("[\r\n]| ", "", outstring)
|
||||
},
|
||||
fromJSONString = function(TagJson) {
|
||||
TagObject <- jsonlite::fromJSON(TagJson)
|
||||
self$`id` <- TagObject$`id`
|
||||
self$`name` <- TagObject$`name`
|
||||
self$`id` <- TagObject$`id`
|
||||
self$`name` <- TagObject$`name`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
177
samples/client/petstore/R/R/user.R
Normal file
177
samples/client/petstore/R/R/user.R
Normal file
@ -0,0 +1,177 @@
|
||||
# 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.
|
||||
#
|
||||
# OpenAPI spec version: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
#' User Class
|
||||
#'
|
||||
#' @field id
|
||||
#' @field username
|
||||
#' @field firstName
|
||||
#' @field lastName
|
||||
#' @field email
|
||||
#' @field password
|
||||
#' @field phone
|
||||
#' @field userStatus
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom jsonlite fromJSON toJSON
|
||||
#' @export
|
||||
User <- R6::R6Class(
|
||||
'User',
|
||||
public = list(
|
||||
`id` = NULL,
|
||||
`username` = NULL,
|
||||
`firstName` = NULL,
|
||||
`lastName` = NULL,
|
||||
`email` = NULL,
|
||||
`password` = NULL,
|
||||
`phone` = NULL,
|
||||
`userStatus` = NULL,
|
||||
initialize = function(`id`=NULL, `username`=NULL, `firstName`=NULL, `lastName`=NULL, `email`=NULL, `password`=NULL, `phone`=NULL, `userStatus`=NULL, ...){
|
||||
local.optional.var <- list(...)
|
||||
if (!is.null(`id`)) {
|
||||
stopifnot(is.numeric(`id`), length(`id`) == 1)
|
||||
self$`id` <- `id`
|
||||
}
|
||||
if (!is.null(`username`)) {
|
||||
stopifnot(is.character(`username`), length(`username`) == 1)
|
||||
self$`username` <- `username`
|
||||
}
|
||||
if (!is.null(`firstName`)) {
|
||||
stopifnot(is.character(`firstName`), length(`firstName`) == 1)
|
||||
self$`firstName` <- `firstName`
|
||||
}
|
||||
if (!is.null(`lastName`)) {
|
||||
stopifnot(is.character(`lastName`), length(`lastName`) == 1)
|
||||
self$`lastName` <- `lastName`
|
||||
}
|
||||
if (!is.null(`email`)) {
|
||||
stopifnot(is.character(`email`), length(`email`) == 1)
|
||||
self$`email` <- `email`
|
||||
}
|
||||
if (!is.null(`password`)) {
|
||||
stopifnot(is.character(`password`), length(`password`) == 1)
|
||||
self$`password` <- `password`
|
||||
}
|
||||
if (!is.null(`phone`)) {
|
||||
stopifnot(is.character(`phone`), length(`phone`) == 1)
|
||||
self$`phone` <- `phone`
|
||||
}
|
||||
if (!is.null(`userStatus`)) {
|
||||
stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
|
||||
self$`userStatus` <- `userStatus`
|
||||
}
|
||||
},
|
||||
toJSON = function() {
|
||||
UserObject <- list()
|
||||
if (!is.null(self$`id`)) {
|
||||
UserObject[['id']] <-
|
||||
self$`id`
|
||||
}
|
||||
if (!is.null(self$`username`)) {
|
||||
UserObject[['username']] <-
|
||||
self$`username`
|
||||
}
|
||||
if (!is.null(self$`firstName`)) {
|
||||
UserObject[['firstName']] <-
|
||||
self$`firstName`
|
||||
}
|
||||
if (!is.null(self$`lastName`)) {
|
||||
UserObject[['lastName']] <-
|
||||
self$`lastName`
|
||||
}
|
||||
if (!is.null(self$`email`)) {
|
||||
UserObject[['email']] <-
|
||||
self$`email`
|
||||
}
|
||||
if (!is.null(self$`password`)) {
|
||||
UserObject[['password']] <-
|
||||
self$`password`
|
||||
}
|
||||
if (!is.null(self$`phone`)) {
|
||||
UserObject[['phone']] <-
|
||||
self$`phone`
|
||||
}
|
||||
if (!is.null(self$`userStatus`)) {
|
||||
UserObject[['userStatus']] <-
|
||||
self$`userStatus`
|
||||
}
|
||||
|
||||
UserObject
|
||||
},
|
||||
fromJSON = function(UserJson) {
|
||||
UserObject <- jsonlite::fromJSON(UserJson)
|
||||
if (!is.null(UserObject$`id`)) {
|
||||
self$`id` <- UserObject$`id`
|
||||
}
|
||||
if (!is.null(UserObject$`username`)) {
|
||||
self$`username` <- UserObject$`username`
|
||||
}
|
||||
if (!is.null(UserObject$`firstName`)) {
|
||||
self$`firstName` <- UserObject$`firstName`
|
||||
}
|
||||
if (!is.null(UserObject$`lastName`)) {
|
||||
self$`lastName` <- UserObject$`lastName`
|
||||
}
|
||||
if (!is.null(UserObject$`email`)) {
|
||||
self$`email` <- UserObject$`email`
|
||||
}
|
||||
if (!is.null(UserObject$`password`)) {
|
||||
self$`password` <- UserObject$`password`
|
||||
}
|
||||
if (!is.null(UserObject$`phone`)) {
|
||||
self$`phone` <- UserObject$`phone`
|
||||
}
|
||||
if (!is.null(UserObject$`userStatus`)) {
|
||||
self$`userStatus` <- UserObject$`userStatus`
|
||||
}
|
||||
},
|
||||
toJSONString = function() {
|
||||
sprintf(
|
||||
'{
|
||||
"id":
|
||||
%d,
|
||||
"username":
|
||||
"%s",
|
||||
"firstName":
|
||||
"%s",
|
||||
"lastName":
|
||||
"%s",
|
||||
"email":
|
||||
"%s",
|
||||
"password":
|
||||
"%s",
|
||||
"phone":
|
||||
"%s",
|
||||
"userStatus":
|
||||
%d
|
||||
}',
|
||||
self$`id`,
|
||||
self$`username`,
|
||||
self$`firstName`,
|
||||
self$`lastName`,
|
||||
self$`email`,
|
||||
self$`password`,
|
||||
self$`phone`,
|
||||
self$`userStatus`
|
||||
)
|
||||
},
|
||||
fromJSONString = function(UserJson) {
|
||||
UserObject <- jsonlite::fromJSON(UserJson)
|
||||
self$`id` <- UserObject$`id`
|
||||
self$`username` <- UserObject$`username`
|
||||
self$`firstName` <- UserObject$`firstName`
|
||||
self$`lastName` <- UserObject$`lastName`
|
||||
self$`email` <- UserObject$`email`
|
||||
self$`password` <- UserObject$`password`
|
||||
self$`phone` <- UserObject$`phone`
|
||||
self$`userStatus` <- UserObject$`userStatus`
|
||||
self
|
||||
}
|
||||
)
|
||||
)
|
@ -11,43 +11,42 @@
|
||||
#'
|
||||
#' @field path Stores url path of the request.
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field userAgent Set the user agent of the request.
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
#'
|
||||
#' create_user Create user
|
||||
#' CreateUser Create user
|
||||
#'
|
||||
#'
|
||||
#' create_users_with_array_input Creates list of users with given input array
|
||||
#' CreateUsersWithArrayInput Creates list of users with given input array
|
||||
#'
|
||||
#'
|
||||
#' create_users_with_list_input Creates list of users with given input array
|
||||
#' CreateUsersWithListInput Creates list of users with given input array
|
||||
#'
|
||||
#'
|
||||
#' delete_user Delete user
|
||||
#' DeleteUser Delete user
|
||||
#'
|
||||
#'
|
||||
#' get_user_by_name Get user by user name
|
||||
#' GetUserByName Get user by user name
|
||||
#'
|
||||
#'
|
||||
#' login_user Logs user into the system
|
||||
#' LoginUser Logs user into the system
|
||||
#'
|
||||
#'
|
||||
#' logout_user Logs out current logged in user session
|
||||
#' LogoutUser Logs out current logged in user session
|
||||
#'
|
||||
#'
|
||||
#' update_user Updated user
|
||||
#' UpdateUser Updated user
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' @importFrom caTools base64encode
|
||||
#' @export
|
||||
UserApi <- R6::R6Class(
|
||||
'UserApi',
|
||||
public = list(
|
||||
userAgent = "OpenAPI-Generator/1.0.0/r",
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
@ -57,10 +56,14 @@ UserApi <- R6::R6Class(
|
||||
self$apiClient <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
create_user = function(body, ...){
|
||||
CreateUser = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -69,7 +72,8 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/user"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -79,16 +83,20 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
create_users_with_array_input = function(body, ...){
|
||||
CreateUsersWithArrayInput = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -97,7 +105,8 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/user/createWithArray"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -107,16 +116,20 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
create_users_with_list_input = function(body, ...){
|
||||
CreateUsersWithListInput = function(body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -125,7 +138,8 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
|
||||
urlPath <- "/user/createWithList"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -135,23 +149,28 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
delete_user = function(username, ...){
|
||||
DeleteUser = function(username, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
urlPath <- "/user/{username}"
|
||||
if (!missing(`username`)) {
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), `username`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -161,23 +180,28 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
get_user_by_name = function(username, ...){
|
||||
GetUserByName = function(username, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
urlPath <- "/user/{username}"
|
||||
if (!missing(`username`)) {
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), `username`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -185,29 +209,34 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
User$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
login_user = function(username, password, ...){
|
||||
LoginUser = function(username, password, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (!missing(`username`)) {
|
||||
queryParams['username'] <- username
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
if (!missing(`password`)) {
|
||||
queryParams['password'] <- password
|
||||
if (missing(`password`)) {
|
||||
stop("Missing required parameter `password`.")
|
||||
}
|
||||
|
||||
queryParams['username'] <- username
|
||||
|
||||
queryParams['password'] <- password
|
||||
|
||||
urlPath <- "/user/login"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -215,21 +244,22 @@ UserApi <- R6::R6Class(
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
character$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
logout_user = function(...){
|
||||
LogoutUser = function(...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
urlPath <- "/user/logout"
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -239,16 +269,24 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
},
|
||||
update_user = function(username, body, ...){
|
||||
UpdateUser = function(username, body, ...){
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- character()
|
||||
headerParams <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
if (missing(`body`)) {
|
||||
stop("Missing required parameter `body`.")
|
||||
}
|
||||
|
||||
if (!missing(`body`)) {
|
||||
body <- `body`$toJSONString()
|
||||
@ -261,7 +299,8 @@ UserApi <- R6::R6Class(
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), `username`, urlPath)
|
||||
}
|
||||
|
||||
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
method = "PUT",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
@ -271,9 +310,9 @@ UserApi <- R6::R6Class(
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
# void response, no need to return anything
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
Response$new("API client error", resp)
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
Response$new("API server error", resp)
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
|
||||
}
|
@ -10,23 +10,104 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
- Build package: org.openapitools.codegen.languages.RClientCodegen
|
||||
|
||||
## Installation
|
||||
You'll need the `devtools` package in order to build the API.
|
||||
Make sure you have a proper CRAN repository from which you can download packages.
|
||||
|
||||
### Prerequisites
|
||||
Install the `devtools` package with the following command.
|
||||
|
||||
Install the dependencies
|
||||
|
||||
```R
|
||||
if(!require(devtools)) { install.packages("devtools") }
|
||||
install.packages("jsonlite")
|
||||
install.packages("httr")
|
||||
install.packages("caTools")
|
||||
```
|
||||
|
||||
### Installation of the API package
|
||||
Make sure you set the working directory to where the API code is located.
|
||||
Then execute
|
||||
```R
|
||||
library(devtools)
|
||||
install(".")
|
||||
### Build the package
|
||||
|
||||
```sh
|
||||
git clone https://github.com/GIT_USER_ID/GIT_REPO_ID
|
||||
cd GIT_REPO_ID
|
||||
R CMD build .
|
||||
R CMD check petstore_1.0.0.tar.gz
|
||||
R CMD INSTALL petstore_1.0.0.tar.gz
|
||||
```
|
||||
|
||||
### Install the package
|
||||
|
||||
```R
|
||||
install.packages("petstore")
|
||||
```
|
||||
|
||||
To install directly from Github, use `devtools`:
|
||||
```R
|
||||
install.packages("devtools")
|
||||
library(devtools)
|
||||
install_github("GIT_USER_ID/GIT_REPO_ID")
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```R
|
||||
library(petstore)
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*PetApi* | [**AddPet**](docs/PetApi.md#AddPet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**DeletePet**](docs/PetApi.md#DeletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#FindPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#FindPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**GetPetById**](docs/PetApi.md#GetPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**UpdatePet**](docs/PetApi.md#UpdatePet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#UpdatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**UploadFile**](docs/PetApi.md#UploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#DeleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
*StoreApi* | [**GetInventory**](docs/StoreApi.md#GetInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#GetOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#PlaceOrder) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**CreateUser**](docs/UserApi.md#CreateUser) | **POST** /user | Create user
|
||||
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#CreateUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#CreateUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**DeleteUser**](docs/UserApi.md#DeleteUser) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**GetUserByName**](docs/UserApi.md#GetUserByName) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**LoginUser**](docs/UserApi.md#LoginUser) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**LogoutUser**](docs/UserApi.md#LogoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**UpdateUser**](docs/UserApi.md#UpdateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [Category](docs/Category.md)
|
||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- write:pets: modify pets in your account
|
||||
- read:pets: read your pets
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
10
samples/client/petstore/R/docs/ApiResponse.md
Normal file
10
samples/client/petstore/R/docs/ApiResponse.md
Normal file
@ -0,0 +1,10 @@
|
||||
# petstore::ApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **integer** | | [optional]
|
||||
**type** | **character** | | [optional]
|
||||
**message** | **character** | | [optional]
|
||||
|
||||
|
9
samples/client/petstore/R/docs/Category.md
Normal file
9
samples/client/petstore/R/docs/Category.md
Normal file
@ -0,0 +1,9 @@
|
||||
# petstore::Category
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **integer** | | [optional]
|
||||
**name** | **character** | | [optional]
|
||||
|
||||
|
10
samples/client/petstore/R/docs/ModelApiResponse.md
Normal file
10
samples/client/petstore/R/docs/ModelApiResponse.md
Normal file
@ -0,0 +1,10 @@
|
||||
# petstore::ModelApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **integer** | | [optional]
|
||||
**type** | **character** | | [optional]
|
||||
**message** | **character** | | [optional]
|
||||
|
||||
|
13
samples/client/petstore/R/docs/Order.md
Normal file
13
samples/client/petstore/R/docs/Order.md
Normal file
@ -0,0 +1,13 @@
|
||||
# petstore::Order
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **integer** | | [optional]
|
||||
**petId** | **integer** | | [optional]
|
||||
**quantity** | **integer** | | [optional]
|
||||
**shipDate** | **character** | | [optional]
|
||||
**status** | **character** | Order Status | [optional]
|
||||
**complete** | **character** | | [optional] [default to FALSE]
|
||||
|
||||
|
13
samples/client/petstore/R/docs/Pet.md
Normal file
13
samples/client/petstore/R/docs/Pet.md
Normal file
@ -0,0 +1,13 @@
|
||||
# petstore::Pet
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **integer** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**name** | **character** | | [default to 'doggie']
|
||||
**photoUrls** | **character** | |
|
||||
**tags** | [**Tag**](Tag.md) | | [optional]
|
||||
**status** | **character** | pet status in the store | [optional]
|
||||
|
||||
|
348
samples/client/petstore/R/docs/PetApi.md
Normal file
348
samples/client/petstore/R/docs/PetApi.md
Normal file
@ -0,0 +1,348 @@
|
||||
# PetApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**AddPet**](PetApi.md#AddPet) | **POST** /pet | Add a new pet to the store
|
||||
[**DeletePet**](PetApi.md#DeletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**FindPetsByStatus**](PetApi.md#FindPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**FindPetsByTags**](PetApi.md#FindPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**GetPetById**](PetApi.md#GetPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**UpdatePet**](PetApi.md#UpdatePet) | **PUT** /pet | Update an existing pet
|
||||
[**UpdatePetWithForm**](PetApi.md#UpdatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**UploadFile**](PetApi.md#UploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
|
||||
|
||||
# **AddPet**
|
||||
> AddPet(body)
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- Pet$new() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
#Add a new pet to the store
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
api.instance$AddPet(var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **DeletePet**
|
||||
> DeletePet(pet.id, api.key=var.api.key)
|
||||
|
||||
Deletes a pet
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.pet.id <- 56 # integer | Pet id to delete
|
||||
var.api.key <- 'api.key_example' # character |
|
||||
|
||||
#Deletes a pet
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
api.instance$DeletePet(var.pet.id, api.key=var.api.key)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet.id** | **integer**| Pet id to delete |
|
||||
**api.key** | **character**| | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **FindPetsByStatus**
|
||||
> Pet FindPetsByStatus(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.status <- ['status_example'] # character | Status values that need to be considered for filter
|
||||
|
||||
#Finds Pets by status
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
result <- api.instance$FindPetsByStatus(var.status)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**character**](character.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **FindPetsByTags**
|
||||
> Pet FindPetsByTags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.tags <- ['tags_example'] # character | Tags to filter by
|
||||
|
||||
#Finds Pets by tags
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
result <- api.instance$FindPetsByTags(var.tags)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**character**](character.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **GetPetById**
|
||||
> Pet GetPetById(pet.id)
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.pet.id <- 56 # integer | ID of pet to return
|
||||
|
||||
#Find pet by ID
|
||||
api.instance <- PetApi$new()
|
||||
# Configure API key authorization: api_key
|
||||
api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
result <- api.instance$GetPetById(var.pet.id)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet.id** | **integer**| ID of pet to return |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **UpdatePet**
|
||||
> UpdatePet(body)
|
||||
|
||||
Update an existing pet
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- Pet$new() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
#Update an existing pet
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
api.instance$UpdatePet(var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **UpdatePetWithForm**
|
||||
> UpdatePetWithForm(pet.id, name=var.name, status=var.status)
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.pet.id <- 56 # integer | ID of pet that needs to be updated
|
||||
var.name <- 'name_example' # character | Updated name of the pet
|
||||
var.status <- 'status_example' # character | Updated status of the pet
|
||||
|
||||
#Updates a pet in the store with form data
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
api.instance$UpdatePetWithForm(var.pet.id, name=var.name, status=var.status)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet.id** | **integer**| ID of pet that needs to be updated |
|
||||
**name** | **character**| Updated name of the pet | [optional]
|
||||
**status** | **character**| Updated status of the pet | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **UploadFile**
|
||||
> ModelApiResponse UploadFile(pet.id, additional.metadata=var.additional.metadata, file=var.file)
|
||||
|
||||
uploads an image
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.pet.id <- 56 # integer | ID of pet to update
|
||||
var.additional.metadata <- 'additional.metadata_example' # character | Additional data to pass to server
|
||||
var.file <- File.new('/path/to/file') # data.frame | file to upload
|
||||
|
||||
#uploads an image
|
||||
api.instance <- PetApi$new()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
result <- api.instance$UploadFile(var.pet.id, additional.metadata=var.additional.metadata, file=var.file)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet.id** | **integer**| ID of pet to update |
|
||||
**additional.metadata** | **character**| Additional data to pass to server | [optional]
|
||||
**file** | **data.frame**| file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
|
167
samples/client/petstore/R/docs/StoreApi.md
Normal file
167
samples/client/petstore/R/docs/StoreApi.md
Normal file
@ -0,0 +1,167 @@
|
||||
# StoreApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**DeleteOrder**](StoreApi.md#DeleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
[**GetInventory**](StoreApi.md#GetInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**GetOrderById**](StoreApi.md#GetOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
[**PlaceOrder**](StoreApi.md#PlaceOrder) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
# **DeleteOrder**
|
||||
> DeleteOrder(order.id)
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.order.id <- 'order.id_example' # character | ID of the order that needs to be deleted
|
||||
|
||||
#Delete purchase order by ID
|
||||
api.instance <- StoreApi$new()
|
||||
api.instance$DeleteOrder(var.order.id)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order.id** | **character**| ID of the order that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **GetInventory**
|
||||
> integer GetInventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
|
||||
#Returns pet inventories by status
|
||||
api.instance <- StoreApi$new()
|
||||
# Configure API key authorization: api_key
|
||||
api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
result <- api.instance$GetInventory()
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**integer**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
|
||||
# **GetOrderById**
|
||||
> Order GetOrderById(order.id)
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.order.id <- 56 # integer | ID of pet that needs to be fetched
|
||||
|
||||
#Find purchase order by ID
|
||||
api.instance <- StoreApi$new()
|
||||
result <- api.instance$GetOrderById(var.order.id)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order.id** | **integer**| ID of pet that needs to be fetched |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **PlaceOrder**
|
||||
> Order PlaceOrder(body)
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- Order$new() # Order | order placed for purchasing the pet
|
||||
|
||||
#Place an order for a pet
|
||||
api.instance <- StoreApi$new()
|
||||
result <- api.instance$PlaceOrder(var.body)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
9
samples/client/petstore/R/docs/Tag.md
Normal file
9
samples/client/petstore/R/docs/Tag.md
Normal file
@ -0,0 +1,9 @@
|
||||
# petstore::Tag
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **integer** | | [optional]
|
||||
**name** | **character** | | [optional]
|
||||
|
||||
|
15
samples/client/petstore/R/docs/User.md
Normal file
15
samples/client/petstore/R/docs/User.md
Normal file
@ -0,0 +1,15 @@
|
||||
# petstore::User
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **integer** | | [optional]
|
||||
**username** | **character** | | [optional]
|
||||
**firstName** | **character** | | [optional]
|
||||
**lastName** | **character** | | [optional]
|
||||
**email** | **character** | | [optional]
|
||||
**password** | **character** | | [optional]
|
||||
**phone** | **character** | | [optional]
|
||||
**userStatus** | **integer** | User Status | [optional]
|
||||
|
||||
|
320
samples/client/petstore/R/docs/UserApi.md
Normal file
320
samples/client/petstore/R/docs/UserApi.md
Normal file
@ -0,0 +1,320 @@
|
||||
# UserApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**CreateUser**](UserApi.md#CreateUser) | **POST** /user | Create user
|
||||
[**CreateUsersWithArrayInput**](UserApi.md#CreateUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**CreateUsersWithListInput**](UserApi.md#CreateUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**DeleteUser**](UserApi.md#DeleteUser) | **DELETE** /user/{username} | Delete user
|
||||
[**GetUserByName**](UserApi.md#GetUserByName) | **GET** /user/{username} | Get user by user name
|
||||
[**LoginUser**](UserApi.md#LoginUser) | **GET** /user/login | Logs user into the system
|
||||
[**LogoutUser**](UserApi.md#LogoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**UpdateUser**](UserApi.md#UpdateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
# **CreateUser**
|
||||
> CreateUser(body)
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- User$new() # User | Created user object
|
||||
|
||||
#Create user
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$CreateUser(var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **CreateUsersWithArrayInput**
|
||||
> CreateUsersWithArrayInput(body)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- [array$new()] # User | List of user object
|
||||
|
||||
#Creates list of users with given input array
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$CreateUsersWithArrayInput(var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](array.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **CreateUsersWithListInput**
|
||||
> CreateUsersWithListInput(body)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.body <- [array$new()] # User | List of user object
|
||||
|
||||
#Creates list of users with given input array
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$CreateUsersWithListInput(var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](array.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **DeleteUser**
|
||||
> DeleteUser(username)
|
||||
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.username <- 'username_example' # character | The name that needs to be deleted
|
||||
|
||||
#Delete user
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$DeleteUser(var.username)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **character**| The name that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **GetUserByName**
|
||||
> User GetUserByName(username)
|
||||
|
||||
Get user by user name
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
#Get user by user name
|
||||
api.instance <- UserApi$new()
|
||||
result <- api.instance$GetUserByName(var.username)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **character**| The name that needs to be fetched. Use user1 for testing. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**User**](User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **LoginUser**
|
||||
> character LoginUser(username, password)
|
||||
|
||||
Logs user into the system
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.username <- 'username_example' # character | The user name for login
|
||||
var.password <- 'password_example' # character | The password for login in clear text
|
||||
|
||||
#Logs user into the system
|
||||
api.instance <- UserApi$new()
|
||||
result <- api.instance$LoginUser(var.username, var.password)
|
||||
dput(result)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **character**| The user name for login |
|
||||
**password** | **character**| The password for login in clear text |
|
||||
|
||||
### Return type
|
||||
|
||||
**character**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
|
||||
# **LogoutUser**
|
||||
> LogoutUser()
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
|
||||
#Logs out current logged in user session
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$LogoutUser()
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
||||
# **UpdateUser**
|
||||
> UpdateUser(username, body)
|
||||
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```R
|
||||
library(petstore)
|
||||
|
||||
var.username <- 'username_example' # character | name that need to be deleted
|
||||
var.body <- User$new() # User | Updated user object
|
||||
|
||||
#Updated user
|
||||
api.instance <- UserApi$new()
|
||||
api.instance$UpdateUser(var.username, var.body)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **character**| name that need to be deleted |
|
||||
**body** | [**User**](User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
|
4
samples/client/petstore/R/tests/testthat.R
Normal file
4
samples/client/petstore/R/tests/testthat.R
Normal file
@ -0,0 +1,4 @@
|
||||
library(testthat)
|
||||
library(petstore)
|
||||
|
||||
test_check("petstore")
|
21
samples/client/petstore/R/tests/testthat/test_category.R
Normal file
21
samples/client/petstore/R/tests/testthat/test_category.R
Normal file
@ -0,0 +1,21 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test Category")
|
||||
|
||||
model.instance <- Category$new()
|
||||
|
||||
test_that("id", {
|
||||
# tests for the property `id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("name", {
|
||||
# tests for the property `name` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`name`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
@ -0,0 +1,28 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test ModelApiResponse")
|
||||
|
||||
model.instance <- ModelApiResponse$new()
|
||||
|
||||
test_that("code", {
|
||||
# tests for the property `code` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`code`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("type", {
|
||||
# tests for the property `type` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`type`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("message", {
|
||||
# tests for the property `message` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`message`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
50
samples/client/petstore/R/tests/testthat/test_order.R
Normal file
50
samples/client/petstore/R/tests/testthat/test_order.R
Normal file
@ -0,0 +1,50 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test Order")
|
||||
|
||||
model.instance <- Order$new()
|
||||
|
||||
test_that("id", {
|
||||
# tests for the property `id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("pet_id", {
|
||||
# tests for the property `pet_id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`pet_id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("quantity", {
|
||||
# tests for the property `quantity` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`quantity`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("ship_date", {
|
||||
# tests for the property `ship_date` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`ship_date`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("status", {
|
||||
# tests for the property `status` (character)
|
||||
# Order Status
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`status`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("complete", {
|
||||
# tests for the property `complete` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`complete`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
50
samples/client/petstore/R/tests/testthat/test_pet.R
Normal file
50
samples/client/petstore/R/tests/testthat/test_pet.R
Normal file
@ -0,0 +1,50 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test Pet")
|
||||
|
||||
model.instance <- Pet$new()
|
||||
|
||||
test_that("id", {
|
||||
# tests for the property `id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("category", {
|
||||
# tests for the property `category` (Category)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`category`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("name", {
|
||||
# tests for the property `name` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`name`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("photo_urls", {
|
||||
# tests for the property `photo_urls` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`photo_urls`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("tags", {
|
||||
# tests for the property `tags` (Tag)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`tags`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("status", {
|
||||
# tests for the property `status` (character)
|
||||
# pet status in the store
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`status`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
103
samples/client/petstore/R/tests/testthat/test_pet_api.R
Normal file
103
samples/client/petstore/R/tests/testthat/test_pet_api.R
Normal file
@ -0,0 +1,103 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test PetApi")
|
||||
|
||||
api.instance <- PetApi$new()
|
||||
|
||||
test_that("AddPet", {
|
||||
# tests for AddPet
|
||||
# Add a new pet to the store
|
||||
# @param body Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("DeletePet", {
|
||||
# tests for DeletePet
|
||||
# Deletes a pet
|
||||
# @param pet.id Pet id to delete
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [character] :api.key
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("FindPetsByStatus", {
|
||||
# tests for FindPetsByStatus
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param status Status values that need to be considered for filter
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("FindPetsByTags", {
|
||||
# tests for FindPetsByTags
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param tags Tags to filter by
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("GetPetById", {
|
||||
# tests for GetPetById
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param pet.id ID of pet to return
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("UpdatePet", {
|
||||
# tests for UpdatePet
|
||||
# Update an existing pet
|
||||
# @param body Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("UpdatePetWithForm", {
|
||||
# tests for UpdatePetWithForm
|
||||
# Updates a pet in the store with form data
|
||||
# @param pet.id ID of pet that needs to be updated
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [character] :name Updated name of the pet
|
||||
# @option opts [character] :status Updated status of the pet
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("UploadFile", {
|
||||
# tests for UploadFile
|
||||
# uploads an image
|
||||
# @param pet.id ID of pet to update
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [character] :additional.metadata Additional data to pass to server
|
||||
# @option opts [data.frame] :file file to upload
|
||||
# @return [ModelApiResponse]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
53
samples/client/petstore/R/tests/testthat/test_store_api.R
Normal file
53
samples/client/petstore/R/tests/testthat/test_store_api.R
Normal file
@ -0,0 +1,53 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test StoreApi")
|
||||
|
||||
api.instance <- StoreApi$new()
|
||||
|
||||
test_that("DeleteOrder", {
|
||||
# tests for DeleteOrder
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param order.id ID of the order that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("GetInventory", {
|
||||
# tests for GetInventory
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [integer]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("GetOrderById", {
|
||||
# tests for GetOrderById
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param order.id ID of pet that needs to be fetched
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("PlaceOrder", {
|
||||
# tests for PlaceOrder
|
||||
# Place an order for a pet
|
||||
# @param body order placed for purchasing the pet
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
21
samples/client/petstore/R/tests/testthat/test_tag.R
Normal file
21
samples/client/petstore/R/tests/testthat/test_tag.R
Normal file
@ -0,0 +1,21 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test Tag")
|
||||
|
||||
model.instance <- Tag$new()
|
||||
|
||||
test_that("id", {
|
||||
# tests for the property `id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("name", {
|
||||
# tests for the property `name` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`name`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
64
samples/client/petstore/R/tests/testthat/test_user.R
Normal file
64
samples/client/petstore/R/tests/testthat/test_user.R
Normal file
@ -0,0 +1,64 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test User")
|
||||
|
||||
model.instance <- User$new()
|
||||
|
||||
test_that("id", {
|
||||
# tests for the property `id` (integer)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`id`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("username", {
|
||||
# tests for the property `username` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`username`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("first_name", {
|
||||
# tests for the property `first_name` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`first_name`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("last_name", {
|
||||
# tests for the property `last_name` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`last_name`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("email", {
|
||||
# tests for the property `email` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`email`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("password", {
|
||||
# tests for the property `password` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`password`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("phone", {
|
||||
# tests for the property `phone` (character)
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`phone`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("user_status", {
|
||||
# tests for the property `user_status` (integer)
|
||||
# User Status
|
||||
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`user_status`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
99
samples/client/petstore/R/tests/testthat/test_user_api.R
Normal file
99
samples/client/petstore/R/tests/testthat/test_user_api.R
Normal file
@ -0,0 +1,99 @@
|
||||
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||
# Please update as you see appropriate
|
||||
|
||||
context("Test UserApi")
|
||||
|
||||
api.instance <- UserApi$new()
|
||||
|
||||
test_that("CreateUser", {
|
||||
# tests for CreateUser
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param body Created user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("CreateUsersWithArrayInput", {
|
||||
# tests for CreateUsersWithArrayInput
|
||||
# Creates list of users with given input array
|
||||
# @param body List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("CreateUsersWithListInput", {
|
||||
# tests for CreateUsersWithListInput
|
||||
# Creates list of users with given input array
|
||||
# @param body List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("DeleteUser", {
|
||||
# tests for DeleteUser
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username The name that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("GetUserByName", {
|
||||
# tests for GetUserByName
|
||||
# Get user by user name
|
||||
# @param username The name that needs to be fetched. Use user1 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [User]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("LoginUser", {
|
||||
# tests for LoginUser
|
||||
# Logs user into the system
|
||||
# @param username The user name for login
|
||||
# @param password The password for login in clear text
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [character]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("LogoutUser", {
|
||||
# tests for LogoutUser
|
||||
# Logs out current logged in user session
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
test_that("UpdateUser", {
|
||||
# tests for UpdateUser
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username name that need to be deleted
|
||||
# @param body Updated user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Void]
|
||||
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
4
samples/client/petstore/R/testthat.R
Normal file
4
samples/client/petstore/R/testthat.R
Normal file
@ -0,0 +1,4 @@
|
||||
library(testthat)
|
||||
library(petstore)
|
||||
|
||||
test_check("petstore")
|
Loading…
x
Reference in New Issue
Block a user