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 90a6302a65.

* fix query parameter in api client (#2214)
This commit is contained in:
William Cheng
2019-02-23 23:51:11 +08:00
committed by GitHub
parent 7486438491
commit e6658278ad
58 changed files with 3129 additions and 1104 deletions

View File

@@ -0,0 +1,10 @@
# petstore::ApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **integer** | | [optional]
**type** | **character** | | [optional]
**message** | **character** | | [optional]

View File

@@ -0,0 +1,9 @@
# petstore::Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **integer** | | [optional]
**name** | **character** | | [optional]

View File

@@ -0,0 +1,10 @@
# petstore::ModelApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **integer** | | [optional]
**type** | **character** | | [optional]
**message** | **character** | | [optional]

View 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]

View 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]

View 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

View 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

View File

@@ -0,0 +1,9 @@
# petstore::Tag
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **integer** | | [optional]
**name** | **character** | | [optional]

View 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]

View 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