mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
commit
70c14092f9
@ -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"));
|
||||
|
@ -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'
|
@ -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 }
|
@ -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)
|
||||
|
57
samples/client/petstore/ruby/README.md
Normal file
57
samples/client/petstore/ruby/README.md
Normal 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
|
||||
```
|
5
samples/client/petstore/ruby/lib/swagger-client.rb
Normal file
5
samples/client/petstore/ruby/lib/swagger-client.rb
Normal 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 }
|
@ -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
|
||||
|
||||
|
@ -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|
|
||||
|
33
samples/client/petstore/ruby/swagger-client.gemspec
Normal file
33
samples/client/petstore/ruby/swagger-client.gemspec
Normal 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
|
Loading…
x
Reference in New Issue
Block a user