forked from loafle/openapi-generator-original
Add config file for bin/ruby-petstore.sh
to rename swagger_client to petstore
This commit is contained in:
parent
2d3d35cfd7
commit
d8b0cb739f
5
bin/ruby-petstore.json
Normal file
5
bin/ruby-petstore.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"gemName": "petstore",
|
||||
"moduleName": "Petstore",
|
||||
"gemVersion": "1.0.0"
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
```
|
||||
|
25
samples/client/petstore/ruby/lib/petstore.rb
Normal file
25
samples/client/petstore/ruby/lib/petstore.rb
Normal 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
|
@ -1,6 +1,6 @@
|
||||
require "uri"
|
||||
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
class PetApi
|
||||
|
||||
# Update an existing pet
|
@ -1,6 +1,6 @@
|
||||
require "uri"
|
||||
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
class StoreApi
|
||||
|
||||
# Returns pet inventories by status
|
@ -1,6 +1,6 @@
|
||||
require "uri"
|
||||
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
class UserApi
|
||||
|
||||
# Create user
|
@ -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
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
#
|
||||
class Category < BaseObject
|
||||
attr_accessor :id, :name
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
#
|
||||
class Order < BaseObject
|
||||
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
#
|
||||
class Pet < BaseObject
|
||||
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
#
|
||||
class Tag < BaseObject
|
||||
attr_accessor :id, :name
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
#
|
||||
class User < BaseObject
|
||||
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
module Swagger
|
||||
class << self
|
||||
attr_accessor :logger, :last_response
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
module Swagger
|
||||
class ApiError < StandardError
|
||||
attr_reader :code, :response_headers, :response_body
|
@ -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
|
@ -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
|
@ -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
|
@ -1,4 +1,4 @@
|
||||
module SwaggerClient
|
||||
module Petstore
|
||||
module Swagger
|
||||
VERSION = "1.0.0"
|
||||
end
|
@ -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
|
@ -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"]
|
Loading…
x
Reference in New Issue
Block a user