openapi-generator/samples/client/petstore/ruby
xhh 1de6952279 Support customizing default headers via config option
for example:

    config.default_headers['X-MY-HEADER'] = 'my-header-value'
2015-06-26 19:09:20 +08:00
..
lib Support customizing default headers via config option 2015-06-26 19:09:20 +08:00
spec Support customizing default headers via config option 2015-06-26 19:09:20 +08:00
Gemfile added ruby sample 2012-09-26 13:02:27 -07:00
Gemfile.lock Avoid warnings for ruby gem building 2015-05-20 09:23:45 +08:00
pom.xml Code reformatting 2015-06-07 11:56:08 -04:00
Rakefile added ruby sample 2012-09-26 13:02:27 -07:00
README.md Rename swagger-client to swagger_client 2015-05-20 09:23:44 +08:00
swagger_client.gemspec fix csharp refer to apiinvoker 2015-06-09 13:52:01 +08:00

Installation

Build a gem

You can build the generated client into a gem:

gem build swagger_client.gemspec

Then you can either install the gem:

gem install ./swagger_client-1.0.0.gem

or publish the gem to a gem server like RubyGems.

Finally add this to your Gemfile:

gem 'swagger_client', '~> 1.0.0'

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

Then you can reference it in Gemfile:

gem 'swagger_client', :git => 'https://github.com/xhh/swagger-petstore-ruby.git'

Use without installation

You can also use the client directly like this:

ruby -Ilib script.rb

Configuration

require 'swagger_client'

SwaggerClient::Swagger.configure do |config|
  config.api_key = 'special-key'
  config.host = 'petstore.swagger.io'
  config.base_path = '/v2'
end

Getting Started

pet = SwaggerClient::PetApi.get_pet_by_id(5)
puts pet.to_body