diff --git a/bin/ruby-petstore.json b/bin/ruby-petstore.json new file mode 100644 index 00000000000..ddb753471a1 --- /dev/null +++ b/bin/ruby-petstore.json @@ -0,0 +1,5 @@ +{ + "gemName": "petstore", + "moduleName": "Petstore", + "gemVersion": "1.0.0" +} diff --git a/bin/ruby-petstore.sh b/bin/ruby-petstore.sh index 971cc154fb9..05cf1ee995e 100755 --- a/bin/ruby-petstore.sh +++ b/bin/ruby-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/ruby -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby" java $JAVA_OPTS -jar $executable $ags diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock index 1b69e10f1fd..05a6aa23790 100644 --- a/samples/client/petstore/ruby/Gemfile.lock +++ b/samples/client/petstore/ruby/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - swagger_client (1.0.0) + petstore (1.0.0) json (~> 1.4, >= 1.4.6) typhoeus (~> 0.2, >= 0.2.1) @@ -54,7 +54,7 @@ DEPENDENCIES autotest-fsevent (~> 0.2, >= 0.2.10) autotest-growl (~> 0.2, >= 0.2.16) autotest-rails-pure (~> 4.1, >= 4.1.2) + petstore! rspec (~> 3.2, >= 3.2.0) - swagger_client! vcr (~> 2.9, >= 2.9.3) webmock (~> 1.6, >= 1.6.2) diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 06ba93a5abc..c98d79e5a89 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -5,20 +5,20 @@ You can build the generated client into a gem: ```shell -gem build swagger_client.gemspec +gem build petstore.gemspec ``` Then you can either install the gem: ```shell -gem install ./swagger_client-1.0.0.gem +gem install ./petstore-1.0.0.gem ``` or publish the gem to a gem server like [RubyGems](https://rubygems.org/). Finally add this to your Gemfile: - gem 'swagger_client', '~> 1.0.0' + gem 'petstore', '~> 1.0.0' ### Host as a git repository @@ -27,7 +27,7 @@ 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' + gem 'petstore', :git => 'https://github.com/xhh/swagger-petstore-ruby.git' ### Use without installation @@ -40,9 +40,9 @@ ruby -Ilib script.rb ## Configuration ```ruby -require 'swagger_client' +require 'petstore' -SwaggerClient::Swagger.configure do |config| +Petstore::Swagger.configure do |config| config.api_key['api_key'] = 'special-key' config.host = 'petstore.swagger.io' config.base_path = '/v2' @@ -54,6 +54,6 @@ end ## Getting Started ```ruby -pet = SwaggerClient::PetApi.get_pet_by_id(5) +pet = Petstore::PetApi.get_pet_by_id(5) puts pet.to_body ``` diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb new file mode 100644 index 00000000000..245170ede61 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -0,0 +1,25 @@ +# Swagger common files +require 'petstore/swagger' +require 'petstore/swagger/configuration' +require 'petstore/swagger/api_error' +require 'petstore/swagger/request' +require 'petstore/swagger/response' +require 'petstore/swagger/version' + +# Models +require 'petstore/models/base_object' +require 'petstore/models/user' +require 'petstore/models/category' +require 'petstore/models/pet' +require 'petstore/models/tag' +require 'petstore/models/order' + +# APIs +require 'petstore/api/user_api' +require 'petstore/api/pet_api' +require 'petstore/api/store_api' + +module Petstore + # Initialize the default configuration + Swagger.configuration ||= Swagger::Configuration.new +end diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb rename to samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 4b3e6bb6a50..096d964752d 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -1,6 +1,6 @@ require "uri" -module SwaggerClient +module Petstore class PetApi # Update an existing pet diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb rename to samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 47e81d5af1c..456b8a2eebb 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -1,6 +1,6 @@ require "uri" -module SwaggerClient +module Petstore class StoreApi # Returns pet inventories by status diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb rename to samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 7d91c0bfd3d..d5aeae31513 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -1,6 +1,6 @@ require "uri" -module SwaggerClient +module Petstore class UserApi # Create user diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb b/samples/client/petstore/ruby/lib/petstore/models/base_object.rb similarity index 96% rename from samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb rename to samples/client/petstore/ruby/lib/petstore/models/base_object.rb index b0fa43c8359..8223b2e844d 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/base_object.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # base class containing fundamental method such as to_hash, build_from_hash and more class BaseObject @@ -39,7 +39,7 @@ module SwaggerClient false end else # model - _model = SwaggerClient.const_get(type).new + _model = Petstore.const_get(type).new _model.build_from_hash(value) end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb similarity index 97% rename from samples/client/petstore/ruby/lib/swagger_client/models/category.rb rename to samples/client/petstore/ruby/lib/petstore/models/category.rb index d856563b11d..3a17b51a7ee 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # class Category < BaseObject attr_accessor :id, :name diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb similarity index 98% rename from samples/client/petstore/ruby/lib/swagger_client/models/order.rb rename to samples/client/petstore/ruby/lib/petstore/models/order.rb index 2cd1ff18f5d..bff40302650 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # class Order < BaseObject attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb similarity index 98% rename from samples/client/petstore/ruby/lib/swagger_client/models/pet.rb rename to samples/client/petstore/ruby/lib/petstore/models/pet.rb index f1f1d1434f4..5ee3d84aaf3 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # class Pet < BaseObject attr_accessor :id, :category, :name, :photo_urls, :tags, :status diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb similarity index 97% rename from samples/client/petstore/ruby/lib/swagger_client/models/tag.rb rename to samples/client/petstore/ruby/lib/petstore/models/tag.rb index 677c828aede..fcbdd68f20f 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # class Tag < BaseObject attr_accessor :id, :name diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb similarity index 98% rename from samples/client/petstore/ruby/lib/swagger_client/models/user.rb rename to samples/client/petstore/ruby/lib/petstore/models/user.rb index ed7a21e167f..f45f7e0c3cb 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore # class User < BaseObject attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger.rb b/samples/client/petstore/ruby/lib/petstore/swagger.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/swagger.rb rename to samples/client/petstore/ruby/lib/petstore/swagger.rb index bf69f05b23a..d2dcc6ab201 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore module Swagger class << self attr_accessor :logger, :last_response diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/api_error.rb b/samples/client/petstore/ruby/lib/petstore/swagger/api_error.rb similarity index 96% rename from samples/client/petstore/ruby/lib/swagger_client/swagger/api_error.rb rename to samples/client/petstore/ruby/lib/petstore/swagger/api_error.rb index 12319927ace..9eab46b6eec 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/api_error.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger/api_error.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore module Swagger class ApiError < StandardError attr_reader :code, :response_headers, :response_body diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb b/samples/client/petstore/ruby/lib/petstore/swagger/configuration.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb rename to samples/client/petstore/ruby/lib/petstore/swagger/configuration.rb index 8811c44b4df..406f729f068 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger/configuration.rb @@ -1,6 +1,6 @@ require 'logger' -module SwaggerClient +module Petstore module Swagger class Configuration attr_accessor :scheme, :host, :base_path, :user_agent, :format, :auth_token, :inject_format, :force_ending_format diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb b/samples/client/petstore/ruby/lib/petstore/swagger/request.rb similarity index 99% rename from samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb rename to samples/client/petstore/ruby/lib/petstore/swagger/request.rb index 8b0276d356a..049c6c15cb1 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger/request.rb @@ -1,7 +1,7 @@ require 'uri' require 'typhoeus' -module SwaggerClient +module Petstore module Swagger class Request attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params, :auth_names, :response diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb b/samples/client/petstore/ruby/lib/petstore/swagger/response.rb similarity index 97% rename from samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb rename to samples/client/petstore/ruby/lib/petstore/swagger/response.rb index 0df6c2e54cd..770f04f6e2c 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger/response.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore module Swagger class Response require 'json' @@ -77,7 +77,7 @@ module SwaggerClient end else # models, e.g. Pet - SwaggerClient.const_get(return_type).new.tap do |model| + Petstore.const_get(return_type).new.tap do |model| model.build_from_hash data end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb b/samples/client/petstore/ruby/lib/petstore/swagger/version.rb similarity index 70% rename from samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb rename to samples/client/petstore/ruby/lib/petstore/swagger/version.rb index c6e8d5aee53..ff3c48bb59e 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb +++ b/samples/client/petstore/ruby/lib/petstore/swagger/version.rb @@ -1,4 +1,4 @@ -module SwaggerClient +module Petstore module Swagger VERSION = "1.0.0" end diff --git a/samples/client/petstore/ruby/lib/swagger_client.rb b/samples/client/petstore/ruby/lib/swagger_client.rb deleted file mode 100644 index f91c8912d98..00000000000 --- a/samples/client/petstore/ruby/lib/swagger_client.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Swagger common files -require 'swagger_client/swagger' -require 'swagger_client/swagger/configuration' -require 'swagger_client/swagger/api_error' -require 'swagger_client/swagger/request' -require 'swagger_client/swagger/response' -require 'swagger_client/swagger/version' - -# Models -require 'swagger_client/models/base_object' -require 'swagger_client/models/user' -require 'swagger_client/models/category' -require 'swagger_client/models/pet' -require 'swagger_client/models/tag' -require 'swagger_client/models/order' - -# APIs -require 'swagger_client/api/user_api' -require 'swagger_client/api/pet_api' -require 'swagger_client/api/store_api' - -module SwaggerClient - # Initialize the default configuration - Swagger.configuration ||= Swagger::Configuration.new -end diff --git a/samples/client/petstore/ruby/swagger_client.gemspec b/samples/client/petstore/ruby/petstore.gemspec similarity index 90% rename from samples/client/petstore/ruby/swagger_client.gemspec rename to samples/client/petstore/ruby/petstore.gemspec index bc09642eaf6..40a169d1741 100644 --- a/samples/client/petstore/ruby/swagger_client.gemspec +++ b/samples/client/petstore/ruby/petstore.gemspec @@ -1,10 +1,10 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "swagger_client/swagger/version" +require "petstore/swagger/version" Gem::Specification.new do |s| - s.name = "swagger_client" - s.version = SwaggerClient::Swagger::VERSION + s.name = "petstore" + s.version = Petstore::Swagger::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Zeke Sikelianos", "Tony Tam"] s.email = ["zeke@wordnik.com", "fehguy@gmail.com"]