Merge pull request #610 from xhh/ruby-gemspec

Generate Ruby gemspec
This commit is contained in:
Tony Tam 2015-04-09 07:37:26 -06:00
commit 70c14092f9
9 changed files with 111 additions and 13 deletions

View File

@ -64,6 +64,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("List", "array");
typeMapping.put("map", "map");
supportingFiles.add(new SupportingFile("swagger-client.gemspec.mustache", "", "swagger-client.gemspec"));
supportingFiles.add(new SupportingFile("swagger-client.mustache", "", "lib/swagger-client.rb"));
supportingFiles.add(new SupportingFile("swagger.mustache", "", "lib/swagger.rb"));
supportingFiles.add(new SupportingFile("monkey.mustache", "", "lib/monkey.rb"));
supportingFiles.add(new SupportingFile("swagger/request.mustache", "", "lib/swagger/request.rb"));

View File

@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
require "swagger/version"
Gem::Specification.new do |s|
s.name = "swagger"
s.name = "{{artifactId}}"
s.version = Swagger::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Zeke Sikelianos", "Tony Tam"]
@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = %q{A ruby wrapper for the swagger APIs}
s.description = %q{This gem maps to a swagger API}
s.rubyforge_project = "swagger"
s.rubyforge_project = "{{artifactId}}"
s.add_dependency 'typhoeus', '>=0.2.1'
s.add_dependency 'addressable', '>=2.2.4'

View File

@ -0,0 +1,5 @@
require 'monkey'
require 'swagger'
Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file if file !~ /swagger-client\.rb\z/ }
Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
swagger (4.06.08)
swagger-client (4.06.08)
addressable (>= 2.2.4)
json (>= 1.4.6)
typhoeus (>= 0.2.1)
@ -56,6 +56,6 @@ DEPENDENCIES
autotest-growl
autotest-rails-pure
rspec (>= 2.5.0)
swagger!
swagger-client!
vcr (>= 1.5.1)
webmock (>= 1.6.2)

View File

@ -0,0 +1,57 @@
## Installation
### Build a gem
You can build the generated client into a gem:
```shell
gem build swagger-client.gemspec
```
Then you can either install the gem:
```shell
gem install ./swagger-client-4.06.08.gem
```
or publish the gem to a gem server like [RubyGems](https://rubygems.org/).
Finally add this to your Gemfile:
gem 'swagger-client', '~> 4.06.08'
### 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:
```shell
ruby -Ilib script.rb
```
## Configuration
```ruby
require 'swagger-client'
Swagger.configure do |config|
config.api_key = 'special-key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
end
```
## Getting Started
```ruby
pet = PetApi.getPetById(5)
puts pet.to_body
```

View File

@ -0,0 +1,5 @@
require 'monkey'
require 'swagger'
Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file if file !~ /swagger-client\.rb\z/ }
Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }

View File

@ -12,8 +12,9 @@ describe "Pet" do
describe "pet methods" do
it "should fetch a pet object" do
pet = PetApi.getPetById(5)
pet.should be_a(Pet)
pet.id.should == 5
pet.name.should == "Dog 2"
pet.name.should == "panda"
end
it "should find pets by status" do
@ -22,7 +23,7 @@ describe "Pet" do
end
it "should not find a pet with invalid status" do
pets = PetApi.findPetsByStatus('dead')
pets = PetApi.findPetsByStatus('invalid-status')
pets.length.should == 0
end

View File

@ -1,17 +1,12 @@
require 'rubygems'
require 'bundler/setup'
require 'monkey'
require 'swagger'
require 'swagger-client'
require 'vcr'
require 'typhoeus'
require 'json'
require 'yaml'
require 'rspec'
Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file }
Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }
Dir[File.join(File.dirname(__FILE__), "../resources/*.rb")].each {|file| require file }
RSpec.configure do |config|
# some (optional) config here
config.expect_with :rspec do |c|

View File

@ -0,0 +1,33 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "swagger/version"
Gem::Specification.new do |s|
s.name = "swagger-client"
s.version = Swagger::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Zeke Sikelianos", "Tony Tam"]
s.email = ["zeke@wordnik.com", "tony@wordnik.com"]
s.homepage = "http://developer.wordnik.com"
s.summary = %q{A ruby wrapper for the swagger APIs}
s.description = %q{This gem maps to a swagger API}
s.rubyforge_project = "swagger-client"
s.add_dependency 'typhoeus', '>=0.2.1'
s.add_dependency 'addressable', '>=2.2.4'
s.add_dependency 'json', '>=1.4.6'
s.add_development_dependency 'rspec', '>=2.5.0'
s.add_development_dependency 'vcr', '>=1.5.1'
s.add_development_dependency 'webmock', '>=1.6.2'
s.add_development_dependency 'autotest'
s.add_development_dependency 'autotest-rails-pure'
s.add_development_dependency 'autotest-growl'
s.add_development_dependency 'autotest-fsevent'
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
s.test_files = `find spec/*`.split("\n")
s.executables = []
s.require_paths = ["lib"]
end