Ruby: add auto-generated documentation in Markdown

This commit is contained in:
xhh 2016-03-09 17:18:15 +08:00
parent 998087d662
commit 2c64b885bb
28 changed files with 2443 additions and 590 deletions

View File

@ -3,6 +3,7 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
@ -40,6 +41,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String gemDescription = "This gem maps to a swagger API";
protected String gemAuthor = "";
protected String gemAuthorEmail = "";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
protected static int emptyMethodNameCounter = 0;
@ -50,6 +53,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
outputFolder = "generated-code" + File.separator + "ruby";
modelTemplateFiles.put("model.mustache", ".rb");
apiTemplateFiles.put("api.mustache", ".rb");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
embeddedTemplateDir = templateDir = "ruby";
modelTestTemplateFiles.put("model_test.mustache", ".rb");
@ -206,6 +211,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb"));
supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb"));
supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
@ -271,6 +277,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
return outputFolder + File.separator + specFolder + File.separator + modelPackage.replace("/", File.separator);
}
@Override
public String apiDocFileFolder() {
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
}
@Override
public String modelDocFileFolder() {
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
}
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
@ -328,7 +344,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (languageSpecificPrimitives.contains(type)) {
if (languageSpecificPrimitives.contains(type)) {
return type;
}
} else {
@ -414,6 +430,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
return underscore(name);
}
@Override
public String toModelDocFilename(String name) {
return toModelFilename(name);
}
@Override
public String toApiFilename(String name) {
// replace - with _ e.g. created-at => created_at
@ -423,6 +444,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
return underscore(name) + "_api";
}
@Override
public String toApiDocFilename(String name) {
return toApiFilename(name);
}
@Override
public String toApiTestFilename(String name) {
return toApiFilename(name) + "_spec";
@ -466,6 +492,16 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
return gemName + "/" + apiPackage() + "/" + toApiFilename(name);
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) ||
Boolean.TRUE.equals(p.isByteArray) || Boolean.TRUE.equals(p.isFile)) {
p.example = "\"" + escapeText(p.example) + "\"";
} else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) {
p.example = "Date.parse(\"" + escapeText(p.example) + "\")";
}
}
public void setGemName(String gemName) {
this.gemName = gemName;
}

View File

