Daniel Ge dd1ed12318 Make connection failures visible with generated Ruby SDKs (#3640)
* Make connection failures visible in Ruby SDK

The underlying HTTP library, Typhoeus, requires you to be explicit about
error handling. Unfortunately, this also means that we can't assume that
`response.success?` will be false only when the HTTP status code is not
a 200; it could also be false when the request fails (timeouts, TLS
verification issues, etc.). This commit adds explicit error handling for
these cases.

* Update samples
2016-08-30 10:28:07 +08:00

105 lines
3.0 KiB
Markdown

# petstore
Petstore - the Ruby gem for the Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
- Package version: 1.0.0
- Build date: 2016-08-29T14:24:34.432-07:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation
### Build a gem
To build the Ruby code into a gem:
```shell
gem build petstore.gemspec
```
Then either install the gem locally:
```shell
gem install ./petstore-1.0.0.gem
```
(for development, run `gem install --dev ./petstore-1.0.0.gem` to install the development dependencies)
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
Finally add this to the Gemfile:
gem 'petstore', '~> 1.0.0'
### Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
gem 'petstore', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
### Include the Ruby code directly
Include the Ruby code directly using `-I` as follows:
```shell
ruby -Ilib script.rb
```
## Getting Started
Please follow the [installation](#installation) procedure and then run the following code:
```ruby
# Load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
}
begin
#To test code injection */ ' \" =_end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(opts)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_code_inject____end__rn_n_r: #{e}"
end
```
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::FakeApi* | [**test_code_inject____end__rn_n_r**](docs/FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
## Documentation for Models
- [Petstore::ModelReturn](docs/ModelReturn.md)
## Documentation for Authorization
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account */ ' \" =_end -- \\r\\n \\n \\r
- read:pets: read your pets */ ' \" =_end -- \\r\\n \\n \\r
### api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
- **Location**: HTTP header