diff --git a/samples/client/petstore/ruby/Gemfile b/samples/client/petstore/ruby/Gemfile deleted file mode 100644 index 06d4a65272e..00000000000 --- a/samples/client/petstore/ruby/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source "http://rubygems.org" - -# Specify dependencies in swagger.gemspec -gemspec diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock deleted file mode 100644 index f90e3382ed2..00000000000 --- a/samples/client/petstore/ruby/Gemfile.lock +++ /dev/null @@ -1,53 +0,0 @@ -PATH - remote: . - specs: - swagger (4.06.08) - addressable (>= 2.2.4) - json (>= 1.4.6) - typhoeus (>= 0.2.1) - -GEM - remote: http://rubygems.org/ - specs: - ZenTest (4.7.0) - addressable (2.2.8) - autotest (4.4.6) - ZenTest (>= 4.4.1) - autotest-fsevent (0.2.8) - sys-uname - autotest-growl (0.2.16) - autotest-rails-pure (4.1.2) - crack (0.3.1) - diff-lcs (1.1.3) - ffi (1.0.11) - json (1.7.0) - mime-types (1.18) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) - diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) - sys-uname (0.9.0) - ffi (>= 1.0.0) - typhoeus (0.3.3) - mime-types - vcr (2.1.1) - webmock (1.8.6) - addressable (>= 2.2.7) - crack (>= 0.1.7) - -PLATFORMS - ruby - -DEPENDENCIES - autotest - autotest-fsevent - autotest-growl - autotest-rails-pure - rspec (>= 2.5.0) - swagger! - vcr (>= 1.5.1) - webmock (>= 1.6.2) diff --git a/samples/client/petstore/ruby/Rakefile b/samples/client/petstore/ruby/Rakefile deleted file mode 100644 index e62140b1677..00000000000 --- a/samples/client/petstore/ruby/Rakefile +++ /dev/null @@ -1,7 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks - -require 'rspec/core/rake_task' -require 'swagger' - -RSpec::Core::RakeTask.new('spec') \ No newline at end of file diff --git a/samples/client/petstore/ruby/models/Category.rb b/samples/client/petstore/ruby/models/Category.rb index c77144950f5..13fa91df299 100644 --- a/samples/client/petstore/ruby/models/Category.rb +++ b/samples/client/petstore/ruby/models/Category.rb @@ -1,4 +1,6 @@ class Category + # alan comment + attr_accessor :id, :name # :internal => :external diff --git a/samples/client/petstore/ruby/models/Order.rb b/samples/client/petstore/ruby/models/Order.rb index 4bc865e31db..86372189d44 100644 --- a/samples/client/petstore/ruby/models/Order.rb +++ b/samples/client/petstore/ruby/models/Order.rb @@ -1,4 +1,6 @@ class Order + # alan comment + attr_accessor :id, :pet_id, :status, :quantity, :ship_date # :internal => :external diff --git a/samples/client/petstore/ruby/models/Pet.rb b/samples/client/petstore/ruby/models/Pet.rb index a8d13a8f9f8..5fe068abec1 100644 --- a/samples/client/petstore/ruby/models/Pet.rb +++ b/samples/client/petstore/ruby/models/Pet.rb @@ -1,4 +1,6 @@ class Pet + # alan comment + attr_accessor :id, :tags, :category, :status, :name, :photo_urls # :internal => :external diff --git a/samples/client/petstore/ruby/models/Tag.rb b/samples/client/petstore/ruby/models/Tag.rb index 5360a29f23d..2807ebf03bc 100644 --- a/samples/client/petstore/ruby/models/Tag.rb +++ b/samples/client/petstore/ruby/models/Tag.rb @@ -1,4 +1,6 @@ class Tag + # alan comment + attr_accessor :id, :name # :internal => :external diff --git a/samples/client/petstore/ruby/models/User.rb b/samples/client/petstore/ruby/models/User.rb index a58bb39d09f..fbf1965f5e3 100644 --- a/samples/client/petstore/ruby/models/User.rb +++ b/samples/client/petstore/ruby/models/User.rb @@ -1,4 +1,6 @@ class User + # alan comment + attr_accessor :id, :last_name, :username, :phone, :email, :user_status, :first_name, :password # :internal => :external diff --git a/samples/client/petstore/ruby/spec/monkey_spec.rb b/samples/client/petstore/ruby/spec/monkey_spec.rb deleted file mode 100644 index 71c04921f1a..00000000000 --- a/samples/client/petstore/ruby/spec/monkey_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe String do - - it "underscores" do - "thisIsATest".underscore.should == "this_is_a_test" - end - - it "camelizes" do - "camel_toe".camelize.should == "CamelToe" - end - - it "camelizes with leading minisculity" do - "dromedary_larry".camelize(:lower).should == "dromedaryLarry" - end - -end - -describe Hash do - - it "symbolizes keys" do - h = {'a' => 1, :b => 2 } - h.symbolize_keys.should be_a Hash - h.symbolize_keys.keys.should == [:a, :b] - end - - it "symbolizes and underscores keys" do - h = {'assHat' => 1, :bargainBasement => 2 } - h.symbolize_and_underscore_keys.should be_a Hash - h.symbolize_and_underscore_keys.keys.should == [:ass_hat, :bargain_basement] - end - -end \ No newline at end of file diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb deleted file mode 100644 index ef71a988bbd..00000000000 --- a/samples/client/petstore/ruby/spec/pet_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper' - -describe "Pet" do - before do - Swagger.configure do |config| - config.api_key = 'special-key' - config.host = 'petstore.swagger.wordnik.com' - config.base_path = '/api' - end - end - - describe "pet methods" do - it "should fetch a pet object" do - pet = Pet_api.get_pet_by_id(1) - pet.id.should == 1 - pet.name.should == "Cat 1" - end - - it "should find pets by status" do - pets = Pet_api.find_pets_by_status('available') - pets.length.should >= 3 - end - - it "should not find a pet with invalid status" do - pets = Pet_api.find_pets_by_status('dead') - pets.length.should == 0 - end - - it "should find a pet by status" do - pets = Pet_api.find_pets_by_status("available,sold") - pets.map {|pet| - if(pet.status != 'available' && pet.status != 'sold') - raise "pet status wasn't right" - end - } - end - - it "should update a pet" do - pet = Pet.new({:id => 99, :name => 'programmer', :status => 'coding'}) - Pet_api.add_pet(pet) - - fetched = Pet_api.get_pet_by_id(99) - fetched.id.should == 99 - end - - it "should create a pet" do - pet = Pet.new({:id => 100, :name => "Gorilla"}) - Pet_api.add_pet(pet) - - pet = Pet_api.get_pet_by_id(100) - pet.id.should == 100 - end - end -end - -describe "Store" do - before do - Swagger.configure do |config| - config.api_key = 'special-key' - config.host = 'petstore.swagger.wordnik.com' - config.base_path = '/api' - end - end - - it "should fetch an order" do - item = Store_api.get_order_by_id(1) - item.id.should == 1 - end -end \ No newline at end of file diff --git a/samples/client/petstore/ruby/spec/request_spec.rb b/samples/client/petstore/ruby/spec/request_spec.rb deleted file mode 100644 index e2afd126873..00000000000 --- a/samples/client/petstore/ruby/spec/request_spec.rb +++ /dev/null @@ -1,196 +0,0 @@ -require 'spec_helper' - -describe Swagger::Request do - - before(:each) do - @default_http_method = :get - @default_path = "pet/fancy" - @default_params = { - :params => {:foo => "1", :bar => "2"} - } - @request = Swagger::Request.new(@default_http_method, @default_path, @default_params) - end - - describe "initialization" do - it "sets default response format to json" do - @request.format.should == 'json' - end - - it "allows params to be nil" do - @request = Swagger::Request.new(@default_http_method, @default_path, :params => nil) - @request.query_string.should == "" - end - - end - - describe "attr_accessors" do - - it "has working attributes" do - @request.format.to_s.should == 'json' - end - - it "allows attributes to be overwritten" do - @request.http_method.should == :get - @request.http_method = "post" - @request.http_method.should == 'post' - end - - end - - describe "url" do - - it "constructs a query string" do - @request.query_string.should == "?bar=2&foo=1" - end - - it "constructs a full url" do - @request.url.should == "http://petstore.swagger.wordnik.com/api/pet.json/fancy?bar=2&foo=1" - end - - end - - describe "body" do - - it "camelCases parameters" do - @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({ - :body => { - :bad_dog => 'bud', - :goodDog => "dud" - } - })) - @request.body.keys.should == [:badDog, :goodDog] - end - - end - - describe "path" do - - it "accounts for a total absence of format in the path string" do - @request = Swagger::Request.new(:get, "/word/{word}/entries", @default_params.merge({ - :format => "xml", - :params => { - :word => "cat" - } - })) - @request.url.should == "http://petstore.swagger.wordnik.com/api/word.xml/cat/entries" - end - - it "does string substitution on path params" do - @request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({ - :format => "xml", - :params => { - :word => "cat" - } - })) - @request.url.should == "http://petstore.swagger.wordnik.com/api/word.xml/cat/entries" - end - - it "leaves path-bound params out of the query string" do - @request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({ - :params => { - :word => "cat", - :limit => 20 - } - })) - @request.query_string.should == "?limit=20" - end - - it "returns a question-mark free (blank) query string if no query params are present" do - @request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({ - :params => { - :word => "cat", - } - })) - @request.query_string.should == "" - end - - it "removes blank params" do - @request = Swagger::Request.new(:get, "words/fancy", @default_params.merge({ - :params => { - :word => "dog", - :limit => "", - :foo => "criminy" - } - })) - @request.query_string.should == "?foo=criminy&word=dog" - end - - it "URI encodes the path" do - @request = Swagger::Request.new(:get, "word.{format}/{word}/definitions", @default_params.merge({ - :params => { - :word => "bill gates" - } - })) - @request.url.should =~ /word.json\/bill\%20gates\/definitions/ - end - - it "converts numeric params to strings" do - @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({ - :params => { - :limit => 100 - } - })) - - @request.interpreted_path.should_not be_nil - @request.query_string.should =~ /\?limit=100/ - @request.url.should =~ /\?limit=100/ - end - - it "camelCases parameters" do - @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({ - :params => { - :bad_dog => 'bud', - :goodDog => "dud" - } - })) - @request.query_string.should == "?badDog=bud&goodDog=dud" - end - - it "converts boolean values to their string representation" do - params = {:stringy => "fish", :truthy => true, :falsey => false} - @request = Swagger::Request.new(:get, 'fakeMethod', :params => params) - @request.query_string.should == "?falsey=false&stringy=fish&truthy=true" - end - - end - - describe "API key" do - - it "is inferred from the Swagger base configuration by default" do - Swagger.configure {|c| c.api_key = "xyz" } - Swagger::Request.new(:get, "word/json").headers[:api_key].should == "xyz" - end - - it "can be obfuscated for public display" do - @request = Swagger::Request.new(:get, "words/fancy", @default_params.merge({ - :params => { - :word => "dog", - :api_key => "123456" - } - })) - - @request.url.should =~ /api\_key=123456/ - @request.url(:obfuscated => true).should =~ /api\_key=YOUR\_API\_KEY/ - end - - it "allows a key in the params to override the configuration-level key, even if it's blank" do - Swagger.configure {|c| c.api_key = "abc" } - @request_with_key = Swagger::Request.new(:get, "word/json", :params => {:api_key => "jkl"}) - @request_with_key.headers[:api_key].should be_nil - @request_with_key.params[:api_key].should == "jkl" - - @request_without_key = Swagger::Request.new(:get, "word/json", :params => {:api_key => nil}) - @request_without_key.headers[:api_key].should be_nil - @request_without_key.params[:api_key].should be_nil - end - - it "allows a key in the headers to override the configuration-level key, even if it's blank" do - Swagger.configure {|c| c.api_key = "hij" } - Swagger::Request.new(:get, "word/json").headers[:api_key].should == "hij" - Swagger::Request.new(:get, "word/json", :headers => {:api_key => "jkl"}).headers[:api_key].should == "jkl" - Swagger::Request.new(:get, "word/json", :headers => {:api_key => nil}).headers[:api_key].should be_nil - end - - end - -end \ No newline at end of file diff --git a/samples/client/petstore/ruby/spec/response_spec.rb b/samples/client/petstore/ruby/spec/response_spec.rb deleted file mode 100644 index 1092ee9d198..00000000000 --- a/samples/client/petstore/ruby/spec/response_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'spec_helper' - -describe Swagger::Response do - - before(:each) do - - VCR.use_cassette('pet_resource', :record => :new_episodes) do - @raw = Typhoeus::Request.get("http://petstore.swagger.wordnik.com/api/pet.json") - end - - @response = Swagger::Response.new(@raw) - end - - describe "initialization" do - it "sets body" do - @response.body.class.should == Hash - @response.body.has_key?('apis').should == true - end - - it "sets code" do - @response.code.should == 200 - end - - it "converts header string into a hash" do - @response.headers.class.should == Hash - end - end - - describe "format" do - - it "recognizes json" do - @response.format.should == 'json' - @response.json?.should == true - end - - it "recognizes xml" do - VCR.use_cassette('xml_response_request', :record => :new_episodes) do - @raw = Typhoeus::Request.get("http://petstore.swagger.wordnik.com/api/pet.xml") - end - @response = Swagger::Response.new(@raw) - @response.format.should == 'xml' - @response.xml?.should == true - end - - end - - describe "prettiness" do - - it "has a pretty json body" do - @response.pretty_body.should =~ /\{.*\}/ - end - - it "has pretty headers" do - @response.pretty_headers.should =~ /\{.*\}/ - end - - end - -end \ No newline at end of file diff --git a/samples/client/petstore/ruby/spec/spec.opts b/samples/client/petstore/ruby/spec/spec.opts deleted file mode 100644 index 391705bf8b0..00000000000 --- a/samples/client/petstore/ruby/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb deleted file mode 100644 index 926f8e2abd6..00000000000 --- a/samples/client/petstore/ruby/spec/spec_helper.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rubygems' -require 'bundler/setup' -require 'monkey' -require 'swagger' -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 -end - -WebMock.allow_net_connect! if defined? WebMock - -def help - puts "\nOh noes! You gotta stuff your swagger credentials in ~/.swagger.yml like so:\n\n" - puts "api_key: '12345abcdefg'" - puts "username: 'fumanchu'" - puts "password: 'kalamazoo'\n\n" - exit -end - -# Parse ~/.swagger.yml for user credentials -begin - CREDENTIALS = YAML::load_file(File.join(ENV['HOME'], ".swagger.yml")).symbolize_keys -rescue - help -end - -def configure_swagger - Swagger.configure do |config| - config.api_key = "special-key" - config.username = "" - config.password = "" - - config.host = 'petstore.swagger.wordnik.com' - config.base_path = '/api' - end -end - -configure_swagger - -# A random string to tack onto stuff to ensure we're not seeing -# data from a previous test run -RAND = ("a".."z").to_a.sample(8).join diff --git a/samples/client/petstore/ruby/spec/swagger_spec.rb b/samples/client/petstore/ruby/spec/swagger_spec.rb deleted file mode 100644 index 4aedc85382c..00000000000 --- a/samples/client/petstore/ruby/spec/swagger_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -# require 'spec_helper' -require File.dirname(__FILE__) + '/spec_helper' - -describe Swagger do - - before(:each) do - configure_swagger - end - - after(:each) do - end - - context 'initialization' do - - context 'URL stuff' do - - context 'host' do - it 'removes http from host' do - Swagger.configure {|c| c.host = 'http://example.com' } - Swagger.configuration.host.should == 'example.com' - end - - it 'removes https from host' do - Swagger.configure {|c| c.host = 'https://wookiee.com' } - Swagger.configuration.host.should == 'wookiee.com' - end - - it 'removes trailing path from host' do - Swagger.configure {|c| c.host = 'hobo.com/v4' } - Swagger.configuration.host.should == 'hobo.com' - end - end - - context 'base_path' do - it "prepends a slash to base_path" do - Swagger.configure {|c| c.base_path = 'v4/dog' } - Swagger.configuration.base_path.should == '/v4/dog' - end - - it "doesn't prepend a slash if one is already there" do - Swagger.configure {|c| c.base_path = '/v4/dog' } - Swagger.configuration.base_path.should == '/v4/dog' - end - - it "ends up as a blank string if nil" do - Swagger.configure {|c| c.base_path = nil } - Swagger.configuration.base_path.should == '' - end - - end - - end - - end - -end \ No newline at end of file diff --git a/samples/client/petstore/ruby/swagger.gemspec b/samples/client/petstore/ruby/swagger.gemspec deleted file mode 100644 index 61bab334b3b..00000000000 --- a/samples/client/petstore/ruby/swagger.gemspec +++ /dev/null @@ -1,33 +0,0 @@ -# -*- encoding: utf-8 -*- -$:.push File.expand_path("../lib", __FILE__) -require "swagger/version" - -Gem::Specification.new do |s| - s.name = "swagger" - 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" - - 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 diff --git a/src/main/resources/ruby/model.mustache b/src/main/resources/ruby/model.mustache index 083570fa4b9..3ae6c419698 100644 --- a/src/main/resources/ruby/model.mustache +++ b/src/main/resources/ruby/model.mustache @@ -2,6 +2,7 @@ {{#model}} class {{classname}} + attr_accessor {{#vars}}:{{{name}}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{newline}} # :internal => :external def self.attribute_map