openapi-generator/samples/client/petstore/ruby
2015-07-27 10:32:51 +08:00
..
lib Ruby: use a default ApiClient when not provided 2015-07-27 10:32:51 +08:00
spec Update tests with latest code 2015-07-22 16:02:18 +08:00
Gemfile added ruby sample 2012-09-26 13:02:27 -07:00
Gemfile.lock Add config file for bin/ruby-petstore.sh 2015-06-26 17:15:14 +08:00
petstore.gemspec Rebuild Ruby petstore sample 2015-07-22 15:39:48 +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 Ruby: use a default ApiClient when not provided 2015-07-27 10:32:51 +08:00

Installation

Build a gem

You can build the generated client into a gem:

gem build petstore.gemspec

Then you can either install the gem:

gem install ./petstore-1.0.0.gem

or publish the gem to a gem server like RubyGems.

Finally add this to your Gemfile:

gem 'petstore', '~> 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 'petstore', :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

Getting Started

require 'petstore'

Petstore::ApiClient.default.configure do |client|
  client.api_key['api_key'] = 'special-key'
  client.host = 'petstore.swagger.io'
  client.base_path = '/v2'
  # enable debugging (default is disabled)
  client.debugging = true
end

pet_api = Petstore::PetApi.new
pet = pet_api.get_pet_by_id(5)
puts pet.to_body