@ -0,0 +1,107 @@
# {{gemName}}
{{moduleName}} - the Ruby gem for the {{appName}}
Version: {{gemVersion}}
Automatically generated by the Ruby Swagger Codegen project:
- Build date: {{generatedDate}}
- Build package: {{generatorClass}}
## Installation
### Build a gem
You can build the generated client into a gem:
```shell
gem build {{gemName}}.gemspec
```
Then you can either install the gem:
```shell
gem install ./{{gemName}}-{{gemVersion}}.gem
```
or publish the gem to a gem server like [RubyGems](https://rubygems.org/).
Finally add this to your Gemfile:
gem '{{gemName}}', '~> {{gemVersion}}'
### Host as a git repository
You can also choose to host the generated client as a git repository, e.g. on github:
https://github.com/YOUR_USERNAME/YOUR_REPO
Then you can reference it in Gemfile:
gem '{{gemName}}', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git'
### Use without installation
You can also use the client directly like this:
```shell
ruby -Ilib script.rb
```
## Getting Started
```ruby
require '{{gemName}}'
{{moduleName}}.configure do |config|
# Use the line below to configure API key authorization if needed:
#config.api_key['api_key'] = 'your api key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
# Enable debugging (default is disabled).
config.debugging = true
end
# Assuming there's a `PetApi` containing a `get_pet_by_id` method
# which returns a model object:
pet_api = Petstore::PetApi.new
pet = pet_api.get_pet_by_id(5)
puts pet.to_body
```
## Documentation for API Endpoints
All URIs are relative to *{{basePath}}*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{moduleName}}::{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
## Documentation for Models
{{#models}}{{#model}} - [{{moduleName}}::{{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}}}
- **Authorizatoin URL**: {{{authorizationUrl}}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}}-- {{{scope}}}: {{{description}}}
{{/scopes}}
{{/isOAuth}}
{{/authMethods}}

View File

@ -0,0 +1,59 @@
# {{moduleName}}::{{classname}}{{#description}}
{{description}}{{/description}}
All URIs are relative to *{{basePath}}*
Method | HTTP request | Description
------------- | ------------- | -------------
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
{{#operation}}
# **{{{operationId}}}**
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{{summary}}}{{#notes}}
{{{notes}}}{{/notes}}
### Example
```ruby
api = {{moduleName}}::{{classname}}.new
{{#allParams}}{{#required}}{{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::{{dataType}}.new{{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}} # [{{{dataType}}}] {{description}}
{{/required}}{{/allParams}}
opts = { {{#allParams}}{{^required}}
{{paramName}}: {{{example}}},{{/required}}{{/allParams}}
}
begin
{{#returnType}}result = {{/returnType}}api.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
rescue {{moduleName}}::ApiError => e
puts "Exception when calling {{operationId}}: #{e}"
end
```
### Parameters
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
{{/allParams}}
### Return type
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}}
### Authorization
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
### HTTP reuqest headers
- **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
{{/operation}}
{{/operations}}

View File

@ -0,0 +1,9 @@
{{#models}}{{#model}}# {{moduleName}}::{{classname}}
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
{{/vars}}
{{/model}}{{/models}}

36
samples/client/petstore/ruby/.gitignore vendored Normal file
View File

@ -0,0 +1,36 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
## Specific to RubyMotion:
.dat*
.repl_history
build/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

View File

@ -1,3 +1,14 @@
# petstore
Petstore - the Ruby gem for the Swagger Petstore
Version: 1.0.0
Automatically generated by the Ruby Swagger Codegen project:
- Build date: 2016-03-09T17:12:59.008+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation
### Build a gem
@ -23,11 +34,11 @@ Finally add this to your Gemfile:
### Host as a git repository
You can also choose to host the generated client as a git repository, e.g. on github:
https://github.com/xhh/swagger-petstore-ruby
https://github.com/YOUR_USERNAME/YOUR_REPO
Then you can reference it in Gemfile:
gem 'petstore', :git => 'https://github.com/xhh/swagger-petstore-ruby.git'
gem 'petstore', :git => 'https://github.com/YOUR_USERNAME/YOUR_REPO.git'
### Use without installation
@ -43,14 +54,106 @@ ruby -Ilib script.rb
require 'petstore'
Petstore.configure do |config|
config.api_key['api_key'] = 'special-key'
# Use the line below to configure API key authorization if needed:
#config.api_key['api_key'] = 'your api key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
# enable debugging (default is disabled)
# Enable debugging (default is disabled).
config.debugging = true
end
# Assuming there's a `PetApi` containing a `get_pet_by_id` method
# which returns a model object:
pet_api = Petstore::PetApi.new
pet = pet_api.get_pet_by_id(5)
puts pet.to_body
```
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::PetApi* | [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*Petstore::PetApi* | [**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
*Petstore::PetApi* | [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
*Petstore::PetApi* | [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
*Petstore::PetApi* | [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
*Petstore::PetApi* | [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
*Petstore::PetApi* | [**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
*Petstore::PetApi* | [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
*Petstore::PetApi* | [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
*Petstore::PetApi* | [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
*Petstore::StoreApi* | [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*Petstore::StoreApi* | [**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status
*Petstore::StoreApi* | [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
*Petstore::StoreApi* | [**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
*Petstore::StoreApi* | [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
*Petstore::StoreApi* | [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
*Petstore::UserApi* | [**create_user**](UserApi.md#create_user) | **POST** /user | Create user
*Petstore::UserApi* | [**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
*Petstore::UserApi* | [**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
*Petstore::UserApi* | [**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
*Petstore::UserApi* | [**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
*Petstore::UserApi* | [**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system
*Petstore::UserApi* | [**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
*Petstore::UserApi* | [**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user
## Documentation for Models
- [Petstore::Category](Category.md)
- [Petstore::InlineResponse200](InlineResponse200.md)
- [Petstore::ModelReturn](ModelReturn.md)
- [Petstore::Order](Order.md)
- [Petstore::Pet](Pet.md)
- [Petstore::SpecialModelName](SpecialModelName.md)
- [Petstore::Tag](Tag.md)
- [Petstore::User](User.md)
## Documentation for Authorization
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
-- write:pets: modify pets in your account
-- read:pets: read your pets
### test_api_client_id
- **Type**: API key
- **API key parameter name**: x-test_api_client_id
- **Location**: HTTP header
### test_api_client_secret
- **Type**: API key
- **API key parameter name**: x-test_api_client_secret
- **Location**: HTTP header
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### test_api_key_query
- **Type**: API key
- **API key parameter name**: test_api_key_query
- **Location**: URL query string
### test_api_key_header
- **Type**: API key
- **API key parameter name**: test_api_key_header
- **Location**: HTTP header

View File

@ -0,0 +1,9 @@
# Petstore::Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**name** | **String** | | [optional]

View File

@ -0,0 +1,13 @@
# Petstore::InlineResponse200
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**photo_urls** | **Array&lt;String&gt;** | | [optional]
**name** | **String** | | [optional]
**id** | **Integer** | |
**category** | **Object** | | [optional]
**tags** | [**Array&lt;Tag&gt;**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [optional]

View File

@ -0,0 +1,8 @@
# Petstore::ModelReturn
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_return** | **Integer** | | [optional]

View File

@ -0,0 +1,13 @@
# Petstore::Order
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**pet_id** | **Integer** | | [optional]
**quantity** | **Integer** | | [optional]
**ship_date** | **DateTime** | | [optional]
**status** | **String** | Order Status | [optional]
**complete** | **BOOLEAN** | | [optional]

View File

@ -0,0 +1,13 @@
# Petstore::Pet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **String** | |
**photo_urls** | **Array&lt;String&gt;** | |
**tags** | [**Array&lt;Tag&gt;**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [optional]

View File

@ -0,0 +1,502 @@
# Petstore::PetApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
# **add_pet**
> add_pet(opts)
Add a new pet to the store
### Example
```ruby
api = Petstore::PetApi.new
opts = {
body: ,
}
begin
api.add_pet(opts)
rescue Petstore::ApiError => e
puts "Exception when calling add_pet: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
# **add_pet_using_byte_array**
> add_pet_using_byte_array(opts)
Fake endpoint to test byte array in body parameter for adding a new pet to the store
### Example
```ruby
api = Petstore::PetApi.new
opts = {
body: "B",
}
begin
api.add_pet_using_byte_array(opts)
rescue Petstore::ApiError => e
puts "Exception when calling add_pet_using_byte_array: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **String**| Pet object in the form of byte array | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
# **delete_pet**
> delete_pet(pet_id, opts)
Deletes a pet
### Example
```ruby
api = Petstore::PetApi.new
pet_id = 789 # [Integer] Pet id to delete
opts = {
api_key: "api_key_example",
}
begin
api.delete_pet(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling delete_pet: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| Pet id to delete |
**api_key** | **String**| | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **find_pets_by_status**
> Array<Pet> find_pets_by_status(opts)
Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example
```ruby
api = Petstore::PetApi.new
opts = {
status: ,
}
begin
result = api.find_pets_by_status(opts)
rescue Petstore::ApiError => e
puts "Exception when calling find_pets_by_status: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**Array&lt;String&gt;**](String.md)| Status values that need to be considered for query | [optional] [default to available]
### Return type
[**Array<Pet>**](Pet.md)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **find_pets_by_tags**
> Array<Pet> find_pets_by_tags(opts)
Finds Pets by tags
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
### Example
```ruby
api = Petstore::PetApi.new
opts = {
tags: ,
}
begin
result = api.find_pets_by_tags(opts)
rescue Petstore::ApiError => e
puts "Exception when calling find_pets_by_tags: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**Array&lt;String&gt;**](String.md)| Tags to filter by | [optional]
### Return type
[**Array<Pet>**](Pet.md)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_pet_by_id**
> Pet get_pet_by_id(pet_id, opts)
Find pet by ID
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
### Example
```ruby
api = Petstore::PetApi.new
pet_id = 789 # [Integer] ID of pet that needs to be fetched
opts = {
}
begin
result = api.get_pet_by_id(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_pet_by_id: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet that needs to be fetched |
### Return type
[**Pet**](Pet.md)
### Authorization
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_pet_by_id_in_object**
> InlineResponse200 get_pet_by_id_in_object(pet_id, opts)
Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
### Example
```ruby
api = Petstore::PetApi.new
pet_id = 789 # [Integer] ID of pet that needs to be fetched
opts = {
}
begin
result = api.get_pet_by_id_in_object(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_pet_by_id_in_object: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet that needs to be fetched |
### Return type
[**InlineResponse200**](InlineResponse200.md)
### Authorization
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **pet_pet_idtesting_byte_arraytrue_get**
> String pet_pet_idtesting_byte_arraytrue_get(pet_id, opts)
Fake endpoint to test byte array return by 'Find pet by ID'
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
### Example
```ruby
api = Petstore::PetApi.new
pet_id = 789 # [Integer] ID of pet that needs to be fetched
opts = {
}
begin
result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet that needs to be fetched |
### Return type
**String**
### Authorization
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **update_pet**
> update_pet(opts)
Update an existing pet
### Example
```ruby
api = Petstore::PetApi.new
opts = {
body: ,
}
begin
api.update_pet(opts)
rescue Petstore::ApiError => e
puts "Exception when calling update_pet: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: application/json, application/xml
- **Accept**: application/json, application/xml
# **update_pet_with_form**
> update_pet_with_form(pet_id, opts)
Updates a pet in the store with form data
### Example
```ruby
api = Petstore::PetApi.new
pet_id = "pet_id_example" # [String] ID of pet that needs to be updated
opts = {
name: "name_example",
status: "status_example",
}
begin
api.update_pet_with_form(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling update_pet_with_form: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **String**| ID of pet that needs to be updated |
**name** | **String**| Updated name of the pet | [optional]
**status** | **String**| Updated status of the pet | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: application/json, application/xml
# **upload_file**
> upload_file(pet_id, opts)
uploads an image
### Example
```ruby
api = Petstore::PetApi.new
pet_id = 789 # [Integer] ID of pet to update
opts = {
additional_metadata: "additional_metadata_example",
file: "/path/to/file.txt",
}
begin
api.upload_file(pet_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling upload_file: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet to update |
**additional_metadata** | **String**| Additional data to pass to server | [optional]
**file** | [**File**](.md)| file to upload | [optional]
### Return type
nil (empty response body)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP reuqest headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json, application/xml

View File

@ -0,0 +1,8 @@
# Petstore::SpecialModelName
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**special_property_name** | **Integer** | | [optional]

View File

@ -0,0 +1,264 @@
# Petstore::StoreApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status
[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
# **delete_order**
> delete_order(order_id, opts)
Delete purchase order by ID
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
### Example
```ruby
api = Petstore::StoreApi.new
order_id = "order_id_example" # [String] ID of the order that needs to be deleted
opts = {
}
begin
api.delete_order(order_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling delete_order: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order_id** | **String**| ID of the order that needs to be deleted |
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **find_orders_by_status**
> Array<Order> find_orders_by_status(opts)
Finds orders by status
A single status value can be provided as a string
### Example
```ruby
api = Petstore::StoreApi.new
opts = {
status: "status_example",
}
begin
result = api.find_orders_by_status(opts)
rescue Petstore::ApiError => e
puts "Exception when calling find_orders_by_status: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | **String**| Status value that needs to be considered for query | [optional] [default to placed]
### Return type
[**Array<Order>**](Order.md)
### Authorization
[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_inventory**
> Hash<String, Integer> get_inventory(opts)
Returns pet inventories by status
Returns a map of status codes to quantities
### Example
```ruby
api = Petstore::StoreApi.new
opts = {
}
begin
result = api.get_inventory(opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_inventory: #{e}"
end
```
### Parameters
This endpoint does not need any parameter.
### Return type
**Hash<String, Integer>**
### Authorization
[api_key](../README.md#api_key)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_inventory_in_object**
> Object get_inventory_in_object(opts)
Fake endpoint to test arbitrary object return by 'Get inventory'
Returns an arbitrary object which is actually a map of status codes to quantities
### Example
```ruby
api = Petstore::StoreApi.new
opts = {
}
begin
result = api.get_inventory_in_object(opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_inventory_in_object: #{e}"
end
```
### Parameters
This endpoint does not need any parameter.
### Return type
**Object**
### Authorization
[api_key](../README.md#api_key)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_order_by_id**
> Order get_order_by_id(order_id, opts)
Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
### Example
```ruby
api = Petstore::StoreApi.new
order_id = "order_id_example" # [String] ID of pet that needs to be fetched
opts = {
}
begin
result = api.get_order_by_id(order_id, opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_order_by_id: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order_id** | **String**| ID of pet that needs to be fetched |
### Return type
[**Order**](Order.md)
### Authorization
[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **place_order**
> Order place_order(opts)
Place an order for a pet
### Example
```ruby
api = Petstore::StoreApi.new
opts = {
body: ,
}
begin
result = api.place_order(opts)
rescue Petstore::ApiError => e
puts "Exception when calling place_order: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional]
### Return type
[**Order**](Order.md)
### Authorization
[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret)
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml

View File

@ -0,0 +1,9 @@
# Petstore::Tag
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**name** | **String** | | [optional]

View File

@ -0,0 +1,15 @@
# Petstore::User
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**username** | **String** | | [optional]
**first_name** | **String** | | [optional]
**last_name** | **String** | | [optional]
**email** | **String** | | [optional]
**password** | **String** | | [optional]
**phone** | **String** | | [optional]
**user_status** | **Integer** | User Status | [optional]

View File

@ -0,0 +1,360 @@
# Petstore::UserApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**create_user**](UserApi.md#create_user) | **POST** /user | Create user
[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system
[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user
# **create_user**
> create_user(opts)
Create user
This can only be done by the logged in user.
### Example
```ruby
api = Petstore::UserApi.new
opts = {
body: ,
}
begin
api.create_user(opts)
rescue Petstore::ApiError => e
puts "Exception when calling create_user: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**User**](User.md)| Created user object | [optional]
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **create_users_with_array_input**
> create_users_with_array_input(opts)
Creates list of users with given input array
### Example
```ruby
api = Petstore::UserApi.new
opts = {
body: ,
}
begin
api.create_users_with_array_input(opts)
rescue Petstore::ApiError => e
puts "Exception when calling create_users_with_array_input: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Array&lt;User&gt;**](User.md)| List of user object | [optional]
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **create_users_with_list_input**
> create_users_with_list_input(opts)
Creates list of users with given input array
### Example
```ruby
api = Petstore::UserApi.new
opts = {
body: ,
}
begin
api.create_users_with_list_input(opts)
rescue Petstore::ApiError => e
puts "Exception when calling create_users_with_list_input: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Array&lt;User&gt;**](User.md)| List of user object | [optional]
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **delete_user**
> delete_user(username, opts)
Delete user
This can only be done by the logged in user.
### Example
```ruby
api = Petstore::UserApi.new
username = "username_example" # [String] The name that needs to be deleted
opts = {
}
begin
api.delete_user(username, opts)
rescue Petstore::ApiError => e
puts "Exception when calling delete_user: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted |
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **get_user_by_name**
> User get_user_by_name(username, opts)
Get user by user name
### Example
```ruby
api = Petstore::UserApi.new
username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing.
opts = {
}
begin
result = api.get_user_by_name(username, opts)
rescue Petstore::ApiError => e
puts "Exception when calling get_user_by_name: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
[**User**](User.md)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **login_user**
> String login_user(opts)
Logs user into the system
### Example
```ruby
api = Petstore::UserApi.new
opts = {
username: "username_example",
password: "password_example",
}
begin
result = api.login_user(opts)
rescue Petstore::ApiError => e
puts "Exception when calling login_user: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [optional]
**password** | **String**| The password for login in clear text | [optional]
### Return type
**String**
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **logout_user**
> logout_user(opts)
Logs out current logged in user session
### Example
```ruby
api = Petstore::UserApi.new
opts = {
}
begin
api.logout_user(opts)
rescue Petstore::ApiError => e
puts "Exception when calling logout_user: #{e}"
end
```
### Parameters
This endpoint does not need any parameter.
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml
# **update_user**
> update_user(username, opts)
Updated user
This can only be done by the logged in user.
### Example
```ruby
api = Petstore::UserApi.new
username = "username_example" # [String] name that need to be deleted
opts = {
body: ,
}
begin
api.update_user(username, opts)
rescue Petstore::ApiError => e
puts "Exception when calling update_user: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object | [optional]
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP reuqest headers
- **Content-Type**: Not defined
- **Accept**: application/json, application/xml

View File

@ -21,19 +21,19 @@ require 'petstore/version'
require 'petstore/configuration'
# Models
require 'petstore/models/order'
require 'petstore/models/special_model_name'
require 'petstore/models/user'
require 'petstore/models/category'
require 'petstore/models/object_return'
require 'petstore/models/inline_response_200'
require 'petstore/models/tag'
require 'petstore/models/model_return'
require 'petstore/models/order'
require 'petstore/models/pet'
require 'petstore/models/special_model_name'
require 'petstore/models/tag'
require 'petstore/models/user'
# APIs
require 'petstore/api/user_api'
require 'petstore/api/store_api'
require 'petstore/api/pet_api'
require 'petstore/api/store_api'
require 'petstore/api/user_api'
module Petstore
class << self

View File

@ -24,62 +24,6 @@ module Petstore
@api_client = api_client
end
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def update_pet(opts = {})
update_pet_with_http_info(opts)
return nil
end
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet ..."
end
# resource path
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/json', 'application/xml']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Add a new pet to the store
#
# @param [Hash] opts the optional parameters
@ -136,6 +80,124 @@ module Petstore
return data, status_code, headers
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @return [nil]
def add_pet_using_byte_array(opts = {})
add_pet_using_byte_array_with_http_info(opts)
return nil
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_using_byte_array_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..."
end
# resource path
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/json', 'application/xml']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts)
return nil
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#delete_pet ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Finds Pets by status
# Multiple status values can be provided with comma separated strings
# @param [Hash] opts the optional parameters
@ -312,198 +374,6 @@ module Petstore
return data, status_code, headers
end
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts)
return nil
end
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/x-www-form-urlencoded']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["name"] = opts[:'name'] if opts[:'name']
form_params["status"] = opts[:'status'] if opts[:'status']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts)
return nil
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#delete_pet ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
def upload_file(pet_id, opts = {})
upload_file_with_http_info(pet_id, opts)
return nil
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#upload_file ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['multipart/form-data']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata']
form_params["file"] = opts[:'file'] if opts[:'file']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
# Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
# @param pet_id ID of pet that needs to be fetched
@ -624,28 +494,28 @@ module Petstore
return data, status_code, headers
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def add_pet_using_byte_array(opts = {})
add_pet_using_byte_array_with_http_info(opts)
def update_pet(opts = {})
update_pet_with_http_info(opts)
return nil
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_using_byte_array_with_http_info(opts = {})
def update_pet_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..."
@api_client.config.logger.debug "Calling API: PetApi#update_pet ..."
end
# resource path
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
@ -667,6 +537,71 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts)
return nil
end
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/x-www-form-urlencoded']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["name"] = opts[:'name'] if opts[:'name']
form_params["status"] = opts[:'status'] if opts[:'status']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -675,7 +610,72 @@ module Petstore
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
def upload_file(pet_id, opts = {})
upload_file_with_http_info(pet_id, opts)
return nil
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#upload_file ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['multipart/form-data']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata']
form_params["file"] = opts[:'file'] if opts[:'file']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

View File

@ -24,6 +24,65 @@ module Petstore
@api_client = api_client
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 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 [nil]
def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts)
return nil
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 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 [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#delete_order ..."
end
# verify the required parameter 'order_id' is set
fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
# resource path
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Finds orders by status
# A single status value can be provided as a string
# @param [Hash] opts the optional parameters
@ -196,63 +255,6 @@ module Petstore
return data, status_code, headers
end
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
data, status_code, headers = place_order_with_http_info(opts)
return data
end
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#place_order ..."
end
# resource path
local_var_path = "/store/order".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Order')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
@ -313,31 +315,28 @@ module Petstore
return data, status_code, headers
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts)
return nil
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
data, status_code, headers = place_order_with_http_info(opts)
return data
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#delete_order ..."
@api_client.config.logger.debug "Calling API: StoreApi#place_order ..."
end
# verify the required parameter 'order_id' is set
fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
# resource path
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
local_var_path = "/store/order".sub('{format}','json')
# query parameters
query_params = {}
@ -357,17 +356,18 @@ module Petstore
form_params = {}
# http body (model)
post_body = nil
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
:auth_names => auth_names,
:return_type => 'Order')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

View File

@ -192,6 +192,125 @@ module Petstore
return data, status_code, headers
end
# 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 [nil]
def delete_user(username, opts = {})
delete_user_with_http_info(username, opts)
return nil
end
# 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 [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#delete_user ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling delete_user" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# 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]
def get_user_by_name(username, opts = {})
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
# 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 [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'User')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Logs user into the system
#
# @param [Hash] opts the optional parameters
@ -307,66 +426,6 @@ module Petstore
return data, status_code, headers
end
# 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]
def get_user_by_name(username, opts = {})
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
# 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 [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'User')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Updated user
# This can only be done by the logged in user.
# @param username name that need to be deleted
@ -427,64 +486,5 @@ module Petstore
end
return data, status_code, headers
end
# 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 [nil]
def delete_user(username, opts = {})
delete_user_with_http_info(username, opts)
return nil
end
# 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 [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#delete_user ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling delete_user" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@ -18,21 +18,34 @@ require 'date'
module Petstore
class InlineResponse200
attr_accessor :photo_urls
attr_accessor :name
attr_accessor :id
attr_accessor :category
attr_accessor :tags
# pet status in the store
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'photo_urls' => :'photoUrls',
:'name' => :'name',
:'id' => :'id',
:'category' => :'category'
:'category' => :'category',
:'tags' => :'tags',
:'status' => :'status'
}
end
@ -40,9 +53,12 @@ module Petstore
# Attribute type mapping.
def self.swagger_types
{
:'photo_urls' => :'Array<String>',
:'name' => :'String',
:'id' => :'Integer',
:'category' => :'Object'
:'category' => :'Object',
:'tags' => :'Array<Tag>',
:'status' => :'String'
}
end
@ -54,6 +70,12 @@ module Petstore
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
if attributes[:'photoUrls']
if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value
end
end
if attributes[:'name']
self.name = attributes[:'name']
end
@ -66,15 +88,37 @@ module Petstore
self.category = attributes[:'category']
end
if attributes[:'tags']
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes[:'status']
self.status = attributes[:'status']
end
end
# Custom attribute writer method checking allowed values (enum).
def status=(status)
allowed_values = ["available", "pending", "sold"]
if status && !allowed_values.include?(status)
fail "invalid value for 'status', must be one of #{allowed_values}"
end
@status = status
end
# Check equality by comparing each attribute.
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
photo_urls == o.photo_urls &&
name == o.name &&
id == o.id &&
category == o.category
category == o.category &&
tags == o.tags &&
status == o.status
end
# @see the `==` method
@ -84,7 +128,7 @@ module Petstore
# Calculate hash code according to all attributes.
def hash
[name, id, category].hash
[photo_urls, name, id, category, tags, status].hash
end
# build the object from hash

View File

@ -0,0 +1,165 @@
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
Terms of Service: http://swagger.io/terms/
=end
require 'date'
module Petstore
class ModelReturn
attr_accessor :_return
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_return' => :'return'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'_return' => :'Integer'
}
end
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
if attributes[:'return']
self._return = attributes[:'return']
end
end
# Check equality by comparing each attribute.
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_return == o._return
end
# @see the `==` method
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
def hash
[_return].hash
end
# build the object from hash
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
else
#TODO show warning in debug mode
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
else
# data not found in attributes(hash), not an issue as the data can be optional
end
end
self
end
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /^(true|t|yes|y|1)$/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
_model = Petstore.const_get(type).new
_model.build_from_hash(value)
end
end
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
def to_body
to_hash
end
# return the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Method to output non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@ -36,13 +36,13 @@ describe 'PetApi' do
end
end
# unit tests for update_pet
# Update an existing pet
# unit tests for add_pet
# Add a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
describe 'update_pet test' do
describe 'add_pet test' do
it "should work" do
# assertion here
# should be_a()
@ -52,13 +52,30 @@ describe 'PetApi' do
end
end
# unit tests for add_pet
# Add a new pet to the store
# unit tests for add_pet_using_byte_array
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @option opts [String] :body Pet object in the form of byte array
# @return [nil]
describe 'add_pet test' do
describe 'add_pet_using_byte_array test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for delete_pet
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
describe 'delete_pet test' do
it "should work" do
# assertion here
# should be_a()
@ -116,59 +133,6 @@ describe 'PetApi' do
end
end
# unit tests for update_pet_with_form
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
describe 'update_pet_with_form test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for delete_pet
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
describe 'delete_pet test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for upload_file
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
describe 'upload_file test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for get_pet_by_id_in_object
# Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
# Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
@ -201,13 +165,49 @@ describe 'PetApi' do
end
end
# unit tests for add_pet_using_byte_array
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
# unit tests for update_pet
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
describe 'add_pet_using_byte_array test' do
describe 'update_pet test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for update_pet_with_form
# 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 [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
describe 'update_pet_with_form test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for upload_file
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
describe 'upload_file test' do
it "should work" do
# assertion here
# should be_a()

View File

@ -36,6 +36,22 @@ describe 'StoreApi' do
end
end
# unit tests for delete_order
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 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 [nil]
describe 'delete_order test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for find_orders_by_status
# Finds orders by status
# A single status value can be provided as a string
@ -82,22 +98,6 @@ describe 'StoreApi' do
end
end
# unit tests for place_order
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
describe 'place_order test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for get_order_by_id
# Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
@ -114,13 +114,13 @@ describe 'StoreApi' do
end
end
# unit tests for delete_order
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# unit tests for place_order
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @return [nil]
describe 'delete_order test' do
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
describe 'place_order test' do
it "should work" do
# assertion here
# should be_a()

View File

@ -84,6 +84,38 @@ describe 'UserApi' do
end
end
# unit tests for delete_user
# 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 [nil]
describe 'delete_user test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for get_user_by_name
# 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]
describe 'get_user_by_name test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for login_user
# Logs user into the system
#
@ -116,22 +148,6 @@ describe 'UserApi' do
end
end
# unit tests for get_user_by_name
# 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]
describe 'get_user_by_name test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for update_user
# Updated user
# This can only be done by the logged in user.
@ -149,20 +165,4 @@ describe 'UserApi' do
end
end
# unit tests for delete_user
# 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 [nil]
describe 'delete_user test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
end

View File

@ -36,6 +36,16 @@ describe 'InlineResponse200' do
@instance.should be_a(Petstore::InlineResponse200)
end
end
describe 'test attribute "photo_urls"' do
it 'should work' do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
describe 'test attribute "name"' do
it 'should work' do
# assertion here
@ -66,5 +76,25 @@ describe 'InlineResponse200' do
end
end
describe 'test attribute "tags"' do
it 'should work' do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
describe 'test attribute "status"' do
it 'should work' do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
end

View File

@ -0,0 +1,50 @@
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
Terms of Service: http://swagger.io/terms/
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'ModelReturn' do
before do
# run before each test
@instance = Petstore::ModelReturn.new
end
after do
# run after each test
end
describe 'test an instance of ModelReturn' do
it 'should create an instact of ModelReturn' do
@instance.should be_a(Petstore::ModelReturn)
end
end
describe 'test attribute "_return"' do
it 'should work' do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
end