update ruby petstore samples

This commit is contained in:
wing328 2017-10-20 22:17:09 +08:00
parent 36f14ab757
commit 4d994a2045
10 changed files with 566 additions and 6 deletions

View File

@ -54,17 +54,17 @@ Please follow the [installation](#installation) procedure and then run the follo
# Load the gem # Load the gem
require 'petstore' require 'petstore'
api_instance = Petstore::FakeApi.new api_instance = Petstore::AnotherFakeApi.new
body = Petstore::Client.new # Client | client model
opts = {
body: Petstore::OuterBoolean.new # OuterBoolean | Input boolean as post body
}
begin begin
result = api_instance.fake_outer_boolean_serialize(opts) #To test special tags
result = api_instance.test_special_tags(body)
p result p result
rescue Petstore::ApiError => e rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->fake_outer_boolean_serialize: #{e}" puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
end end
``` ```
@ -75,6 +75,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*Petstore::AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
@ -82,6 +83,7 @@ Class | Method | HTTP request | Description
*Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*Petstore::FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters *Petstore::FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
*Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
*Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store

View File

@ -0,0 +1,56 @@
# Petstore::AnotherFakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
# **test_special_tags**
> Client test_special_tags(body)
To test special tags
To test special tags
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::AnotherFakeApi.new
body = Petstore::Client.new # Client | client model
begin
#To test special tags
result = api_instance.test_special_tags(body)
p result
rescue Petstore::ApiError => e
puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
### Return type
[**Client**](Client.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -0,0 +1,93 @@
# Petstore::DefaultApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**get_xml_features**](DefaultApi.md#get_xml_features) | **GET** /fake/xmlFeatures | Get some XML
[**post_xml_features**](DefaultApi.md#post_xml_features) | **POST** /fake/xmlFeatures | Post some xml
# **get_xml_features**
> XmlObject get_xml_features
Get some XML
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::DefaultApi.new
begin
#Get some XML
result = api_instance.get_xml_features
p result
rescue Petstore::ApiError => e
puts "Exception when calling DefaultApi->get_xml_features: #{e}"
end
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**XmlObject**](XmlObject.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/xml
- **Accept**: application/xml
# **post_xml_features**
> post_xml_features(xml_object)
Post some xml
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::DefaultApi.new
xml_object = Petstore::XmlObject.new # XmlObject |
begin
#Post some xml
api_instance.post_xml_features(xml_object)
rescue Petstore::ApiError => e
puts "Exception when calling DefaultApi->post_xml_features: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**xml_object** | [**XmlObject**](XmlObject.md)| |
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/xml
- **Accept**: application/xml

View File

@ -11,6 +11,7 @@ Method | HTTP request | Description
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters [**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
@ -393,6 +394,52 @@ No authorization required
# **test_inline_additional_properties**
> test_inline_additional_properties(param)
test inline additionalProperties
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
param = nil # Object | request body
begin
#test inline additionalProperties
api_instance.test_inline_additional_properties(param)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_inline_additional_properties: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | **Object**| request body |
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
# **test_json_form_data** # **test_json_form_data**
> test_json_form_data(param, param2) > test_json_form_data(param, param2)

View File

@ -55,6 +55,7 @@ require 'petstore/models/cat'
require 'petstore/models/dog' require 'petstore/models/dog'
# APIs # APIs
require 'petstore/api/another_fake_api'
require 'petstore/api/fake_api' require 'petstore/api/fake_api'
require 'petstore/api/fake_classname_tags123_api' require 'petstore/api/fake_classname_tags123_api'
require 'petstore/api/pet_api' require 'petstore/api/pet_api'

View File

@ -0,0 +1,78 @@
=begin
#Swagger Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
=end
require "uri"
module Petstore
class AnotherFakeApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# To test special tags
# To test special tags
# @param body client model
# @param [Hash] opts the optional parameters
# @return [Client]
def test_special_tags(body, opts = {})
data, _status_code, _headers = test_special_tags_with_http_info(body, opts)
return data
end
# To test special tags
# To test special tags
# @param body client model
# @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_special_tags_with_http_info(body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: AnotherFakeApi.test_special_tags ..."
end
# verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling AnotherFakeApi.test_special_tags"
end
# resource path
local_var_path = "/another-fake/dummy"
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(body)
auth_names = []
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Client')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: AnotherFakeApi#test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@ -0,0 +1,126 @@
=begin
#Swagger Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
=end
require "uri"
module Petstore
class DefaultApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Get some XML
#
# @param [Hash] opts the optional parameters
# @return [XmlObject]
def get_xml_features(opts = {})
data, _status_code, _headers = get_xml_features_with_http_info(opts)
return data
end
# Get some XML
#
# @param [Hash] opts the optional parameters
# @return [Array<(XmlObject, Fixnum, Hash)>] XmlObject data, response status code and response headers
def get_xml_features_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: DefaultApi.get_xml_features ..."
end
# resource path
local_var_path = "/fake/xmlFeatures"
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/xml'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml'])
# 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 => 'XmlObject')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DefaultApi#get_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Post some xml
#
# @param xml_object
# @param [Hash] opts the optional parameters
# @return [nil]
def post_xml_features(xml_object, opts = {})
post_xml_features_with_http_info(xml_object, opts)
return nil
end
# Post some xml
#
# @param xml_object
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def post_xml_features_with_http_info(xml_object, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: DefaultApi.post_xml_features ..."
end
# verify the required parameter 'xml_object' is set
if @api_client.config.client_side_validation && xml_object.nil?
fail ArgumentError, "Missing the required parameter 'xml_object' when calling DefaultApi.post_xml_features"
end
# resource path
local_var_path = "/fake/xmlFeatures"
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/xml'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml'])
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(xml_object)
auth_names = []
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: DefaultApi#post_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@ -517,6 +517,58 @@ module Petstore
return data, status_code, headers return data, status_code, headers
end end
# test inline additionalProperties
#
# @param param request body
# @param [Hash] opts the optional parameters
# @return [nil]
def test_inline_additional_properties(param, opts = {})
test_inline_additional_properties_with_http_info(param, opts)
return nil
end
# test inline additionalProperties
#
# @param param request body
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_inline_additional_properties_with_http_info(param, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_inline_additional_properties ..."
end
# verify the required parameter 'param' is set
if @api_client.config.client_side_validation && param.nil?
fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_inline_additional_properties"
end
# resource path
local_var_path = "/fake/inline-additionalProperties"
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(param)
auth_names = []
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: FakeApi#test_inline_additional_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# test json serialization of form data # test json serialization of form data
# #
# @param param field1 # @param param field1

View File

@ -0,0 +1,47 @@
=begin
#Swagger Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
# Unit tests for Petstore::AnotherFakeApi
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'AnotherFakeApi' do
before do
# run before each test
@instance = Petstore::AnotherFakeApi.new
end
after do
# run after each test
end
describe 'test an instance of AnotherFakeApi' do
it 'should create an instance of AnotherFakeApi' do
expect(@instance).to be_instance_of(Petstore::AnotherFakeApi)
end
end
# unit tests for test_special_tags
# To test special tags
# To test special tags
# @param body client model
# @param [Hash] opts the optional parameters
# @return [Client]
describe 'test_special_tags test' do
it "should work" do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@ -0,0 +1,58 @@
=begin
#Swagger Petstore
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
# Unit tests for Petstore::DefaultApi
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'DefaultApi' do
before do
# run before each test
@instance = Petstore::DefaultApi.new
end
after do
# run after each test
end
describe 'test an instance of DefaultApi' do
it 'should create an instance of DefaultApi' do
expect(@instance).to be_instance_of(Petstore::DefaultApi)
end
end
# unit tests for get_xml_features
# Get some XML
#
# @param [Hash] opts the optional parameters
# @return [XmlObject]
describe 'get_xml_features test' do
it "should work" do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
# unit tests for post_xml_features
# Post some xml
#
# @param xml_object
# @param [Hash] opts the optional parameters
# @return [nil]
describe 'post_xml_features test' do
it "should work" do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end