Add config file for bin/ruby-petstore.sh

to rename swagger_client to petstore
This commit is contained in:
xhh 2015-06-26 17:15:14 +08:00
parent 2d3d35cfd7
commit d8b0cb739f
22 changed files with 60 additions and 55 deletions

5
bin/ruby-petstore.json Normal file
View File

@ -0,0 +1,5 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"gemVersion": "1.0.0"
}

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # 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" 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 java $JAVA_OPTS -jar $executable $ags

View File

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
swagger_client (1.0.0) petstore (1.0.0)
json (~> 1.4, >= 1.4.6) json (~> 1.4, >= 1.4.6)
typhoeus (~> 0.2, >= 0.2.1) typhoeus (~> 0.2, >= 0.2.1)
@ -54,7 +54,7 @@ DEPENDENCIES
autotest-fsevent (~> 0.2, >= 0.2.10) autotest-fsevent (~> 0.2, >= 0.2.10)
autotest-growl (~> 0.2, >= 0.2.16) autotest-growl (~> 0.2, >= 0.2.16)
autotest-rails-pure (~> 4.1, >= 4.1.2) autotest-rails-pure (~> 4.1, >= 4.1.2)
petstore!
rspec (~> 3.2, >= 3.2.0) rspec (~> 3.2, >= 3.2.0)
swagger_client!
vcr (~> 2.9, >= 2.9.3) vcr (~> 2.9, >= 2.9.3)
webmock (~> 1.6, >= 1.6.2) webmock (~> 1.6, >= 1.6.2)

View File

@ -5,20 +5,20 @@
You can build the generated client into a gem: You can build the generated client into a gem:
```shell ```shell
gem build swagger_client.gemspec gem build petstore.gemspec
``` ```
Then you can either install the gem: Then you can either install the gem:
```shell ```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/). or publish the gem to a gem server like [RubyGems](https://rubygems.org/).
Finally add this to your Gemfile: Finally add this to your Gemfile:
gem 'swagger_client', '~> 1.0.0' gem 'petstore', '~> 1.0.0'
### Host as a git repository ### Host as a git repository
@ -27,7 +27,7 @@ https://github.com/xhh/swagger-petstore-ruby
Then you can reference it in Gemfile: 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 ### Use without installation
@ -40,9 +40,9 @@ ruby -Ilib script.rb
## Configuration ## Configuration
```ruby ```ruby
require 'swagger_client' require 'petstore'
SwaggerClient::Swagger.configure do |config| Petstore::Swagger.configure do |config|
config.api_key['api_key'] = 'special-key' config.api_key['api_key'] = 'special-key'
config.host = 'petstore.swagger.io' config.host = 'petstore.swagger.io'
config.base_path = '/v2' config.base_path = '/v2'
@ -54,6 +54,6 @@ end
## Getting Started ## Getting Started
```ruby ```ruby
pet = SwaggerClient::PetApi.get_pet_by_id(5) pet = Petstore::PetApi.get_pet_by_id(5)
puts pet.to_body puts pet.to_body
``` ```

View File

@ -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

View File

@ -1,6 +1,6 @@
require "uri" require "uri"
module SwaggerClient module Petstore
class PetApi class PetApi
# Update an existing pet # Update an existing pet

View File

@ -1,6 +1,6 @@
require "uri" require "uri"
module SwaggerClient module Petstore
class StoreApi class StoreApi
# Returns pet inventories by status # Returns pet inventories by status

View File

@ -1,6 +1,6 @@
require "uri" require "uri"
module SwaggerClient module Petstore
class UserApi class UserApi
# Create user # Create user

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# base class containing fundamental method such as to_hash, build_from_hash and more # base class containing fundamental method such as to_hash, build_from_hash and more
class BaseObject class BaseObject
@ -39,7 +39,7 @@ module SwaggerClient
false false
end end
else # model else # model
_model = SwaggerClient.const_get(type).new _model = Petstore.const_get(type).new
_model.build_from_hash(value) _model.build_from_hash(value)
end end
end end

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# #
class Category < BaseObject class Category < BaseObject
attr_accessor :id, :name attr_accessor :id, :name

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# #
class Order < BaseObject class Order < BaseObject
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# #
class Pet < BaseObject class Pet < BaseObject
attr_accessor :id, :category, :name, :photo_urls, :tags, :status attr_accessor :id, :category, :name, :photo_urls, :tags, :status

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# #
class Tag < BaseObject class Tag < BaseObject
attr_accessor :id, :name attr_accessor :id, :name

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
# #
class User < BaseObject class User < BaseObject
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
module Swagger module Swagger
class << self class << self
attr_accessor :logger, :last_response attr_accessor :logger, :last_response

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
module Swagger module Swagger
class ApiError < StandardError class ApiError < StandardError
attr_reader :code, :response_headers, :response_body attr_reader :code, :response_headers, :response_body

View File

@ -1,6 +1,6 @@
require 'logger' require 'logger'
module SwaggerClient module Petstore
module Swagger module Swagger
class Configuration class Configuration
attr_accessor :scheme, :host, :base_path, :user_agent, :format, :auth_token, :inject_format, :force_ending_format attr_accessor :scheme, :host, :base_path, :user_agent, :format, :auth_token, :inject_format, :force_ending_format

View File

@ -1,7 +1,7 @@
require 'uri' require 'uri'
require 'typhoeus' require 'typhoeus'
module SwaggerClient module Petstore
module Swagger module Swagger
class Request class Request
attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params, :auth_names, :response attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params, :auth_names, :response

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
module Swagger module Swagger
class Response class Response
require 'json' require 'json'
@ -77,7 +77,7 @@ module SwaggerClient
end end
else else
# models, e.g. Pet # 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 model.build_from_hash data
end end
end end

View File

@ -1,4 +1,4 @@
module SwaggerClient module Petstore
module Swagger module Swagger
VERSION = "1.0.0" VERSION = "1.0.0"
end end

View File

@ -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

View File

@ -1,10 +1,10 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__) $:.push File.expand_path("../lib", __FILE__)
require "swagger_client/swagger/version" require "petstore/swagger/version"
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "swagger_client" s.name = "petstore"
s.version = SwaggerClient::Swagger::VERSION s.version = Petstore::Swagger::VERSION
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.authors = ["Zeke Sikelianos", "Tony Tam"] s.authors = ["Zeke Sikelianos", "Tony Tam"]
s.email = ["zeke@wordnik.com", "fehguy@gmail.com"] s.email = ["zeke@wordnik.com", "fehguy@gmail.com"]