add new ruby files

This commit is contained in:
wing328 2016-04-26 00:32:01 +08:00
parent 354449ebfe
commit 875414ff64
3 changed files with 319 additions and 0 deletions

View File

@ -0,0 +1,82 @@
# Petstore::FakeApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters
# **test_endpoint_parameters**
> test_endpoint_parameters(number, double, string, byte, opts)
Fake endpoint for testing various parameters
Fake endpoint for testing various parameters
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
number = "number_example" # String | None
double = 1.2 # Float | None
string = "string_example" # String | None
byte = "B" # String | None
opts = {
integer: 56, # Integer | None
int32: 56, # Integer | None
int64: 789, # Integer | None
float: 3.4, # Float | None
binary: "B", # String | None
date: Date.parse("2013-10-20"), # Date | None
date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None
password: "password_example" # String | None
}
begin
#Fake endpoint for testing various parameters
api_instance.test_endpoint_parameters(number, double, string, byte, opts)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}"
end
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**number** | **String**| None |
**double** | **Float**| None |
**string** | **String**| None |
**byte** | **String**| None |
**integer** | **Integer**| None | [optional]
**int32** | **Integer**| None | [optional]
**int64** | **Integer**| None | [optional]
**float** | **Float**| None | [optional]
**binary** | **String**| None | [optional]
**date** | **Date**| None | [optional]
**date_time** | **DateTime**| None | [optional]
**password** | **String**| None | [optional]
### Return type
nil (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

View File

@ -0,0 +1,171 @@
=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.
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 "uri"
module Petstore
class FakeApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Fake endpoint for testing various parameters
# Fake endpoint for testing various parameters
# @param number None
# @param double None
# @param string None
# @param byte None
# @param [Hash] opts the optional parameters
# @option opts [Integer] :integer None
# @option opts [Integer] :int32 None
# @option opts [Integer] :int64 None
# @option opts [Float] :float None
# @option opts [String] :binary None
# @option opts [Date] :date None
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @return [nil]
def test_endpoint_parameters(number, double, string, byte, opts = {})
test_endpoint_parameters_with_http_info(number, double, string, byte, opts)
return nil
end
# Fake endpoint for testing various parameters
# Fake endpoint for testing various parameters
# @param number None
# @param double None
# @param string None
# @param byte None
# @param [Hash] opts the optional parameters
# @option opts [Integer] :integer None
# @option opts [Integer] :int32 None
# @option opts [Integer] :int64 None
# @option opts [Float] :float None
# @option opts [String] :binary None
# @option opts [Date] :date None
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_endpoint_parameters_with_http_info(number, double, string, byte, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_endpoint_parameters ..."
end
# verify the required parameter 'number' is set
fail ArgumentError, "Missing the required parameter 'number' when calling FakeApi.test_endpoint_parameters" if number.nil?
if number > 543.2
fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 543.2.'
end
if number < 32.1
fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 32.1.'
end
# verify the required parameter 'double' is set
fail ArgumentError, "Missing the required parameter 'double' when calling FakeApi.test_endpoint_parameters" if double.nil?
if double > 123.4
fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 123.4.'
end
if double < 67.8
fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 67.8.'
end
# verify the required parameter 'string' is set
fail ArgumentError, "Missing the required parameter 'string' when calling FakeApi.test_endpoint_parameters" if string.nil?
if string !~ Regexp.new(/[a-z]/i)
fail ArgumentError, 'invalid value for "string" when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i.'
end
# verify the required parameter 'byte' is set
fail ArgumentError, "Missing the required parameter 'byte' when calling FakeApi.test_endpoint_parameters" if byte.nil?
if opts[:'integer'] > 100.0
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.0.'
end
if opts[:'integer'] < 10.0
fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.0.'
end
if opts[:'int32'] > 200.0
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.0.'
end
if opts[:'int32'] < 20.0
fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.0.'
end
if opts[:'float'] > 987.6
fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.'
end
if opts[:'password'].to_s.length > 64
fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be smaller than or equal to 64.'
end
if opts[:'password'].to_s.length < 10
fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be great than or equal to 10.'
end
# resource path
local_var_path = "/fake".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
local_header_accept = ['application/xml', 'application/json']
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
# HTTP header 'Content-Type'
local_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
# form parameters
form_params = {}
form_params["number"] = number
form_params["double"] = double
form_params["string"] = string
form_params["byte"] = byte
form_params["integer"] = opts[:'integer'] if opts[:'integer']
form_params["int32"] = opts[:'int32'] if opts[:'int32']
form_params["int64"] = opts[:'int64'] if opts[:'int64']
form_params["float"] = opts[:'float'] if opts[:'float']
form_params["binary"] = opts[:'binary'] if opts[:'binary']
form_params["date"] = opts[:'date'] if opts[:'date']
form_params["dateTime"] = opts[:'date_time'] if opts[:'date_time']
form_params["password"] = opts[:'password'] if opts[:'password']
# http body (model)
post_body = nil
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_endpoint_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@ -0,0 +1,66 @@
=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.
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'
# Unit tests for Petstore::FakeApi
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'FakeApi' do
before do
# run before each test
@instance = Petstore::FakeApi.new
end
after do
# run after each test
end
describe 'test an instance of FakeApi' do
it 'should create an instact of FakeApi' do
@instance.should be_a(Petstore::FakeApi)
end
end
# unit tests for test_endpoint_parameters
# Fake endpoint for testing various parameters
# Fake endpoint for testing various parameters
# @param number None
# @param double None
# @param string None
# @param byte None
# @param [Hash] opts the optional parameters
# @option opts [Integer] :integer None
# @option opts [Integer] :int32 None
# @option opts [Integer] :int64 None
# @option opts [Float] :float None
# @option opts [String] :binary None
# @option opts [Date] :date None
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @return [nil]
describe 'test_endpoint_parameters test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
end