#include "SWGObject.h"
diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock
index 232facf4677..e9e03f10b77 100644
--- a/samples/client/petstore/ruby/Gemfile.lock
+++ b/samples/client/petstore/ruby/Gemfile.lock
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
- swagger-client (4.06.08)
- addressable (>= 2.2.4)
- json (>= 1.4.6)
- typhoeus (>= 0.2.1)
+ swagger_client (1.0.0)
+ addressable (~> 2.2, >= 2.2.4)
+ json (~> 1.4, >= 1.4.6)
+ typhoeus (~> 0.2, >= 0.2.1)
GEM
remote: http://rubygems.org/
@@ -51,11 +51,11 @@ PLATFORMS
ruby
DEPENDENCIES
- autotest
- autotest-fsevent
- autotest-growl
- autotest-rails-pure
- rspec (>= 2.5.0)
- swagger-client!
- vcr (>= 1.5.1)
- webmock (>= 1.6.2)
+ autotest (~> 4.4, >= 4.4.6)
+ autotest-fsevent (~> 0.2, >= 0.2.10)
+ autotest-growl (~> 0.2, >= 0.2.16)
+ autotest-rails-pure (~> 4.1, >= 4.1.2)
+ 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 29a7ce844ce..2a15c1661cc 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 swagger_client.gemspec
```
Then you can either install the gem:
```shell
-gem install ./swagger-client-4.06.08.gem
+gem install ./swagger_client-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', '~> 4.06.08'
+ gem 'swagger_client', '~> 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 'swagger_client', :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 'swagger_client'
-Swagger.configure do |config|
+SwaggerClient::Swagger.configure do |config|
config.api_key = 'special-key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
@@ -52,6 +52,6 @@ end
## Getting Started
```ruby
-pet = PetApi.getPetById(5)
+pet = SwaggerClient::PetApi.get_pet_by_id(5)
puts pet.to_body
```
diff --git a/samples/client/petstore/ruby/lib/pet_api.rb b/samples/client/petstore/ruby/lib/pet_api.rb
deleted file mode 100644
index b15198588aa..00000000000
--- a/samples/client/petstore/ruby/lib/pet_api.rb
+++ /dev/null
@@ -1,313 +0,0 @@
-require "uri"
-
-class PetApi
- basePath = "http://petstore.swagger.io/v2"
- # apiInvoker = APIInvoker
-
- # Update an existing pet
- #
- # @param [Hash] opts the optional parameters
- # @option opts [Pet] :body Pet object that needs to be added to the store
- # @return void
- def self.update_pet(opts = {})
-
-
- # resource path
- path = "/pet".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = ['application/json', 'application/xml', ]
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Add a new pet to the store
- #
- # @param [Hash] opts the optional parameters
- # @option opts [Pet] :body Pet object that needs to be added to the store
- # @return void
- def self.add_pet(opts = {})
-
-
- # resource path
- path = "/pet".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = ['application/json', 'application/xml', ]
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Finds Pets by status
- # Multiple status values can be provided with comma seperated strings
- # @param [Hash] opts the optional parameters
- # @option opts [array[string]] :status Status values that need to be considered for filter
- # @return array[Pet]
- def self.find_pets_by_status(opts = {})
-
-
- # resource path
- path = "/pet/findByStatus".sub('{format}','json')
-
- # query parameters
- query_params = {}
- query_params[:'status'] = opts[:'status'] if opts[:'status']
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
- end
-
- # Finds Pets by tags
- # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
- # @param [Hash] opts the optional parameters
- # @option opts [array[string]] :tags Tags to filter by
- # @return array[Pet]
- def self.find_pets_by_tags(opts = {})
-
-
- # resource path
- path = "/pet/findByTags".sub('{format}','json')
-
- # query parameters
- query_params = {}
- query_params[:'tags'] = opts[:'tags'] if opts[:'tags']
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
- end
-
- # Find pet by ID
- # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- # @param pet_id ID of pet that needs to be fetched
- # @param [Hash] opts the optional parameters
- # @return Pet
- def self.get_pet_by_id(pet_id, opts = {})
-
- # verify the required parameter 'pet_id' is set
- raise "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil?
-
-
- # resource path
- path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- obj = Pet.new() and obj.build_from_hash(response)
- end
-
- # Updates a pet in the store with form data
- #
- # @param pet_id ID of pet that needs to be updated
- # @param [Hash] opts the optional parameters
- # @option opts [string] :name Updated name of the pet
- # @option opts [string] :status Updated status of the pet
- # @return void
- def self.update_pet_with_form(pet_id, opts = {})
-
- # verify the required parameter 'pet_id' is set
- raise "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
-
-
- # resource path
- path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = ['application/x-www-form-urlencoded', ]
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
- form_params["name"] = opts[:'name'] if opts[:'name']
- form_params["status"] = opts[:'status'] if opts[:'status']
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Deletes a pet
- #
- # @param pet_id Pet id to delete
- # @param [Hash] opts the optional parameters
- # @option opts [string] :api_key
- # @return void
- def self.delete_pet(pet_id, opts = {})
-
- # verify the required parameter 'pet_id' is set
- raise "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
-
-
- # resource path
- path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
- header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # uploads an image
- #
- # @param pet_id ID of pet to update
- # @param [Hash] opts the optional parameters
- # @option opts [string] :additional_metadata Additional data to pass to server
- # @option opts [file] :file file to upload
- # @return void
- def self.upload_file(pet_id, opts = {})
-
- # verify the required parameter 'pet_id' is set
- raise "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
-
-
- # resource path
- path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = ['multipart/form-data', ]
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
- form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata']
- form_params["file"] = opts[:'file'] if opts[:'file']
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-end
diff --git a/samples/client/petstore/ruby/lib/store_api.rb b/samples/client/petstore/ruby/lib/store_api.rb
deleted file mode 100644
index c6d670cd8c0..00000000000
--- a/samples/client/petstore/ruby/lib/store_api.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-require "uri"
-
-class StoreApi
- basePath = "http://petstore.swagger.io/v2"
- # apiInvoker = APIInvoker
-
- # Returns pet inventories by status
- # Returns a map of status codes to quantities
- # @param [Hash] opts the optional parameters
- # @return map[string,int]
- def self.get_inventory(opts = {})
-
-
- # resource path
- path = "/store/inventory".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- response.map {|response| obj = map.new() and obj.build_from_hash(response) }
- end
-
- # Place an order for a pet
- #
- # @param [Hash] opts the optional parameters
- # @option opts [Order] :body order placed for purchasing the pet
- # @return Order
- def self.place_order(opts = {})
-
-
- # resource path
- path = "/store/order".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- obj = Order.new() and obj.build_from_hash(response)
- end
-
- # Find purchase order by ID
- # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- # @param order_id ID of pet that needs to be fetched
- # @param [Hash] opts the optional parameters
- # @return Order
- def self.get_order_by_id(order_id, opts = {})
-
- # verify the required parameter 'order_id' is set
- raise "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil?
-
-
- # resource path
- path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- obj = Order.new() and obj.build_from_hash(response)
- end
-
- # Delete purchase order by ID
- # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- # @param order_id ID of the order that needs to be deleted
- # @param [Hash] opts the optional parameters
- # @return void
- def self.delete_order(order_id, opts = {})
-
- # verify the required parameter 'order_id' is set
- raise "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
-
-
- # resource path
- path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-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 b13f83b1dbc..00000000000
--- a/samples/client/petstore/ruby/lib/swagger-client.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-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 }
diff --git a/samples/client/petstore/ruby/lib/swagger.rb b/samples/client/petstore/ruby/lib/swagger.rb
deleted file mode 100644
index f393330b148..00000000000
--- a/samples/client/petstore/ruby/lib/swagger.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'monkey'
-require 'swagger/configuration'
-require 'swagger/request'
-require 'swagger/response'
-require 'swagger/version'
-require 'logger'
-require 'json'
-
-module Swagger
-
- @configuration = Configuration.new
-
- class << self
- attr_accessor :logger
-
- # A Swagger configuration object. Must act like a hash and return sensible
- # values for all Swagger configuration options. See Swagger::Configuration.
- attr_accessor :configuration
-
- attr_accessor :resources
-
- # Call this method to modify defaults in your initializers.
- #
- # @example
- # Swagger.configure do |config|
- # config.api_key = '1234567890abcdef' # required
- # config.username = 'wordlover' # optional, but needed for user-related functions
- # config.password = 'i<3words' # optional, but needed for user-related functions
- # config.format = 'json' # optional, defaults to 'json'
- # end
- #
- def configure
- yield(configuration) if block_given?
-
- # Configure logger. Default to use Rails
- self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT))
-
- # remove :// from scheme
- configuration.scheme.sub!(/:\/\//, '')
-
- # remove http(s):// and anything after a slash
- configuration.host.sub!(/https?:\/\//, '')
- configuration.host = configuration.host.split('/').first
-
- # Add leading and trailing slashes to base_path
- configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
- configuration.base_path = "" if configuration.base_path == "/"
- end
-
- def authenticated?
- Swagger.configuration.auth_token.present?
- end
-
- def de_authenticate
- Swagger.configuration.auth_token = nil
- end
-
- def authenticate
- return if Swagger.authenticated?
-
- if Swagger.configuration.username.blank? || Swagger.configuration.password.blank?
- raise ClientError, "Username and password are required to authenticate."
- end
-
- request = Swagger::Request.new(
- :get,
- "account/authenticate/{username}",
- :params => {
- :username => Swagger.configuration.username,
- :password => Swagger.configuration.password
- }
- )
-
- response_body = request.response.body
- Swagger.configuration.auth_token = response_body['token']
- end
-
- end
-
-end
-
-class ServerError < StandardError
-end
-
-class ClientError < StandardError
-end
diff --git a/samples/client/petstore/ruby/lib/swagger/configuration.rb b/samples/client/petstore/ruby/lib/swagger/configuration.rb
deleted file mode 100644
index 2a3728483f5..00000000000
--- a/samples/client/petstore/ruby/lib/swagger/configuration.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Swagger
-
- class Configuration
- require 'swagger/version'
-
- attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent
-
- # Defaults go in here..
- def initialize
- @format = 'json'
- @scheme = 'http'
- @host = 'petstore.swagger.io'
- @base_path = '/v2'
- @user_agent = "ruby-swagger-#{Swagger::VERSION}"
- @inject_format = false
- @force_ending_format = false
- @camelize_params = true
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/lib/swagger/request.rb b/samples/client/petstore/ruby/lib/swagger/request.rb
deleted file mode 100644
index 4ec071b93d5..00000000000
--- a/samples/client/petstore/ruby/lib/swagger/request.rb
+++ /dev/null
@@ -1,263 +0,0 @@
-module Swagger
-
- class Request
- require 'uri'
- require 'addressable/uri'
- require 'typhoeus'
- require "swagger/version"
-
- attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params
-
-
- # All requests must have an HTTP method and a path
- # Optionals parameters are :params, :headers, :body, :format, :host
- #
- def initialize(http_method, path, attributes={})
- attributes[:format] ||= Swagger.configuration.format
- attributes[:params] ||= {}
-
- # Set default headers
- default_headers = {
- 'Content-Type' => "application/#{attributes[:format].downcase}",
- :api_key => Swagger.configuration.api_key,
- 'User-Agent' => Swagger.configuration.user_agent
- }
-
- # api_key from headers hash trumps the default, even if its value is blank
- if attributes[:headers].present? && attributes[:headers].has_key?(:api_key)
- default_headers.delete(:api_key)
- end
-
- # api_key from params hash trumps all others (headers and default_headers)
- if attributes[:params].present? && attributes[:params].has_key?(:api_key)
- default_headers.delete(:api_key)
- attributes[:headers].delete(:api_key) if attributes[:headers].present?
- end
-
- # Merge argument headers into defaults
- attributes[:headers] = default_headers.merge(attributes[:headers] || {})
-
- # Stick in the auth token if there is one
- if Swagger.authenticated?
- attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token})
- end
-
- self.http_method = http_method.to_sym
- self.path = path
- attributes.each do |name, value|
- send("#{name.to_s.underscore.to_sym}=", value)
- end
- end
-
- # Construct a base URL
- #
- def url(options = {})
- u = Addressable::URI.new(
- :scheme => Swagger.configuration.scheme,
- :host => Swagger.configuration.host,
- :path => self.interpreted_path,
- :query => self.query_string.sub(/\?/, '')
- ).to_s
-
- # Drop trailing question mark, if present
- u.sub! /\?$/, ''
-
- # Obfuscate API key?
- u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
-
- u
- end
-
- # Iterate over the params hash, injecting any path values into the path string
- #
- # e.g. /word.{format}/{word}/entries => /word.json/cat/entries
- def interpreted_path
- p = self.path.dup
-
- # Stick a .{format} placeholder into the path if there isn't
- # one already or an actual format like json or xml
- # e.g. /words/blah => /words.{format}/blah
- if Swagger.configuration.inject_format
- unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
- p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
- end
- end
-
- # Stick a .{format} placeholder on the end of the path if there isn't
- # one already or an actual format like json or xml
- # e.g. /words/blah => /words/blah.{format}
- if Swagger.configuration.force_ending_format
- unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
- p = "#{p}.#{format}"
- end
- end
-
- p = p.sub("{format}", self.format.to_s)
-
- URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
- end
-
- # Massage the request body into a state of readiness
- # If body is a hash, camelize all keys then convert to a json string
- #
- def body=(value)
- if value.is_a?(Hash)
- value = value.inject({}) do |memo, (k,v)|
- memo[k.to_s.camelize(:lower).to_sym] = v
- memo
- end
- end
- @body = value
- end
-
- # If body is an object, JSONify it before making the actual request.
- # For form parameters, remove empty value
- def outgoing_body
- # http form
- if @body.nil? && @form_params && !@form_params.empty?
- data = form_params.dup
- data.each do |key, value|
- data[key] = value.to_s if value && !value.is_a?(File) # remove emtpy form parameter
- end
- data
- else # http body is JSON
- @body.is_a?(String) ? @body : @body.to_json
- end
- end
-
- # Construct a query string from the query-string-type params
- def query_string
-
- # Iterate over all params,
- # .. removing the ones that are part of the path itself.
- # .. stringifying values so Addressable doesn't blow up.
- query_values = {}
- self.params.each_pair do |key, value|
- next if self.path.include? "{#{key}}" # skip path params
- next if value.blank? && value.class != FalseClass # skip empties
- if Swagger.configuration.camelize_params
- key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
- end
- query_values[key] = value.to_s
- end
-
- # We don't want to end up with '?' as our query string
- # if there aren't really any params
- return "" if query_values.blank?
-
- # Addressable requires query_values to be set after initialization..
- qs = Addressable::URI.new
- qs.query_values = query_values
- qs.to_s
- end
-
- def make
- #TODO use configuration setting to determine if debugging
- #logger = Logger.new STDOUT
- #logger.debug self.url
- response = case self.http_method.to_sym
- when :get,:GET
- Typhoeus::Request.get(
- self.url,
- :headers => self.headers.stringify_keys,
- )
-
- when :post,:POST
- Typhoeus::Request.post(
- self.url,
- :body => self.outgoing_body,
- :headers => self.headers.stringify_keys,
- )
-
- when :patch,:PATCH
- Typhoeus::Request.patch(
- self.url,
- :body => self.outgoing_body,
- :headers => self.headers.stringify_keys,
- )
-
- when :put,:PUT
- Typhoeus::Request.put(
- self.url,
- :body => self.outgoing_body,
- :headers => self.headers.stringify_keys,
- )
-
- when :delete,:DELETE
- Typhoeus::Request.delete(
- self.url,
- :body => self.outgoing_body,
- :headers => self.headers.stringify_keys,
- )
- end
- Response.new(response)
- end
-
- def response
- self.make
- end
-
- def response_code_pretty
- return unless @response.present?
- @response.code.to_s
- end
-
- def response_headers_pretty
- return unless @response.present?
- # JSON.pretty_generate(@response.headers).gsub(/\n/, ' ') # <- This was for RestClient
- @response.headers.gsub(/\n/, ' ') # <- This is for Typhoeus
- end
-
- # return 'Accept' based on an array of accept provided
- # @param [Array] header_accept_array Array fo 'Accept'
- # @return String Accept (e.g. application/json)
- def self.select_header_accept header_accept_array
- if header_accept_array.empty?
- return
- elsif header_accept_array.any?{ |s| s.casecmp('application/json')==0 }
- 'application/json' # look for json data by default
- else
- header_accept_array.join(',')
- end
- end
-
- # return the content type based on an array of content-type provided
- # @param [Array] content_type_array Array fo content-type
- # @return String Content-Type (e.g. application/json)
- def self.select_header_content_type content_type_array
- if content_type_array.empty?
- 'application/json' # use application/json by default
- elsif content_type_array.any?{ |s| s.casecmp('application/json')==0 }
- 'application/json' # use application/json if it's included
- else
- content_type_array[0]; # otherwise, use the first one
- end
- end
-
- # static method to convert object (array, hash, object, etc) to JSON string
- # @param model object to be converted into JSON string
- # @return string JSON string representation of the object
- def self.object_to_http_body model
- return if model.nil?
- _body = nil
- if model.is_a?(Array)
- _body = model.map{|m| object_to_hash(m) }
- else
- _body = object_to_hash(model)
- end
- _body.to_json
- end
-
- # static method to convert object(non-array) to hash
- # @param obj object to be converted into JSON string
- # @return string JSON string representation of the object
- def self.object_to_hash obj
- if obj.respond_to?(:to_hash)
- obj.to_hash
- else
- obj
- end
- end
-
- end
-end
diff --git a/samples/client/petstore/ruby/lib/swagger/response.rb b/samples/client/petstore/ruby/lib/swagger/response.rb
deleted file mode 100644
index 641b7ccc756..00000000000
--- a/samples/client/petstore/ruby/lib/swagger/response.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-module Swagger
-
- class Response
- require 'json'
-
- attr_accessor :raw
-
- def initialize(raw)
- self.raw = raw
-
- case self.code
- when 500..510 then raise(ServerError, self.error_message)
- when 299..426 then raise(ClientError, self.error_message)
- end
- end
-
- def code
- raw.code
- end
-
- # Account for error messages that take different forms...
- def error_message
- body['message']
- rescue
- body
- end
-
- # If body is JSON, parse it
- # Otherwise return raw string
- def body
- JSON.parse(raw.body, :symbolize_names => true)
- rescue
- raw.body
- end
-
- # `headers_hash` is a Typhoeus-specific extension of Hash,
- # so simplify it back into a regular old Hash.
- def headers
- h = {}
- raw.headers_hash.each {|k,v| h[k] = v }
- h
- end
-
- # Extract the response format from the header hash
- # e.g. {'Content-Type' => 'application/json'}
- def format
- headers['Content-Type'].split("/").last.downcase
- end
-
- def json?
- format == 'json'
- end
-
- def xml?
- format == 'xml'
- end
-
- def pretty_body
- return unless body.present?
- case format
- when 'json' then JSON.pretty_generate(body).gsub(/\n/, ' ')
- end
- end
-
- def pretty_headers
- JSON.pretty_generate(headers).gsub(/\n/, ' ')
- end
-
- end
-end
diff --git a/samples/client/petstore/ruby/lib/swagger/version.rb b/samples/client/petstore/ruby/lib/swagger/version.rb
deleted file mode 100644
index 39357c0ed6d..00000000000
--- a/samples/client/petstore/ruby/lib/swagger/version.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module Swagger
- VERSION = "4.06.08"
-end
-
diff --git a/samples/client/petstore/ruby/lib/swagger_client.rb b/samples/client/petstore/ruby/lib/swagger_client.rb
new file mode 100644
index 00000000000..6d239185005
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client.rb
@@ -0,0 +1,25 @@
+# Swagger common files
+require 'swagger_client/monkey'
+require 'swagger_client/swagger'
+require 'swagger_client/swagger/configuration'
+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/lib/swagger_client/api/pet_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb
new file mode 100644
index 00000000000..d89cb6ae566
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb
@@ -0,0 +1,315 @@
+require "uri"
+
+module SwaggerClient
+ class PetApi
+ basePath = "http://petstore.swagger.io/v2"
+ # apiInvoker = APIInvoker
+
+ # Update an existing pet
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [Pet] :body Pet object that needs to be added to the store
+ # @return void
+ def self.update_pet(opts = {})
+
+
+ # resource path
+ path = "/pet".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = ['application/json', 'application/xml']
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Add a new pet to the store
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [Pet] :body Pet object that needs to be added to the store
+ # @return void
+ def self.add_pet(opts = {})
+
+
+ # resource path
+ path = "/pet".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = ['application/json', 'application/xml']
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Finds Pets by status
+ # Multiple status values can be provided with comma seperated strings
+ # @param [Hash] opts the optional parameters
+ # @option opts [array[string]] :status Status values that need to be considered for filter
+ # @return array[Pet]
+ def self.find_pets_by_status(opts = {})
+
+
+ # resource path
+ path = "/pet/findByStatus".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+ query_params[:'status'] = opts[:'status'] if opts[:'status']
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
+ end
+
+ # Finds Pets by tags
+ # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
+ # @param [Hash] opts the optional parameters
+ # @option opts [array[string]] :tags Tags to filter by
+ # @return array[Pet]
+ def self.find_pets_by_tags(opts = {})
+
+
+ # resource path
+ path = "/pet/findByTags".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+ query_params[:'tags'] = opts[:'tags'] if opts[:'tags']
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
+ end
+
+ # Find pet by ID
+ # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ # @param pet_id ID of pet that needs to be fetched
+ # @param [Hash] opts the optional parameters
+ # @return Pet
+ def self.get_pet_by_id(pet_id, opts = {})
+
+ # verify the required parameter 'pet_id' is set
+ raise "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil?
+
+
+ # resource path
+ path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ obj = Pet.new() and obj.build_from_hash(response)
+ end
+
+ # Updates a pet in the store with form data
+ #
+ # @param pet_id ID of pet that needs to be updated
+ # @param [Hash] opts the optional parameters
+ # @option opts [string] :name Updated name of the pet
+ # @option opts [string] :status Updated status of the pet
+ # @return void
+ def self.update_pet_with_form(pet_id, opts = {})
+
+ # verify the required parameter 'pet_id' is set
+ raise "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
+
+
+ # resource path
+ path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = ['application/x-www-form-urlencoded']
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+ form_params["name"] = opts[:'name'] if opts[:'name']
+ form_params["status"] = opts[:'status'] if opts[:'status']
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Deletes a pet
+ #
+ # @param pet_id Pet id to delete
+ # @param [Hash] opts the optional parameters
+ # @option opts [string] :api_key
+ # @return void
+ def self.delete_pet(pet_id, opts = {})
+
+ # verify the required parameter 'pet_id' is set
+ raise "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
+
+
+ # resource path
+ path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+ header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # uploads an image
+ #
+ # @param pet_id ID of pet to update
+ # @param [Hash] opts the optional parameters
+ # @option opts [string] :additional_metadata Additional data to pass to server
+ # @option opts [file] :file file to upload
+ # @return void
+ def self.upload_file(pet_id, opts = {})
+
+ # verify the required parameter 'pet_id' is set
+ raise "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
+
+
+ # resource path
+ path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = ['multipart/form-data']
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+ form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata']
+ form_params["file"] = opts[:'file'] if opts[:'file']
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb
new file mode 100644
index 00000000000..37595c2147e
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb
@@ -0,0 +1,156 @@
+require "uri"
+
+module SwaggerClient
+ class StoreApi
+ basePath = "http://petstore.swagger.io/v2"
+ # apiInvoker = APIInvoker
+
+ # Returns pet inventories by status
+ # Returns a map of status codes to quantities
+ # @param [Hash] opts the optional parameters
+ # @return map[string,int]
+ def self.get_inventory(opts = {})
+
+
+ # resource path
+ path = "/store/inventory".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ response.map {|response| obj = map.new() and obj.build_from_hash(response) }
+ end
+
+ # Place an order for a pet
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [Order] :body order placed for purchasing the pet
+ # @return Order
+ def self.place_order(opts = {})
+
+
+ # resource path
+ path = "/store/order".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ obj = Order.new() and obj.build_from_hash(response)
+ end
+
+ # Find purchase order by ID
+ # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ # @param order_id ID of pet that needs to be fetched
+ # @param [Hash] opts the optional parameters
+ # @return Order
+ def self.get_order_by_id(order_id, opts = {})
+
+ # verify the required parameter 'order_id' is set
+ raise "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil?
+
+
+ # resource path
+ path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ obj = Order.new() and obj.build_from_hash(response)
+ end
+
+ # Delete purchase order by ID
+ # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ # @param order_id ID of the order that needs to be deleted
+ # @param [Hash] opts the optional parameters
+ # @return void
+ def self.delete_order(order_id, opts = {})
+
+ # verify the required parameter 'order_id' is set
+ raise "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
+
+
+ # resource path
+ path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb
new file mode 100644
index 00000000000..12a45561e3f
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb
@@ -0,0 +1,302 @@
+require "uri"
+
+module SwaggerClient
+ class UserApi
+ basePath = "http://petstore.swagger.io/v2"
+ # apiInvoker = APIInvoker
+
+ # Create user
+ # This can only be done by the logged in user.
+ # @param [Hash] opts the optional parameters
+ # @option opts [User] :body Created user object
+ # @return void
+ def self.create_user(opts = {})
+
+
+ # resource path
+ path = "/user".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Creates list of users with given input array
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [array[User]] :body List of user object
+ # @return void
+ def self.create_users_with_array_input(opts = {})
+
+
+ # resource path
+ path = "/user/createWithArray".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Creates list of users with given input array
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [array[User]] :body List of user object
+ # @return void
+ def self.create_users_with_list_input(opts = {})
+
+
+ # resource path
+ path = "/user/createWithList".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Logs user into the system
+ #
+ # @param [Hash] opts the optional parameters
+ # @option opts [string] :username The user name for login
+ # @option opts [string] :password The password for login in clear text
+ # @return string
+ def self.login_user(opts = {})
+
+
+ # resource path
+ path = "/user/login".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+ query_params[:'username'] = opts[:'username'] if opts[:'username']
+ query_params[:'password'] = opts[:'password'] if opts[:'password']
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ obj = string.new() and obj.build_from_hash(response)
+ end
+
+ # Logs out current logged in user session
+ #
+ # @param [Hash] opts the optional parameters
+ # @return void
+ def self.logout_user(opts = {})
+
+
+ # resource path
+ path = "/user/logout".sub('{format}','json')
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Get user by user name
+ #
+ # @param username The name that needs to be fetched. Use user1 for testing.
+ # @param [Hash] opts the optional parameters
+ # @return User
+ def self.get_user_by_name(username, opts = {})
+
+ # verify the required parameter 'username' is set
+ raise "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
+
+
+ # resource path
+ path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
+ obj = User.new() and obj.build_from_hash(response)
+ end
+
+ # Updated user
+ # This can only be done by the logged in user.
+ # @param username name that need to be deleted
+ # @param [Hash] opts the optional parameters
+ # @option opts [User] :body Updated user object
+ # @return void
+ def self.update_user(username, opts = {})
+
+ # verify the required parameter 'username' is set
+ raise "Missing the required parameter 'username' when calling update_user" if username.nil?
+
+
+ # resource path
+ path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = Swagger::Request.object_to_http_body(opts[:'body'])
+
+
+ Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+
+ # Delete user
+ # This can only be done by the logged in user.
+ # @param username The name that needs to be deleted
+ # @param [Hash] opts the optional parameters
+ # @return void
+ def self.delete_user(username, opts = {})
+
+ # verify the required parameter 'username' is set
+ raise "Missing the required parameter 'username' when calling delete_user" if username.nil?
+
+
+ # resource path
+ path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
+
+ # query parameters
+ query_params = {}
+
+ # header parameters
+ header_params = {}
+
+ # HTTP header 'Accept' (if needed)
+ _header_accept = ['application/json', 'application/xml']
+ _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+
+ # HTTP header 'Content-Type'
+ _header_content_type = []
+ header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
+
+ # form parameters
+ form_params = {}
+
+ # http body (model)
+ post_body = nil
+
+
+ Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb b/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb
new file mode 100644
index 00000000000..642e4769e55
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb
@@ -0,0 +1,83 @@
+module SwaggerClient
+ # base class containing fundamental method such as to_hash, build_from_hash and more
+ class BaseObject
+
+ # return the object in the form of hash
+ def to_body
+ body = {}
+ self.class.attribute_map.each_pair do |key, value|
+ body[value] = self.send(key) unless self.send(key).nil?
+ end
+ body
+ end
+
+ # build the object from hash
+ def build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ self.class.swagger_types.each_pair do |key, type|
+ if type =~ /^array\[(.*)\]/i
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
+ else
+ #TODO show warning in debug mode
+ end
+ elsif !attributes[self.class.attribute_map[key]].nil?
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
+ else
+ # data not found in attributes(hash), not an issue as the data can be optional
+ end
+ end
+
+ self
+ end
+
+ def _deserialize(type, value)
+ case type.to_sym
+ when :DateTime
+ DateTime.parse(value)
+ when :string
+ value.to_s
+ when :int
+ value.to_i
+ when :double
+ value.to_f
+ when :boolean
+ if value =~ /^(true|t|yes|y|1)$/i
+ true
+ else
+ false
+ end
+ else # model
+ _model = SwaggerClient.const_get(type).new
+ _model.build_from_hash(value)
+ end
+ end
+
+ # to_body is an alias to to_body (backward compatibility)
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |key, value|
+ if self.send(key).is_a?(Array)
+ next if self.send(key).empty?
+ hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
+ else
+ unless (_tmp_value = _to_hash self.send(key)).nil?
+ hash[value] = _tmp_value
+ end
+ end
+ end
+ hash
+ end
+
+ # Method to output non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ def _to_hash(value)
+ if value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb b/samples/client/petstore/ruby/lib/swagger_client/models/category.rb
new file mode 100644
index 00000000000..fe195c7ac87
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/category.rb
@@ -0,0 +1,44 @@
+module SwaggerClient
+ #
+ class Category < BaseObject
+ attr_accessor :id, :name
+ # attribute mapping from ruby-style variable name to JSON key
+ def self.attribute_map
+ {
+
+ #
+ :'id' => :'id',
+
+ #
+ :'name' => :'name'
+
+ }
+ end
+
+ # attribute type
+ def self.swagger_types
+ {
+ :'id' => :'int',
+ :'name' => :'string'
+
+ }
+ end
+
+ def initialize(attributes = {})
+ return if !attributes.is_a?(Hash) || attributes.empty?
+
+ # convert string to symbol for hash key
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
+
+ if attributes[:'id']
+ @id = attributes[:'id']
+ end
+
+ if attributes[:'name']
+ @name = attributes[:'name']
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb b/samples/client/petstore/ruby/lib/swagger_client/models/order.rb
new file mode 100644
index 00000000000..3fe0282ed9b
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/order.rb
@@ -0,0 +1,76 @@
+module SwaggerClient
+ #
+ class Order < BaseObject
+ attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
+ # attribute mapping from ruby-style variable name to JSON key
+ def self.attribute_map
+ {
+
+ #
+ :'id' => :'id',
+
+ #
+ :'pet_id' => :'petId',
+
+ #
+ :'quantity' => :'quantity',
+
+ #
+ :'ship_date' => :'shipDate',
+
+ # Order Status
+ :'status' => :'status',
+
+ #
+ :'complete' => :'complete'
+
+ }
+ end
+
+ # attribute type
+ def self.swagger_types
+ {
+ :'id' => :'int',
+ :'pet_id' => :'int',
+ :'quantity' => :'int',
+ :'ship_date' => :'DateTime',
+ :'status' => :'string',
+ :'complete' => :'boolean'
+
+ }
+ end
+
+ def initialize(attributes = {})
+ return if !attributes.is_a?(Hash) || attributes.empty?
+
+ # convert string to symbol for hash key
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
+
+ if attributes[:'id']
+ @id = attributes[:'id']
+ end
+
+ if attributes[:'petId']
+ @pet_id = attributes[:'petId']
+ end
+
+ if attributes[:'quantity']
+ @quantity = attributes[:'quantity']
+ end
+
+ if attributes[:'shipDate']
+ @ship_date = attributes[:'shipDate']
+ end
+
+ if attributes[:'status']
+ @status = attributes[:'status']
+ end
+
+ if attributes[:'complete']
+ @complete = attributes[:'complete']
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb b/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb
new file mode 100644
index 00000000000..32f95646c72
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb
@@ -0,0 +1,80 @@
+module SwaggerClient
+ #
+ class Pet < BaseObject
+ attr_accessor :id, :category, :name, :photo_urls, :tags, :status
+ # attribute mapping from ruby-style variable name to JSON key
+ def self.attribute_map
+ {
+
+ #
+ :'id' => :'id',
+
+ #
+ :'category' => :'category',
+
+ #
+ :'name' => :'name',
+
+ #
+ :'photo_urls' => :'photoUrls',
+
+ #
+ :'tags' => :'tags',
+
+ # pet status in the store
+ :'status' => :'status'
+
+ }
+ end
+
+ # attribute type
+ def self.swagger_types
+ {
+ :'id' => :'int',
+ :'category' => :'Category',
+ :'name' => :'string',
+ :'photo_urls' => :'array[string]',
+ :'tags' => :'array[Tag]',
+ :'status' => :'string'
+
+ }
+ end
+
+ def initialize(attributes = {})
+ return if !attributes.is_a?(Hash) || attributes.empty?
+
+ # convert string to symbol for hash key
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
+
+ if attributes[:'id']
+ @id = attributes[:'id']
+ end
+
+ if attributes[:'category']
+ @category = attributes[:'category']
+ end
+
+ if attributes[:'name']
+ @name = attributes[:'name']
+ end
+
+ if attributes[:'photoUrls']
+ if (value = attributes[:'photoUrls']).is_a?(Array)
+ @photo_urls = value
+ end
+ end
+
+ if attributes[:'tags']
+ if (value = attributes[:'tags']).is_a?(Array)
+ @tags = value
+ end
+ end
+
+ if attributes[:'status']
+ @status = attributes[:'status']
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb b/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb
new file mode 100644
index 00000000000..9c5cdde1af6
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb
@@ -0,0 +1,44 @@
+module SwaggerClient
+ #
+ class Tag < BaseObject
+ attr_accessor :id, :name
+ # attribute mapping from ruby-style variable name to JSON key
+ def self.attribute_map
+ {
+
+ #
+ :'id' => :'id',
+
+ #
+ :'name' => :'name'
+
+ }
+ end
+
+ # attribute type
+ def self.swagger_types
+ {
+ :'id' => :'int',
+ :'name' => :'string'
+
+ }
+ end
+
+ def initialize(attributes = {})
+ return if !attributes.is_a?(Hash) || attributes.empty?
+
+ # convert string to symbol for hash key
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
+
+ if attributes[:'id']
+ @id = attributes[:'id']
+ end
+
+ if attributes[:'name']
+ @name = attributes[:'name']
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb b/samples/client/petstore/ruby/lib/swagger_client/models/user.rb
new file mode 100644
index 00000000000..2d723da54c4
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/models/user.rb
@@ -0,0 +1,92 @@
+module SwaggerClient
+ #
+ class User < BaseObject
+ attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
+ # attribute mapping from ruby-style variable name to JSON key
+ def self.attribute_map
+ {
+
+ #
+ :'id' => :'id',
+
+ #
+ :'username' => :'username',
+
+ #
+ :'first_name' => :'firstName',
+
+ #
+ :'last_name' => :'lastName',
+
+ #
+ :'email' => :'email',
+
+ #
+ :'password' => :'password',
+
+ #
+ :'phone' => :'phone',
+
+ # User Status
+ :'user_status' => :'userStatus'
+
+ }
+ end
+
+ # attribute type
+ def self.swagger_types
+ {
+ :'id' => :'int',
+ :'username' => :'string',
+ :'first_name' => :'string',
+ :'last_name' => :'string',
+ :'email' => :'string',
+ :'password' => :'string',
+ :'phone' => :'string',
+ :'user_status' => :'int'
+
+ }
+ end
+
+ def initialize(attributes = {})
+ return if !attributes.is_a?(Hash) || attributes.empty?
+
+ # convert string to symbol for hash key
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
+
+ if attributes[:'id']
+ @id = attributes[:'id']
+ end
+
+ if attributes[:'username']
+ @username = attributes[:'username']
+ end
+
+ if attributes[:'firstName']
+ @first_name = attributes[:'firstName']
+ end
+
+ if attributes[:'lastName']
+ @last_name = attributes[:'lastName']
+ end
+
+ if attributes[:'email']
+ @email = attributes[:'email']
+ end
+
+ if attributes[:'password']
+ @password = attributes[:'password']
+ end
+
+ if attributes[:'phone']
+ @phone = attributes[:'phone']
+ end
+
+ if attributes[:'userStatus']
+ @user_status = attributes[:'userStatus']
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/monkey.rb b/samples/client/petstore/ruby/lib/swagger_client/monkey.rb
similarity index 100%
rename from samples/client/petstore/ruby/lib/monkey.rb
rename to samples/client/petstore/ruby/lib/swagger_client/monkey.rb
diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger.rb
new file mode 100644
index 00000000000..278db36e4ca
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/swagger.rb
@@ -0,0 +1,78 @@
+require 'logger'
+require 'json'
+
+module SwaggerClient
+ module Swagger
+ class << self
+ attr_accessor :logger
+
+ # A Swagger configuration object. Must act like a hash and return sensible
+ # values for all Swagger configuration options. See Swagger::Configuration.
+ attr_accessor :configuration
+
+ attr_accessor :resources
+
+ # Call this method to modify defaults in your initializers.
+ #
+ # @example
+ # Swagger.configure do |config|
+ # config.api_key = '1234567890abcdef' # required
+ # config.username = 'wordlover' # optional, but needed for user-related functions
+ # config.password = 'i<3words' # optional, but needed for user-related functions
+ # config.format = 'json' # optional, defaults to 'json'
+ # end
+ #
+ def configure
+ yield(configuration) if block_given?
+
+ # Configure logger. Default to use Rails
+ self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT))
+
+ # remove :// from scheme
+ configuration.scheme.sub!(/:\/\//, '')
+
+ # remove http(s):// and anything after a slash
+ configuration.host.sub!(/https?:\/\//, '')
+ configuration.host = configuration.host.split('/').first
+
+ # Add leading and trailing slashes to base_path
+ configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
+ configuration.base_path = "" if configuration.base_path == "/"
+ end
+
+ def authenticated?
+ Swagger.configuration.auth_token.present?
+ end
+
+ def de_authenticate
+ Swagger.configuration.auth_token = nil
+ end
+
+ def authenticate
+ return if Swagger.authenticated?
+
+ if Swagger.configuration.username.blank? || Swagger.configuration.password.blank?
+ raise ClientError, "Username and password are required to authenticate."
+ end
+
+ request = Swagger::Request.new(
+ :get,
+ "account/authenticate/{username}",
+ :params => {
+ :username => Swagger.configuration.username,
+ :password => Swagger.configuration.password
+ }
+ )
+
+ response_body = request.response.body
+ Swagger.configuration.auth_token = response_body['token']
+ end
+ end
+ end
+
+ class ServerError < StandardError
+ end
+
+ class ClientError < StandardError
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb
new file mode 100644
index 00000000000..51f9539a9ab
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb
@@ -0,0 +1,19 @@
+module SwaggerClient
+ module Swagger
+ class Configuration
+ attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent
+
+ # Defaults go in here..
+ def initialize
+ @format = 'json'
+ @scheme = 'http'
+ @host = 'petstore.swagger.io'
+ @base_path = '/v2'
+ @user_agent = "ruby-swagger-#{Swagger::VERSION}"
+ @inject_format = false
+ @force_ending_format = false
+ @camelize_params = true
+ end
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb
new file mode 100644
index 00000000000..d5f266267da
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb
@@ -0,0 +1,257 @@
+module SwaggerClient
+ module Swagger
+ class Request
+ require 'uri'
+ require 'addressable/uri'
+ require 'typhoeus'
+
+ attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params
+
+ # All requests must have an HTTP method and a path
+ # Optionals parameters are :params, :headers, :body, :format, :host
+ def initialize(http_method, path, attributes={})
+ attributes[:format] ||= Swagger.configuration.format
+ attributes[:params] ||= {}
+
+ # Set default headers
+ default_headers = {
+ 'Content-Type' => "application/#{attributes[:format].downcase}",
+ :api_key => Swagger.configuration.api_key,
+ 'User-Agent' => Swagger.configuration.user_agent
+ }
+
+ # api_key from headers hash trumps the default, even if its value is blank
+ if attributes[:headers].present? && attributes[:headers].has_key?(:api_key)
+ default_headers.delete(:api_key)
+ end
+
+ # api_key from params hash trumps all others (headers and default_headers)
+ if attributes[:params].present? && attributes[:params].has_key?(:api_key)
+ default_headers.delete(:api_key)
+ attributes[:headers].delete(:api_key) if attributes[:headers].present?
+ end
+
+ # Merge argument headers into defaults
+ attributes[:headers] = default_headers.merge(attributes[:headers] || {})
+
+ # Stick in the auth token if there is one
+ if Swagger.authenticated?
+ attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token})
+ end
+
+ self.http_method = http_method.to_sym
+ self.path = path
+ attributes.each do |name, value|
+ send("#{name.to_s.underscore.to_sym}=", value)
+ end
+ end
+
+ # Construct a base URL
+ def url(options = {})
+ u = Addressable::URI.new(
+ :scheme => Swagger.configuration.scheme,
+ :host => Swagger.configuration.host,
+ :path => self.interpreted_path,
+ :query => self.query_string.sub(/\?/, '')
+ ).to_s
+
+ # Drop trailing question mark, if present
+ u.sub! /\?$/, ''
+
+ # Obfuscate API key?
+ u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
+
+ u
+ end
+
+ # Iterate over the params hash, injecting any path values into the path string
+ # e.g. /word.{format}/{word}/entries => /word.json/cat/entries
+ def interpreted_path
+ p = self.path.dup
+
+ # Stick a .{format} placeholder into the path if there isn't
+ # one already or an actual format like json or xml
+ # e.g. /words/blah => /words.{format}/blah
+ if Swagger.configuration.inject_format
+ unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
+ p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
+ end
+ end
+
+ # Stick a .{format} placeholder on the end of the path if there isn't
+ # one already or an actual format like json or xml
+ # e.g. /words/blah => /words/blah.{format}
+ if Swagger.configuration.force_ending_format
+ unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
+ p = "#{p}.#{format}"
+ end
+ end
+
+ p = p.sub("{format}", self.format.to_s)
+
+ URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
+ end
+
+ # Massage the request body into a state of readiness
+ # If body is a hash, camelize all keys then convert to a json string
+ def body=(value)
+ if value.is_a?(Hash)
+ value = value.inject({}) do |memo, (k,v)|
+ memo[k.to_s.camelize(:lower).to_sym] = v
+ memo
+ end
+ end
+ @body = value
+ end
+
+ # If body is an object, JSONify it before making the actual request.
+ # For form parameters, remove empty value
+ def outgoing_body
+ # http form
+ if @body.nil? && @form_params && !@form_params.empty?
+ data = form_params.dup
+ data.each do |key, value|
+ data[key] = value.to_s if value && !value.is_a?(File) # remove emtpy form parameter
+ end
+ data
+ else # http body is JSON
+ @body.is_a?(String) ? @body : @body.to_json
+ end
+ end
+
+ # Construct a query string from the query-string-type params
+ def query_string
+ # Iterate over all params,
+ # .. removing the ones that are part of the path itself.
+ # .. stringifying values so Addressable doesn't blow up.
+ query_values = {}
+ self.params.each_pair do |key, value|
+ next if self.path.include? "{#{key}}" # skip path params
+ next if value.blank? && value.class != FalseClass # skip empties
+ if Swagger.configuration.camelize_params
+ key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
+ end
+ query_values[key] = value.to_s
+ end
+
+ # We don't want to end up with '?' as our query string
+ # if there aren't really any params
+ return "" if query_values.blank?
+
+ # Addressable requires query_values to be set after initialization..
+ qs = Addressable::URI.new
+ qs.query_values = query_values
+ qs.to_s
+ end
+
+ def make
+ #TODO use configuration setting to determine if debugging
+ #logger = Logger.new STDOUT
+ #logger.debug self.url
+ response = case self.http_method.to_sym
+ when :get,:GET
+ Typhoeus::Request.get(
+ self.url,
+ :headers => self.headers.stringify_keys,
+ )
+
+ when :post,:POST
+ Typhoeus::Request.post(
+ self.url,
+ :body => self.outgoing_body,
+ :headers => self.headers.stringify_keys,
+ )
+
+ when :patch,:PATCH
+ Typhoeus::Request.patch(
+ self.url,
+ :body => self.outgoing_body,
+ :headers => self.headers.stringify_keys,
+ )
+
+ when :put,:PUT
+ Typhoeus::Request.put(
+ self.url,
+ :body => self.outgoing_body,
+ :headers => self.headers.stringify_keys,
+ )
+
+ when :delete,:DELETE
+ Typhoeus::Request.delete(
+ self.url,
+ :body => self.outgoing_body,
+ :headers => self.headers.stringify_keys,
+ )
+ end
+ Response.new(response)
+ end
+
+ def response
+ self.make
+ end
+
+ def response_code_pretty
+ return unless @response.present?
+ @response.code.to_s
+ end
+
+ def response_headers_pretty
+ return unless @response.present?
+ # JSON.pretty_generate(@response.headers).gsub(/\n/, ' ') # <- This was for RestClient
+ @response.headers.gsub(/\n/, ' ') # <- This is for Typhoeus
+ end
+
+ # return 'Accept' based on an array of accept provided
+ # @param [Array] header_accept_array Array fo 'Accept'
+ # @return String Accept (e.g. application/json)
+ def self.select_header_accept header_accept_array
+ if header_accept_array.empty?
+ return
+ elsif header_accept_array.any?{ |s| s.casecmp('application/json')==0 }
+ 'application/json' # look for json data by default
+ else
+ header_accept_array.join(',')
+ end
+ end
+
+ # return the content type based on an array of content-type provided
+ # @param [Array] content_type_array Array fo content-type
+ # @return String Content-Type (e.g. application/json)
+ def self.select_header_content_type content_type_array
+ if content_type_array.empty?
+ 'application/json' # use application/json by default
+ elsif content_type_array.any?{ |s| s.casecmp('application/json')==0 }
+ 'application/json' # use application/json if it's included
+ else
+ content_type_array[0]; # otherwise, use the first one
+ end
+ end
+
+ # static method to convert object (array, hash, object, etc) to JSON string
+ # @param model object to be converted into JSON string
+ # @return string JSON string representation of the object
+ def self.object_to_http_body model
+ return if model.nil?
+ _body = nil
+ if model.is_a?(Array)
+ _body = model.map{|m| object_to_hash(m) }
+ else
+ _body = object_to_hash(model)
+ end
+ _body.to_json
+ end
+
+ # static method to convert object(non-array) to hash
+ # @param obj object to be converted into JSON string
+ # @return string JSON string representation of the object
+ def self.object_to_hash obj
+ if obj.respond_to?(:to_hash)
+ obj.to_hash
+ else
+ obj
+ end
+ end
+
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb
new file mode 100644
index 00000000000..538821bea69
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb
@@ -0,0 +1,70 @@
+module SwaggerClient
+ module Swagger
+ class Response
+ require 'json'
+
+ attr_accessor :raw
+
+ def initialize(raw)
+ self.raw = raw
+
+ case self.code
+ when 500..510 then raise(ServerError, self.error_message)
+ when 299..426 then raise(ClientError, self.error_message)
+ end
+ end
+
+ def code
+ raw.code
+ end
+
+ # Account for error messages that take different forms...
+ def error_message
+ body['message']
+ rescue
+ body
+ end
+
+ # If body is JSON, parse it
+ # Otherwise return raw string
+ def body
+ JSON.parse(raw.body, :symbolize_names => true)
+ rescue
+ raw.body
+ end
+
+ # `headers_hash` is a Typhoeus-specific extension of Hash,
+ # so simplify it back into a regular old Hash.
+ def headers
+ h = {}
+ raw.headers_hash.each {|k,v| h[k] = v }
+ h
+ end
+
+ # Extract the response format from the header hash
+ # e.g. {'Content-Type' => 'application/json'}
+ def format
+ headers['Content-Type'].split("/").last.downcase
+ end
+
+ def json?
+ format == 'json'
+ end
+
+ def xml?
+ format == 'xml'
+ end
+
+ def pretty_body
+ return unless body.present?
+ case format
+ when 'json' then JSON.pretty_generate(body).gsub(/\n/, ' ')
+ end
+ end
+
+ def pretty_headers
+ JSON.pretty_generate(headers).gsub(/\n/, ' ')
+ end
+ end
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb
new file mode 100644
index 00000000000..c6e8d5aee53
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb
@@ -0,0 +1,5 @@
+module SwaggerClient
+ module Swagger
+ VERSION = "1.0.0"
+ end
+end
diff --git a/samples/client/petstore/ruby/lib/user_api.rb b/samples/client/petstore/ruby/lib/user_api.rb
deleted file mode 100644
index e7d0644d320..00000000000
--- a/samples/client/petstore/ruby/lib/user_api.rb
+++ /dev/null
@@ -1,300 +0,0 @@
-require "uri"
-
-class UserApi
- basePath = "http://petstore.swagger.io/v2"
- # apiInvoker = APIInvoker
-
- # Create user
- # This can only be done by the logged in user.
- # @param [Hash] opts the optional parameters
- # @option opts [User] :body Created user object
- # @return void
- def self.create_user(opts = {})
-
-
- # resource path
- path = "/user".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Creates list of users with given input array
- #
- # @param [Hash] opts the optional parameters
- # @option opts [array[User]] :body List of user object
- # @return void
- def self.create_users_with_array_input(opts = {})
-
-
- # resource path
- path = "/user/createWithArray".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Creates list of users with given input array
- #
- # @param [Hash] opts the optional parameters
- # @option opts [array[User]] :body List of user object
- # @return void
- def self.create_users_with_list_input(opts = {})
-
-
- # resource path
- path = "/user/createWithList".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Logs user into the system
- #
- # @param [Hash] opts the optional parameters
- # @option opts [string] :username The user name for login
- # @option opts [string] :password The password for login in clear text
- # @return string
- def self.login_user(opts = {})
-
-
- # resource path
- path = "/user/login".sub('{format}','json')
-
- # query parameters
- query_params = {}
- query_params[:'username'] = opts[:'username'] if opts[:'username']
- query_params[:'password'] = opts[:'password'] if opts[:'password']
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- obj = string.new() and obj.build_from_hash(response)
- end
-
- # Logs out current logged in user session
- #
- # @param [Hash] opts the optional parameters
- # @return void
- def self.logout_user(opts = {})
-
-
- # resource path
- path = "/user/logout".sub('{format}','json')
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Get user by user name
- #
- # @param username The name that needs to be fetched. Use user1 for testing.
- # @param [Hash] opts the optional parameters
- # @return User
- def self.get_user_by_name(username, opts = {})
-
- # verify the required parameter 'username' is set
- raise "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
-
-
- # resource path
- path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
- obj = User.new() and obj.build_from_hash(response)
- end
-
- # Updated user
- # This can only be done by the logged in user.
- # @param username name that need to be deleted
- # @param [Hash] opts the optional parameters
- # @option opts [User] :body Updated user object
- # @return void
- def self.update_user(username, opts = {})
-
- # verify the required parameter 'username' is set
- raise "Missing the required parameter 'username' when calling update_user" if username.nil?
-
-
- # resource path
- path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = Swagger::Request.object_to_http_body(opts[:'body'])
-
-
- Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-
- # Delete user
- # This can only be done by the logged in user.
- # @param username The name that needs to be deleted
- # @param [Hash] opts the optional parameters
- # @return void
- def self.delete_user(username, opts = {})
-
- # verify the required parameter 'username' is set
- raise "Missing the required parameter 'username' when calling delete_user" if username.nil?
-
-
- # resource path
- path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
-
- # query parameters
- query_params = {}
-
- # header parameters
- header_params = {}
-
- # HTTP header 'Accept' (if needed)
- _header_accept = ['application/json', 'application/xml']
- _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
-
- # HTTP header 'Content-Type'
- _header_content_type = []
- header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
-
- # form parameters
- form_params = {}
-
- # http body (model)
- post_body = nil
-
-
- Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
- end
-end
diff --git a/samples/client/petstore/ruby/models/base_object.rb b/samples/client/petstore/ruby/models/base_object.rb
deleted file mode 100644
index ecad551c77b..00000000000
--- a/samples/client/petstore/ruby/models/base_object.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-# base class containing fundamental method such as to_hash, build_from_hash and more
-class BaseObject
-
- # return the object in the form of hash
- def to_body
- body = {}
- self.class.attribute_map.each_pair do |key, value|
- body[value] = self.send(key) unless self.send(key).nil?
- end
- body
- end
-
- # build the object from hash
- def build_from_hash(attributes)
- return nil unless attributes.is_a?(Hash)
- self.class.swagger_types.each_pair do |key, type|
- if type =~ /^array\[(.*)\]/i
- if attributes[self.class.attribute_map[key]].is_a?(Array)
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
- else
- #TODO show warning in debug mode
- end
- elsif !attributes[self.class.attribute_map[key]].nil?
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
- else
- # data not found in attributes(hash), not an issue as the data can be optional
- end
- end
-
- self
- end
-
- def _deserialize(type, value)
- case type.to_sym
- when :DateTime
- DateTime.parse(value)
- when :string
- value.to_s
- when :int
- value.to_i
- when :double
- value.to_f
- when :boolean
- if value =~ /^(true|t|yes|y|1)$/i
- true
- else
- false
- end
- else # model
- _model = Object.const_get(type).new
- _model.build_from_hash(value)
- end
- end
-
-
-
- # to_body is an alias to to_body (backward compatibility)
- def to_hash
- hash = {}
- self.class.attribute_map.each_pair do |key, value|
- if self.send(key).is_a?(Array)
- next if self.send(key).empty?
- hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
- else
- unless (_tmp_value = _to_hash self.send(key)).nil?
- hash[value] = _tmp_value
- end
- end
- end
- hash
- end
-
- # Method to output non-array value in the form of hash
- # For object, use to_hash. Otherwise, just return the value
- def _to_hash(value)
- if value.respond_to? :to_hash
- value.to_hash
- else
- value
- end
- end
-
-end
diff --git a/samples/client/petstore/ruby/models/category.rb b/samples/client/petstore/ruby/models/category.rb
deleted file mode 100644
index c1da69482e0..00000000000
--- a/samples/client/petstore/ruby/models/category.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative 'base_object'
-
-#
-class Category < BaseObject
- attr_accessor :id, :name
- # attribute mapping from ruby-style variable name to JSON key
- def self.attribute_map
- {
-
- #
- :'id' => :'id',
-
- #
- :'name' => :'name'
-
- }
- end
-
- # attribute type
- def self.swagger_types
- {
- :'id' => :'int',
- :'name' => :'string'
-
- }
- end
-
- def initialize(attributes = {})
- return if !attributes.is_a?(Hash) || attributes.empty?
-
- # convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
-
-
- if attributes[:'id']
- @id = attributes[:'id']
- end
-
- if attributes[:'name']
- @name = attributes[:'name']
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/models/order.rb b/samples/client/petstore/ruby/models/order.rb
deleted file mode 100644
index 6347167c860..00000000000
--- a/samples/client/petstore/ruby/models/order.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require_relative 'base_object'
-
-#
-class Order < BaseObject
- attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
- # attribute mapping from ruby-style variable name to JSON key
- def self.attribute_map
- {
-
- #
- :'id' => :'id',
-
- #
- :'pet_id' => :'petId',
-
- #
- :'quantity' => :'quantity',
-
- #
- :'ship_date' => :'shipDate',
-
- # Order Status
- :'status' => :'status',
-
- #
- :'complete' => :'complete'
-
- }
- end
-
- # attribute type
- def self.swagger_types
- {
- :'id' => :'int',
- :'pet_id' => :'int',
- :'quantity' => :'int',
- :'ship_date' => :'DateTime',
- :'status' => :'string',
- :'complete' => :'boolean'
-
- }
- end
-
- def initialize(attributes = {})
- return if !attributes.is_a?(Hash) || attributes.empty?
-
- # convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
-
-
- if attributes[:'id']
- @id = attributes[:'id']
- end
-
- if attributes[:'petId']
- @pet_id = attributes[:'petId']
- end
-
- if attributes[:'quantity']
- @quantity = attributes[:'quantity']
- end
-
- if attributes[:'shipDate']
- @ship_date = attributes[:'shipDate']
- end
-
- if attributes[:'status']
- @status = attributes[:'status']
- end
-
- if attributes[:'complete']
- @complete = attributes[:'complete']
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/models/pet.rb b/samples/client/petstore/ruby/models/pet.rb
deleted file mode 100644
index 9accf4d1c81..00000000000
--- a/samples/client/petstore/ruby/models/pet.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-require_relative 'base_object'
-
-#
-class Pet < BaseObject
- attr_accessor :id, :category, :name, :photo_urls, :tags, :status
- # attribute mapping from ruby-style variable name to JSON key
- def self.attribute_map
- {
-
- #
- :'id' => :'id',
-
- #
- :'category' => :'category',
-
- #
- :'name' => :'name',
-
- #
- :'photo_urls' => :'photoUrls',
-
- #
- :'tags' => :'tags',
-
- # pet status in the store
- :'status' => :'status'
-
- }
- end
-
- # attribute type
- def self.swagger_types
- {
- :'id' => :'int',
- :'category' => :'Category',
- :'name' => :'string',
- :'photo_urls' => :'array[string]',
- :'tags' => :'array[Tag]',
- :'status' => :'string'
-
- }
- end
-
- def initialize(attributes = {})
- return if !attributes.is_a?(Hash) || attributes.empty?
-
- # convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
-
-
- if attributes[:'id']
- @id = attributes[:'id']
- end
-
- if attributes[:'category']
- @category = attributes[:'category']
- end
-
- if attributes[:'name']
- @name = attributes[:'name']
- end
-
- if attributes[:'photoUrls']
- if (value = attributes[:'photoUrls']).is_a?(Array)
- @photo_urls = value
- end
- end
-
- if attributes[:'tags']
- if (value = attributes[:'tags']).is_a?(Array)
- @tags = value
- end
- end
-
- if attributes[:'status']
- @status = attributes[:'status']
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/models/tag.rb b/samples/client/petstore/ruby/models/tag.rb
deleted file mode 100644
index 7eb332a3218..00000000000
--- a/samples/client/petstore/ruby/models/tag.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative 'base_object'
-
-#
-class Tag < BaseObject
- attr_accessor :id, :name
- # attribute mapping from ruby-style variable name to JSON key
- def self.attribute_map
- {
-
- #
- :'id' => :'id',
-
- #
- :'name' => :'name'
-
- }
- end
-
- # attribute type
- def self.swagger_types
- {
- :'id' => :'int',
- :'name' => :'string'
-
- }
- end
-
- def initialize(attributes = {})
- return if !attributes.is_a?(Hash) || attributes.empty?
-
- # convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
-
-
- if attributes[:'id']
- @id = attributes[:'id']
- end
-
- if attributes[:'name']
- @name = attributes[:'name']
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/models/user.rb b/samples/client/petstore/ruby/models/user.rb
deleted file mode 100644
index 20420e1c69b..00000000000
--- a/samples/client/petstore/ruby/models/user.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require_relative 'base_object'
-
-#
-class User < BaseObject
- attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
- # attribute mapping from ruby-style variable name to JSON key
- def self.attribute_map
- {
-
- #
- :'id' => :'id',
-
- #
- :'username' => :'username',
-
- #
- :'first_name' => :'firstName',
-
- #
- :'last_name' => :'lastName',
-
- #
- :'email' => :'email',
-
- #
- :'password' => :'password',
-
- #
- :'phone' => :'phone',
-
- # User Status
- :'user_status' => :'userStatus'
-
- }
- end
-
- # attribute type
- def self.swagger_types
- {
- :'id' => :'int',
- :'username' => :'string',
- :'first_name' => :'string',
- :'last_name' => :'string',
- :'email' => :'string',
- :'password' => :'string',
- :'phone' => :'string',
- :'user_status' => :'int'
-
- }
- end
-
- def initialize(attributes = {})
- return if !attributes.is_a?(Hash) || attributes.empty?
-
- # convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
-
-
- if attributes[:'id']
- @id = attributes[:'id']
- end
-
- if attributes[:'username']
- @username = attributes[:'username']
- end
-
- if attributes[:'firstName']
- @first_name = attributes[:'firstName']
- end
-
- if attributes[:'lastName']
- @last_name = attributes[:'lastName']
- end
-
- if attributes[:'email']
- @email = attributes[:'email']
- end
-
- if attributes[:'password']
- @password = attributes[:'password']
- end
-
- if attributes[:'phone']
- @phone = attributes[:'phone']
- end
-
- if attributes[:'userStatus']
- @user_status = attributes[:'userStatus']
- end
-
- end
-
-end
diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb
index 90df1cd821b..f66f33cf84c 100644
--- a/samples/client/petstore/ruby/spec/pet_spec.rb
+++ b/samples/client/petstore/ruby/spec/pet_spec.rb
@@ -6,17 +6,17 @@ describe "Pet" do
configure_swagger
prepare_pet
end
-
+
describe "pet methods" do
it "should construct a new pet object" do
- tag1 = Tag.new({'id' => 1, 'name'=> 'tag1'})
- tag2 = Tag.new({'id' => 2, 'name'=> 'tag2'})
- category1 = Category.new({:id => 1, :name => 'category unknown'})
+ tag1 = SwaggerClient::Tag.new({'id' => 1, 'name'=> 'tag1'})
+ tag2 = SwaggerClient::Tag.new({'id' => 2, 'name'=> 'tag2'})
+ category1 = SwaggerClient::Category.new({:id => 1, :name => 'category unknown'})
# initalize using both string and symbol key
pet_hash = {:'id' => 10002, :'name' => "RUBY UNIT TESTING", :'status' => "pending",
:'photo_urls' => ["url1", "url2"], :'category' => category1,
:'tags' => [tag1, tag2]}
- pet = Pet.new(pet_hash)
+ pet = SwaggerClient::Pet.new(pet_hash)
# test new
pet.name.should == "RUBY UNIT TESTING"
pet.status.should == "pending"
@@ -26,7 +26,7 @@ describe "Pet" do
pet.category.name.should == 'category unknown'
# test build_from_hash
- pet2 = Pet.new
+ pet2 = SwaggerClient::Pet.new
pet2.build_from_hash(pet.to_hash)
pet.to_hash.should == pet2.to_hash
@@ -37,8 +37,8 @@ describe "Pet" do
end
it "should fetch a pet object" do
- pet = PetApi.get_pet_by_id(10002)
- pet.should be_a(Pet)
+ pet = SwaggerClient::PetApi.get_pet_by_id(10002)
+ pet.should be_a(SwaggerClient::Pet)
pet.id.should == 10002
pet.name.should == "RUBY UNIT TESTING"
pet.tags[0].name.should == "tag test"
@@ -46,38 +46,38 @@ describe "Pet" do
end
it "should find pets by status" do
- pets = PetApi.find_pets_by_status(:status => 'available')
+ pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'available')
pets.length.should >= 3
end
-
+
it "should not find a pet with invalid status" do
- pets = PetApi.find_pets_by_status(:status => 'invalid-status')
+ pets = SwaggerClient::PetApi.find_pets_by_status(:status => 'invalid-status')
pets.length.should == 0
end
it "should find a pet by status" do
- pets = PetApi.find_pets_by_status(:status => "available,sold")
- pets.map {|pet|
- if(pet.status != 'available' && pet.status != 'sold')
+ pets = SwaggerClient::PetApi.find_pets_by_status(: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' => 10002, 'status' => 'sold'})
- PetApi.add_pet(:body => pet)
-
- fetched = PetApi.get_pet_by_id(10002)
+ pet = SwaggerClient::Pet.new({'id' => 10002, 'status' => 'sold'})
+ SwaggerClient::PetApi.add_pet(:body => pet)
+
+ fetched = SwaggerClient::PetApi.get_pet_by_id(10002)
fetched.id.should == 10002
fetched.status.should == 'sold'
end
- it "should create a pet" do
- pet = Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
- PetApi.add_pet(:body => pet)
+ it "should create a pet" do
+ pet = SwaggerClient::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
+ SwaggerClient::PetApi.add_pet(:body => pet)
- pet = PetApi.get_pet_by_id(10002)
+ pet = SwaggerClient::PetApi.get_pet_by_id(10002)
pet.id.should == 10002
pet.name.should == "RUBY UNIT TESTING"
end
diff --git a/samples/client/petstore/ruby/spec/request_spec.rb b/samples/client/petstore/ruby/spec/request_spec.rb
index 61389eddc9c..8856a0cf315 100644
--- a/samples/client/petstore/ruby/spec/request_spec.rb
+++ b/samples/client/petstore/ruby/spec/request_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
-describe Swagger::Request do
+describe SwaggerClient::Swagger::Request do
before(:each) do
- Swagger.configure do |config|
+ SwaggerClient::Swagger.configure do |config|
inject_format = true
config.api_key = 'special-key'
config.host = 'petstore.swagger.io'
@@ -15,7 +15,7 @@ describe Swagger::Request do
@default_params = {
:params => {:foo => "1", :bar => "2"}
}
- @request = Swagger::Request.new(@default_http_method, @default_path, @default_params)
+ @request = SwaggerClient::Swagger::Request.new(@default_http_method, @default_path, @default_params)
end
describe "initialization" do
@@ -24,7 +24,7 @@ describe Swagger::Request do
end
it "allows params to be nil" do
- @request = Swagger::Request.new(@default_http_method, @default_path, :params => nil)
+ @request = SwaggerClient::Swagger::Request.new(@default_http_method, @default_path, :params => nil)
@request.query_string.should == ""
end
@@ -59,7 +59,7 @@ describe Swagger::Request do
describe "body" do
it "camelCases parameters" do
- @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
:body => {
:bad_dog => 'bud',
:goodDog => "dud"
@@ -73,7 +73,7 @@ describe Swagger::Request do
describe "path" do
it "accounts for a total absence of format in the path string" do
- @request = Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
:format => "xml",
:params => {
}
@@ -82,7 +82,7 @@ describe Swagger::Request do
end
it "does string substitution (format) on path params" do
- @request = Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
:format => "xml",
:params => {
}
@@ -91,7 +91,7 @@ describe Swagger::Request do
end
it "leaves path-bound params out of the query string" do
- @request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({
:params => {
:word => "cat",
:limit => 20
@@ -101,7 +101,7 @@ describe Swagger::Request do
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({
+ @request = SwaggerClient::Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({
:params => {
:word => "cat",
}
@@ -110,7 +110,7 @@ describe Swagger::Request do
end
it "removes blank params" do
- @request = Swagger::Request.new(:get, "words/fancy", @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(:get, "words/fancy", @default_params.merge({
:params => {
:word => "dog",
:limit => "",
@@ -121,7 +121,7 @@ describe Swagger::Request do
end
it "URI encodes the path" do
- @request = Swagger::Request.new(:get, "word.{format}/bill gates/definitions", @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(:get, "word.{format}/bill gates/definitions", @default_params.merge({
:params => {
:word => "bill gates"
}
@@ -130,7 +130,7 @@ describe Swagger::Request do
end
it "converts numeric params to strings" do
- @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
:params => {
:limit => 100
}
@@ -142,7 +142,7 @@ describe Swagger::Request do
end
it "camelCases parameters" do
- @request = Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
+ @request = SwaggerClient::Swagger::Request.new(@default_http_method, @default_path, @default_params.merge({
:params => {
:bad_dog => 'bud',
:goodDog => "dud"
@@ -153,7 +153,7 @@ describe Swagger::Request do
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 = SwaggerClient::Swagger::Request.new(:get, 'fakeMethod', :params => params)
@request.query_string.should == "?falsey=false&stringy=fish&truthy=true"
end
@@ -162,12 +162,12 @@ describe Swagger::Request do
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"
+ SwaggerClient::Swagger.configure {|c| c.api_key = "xyz" }
+ SwaggerClient::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({
+ @request = SwaggerClient::Swagger::Request.new(:get, "words/fancy", @default_params.merge({
:params => {
:word => "dog",
:api_key => "123456"
@@ -179,21 +179,21 @@ describe Swagger::Request do
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"})
+ SwaggerClient::Swagger.configure {|c| c.api_key = "abc" }
+ @request_with_key = SwaggerClient::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 = SwaggerClient::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
+ SwaggerClient::Swagger.configure {|c| c.api_key = "hij" }
+ SwaggerClient::Swagger::Request.new(:get, "word/json").headers[:api_key].should == "hij"
+ SwaggerClient::Swagger::Request.new(:get, "word/json", :headers => {:api_key => "jkl"}).headers[:api_key].should == "jkl"
+ SwaggerClient::Swagger::Request.new(:get, "word/json", :headers => {:api_key => nil}).headers[:api_key].should be_nil
end
end
diff --git a/samples/client/petstore/ruby/spec/response_spec.rb b/samples/client/petstore/ruby/spec/response_spec.rb
index f29a0d2a62f..528b67e1fa7 100644
--- a/samples/client/petstore/ruby/spec/response_spec.rb
+++ b/samples/client/petstore/ruby/spec/response_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Swagger::Response do
+describe SwaggerClient::Swagger::Response do
before do
configure_swagger
@@ -13,7 +13,7 @@ describe Swagger::Response do
@raw = Typhoeus::Request.get("http://petstore.swagger.io/v2/pet/10002")
end
- @response = Swagger::Response.new(@raw)
+ @response = SwaggerClient::Swagger::Response.new(@raw)
end
describe "initialization" do
@@ -43,7 +43,7 @@ describe Swagger::Response do
@raw = Typhoeus::Request.get("http://petstore.swagger.io/v2/pet/10002",
:headers => {'Accept'=> "application/xml"})
end
- @response = Swagger::Response.new(@raw)
+ @response = SwaggerClient::Swagger::Response.new(@raw)
@response.format.should == 'xml'
@response.xml?.should == true
end
diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb
index d247ba5cbec..09012db2998 100644
--- a/samples/client/petstore/ruby/spec/spec_helper.rb
+++ b/samples/client/petstore/ruby/spec/spec_helper.rb
@@ -1,6 +1,6 @@
require 'rubygems'
require 'bundler/setup'
-require 'swagger-client'
+require 'swagger_client'
require 'vcr'
require 'typhoeus'
require 'json'
@@ -37,7 +37,7 @@ end
#end
def configure_swagger
- Swagger.configure do |config|
+ SwaggerClient::Swagger.configure do |config|
config.api_key = 'special-key'
config.host = 'petstore.swagger.io'
config.base_path = '/v2'
@@ -47,29 +47,29 @@ end
# always delete and then re-create the pet object with 10002
def prepare_pet
# remove the pet
- PetApi.delete_pet(10002)
+ SwaggerClient::PetApi.delete_pet(10002)
# recreate the pet
- category = Category.new('id' => 20002, 'name' => 'category test')
- tag = Tag.new('id' => 30002, 'name' => 'tag test')
- pet = Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url',
- 'category' => category, 'tags' => [tag], 'status' => 'pending')
+ category = SwaggerClient::Category.new('id' => 20002, 'name' => 'category test')
+ tag = SwaggerClient::Tag.new('id' => 30002, 'name' => 'tag test')
+ pet = SwaggerClient::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url',
+ 'category' => category, 'tags' => [tag], 'status' => 'pending')
- PetApi.add_pet(:'body'=> pet)
+ SwaggerClient::PetApi.add_pet(:'body'=> pet)
end
-# always delete and then re-create the store order
+# always delete and then re-create the store order
def prepare_store
- order = Order.new("id" => 10002,
+ order = SwaggerClient::Order.new("id" => 10002,
"petId" => 10002,
"quantity" => 789,
"shipDate" => "2015-04-06T23:42:01.678Z",
"status" => "placed",
"complete" => false)
- StoreApi.place_order(:body => order)
+ SwaggerClient::StoreApi.place_order(:body => order)
end
configure_swagger
-# A random string to tack onto stuff to ensure we're not seeing
+# 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/store_spec.rb b/samples/client/petstore/ruby/spec/store_spec.rb
index a1e2bd3193f..1b37400bc5c 100644
--- a/samples/client/petstore/ruby/spec/store_spec.rb
+++ b/samples/client/petstore/ruby/spec/store_spec.rb
@@ -7,7 +7,7 @@ describe "Store" do
end
it "should fetch an order" do
- item = StoreApi.get_order_by_id(10002)
+ item = SwaggerClient::StoreApi.get_order_by_id(10002)
item.id.should == 10002
end
end
diff --git a/samples/client/petstore/ruby/spec/swagger_spec.rb b/samples/client/petstore/ruby/spec/swagger_spec.rb
index 4aedc85382c..38b4a850ae9 100644
--- a/samples/client/petstore/ruby/spec/swagger_spec.rb
+++ b/samples/client/petstore/ruby/spec/swagger_spec.rb
@@ -1,7 +1,7 @@
# require 'spec_helper'
require File.dirname(__FILE__) + '/spec_helper'
-describe Swagger do
+describe SwaggerClient::Swagger do
before(:each) do
configure_swagger
@@ -16,35 +16,35 @@ describe Swagger do
context 'host' do
it 'removes http from host' do
- Swagger.configure {|c| c.host = 'http://example.com' }
- Swagger.configuration.host.should == 'example.com'
+ SwaggerClient::Swagger.configure {|c| c.host = 'http://example.com' }
+ SwaggerClient::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'
+ SwaggerClient::Swagger.configure {|c| c.host = 'https://wookiee.com' }
+ SwaggerClient::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'
+ SwaggerClient::Swagger.configure {|c| c.host = 'hobo.com/v4' }
+ SwaggerClient::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'
+ SwaggerClient::Swagger.configure {|c| c.base_path = 'v4/dog' }
+ SwaggerClient::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'
+ SwaggerClient::Swagger.configure {|c| c.base_path = '/v4/dog' }
+ SwaggerClient::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 == ''
+ SwaggerClient::Swagger.configure {|c| c.base_path = nil }
+ SwaggerClient::Swagger.configuration.base_path.should == ''
end
end
@@ -53,4 +53,4 @@ describe Swagger do
end
-end
\ No newline at end of file
+end
diff --git a/samples/client/petstore/ruby/swagger-client.gemspec b/samples/client/petstore/ruby/swagger-client.gemspec
deleted file mode 100644
index bbff5f95f6b..00000000000
--- a/samples/client/petstore/ruby/swagger-client.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-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
diff --git a/samples/client/petstore/ruby/swagger_client.gemspec b/samples/client/petstore/ruby/swagger_client.gemspec
new file mode 100644
index 00000000000..6ec2484e05c
--- /dev/null
+++ b/samples/client/petstore/ruby/swagger_client.gemspec
@@ -0,0 +1,32 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "swagger_client/swagger/version"
+
+Gem::Specification.new do |s|
+ s.name = "swagger_client"
+ s.version = SwaggerClient::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.license = "Apache-2.0"
+
+ s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1'
+ s.add_runtime_dependency 'addressable', '~> 2.2', '>= 2.2.4'
+ s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
+
+ s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
+ s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
+ s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2'
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.10'
+
+ 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/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
index c17f0a12911..bdf489c08c0 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
@@ -123,7 +123,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
* @param status Status values that need to be considered for filter
* @return List[Pet]
*/
- def findPetsByStatus (status: List[String]) : Option[List[Pet]] = {
+ def findPetsByStatus (status: List[String] = available) : Option[List[Pet]] = {
// create path and map variables
val path = "/pet/findByStatus".replaceAll("\\{format\\}","json")
diff --git a/samples/client/wordnik/akka-scala/pom.xml b/samples/client/wordnik/akka-scala/pom.xml
new file mode 100644
index 00000000000..f865a97c38b
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/pom.xml
@@ -0,0 +1,227 @@
+
+ 4.0.0
+ com.wordnik
+ swagger-client
+ jar
+ swagger-client
+ 1.0.0
+
+ 2.2.0
+
+
+
+
+ maven-mongodb-plugin-repo
+ maven mongodb plugin repository
+ http://maven-mongodb-plugin.googlecode.com/svn/maven/repo
+ default
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.12
+
+
+
+ loggerPath
+ conf/log4j.properties
+
+
+ -Xms512m -Xmx1500m
+ methods
+ pertest
+
+
+
+ maven-dependency-plugin
+
+
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/lib
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.2
+
+
+
+ jar
+ test-jar
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add_sources
+ generate-sources
+
+ add-source
+
+
+
+
+ src/main/java
+
+
+
+
+ add_test_sources
+ generate-test-sources
+
+ add-test-source
+
+
+
+
+ src/test/java
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+
+ 1.6
+ 1.6
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+ ${scala-maven-plugin-version}
+
+
+ scala-compile-first
+ process-resources
+
+ add-source
+ compile
+
+
+
+ scala-test-compile
+ process-test-resources
+
+ testCompile
+
+
+
+
+
+ -feature
+
+
+ -Xms128m
+ -Xmx1500m
+
+
+
+
+
+
+
+
+ org.scala-tools
+ maven-scala-plugin
+
+ ${scala-version}
+
+
+
+
+
+
+ org.scala-lang
+ scala-library
+ ${scala-version}
+
+
+ com.wordnik
+ swagger-core
+ ${swagger-core-version}
+
+
+ org.scalatest
+ scalatest_2.10
+ ${scala-test-version}
+ test
+
+
+ junit
+ junit
+ ${junit-version}
+ test
+
+
+ joda-time
+ joda-time
+ ${joda-time-version}
+
+
+ org.joda
+ joda-convert
+ ${joda-version}
+
+
+ com.typesafe
+ config
+ 1.2.1
+
+
+ com.typesafe.akka
+ akka-actor_2.10
+ ${akka-version}
+
+
+ io.spray
+ spray-client
+ ${spray-version}
+
+
+ org.json4s
+ json4s-jackson_2.10
+ ${json4s-jackson-version}
+
+
+
+ 2.10.4
+ 3.2.11
+ 3.2.11
+ 1.3.1
+ 2.3.9
+ 1.2
+ 2.2
+ 1.5.0-M1
+ 1.0.0
+
+ 4.8.1
+ 3.1.5
+ 2.1.3
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/resources/reference.conf b/samples/client/wordnik/akka-scala/src/main/resources/reference.conf
new file mode 100644
index 00000000000..f993f765edd
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/resources/reference.conf
@@ -0,0 +1,24 @@
+io.swagger.client {
+
+ apiRequest {
+
+ compression {
+ enabled: false
+ size-threshold: 0
+ }
+
+ trust-certificates: true
+
+ connection-timeout: 5000ms
+
+ default-headers {
+ "userAgent": "swagger-client_1.0.0"
+ }
+
+ // let you define custom http status code, as in :
+ // { code: 601, reason: "some custom http status code", success: false }
+ custom-codes : []
+ }
+}
+
+spray.can.host-connector.max-redirects = 10
\ No newline at end of file
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala
new file mode 100644
index 00000000000..8168c1c0f4f
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/AccountApi.scala
@@ -0,0 +1,109 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.ApiTokenStatus
+import io.swagger.client.model.AuthenticationToken
+import io.swagger.client.model.User
+import io.swagger.client.model.WordList
+import io.swagger.client.core._
+import io.swagger.client.core.CollectionFormats._
+import io.swagger.client.core.ApiKeyLocations._
+
+object AccountApi {
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : ApiTokenStatus (Usage statistics for the supplied API key)
+ * code 400 : (No token supplied.)
+ * code 404 : (No API account with supplied token.)
+ *
+ * @param apiKey Wordnik authentication token
+ */
+ def getApiTokenStatus(apiKey: Option[String] = None): ApiRequest[ApiTokenStatus] =
+ ApiRequest[ApiTokenStatus](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/apiTokenStatus", "application/json")
+ .withHeaderParam("api_key", apiKey)
+ .withSuccessResponse[ApiTokenStatus](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : AuthenticationToken (A valid authentication token)
+ * code 403 : (Account not available.)
+ * code 404 : (User not found.)
+ *
+ * @param username A confirmed Wordnik username
+ * @param password The user's password
+ */
+ def authenticate(username: String, password: String): ApiRequest[AuthenticationToken] =
+ ApiRequest[AuthenticationToken](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json")
+ .withQueryParam("password", password)
+ .withPathParam("username", username)
+ .withSuccessResponse[AuthenticationToken](200)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : AuthenticationToken (A valid authentication token)
+ * code 403 : (Account not available.)
+ * code 404 : (User not found.)
+ *
+ * @param username A confirmed Wordnik username
+ * @param body The user's password
+ */
+ def authenticatePost(username: String, body: String): ApiRequest[AuthenticationToken] =
+ ApiRequest[AuthenticationToken](ApiMethods.POST, "https://api.wordnik.com/v4", "/account.json/authenticate/{username}", "application/json")
+ .withBody(body)
+ .withPathParam("username", username)
+ .withSuccessResponse[AuthenticationToken](200)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ * Requires a valid auth_token to be set.
+ *
+ * Expected answers:
+ * code 200 : User (The logged-in user)
+ * code 403 : (Not logged in.)
+ * code 404 : (User not found.)
+ *
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def getLoggedInUser(authToken: String): ApiRequest[User] =
+ ApiRequest[User](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/user", "application/json")
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[User](200)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : Seq[WordList] (success)
+ * code 403 : (Not authenticated.)
+ * code 404 : (User account not found.)
+ *
+ * @param authToken auth_token of logged-in user
+ * @param skip Results to skip
+ * @param limit Maximum number of results to return
+ */
+ def getWordListsForLoggedInUser(authToken: String, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[Seq[WordList]] =
+ ApiRequest[Seq[WordList]](ApiMethods.GET, "https://api.wordnik.com/v4", "/account.json/wordLists", "application/json")
+ .withQueryParam("skip", skip)
+ .withQueryParam("limit", limit)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Seq[WordList]](200)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+
+
+}
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala
new file mode 100644
index 00000000000..c95a49ad0b2
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala
@@ -0,0 +1,41 @@
+package io.swagger.client.api
+
+import io.swagger.client.model._
+import org.json4s._
+import scala.reflect.ClassTag
+
+object EnumsSerializers {
+
+ def all = Seq[Serializer[_]]()
+
+
+
+ private class EnumNameSerializer[E <: Enumeration: ClassTag](enum: E)
+ extends Serializer[E#Value] {
+ import JsonDSL._
+
+ val EnumerationClass = classOf[E#Value]
+
+ def deserialize(implicit format: Formats):
+ PartialFunction[(TypeInfo, JValue), E#Value] = {
+ case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) => {
+ json match {
+ case JString(value) =>
+ enum.withName(value)
+ case value =>
+ throw new MappingException(s"Can't convert $value to $EnumerationClass")
+ }
+ }
+ }
+
+ private[this] def isValid(json: JValue) = json match {
+ case JString(value) if enum.values.exists(_.toString == value) => true
+ case _ => false
+ }
+
+ def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
+ case i: E#Value => i.toString
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala
new file mode 100644
index 00000000000..3c85b1a857f
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordApi.scala
@@ -0,0 +1,253 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordObject
+import io.swagger.client.model.AudioFile
+import io.swagger.client.model.Definition
+import io.swagger.client.model.FrequencySummary
+import io.swagger.client.model.Bigram
+import io.swagger.client.model.Example
+import io.swagger.client.core._
+import io.swagger.client.core.CollectionFormats._
+import io.swagger.client.core.ApiKeyLocations._
+
+object WordApi {
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : WordObject (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word String value of WordObject to return
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param includeSuggestions Return suggestions (for correct spelling, case variants, etc.)
+ */
+ def getWord(word: String, useCanonical: Option[String] = None, includeSuggestions: Option[String] = None): ApiRequest[WordObject] =
+ ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("includeSuggestions", includeSuggestions)
+ .withPathParam("word", word)
+ .withSuccessResponse[WordObject](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ * The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported.
+ *
+ * Expected answers:
+ * code 200 : Seq[AudioFile] (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to get audio for.
+ * @param useCanonical Use the canonical form of the word
+ * @param limit Maximum number of results to return
+ */
+ def getAudio(word: String, useCanonical: Option[String] = None, limit: Option[Int] = None): ApiRequest[Seq[AudioFile]] =
+ ApiRequest[Seq[AudioFile]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/audio", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("limit", limit)
+ .withPathParam("word", word)
+ .withSuccessResponse[Seq[AudioFile]](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : Seq[Definition] (success)
+ * code 400 : (Invalid word supplied.)
+ * code 404 : (No definitions found.)
+ *
+ * @param word Word to return definitions for
+ * @param limit Maximum number of results to return
+ * @param partOfSpeech CSV list of part-of-speech types
+ * @param includeRelated Return related words with definitions
+ * @param sourceDictionaries Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param includeTags Return a closed set of XML tags in response
+ */
+ def getDefinitions(word: String, limit: Option[Int] = None, partOfSpeech: Option[String] = None, includeRelated: Option[String] = None, sourceDictionaries: Seq[String], useCanonical: Option[String] = None, includeTags: Option[String] = None): ApiRequest[Seq[Definition]] =
+ ApiRequest[Seq[Definition]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/definitions", "application/json")
+ .withQueryParam("limit", limit)
+ .withQueryParam("partOfSpeech", partOfSpeech)
+ .withQueryParam("includeRelated", includeRelated)
+ .withQueryParam("sourceDictionaries", ArrayValues(sourceDictionaries, CSV))
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("includeTags", includeTags)
+ .withPathParam("word", word)
+ .withSuccessResponse[Seq[Definition]](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : Seq[String] (success)
+ * code 400 : (Invalid word supplied.)
+ * code 404 : (No definitions found.)
+ *
+ * @param word Word to return
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ */
+ def getEtymologies(word: String, useCanonical: Option[String] = None): ApiRequest[Seq[String]] =
+ ApiRequest[Seq[String]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/etymologies", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withPathParam("word", word)
+ .withSuccessResponse[Seq[String]](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to return examples for
+ * @param includeDuplicates Show duplicate examples from different sources
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param skip Results to skip
+ * @param limit Maximum number of results to return
+ */
+ def getExamples(word: String, includeDuplicates: Option[String] = None, useCanonical: Option[String] = None, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/examples", "application/json")
+ .withQueryParam("includeDuplicates", includeDuplicates)
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("skip", skip)
+ .withQueryParam("limit", limit)
+ .withPathParam("word", word)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : FrequencySummary (success)
+ * code 400 : (Invalid word supplied.)
+ * code 404 : (No results.)
+ *
+ * @param word Word to return
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param startYear Starting Year
+ * @param endYear Ending Year
+ */
+ def getWordFrequency(word: String, useCanonical: Option[String] = None, startYear: Option[Int] = None, endYear: Option[Int] = None): ApiRequest[FrequencySummary] =
+ ApiRequest[FrequencySummary](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/frequency", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("startYear", startYear)
+ .withQueryParam("endYear", endYear)
+ .withPathParam("word", word)
+ .withSuccessResponse[FrequencySummary](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to get syllables for
+ * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param sourceDictionary Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet.
+ * @param limit Maximum number of results to return
+ */
+ def getHyphenation(word: String, useCanonical: Option[String] = None, sourceDictionary: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/hyphenation", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("sourceDictionary", sourceDictionary)
+ .withQueryParam("limit", limit)
+ .withPathParam("word", word)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : Seq[Bigram] (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to fetch phrases for
+ * @param limit Maximum number of results to return
+ * @param wlmi Minimum WLMI for the phrase
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ */
+ def getPhrases(word: String, limit: Option[Int] = None, wlmi: Option[Int] = None, useCanonical: Option[String] = None): ApiRequest[Seq[Bigram]] =
+ ApiRequest[Seq[Bigram]](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/phrases", "application/json")
+ .withQueryParam("limit", limit)
+ .withQueryParam("wlmi", wlmi)
+ .withQueryParam("useCanonical", useCanonical)
+ .withPathParam("word", word)
+ .withSuccessResponse[Seq[Bigram]](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to get pronunciations for
+ * @param useCanonical If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param sourceDictionary Get from a single dictionary
+ * @param typeFormat Text pronunciation type
+ * @param limit Maximum number of results to return
+ */
+ def getTextPronunciations(word: String, useCanonical: Option[String] = None, sourceDictionary: Option[String] = None, typeFormat: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/pronunciations", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("sourceDictionary", sourceDictionary)
+ .withQueryParam("typeFormat", typeFormat)
+ .withQueryParam("limit", limit)
+ .withPathParam("word", word)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to fetch relationships for
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ * @param relationshipTypes Limits the total results per type of relationship type
+ * @param limitPerRelationshipType Restrict to the supplied relationship types
+ */
+ def getRelatedWords(word: String, useCanonical: Option[String] = None, relationshipTypes: Option[String] = None, limitPerRelationshipType: Option[Int] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/relatedWords", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withQueryParam("relationshipTypes", relationshipTypes)
+ .withQueryParam("limitPerRelationshipType", limitPerRelationshipType)
+ .withPathParam("word", word)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : Example (success)
+ * code 400 : (Invalid word supplied.)
+ *
+ * @param word Word to fetch examples for
+ * @param useCanonical If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.
+ */
+ def getTopExample(word: String, useCanonical: Option[String] = None): ApiRequest[Example] =
+ ApiRequest[Example](ApiMethods.GET, "https://api.wordnik.com/v4", "/word.json/{word}/topExample", "application/json")
+ .withQueryParam("useCanonical", useCanonical)
+ .withPathParam("word", word)
+ .withSuccessResponse[Example](200)
+ .withErrorResponse[Unit](400)
+
+
+
+}
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala
new file mode 100644
index 00000000000..6ff76587e1a
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListApi.scala
@@ -0,0 +1,154 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordList
+import io.swagger.client.model.StringValue
+import io.swagger.client.core._
+import io.swagger.client.core.CollectionFormats._
+import io.swagger.client.core.ApiKeyLocations._
+
+object WordListApi {
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : WordList (success)
+ * code 400 : (Invalid ID supplied)
+ * code 403 : (Not Authorized to access WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink permalink of WordList to fetch
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def getWordListByPermalink(permalink: String, authToken: String): ApiRequest[WordList] =
+ ApiRequest[WordList](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json")
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[WordList](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid ID supplied)
+ * code 403 : (Not Authorized to update WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink permalink of WordList to update
+ * @param body Updated WordList
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def updateWordList(permalink: String, body: Option[WordList] = None, authToken: String): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.PUT, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json")
+ .withBody(body)
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid ID supplied)
+ * code 403 : (Not Authorized to delete WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink ID of WordList to delete
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def deleteWordList(permalink: String, authToken: String): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.DELETE, "https://api.wordnik.com/v4", "/wordList.json/{permalink}", "application/json")
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid permalink supplied)
+ * code 403 : (Not Authorized to modify WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink permalink of WordList to use
+ * @param body Words to remove from WordList
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def deleteWordsFromWordList(permalink: String, body: Seq[StringValue], authToken: String): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/deleteWords", "application/json")
+ .withBody(body)
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid ID supplied)
+ * code 403 : (Not Authorized to access WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink ID of WordList to use
+ * @param sortBy Field to sort by
+ * @param sortOrder Direction to sort
+ * @param skip Results to skip
+ * @param limit Maximum number of results to return
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def getWordListWords(permalink: String, sortBy: Option[String] = None, sortOrder: Option[String] = None, skip: Option[Int] = None, limit: Option[Int] = None, authToken: String): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json")
+ .withQueryParam("sortBy", sortBy)
+ .withQueryParam("sortOrder", sortOrder)
+ .withQueryParam("skip", skip)
+ .withQueryParam("limit", limit)
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid permalink supplied)
+ * code 403 : (Not Authorized to access WordList)
+ * code 404 : (WordList not found)
+ *
+ * @param permalink permalink of WordList to user
+ * @param body Array of words to add to WordList
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def addWordsToWordList(permalink: String, body: Seq[StringValue], authToken: String): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordList.json/{permalink}/words", "application/json")
+ .withBody(body)
+ .withPathParam("permalink", permalink)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+
+
+}
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala
new file mode 100644
index 00000000000..cad9a37ba87
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordListsApi.scala
@@ -0,0 +1,34 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordList
+import io.swagger.client.core._
+import io.swagger.client.core.CollectionFormats._
+import io.swagger.client.core.ApiKeyLocations._
+
+object WordListsApi {
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : WordList (success)
+ * code 400 : (Invalid WordList supplied or mandatory fields are missing)
+ * code 403 : (Not authenticated)
+ * code 404 : (WordList owner not found)
+ *
+ * @param body WordList to create
+ * @param authToken The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)
+ */
+ def createWordList(body: Option[WordList] = None, authToken: String): ApiRequest[WordList] =
+ ApiRequest[WordList](ApiMethods.POST, "https://api.wordnik.com/v4", "/wordLists.json", "application/json")
+ .withBody(body)
+ .withHeaderParam("auth_token", authToken)
+ .withSuccessResponse[WordList](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](403)
+ .withErrorResponse[Unit](404)
+
+
+
+}
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala
new file mode 100644
index 00000000000..b3b33679252
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/api/WordsApi.scala
@@ -0,0 +1,181 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordObject
+import io.swagger.client.model.DefinitionSearchResults
+import io.swagger.client.model.WordSearchResults
+import io.swagger.client.model.WordOfTheDay
+import io.swagger.client.core._
+import io.swagger.client.core.CollectionFormats._
+import io.swagger.client.core.ApiKeyLocations._
+
+object WordsApi {
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : WordObject (success)
+ * code 404 : (No word found.)
+ *
+ * @param hasDictionaryDef Only return words with dictionary definitions
+ * @param includePartOfSpeech CSV part-of-speech values to include
+ * @param excludePartOfSpeech CSV part-of-speech values to exclude
+ * @param minCorpusCount Minimum corpus frequency for terms
+ * @param maxCorpusCount Maximum corpus frequency for terms
+ * @param minDictionaryCount Minimum dictionary count
+ * @param maxDictionaryCount Maximum dictionary count
+ * @param minLength Minimum word length
+ * @param maxLength Maximum word length
+ */
+ def getRandomWord(hasDictionaryDef: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None): ApiRequest[WordObject] =
+ ApiRequest[WordObject](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWord", "application/json")
+ .withQueryParam("hasDictionaryDef", hasDictionaryDef)
+ .withQueryParam("includePartOfSpeech", includePartOfSpeech)
+ .withQueryParam("excludePartOfSpeech", excludePartOfSpeech)
+ .withQueryParam("minCorpusCount", minCorpusCount)
+ .withQueryParam("maxCorpusCount", maxCorpusCount)
+ .withQueryParam("minDictionaryCount", minDictionaryCount)
+ .withQueryParam("maxDictionaryCount", maxDictionaryCount)
+ .withQueryParam("minLength", minLength)
+ .withQueryParam("maxLength", maxLength)
+ .withSuccessResponse[WordObject](200)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : (success)
+ * code 400 : (Invalid term supplied.)
+ * code 404 : (No results.)
+ *
+ * @param hasDictionaryDef Only return words with dictionary definitions
+ * @param includePartOfSpeech CSV part-of-speech values to include
+ * @param excludePartOfSpeech CSV part-of-speech values to exclude
+ * @param minCorpusCount Minimum corpus frequency for terms
+ * @param maxCorpusCount Maximum corpus frequency for terms
+ * @param minDictionaryCount Minimum dictionary count
+ * @param maxDictionaryCount Maximum dictionary count
+ * @param minLength Minimum word length
+ * @param maxLength Maximum word length
+ * @param sortBy Attribute to sort by
+ * @param sortOrder Sort direction
+ * @param limit Maximum number of results to return
+ */
+ def getRandomWords(hasDictionaryDef: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, sortBy: Option[String] = None, sortOrder: Option[String] = None, limit: Option[Int] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/randomWords", "application/json")
+ .withQueryParam("hasDictionaryDef", hasDictionaryDef)
+ .withQueryParam("includePartOfSpeech", includePartOfSpeech)
+ .withQueryParam("excludePartOfSpeech", excludePartOfSpeech)
+ .withQueryParam("minCorpusCount", minCorpusCount)
+ .withQueryParam("maxCorpusCount", maxCorpusCount)
+ .withQueryParam("minDictionaryCount", minDictionaryCount)
+ .withQueryParam("maxDictionaryCount", maxDictionaryCount)
+ .withQueryParam("minLength", minLength)
+ .withQueryParam("maxLength", maxLength)
+ .withQueryParam("sortBy", sortBy)
+ .withQueryParam("sortOrder", sortOrder)
+ .withQueryParam("limit", limit)
+ .withSuccessResponse[Unit](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : DefinitionSearchResults (success)
+ * code 400 : (Invalid term supplied.)
+ *
+ * @param query Search term
+ * @param findSenseForWord Restricts words and finds closest sense
+ * @param includeSourceDictionaries Only include these comma-delimited source dictionaries
+ * @param excludeSourceDictionaries Exclude these comma-delimited source dictionaries
+ * @param includePartOfSpeech Only include these comma-delimited parts of speech
+ * @param excludePartOfSpeech Exclude these comma-delimited parts of speech
+ * @param minCorpusCount Minimum corpus frequency for terms
+ * @param maxCorpusCount Maximum corpus frequency for terms
+ * @param minLength Minimum word length
+ * @param maxLength Maximum word length
+ * @param expandTerms Expand terms
+ * @param includeTags Return a closed set of XML tags in response
+ * @param sortBy Attribute to sort by
+ * @param sortOrder Sort direction
+ * @param skip Results to skip
+ * @param limit Maximum number of results to return
+ */
+ def reverseDictionary(query: String, findSenseForWord: Option[String] = None, includeSourceDictionaries: Option[String] = None, excludeSourceDictionaries: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, expandTerms: Option[String] = None, includeTags: Option[String] = None, sortBy: Option[String] = None, sortOrder: Option[String] = None, skip: Option[String] = None, limit: Option[Int] = None): ApiRequest[DefinitionSearchResults] =
+ ApiRequest[DefinitionSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/reverseDictionary", "application/json")
+ .withQueryParam("query", query)
+ .withQueryParam("findSenseForWord", findSenseForWord)
+ .withQueryParam("includeSourceDictionaries", includeSourceDictionaries)
+ .withQueryParam("excludeSourceDictionaries", excludeSourceDictionaries)
+ .withQueryParam("includePartOfSpeech", includePartOfSpeech)
+ .withQueryParam("excludePartOfSpeech", excludePartOfSpeech)
+ .withQueryParam("minCorpusCount", minCorpusCount)
+ .withQueryParam("maxCorpusCount", maxCorpusCount)
+ .withQueryParam("minLength", minLength)
+ .withQueryParam("maxLength", maxLength)
+ .withQueryParam("expandTerms", expandTerms)
+ .withQueryParam("includeTags", includeTags)
+ .withQueryParam("sortBy", sortBy)
+ .withQueryParam("sortOrder", sortOrder)
+ .withQueryParam("skip", skip)
+ .withQueryParam("limit", limit)
+ .withSuccessResponse[DefinitionSearchResults](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 200 : WordSearchResults (success)
+ * code 400 : (Invalid query supplied.)
+ *
+ * @param query Search query
+ * @param caseSensitive Search case sensitive
+ * @param includePartOfSpeech Only include these comma-delimited parts of speech
+ * @param excludePartOfSpeech Exclude these comma-delimited parts of speech
+ * @param minCorpusCount Minimum corpus frequency for terms
+ * @param maxCorpusCount Maximum corpus frequency for terms
+ * @param minDictionaryCount Minimum number of dictionary entries for words returned
+ * @param maxDictionaryCount Maximum dictionary definition count
+ * @param minLength Minimum word length
+ * @param maxLength Maximum word length
+ * @param skip Results to skip
+ * @param limit Maximum number of results to return
+ */
+ def searchWords(query: String, caseSensitive: Option[String] = None, includePartOfSpeech: Option[String] = None, excludePartOfSpeech: Option[String] = None, minCorpusCount: Option[Int] = None, maxCorpusCount: Option[Int] = None, minDictionaryCount: Option[Int] = None, maxDictionaryCount: Option[Int] = None, minLength: Option[Int] = None, maxLength: Option[Int] = None, skip: Option[Int] = None, limit: Option[Int] = None): ApiRequest[WordSearchResults] =
+ ApiRequest[WordSearchResults](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/search/{query}", "application/json")
+ .withQueryParam("caseSensitive", caseSensitive)
+ .withQueryParam("includePartOfSpeech", includePartOfSpeech)
+ .withQueryParam("excludePartOfSpeech", excludePartOfSpeech)
+ .withQueryParam("minCorpusCount", minCorpusCount)
+ .withQueryParam("maxCorpusCount", maxCorpusCount)
+ .withQueryParam("minDictionaryCount", minDictionaryCount)
+ .withQueryParam("maxDictionaryCount", maxDictionaryCount)
+ .withQueryParam("minLength", minLength)
+ .withQueryParam("maxLength", maxLength)
+ .withQueryParam("skip", skip)
+ .withQueryParam("limit", limit)
+ .withPathParam("query", query)
+ .withSuccessResponse[WordSearchResults](200)
+ .withErrorResponse[Unit](400)
+
+ /**
+ *
+ *
+ * Expected answers:
+ * code 0 : WordOfTheDay (success)
+ *
+ * @param date Fetches by date in yyyy-MM-dd
+ */
+ def getWordOfTheDay(date: Option[String] = None): ApiRequest[WordOfTheDay] =
+ ApiRequest[WordOfTheDay](ApiMethods.GET, "https://api.wordnik.com/v4", "/words.json/wordOfTheDay", "application/json")
+ .withQueryParam("date", date)
+ .withDefaultSuccessResponse[WordOfTheDay]
+
+
+
+}
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala
new file mode 100644
index 00000000000..3b11d866017
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala
@@ -0,0 +1,323 @@
+package io.swagger.client.core
+
+import java.io.File
+import java.security.cert.X509Certificate
+import javax.net.ssl._
+
+import akka.actor.ActorSystem
+import akka.io.IO
+import akka.pattern.ask
+import akka.util.Timeout
+import org.joda.time.DateTime
+import org.joda.time.format.ISODateTimeFormat
+import org.json4s.JsonAST.JString
+import org.json4s._
+import org.json4s.jackson.JsonMethods._
+import org.json4s.jackson.Serialization
+import spray.can.Http
+import spray.can.Http.HostConnectorSetup
+import spray.client.pipelining
+import spray.client.pipelining._
+import spray.http.HttpEncodings._
+import spray.http.HttpHeaders.{RawHeader, `Accept-Encoding`}
+import spray.http.Uri.Query
+import spray.http._
+import spray.http.parser.HttpParser
+import spray.httpx.encoding.{Deflate, Encoder, Gzip}
+import spray.httpx.unmarshalling._
+import spray.io.ClientSSLEngineProvider
+
+import scala.concurrent.{ExecutionContext, Future}
+import scala.reflect.ClassTag
+import scala.util.control.NonFatal
+
+object ApiInvoker {
+
+ def apply()(implicit system: ActorSystem): ApiInvoker =
+ apply(DefaultFormats + DateTimeSerializer)
+ def apply(serializers: Traversable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker =
+ apply(DefaultFormats + DateTimeSerializer ++ serializers)
+ def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats)
+
+ case class CustomStatusCode(value: Int, reason: String = "Application-defined status code", isSuccess: Boolean = true)
+
+ def addCustomStatusCode(code: CustomStatusCode): Unit = addCustomStatusCode(code.value, code.reason, code.isSuccess)
+
+ def addCustomStatusCode(code: Int, reason: String = "Application defined code", isSuccess: Boolean = true) = {
+ StatusCodes.getForKey(code) foreach { c =>
+ StatusCodes.registerCustom(code, reason, reason, isSuccess, allowsEntity = true)
+ }
+ }
+
+ /**
+ * Allows request execution without calling apiInvoker.execute(request)
+ * request.response can be used to get a future of the ApiResponse generated.
+ * request.result can be used to get a future of the expected ApiResponse content. If content doesn't match, a
+ * Future will failed with a ClassCastException
+ * @param request the apiRequest to be executed
+ */
+ implicit class ApiRequestImprovements[T](request: ApiRequest[T]) {
+
+ def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] =
+ response(ec, system, invoker)
+
+ def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] =
+ invoker.execute(request)
+
+ def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] =
+ invoker.execute(request).map(_.content).mapTo[U]
+
+ }
+
+ /**
+ * Allows transformation from ApiMethod to spray HttpMethods
+ * @param method the ApiMethod to be converted
+ */
+ implicit class ApiMethodExtensions(val method: ApiMethod) {
+ def toSprayMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET)
+ }
+
+ case object DateTimeSerializer extends CustomSerializer[DateTime](format => ( {
+ case JString(s) =>
+ ISODateTimeFormat.dateTimeParser().parseDateTime(s)
+ }, {
+ case d: DateTime =>
+ JString(ISODateTimeFormat.dateTimeParser().print(d))
+ }))
+}
+
+class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends UntrustedSslContext with CustomContentTypes {
+
+ import io.swagger.client.core.ApiInvoker._
+ import io.swagger.client.core.ParametersMap._
+
+ implicit val ec = system.dispatcher
+ implicit val jsonFormats = formats
+
+ def settings = ApiSettings(system)
+
+ import spray.http.MessagePredicate._
+
+ val CompressionFilter = MessagePredicate({ _ => settings.compressionEnabled}) &&
+ Encoder.DefaultFilter &&
+ minEntitySize(settings.compressionSizeThreshold)
+
+ settings.customCodes.foreach(addCustomStatusCode)
+
+ private def addAuthentication(credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer =
+ request =>
+ credentialsSeq.foldLeft(request) {
+ case (req, BasicCredentials(login, password)) =>
+ req ~> addCredentials(BasicHttpCredentials(login, password))
+ case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
+ req ~> addHeader(RawHeader(keyName, keyValue.value))
+ case (req, _) => req
+ }
+
+ private def addHeaders(headers: Map[String, Any]): pipelining.RequestTransformer = { request =>
+
+ val rawHeaders = for {
+ (name, value) <- headers.asFormattedParams
+ header = RawHeader(name, String.valueOf(value))
+ } yield header
+
+ request.withHeaders(rawHeaders.toList)
+ }
+
+ private def bodyPart(name: String, value: Any): BodyPart = {
+ value match {
+ case f: File =>
+ BodyPart(f, name)
+ case v: String =>
+ BodyPart(HttpEntity(String.valueOf(v)))
+ case NumericValue(v) =>
+ BodyPart(HttpEntity(String.valueOf(v)))
+ case m: ApiModel =>
+ BodyPart(HttpEntity(Serialization.write(m)))
+ }
+ }
+
+ private def formDataContent(request: ApiRequest[_]) = {
+ val params = request.formParams.asFormattedParams
+ if (params.isEmpty)
+ None
+ else
+ Some(
+ normalizedContentType(request.contentType).mediaType match {
+ case MediaTypes.`multipart/form-data` =>
+ MultipartFormData(params.map { case (name, value) => (name, bodyPart(name, value))})
+ case MediaTypes.`application/x-www-form-urlencoded` =>
+ FormData(params.mapValues(String.valueOf))
+ case m: MediaType => // Default : application/x-www-form-urlencoded.
+ FormData(params.mapValues(String.valueOf))
+ }
+ )
+ }
+
+ private def bodyContent(request: ApiRequest[_]): Option[Any] = {
+ request.bodyParam.map(Extraction.decompose).map(compact)
+ }
+
+ private def createRequest(uri: Uri, request: ApiRequest[_]): HttpRequest = {
+
+ val builder = new RequestBuilder(request.method.toSprayMethod)
+ val httpRequest = request.method.toSprayMethod match {
+ case HttpMethods.GET | HttpMethods.DELETE => builder.apply(uri)
+ case HttpMethods.POST | HttpMethods.PUT =>
+ formDataContent(request) orElse bodyContent(request) match {
+ case Some(c: FormData) =>
+ builder.apply(uri, c)
+ case Some(c: MultipartFormData) =>
+ builder.apply(uri, c)
+ case Some(c: String) =>
+ builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), c))
+ case _ =>
+ builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), " "))
+ }
+ case _ => builder.apply(uri)
+ }
+
+ httpRequest ~>
+ addHeaders(request.headerParams) ~>
+ addAuthentication(request.credentials) ~>
+ encode(Gzip(CompressionFilter))
+ }
+
+ def makeQuery(r: ApiRequest[_]): Query = {
+ r.credentials.foldLeft(r.queryParams) {
+ case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) =>
+ params + (keyName -> key.value)
+ case (params, _) => params
+ }.asFormattedParams
+ .mapValues(String.valueOf)
+ .foldRight[Query](Uri.Query.Empty) {
+ case ((name, value), acc) => acc.+:(name, value)
+ }
+ }
+
+ def makeUri(r: ApiRequest[_]): Uri = {
+ val opPath = r.operationPath.replaceAll("\\{format\\}", "json")
+ val opPathWithParams = r.pathParams.asFormattedParams
+ .mapValues(String.valueOf)
+ .foldLeft(opPath) {
+ case (path, (name, value)) => path.replaceAll(s"\\{$name\\}", value)
+ }
+ val query = makeQuery(r)
+
+ Uri(r.basePath + opPathWithParams).withQuery(query)
+ }
+
+ def execute[T](r: ApiRequest[T]): Future[ApiResponse[T]] = {
+ try {
+ implicit val timeout: Timeout = settings.connectionTimeout
+
+ val uri = makeUri(r)
+
+ val connector = HostConnectorSetup(
+ uri.authority.host.toString,
+ uri.effectivePort,
+ sslEncryption = "https".equals(uri.scheme),
+ defaultHeaders = settings.defaultHeaders ++ List(`Accept-Encoding`(gzip, deflate)))
+
+ val request = createRequest(uri, r)
+
+ for {
+ Http.HostConnectorInfo(hostConnector, _) <- IO(Http) ? connector
+ response <- hostConnector.ask(request).mapTo[HttpResponse]
+ } yield {
+ response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r)
+ }
+ }
+ catch {
+ case NonFatal(x) => Future.failed(x)
+ }
+ }
+
+ def unmarshallApiResponse[T](request: ApiRequest[T])(response: HttpResponse): ApiResponse[T] = {
+ request.responseForCode(response.status.intValue) match {
+ case Some( (manifest: Manifest[T], state: ResponseState) ) =>
+ entityUnmarshaller(manifest)(response.entity) match {
+ case Right(value) ⇒
+ state match {
+ case ResponseState.Success =>
+ ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap)
+ case ResponseState.Error =>
+ throw new ApiError(response.status.intValue, "Error response received",
+ Some(value),
+ headers = response.headers.map(header => (header.name, header.value)).toMap)
+ }
+
+ case Left(MalformedContent(error, Some(cause))) ⇒
+ throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), cause)
+
+ case Left(MalformedContent(error, None)) ⇒
+ throw new ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString))
+
+ case Left(ContentExpected) ⇒
+ throw new ApiError(response.status.intValue, s"Unable to unmarshall empty response to [$manifest]", Some(response.entity.toString))
+ }
+
+ case _ => throw new ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString))
+ }
+ }
+
+ def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] =
+ Unmarshaller[T](MediaTypes.`application/json`) {
+ case x: HttpEntity.NonEmpty ⇒
+ parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`))
+ .noNulls
+ .camelizeKeys
+ .extract[T]
+ }
+
+}
+
+sealed trait CustomContentTypes {
+
+ def normalizedContentType(original: String): ContentType =
+ MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType(original)
+
+ def parseContentType(contentType: String): ContentType = {
+ val contentTypeAsRawHeader = HttpHeaders.RawHeader("Content-Type", contentType)
+ val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader)
+ (parsedContentTypeHeader: @unchecked) match {
+ case Right(ct: HttpHeaders.`Content-Type`) =>
+ ct.contentType
+ case Left(error: ErrorInfo) =>
+ throw new IllegalArgumentException(
+ s"Error converting '$contentType' to a ContentType header: '${error.summary}'")
+ }
+ }
+}
+
+sealed trait UntrustedSslContext {
+ this: ApiInvoker =>
+
+ implicit lazy val trustfulSslContext: SSLContext = {
+ settings.alwaysTrustCertificates match {
+ case false =>
+ SSLContext.getDefault
+
+ case true =>
+ class IgnoreX509TrustManager extends X509TrustManager {
+ def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
+
+ def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
+
+ def getAcceptedIssuers = null
+ }
+
+ val context = SSLContext.getInstance("TLS")
+ context.init(null, Array(new IgnoreX509TrustManager), null)
+ context
+ }
+ }
+
+ implicit val clientSSLEngineProvider =
+ ClientSSLEngineProvider {
+ _ =>
+ val engine = trustfulSslContext.createSSLEngine()
+ engine.setUseClientMode(true)
+ engine
+ }
+}
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala
new file mode 100644
index 00000000000..0588193cfbe
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala
@@ -0,0 +1,50 @@
+package io.swagger.client.core
+
+sealed trait ResponseState
+object ResponseState {
+ case object Success extends ResponseState
+ case object Error extends ResponseState
+}
+
+case class ApiRequest[U](
+ // required fields
+ method: ApiMethod,
+ basePath: String,
+ operationPath: String,
+ contentType: String,
+
+ // optional fields
+ responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty,
+ bodyParam: Option[Any] = None,
+ formParams: Map[String, Any] = Map.empty,
+ pathParams: Map[String, Any] = Map.empty,
+ queryParams: Map[String, Any] = Map.empty,
+ headerParams: Map[String, Any] = Map.empty,
+ credentials: Seq[Credentials] = List.empty) {
+
+ def withCredentials(cred: Credentials) = copy[U](credentials = credentials :+ cred)
+
+ def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) = withCredentials(ApiKeyCredentials(key, keyName, location))
+
+ def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Success)))
+
+ def withErrorResponse[T](code: Int)(implicit m: Manifest[T]) = copy[U](responses = responses + (code -> (m, ResponseState.Error)))
+
+ def withDefaultSuccessResponse[T](implicit m: Manifest[T]) = withSuccessResponse[T](0)
+
+ def withDefaultErrorResponse[T](implicit m: Manifest[T]) = withErrorResponse[T](0)
+
+ def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0)
+
+ def withoutBody() = copy[U](bodyParam = None)
+
+ def withBody(body: Any) = copy[U](bodyParam = Some(body))
+
+ def withFormParam(name: String, value: Any) = copy[U](formParams = formParams + (name -> value))
+
+ def withPathParam(name: String, value: Any) = copy[U](pathParams = pathParams + (name -> value))
+
+ def withQueryParam(name: String, value: Any) = copy[U](queryParams = queryParams + (name -> value))
+
+ def withHeaderParam(name: String, value: Any) = copy[U](headerParams = headerParams + (name -> value))
+}
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala
new file mode 100644
index 00000000000..3162fb9f6be
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala
@@ -0,0 +1,32 @@
+package io.swagger.client.core
+
+import java.util.concurrent.TimeUnit
+
+import akka.actor.{ExtendedActorSystem, Extension, ExtensionKey}
+import com.typesafe.config.Config
+import io.swagger.client.core.ApiInvoker.CustomStatusCode
+import spray.http.HttpHeaders.RawHeader
+
+import scala.collection.JavaConversions._
+import scala.concurrent.duration.FiniteDuration
+
+class ApiSettings(config: Config) extends Extension {
+ def this(system: ExtendedActorSystem) = this(system.settings.config)
+
+ private def cfg = config.getConfig("io.swagger.client.apiRequest")
+
+ val alwaysTrustCertificates = cfg.getBoolean("trust-certificates")
+ val defaultHeaders = cfg.getConfig("default-headers").entrySet.toList.map(c => RawHeader(c.getKey, c.getValue.render))
+ val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
+ val compressionEnabled = cfg.getBoolean("compression.enabled")
+ val compressionSizeThreshold = cfg.getBytes("compression.size-threshold").toInt
+ val customCodes = cfg.getConfigList("custom-codes").toList.map { c => CustomStatusCode(
+ c.getInt("code"),
+ c.getString("reason"),
+ c.getBoolean("success"))
+ }
+
+
+}
+
+object ApiSettings extends ExtensionKey[ApiSettings]
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala
new file mode 100644
index 00000000000..a096a994ea3
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/core/requests.scala
@@ -0,0 +1,166 @@
+package io.swagger.client.core
+
+import java.io.File
+import java.net.URLEncoder
+import scala.util.Try
+
+sealed trait ApiReturnWithHeaders {
+ def headers: Map[String, String]
+ def header(name: String): Option[String] = headers.get(name)
+ def getStringHeader(name: String) = header(name)
+ def getIntHeader(name: String) = castedHeader(name, java.lang.Integer.parseInt)
+ def getLongHeader(name: String) = castedHeader(name, java.lang.Long.parseLong)
+ def getFloatHeader(name: String) = castedHeader(name, java.lang.Float.parseFloat)
+ def getDoubleHeader(name: String) = castedHeader(name, java.lang.Double.parseDouble)
+ def getBooleanHeader(name: String) = castedHeader(name, java.lang.Boolean.parseBoolean)
+ private def castedHeader[U](name: String, conversion: String => U): Option[U] = { Try { header(name).map( conversion ) }.get }
+}
+
+sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty)
+ extends ApiReturnWithHeaders
+
+sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty)
+ extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause)
+ with ApiReturnWithHeaders
+
+sealed case class ApiMethod(value: String)
+
+object ApiMethods {
+ val CONNECT = ApiMethod("CONNECT")
+ val DELETE = ApiMethod("DELETE")
+ val GET = ApiMethod("GET")
+ val HEAD = ApiMethod("HEAD")
+ val OPTIONS = ApiMethod("OPTIONS")
+ val PATCH = ApiMethod("PATCH")
+ val POST = ApiMethod("POST")
+ val PUT = ApiMethod("PUT")
+ val TRACE = ApiMethod("TRACE")
+}
+
+/**
+ * This trait needs to be added to any model defined by the api.
+ */
+trait ApiModel
+
+/**
+ * Single trait defining a credential that can be transformed to a paramName / paramValue tupple
+ */
+sealed trait Credentials {
+ def asQueryParam: Option[(String, String)] = None
+}
+
+sealed case class BasicCredentials(user: String, password: String) extends Credentials
+
+sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials {
+ override def asQueryParam: Option[(String, String)] = location match {
+ case ApiKeyLocations.QUERY => Some((keyName, key.value))
+ case _ => None
+ }
+}
+
+sealed case class ApiKeyValue(value: String)
+
+sealed trait ApiKeyLocation
+
+object ApiKeyLocations {
+
+ case object QUERY extends ApiKeyLocation
+
+ case object HEADER extends ApiKeyLocation
+}
+
+
+/**
+ * Case class used to unapply numeric values only in pattern matching
+ * @param value the string representation of the numeric value
+ */
+sealed case class NumericValue(value: String) {
+ override def toString = value
+}
+
+object NumericValue {
+ def unapply(n: Any): Option[NumericValue] = n match {
+ case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n)))
+ case _ => None
+ }
+}
+
+/**
+ * Used for params being arrays
+ */
+sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV)
+
+object ArrayValues {
+ def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues =
+ ArrayValues(values.getOrElse(Seq.empty), format)
+
+ def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV)
+}
+
+
+/**
+ * Defines how arrays should be rendered in query strings.
+ */
+sealed trait CollectionFormat
+
+trait MergedArrayFormat extends CollectionFormat {
+ def separator: String
+}
+
+object CollectionFormats {
+
+ case object CSV extends MergedArrayFormat {
+ override val separator = ","
+ }
+
+ case object TSV extends MergedArrayFormat {
+ override val separator = "\t"
+ }
+
+ case object SSV extends MergedArrayFormat {
+ override val separator = " "
+ }
+
+ case object PIPES extends MergedArrayFormat {
+ override val separator = "|"
+ }
+
+ case object MULTI extends CollectionFormat
+
+}
+
+object ParametersMap {
+
+ /**
+ * Pimp parameters maps (Map[String, Any]) in order to transform them in a sequence of String -> Any tupples,
+ * with valid url-encoding, arrays handling, files preservation, ...
+ */
+ implicit class ParametersMapImprovements(val m: Map[String, Any]) {
+
+ def asFormattedParamsList = m.toList.flatMap(formattedParams)
+
+ def asFormattedParams = m.flatMap(formattedParams)
+
+ private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20")
+
+ private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2)
+
+ private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match {
+ case arr: ArrayValues =>
+ arr.format match {
+ case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _))
+ case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator)))
+ }
+ case None => Seq.empty
+ case Some(opt) =>
+ formattedParams(name, opt)
+ case s: Seq[Any] =>
+ formattedParams(name, ArrayValues(s))
+ case v: String => Seq((name, urlEncode(v)))
+ case NumericValue(v) => Seq((name, urlEncode(v)))
+ case f: File => Seq((name, f))
+ case m: ApiModel => Seq((name, m))
+ }
+
+ }
+}
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala
new file mode 100644
index 00000000000..0887fb0ba76
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala
@@ -0,0 +1,16 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ApiTokenStatus (
+ valid: Option[Boolean],
+ token: Option[String],
+ resetsInMillis: Option[Long],
+ remainingCalls: Option[Long],
+ expiresInMillis: Option[Long],
+ totalRequests: Option[Long])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala
new file mode 100644
index 00000000000..3b3e9186b69
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioFile.scala
@@ -0,0 +1,24 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class AudioFile (
+ attributionUrl: Option[String],
+ commentCount: Option[Int],
+ voteCount: Option[Int],
+ fileUrl: Option[String],
+ audioType: Option[String],
+ id: Option[Long],
+ duration: Option[Double],
+ attributionText: Option[String],
+ createdBy: Option[String],
+ description: Option[String],
+ createdAt: Option[DateTime],
+ voteWeightedAverage: Option[Float],
+ voteAverage: Option[Float],
+ word: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala
new file mode 100644
index 00000000000..be7d0a1d5ef
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AudioType.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class AudioType (
+ id: Option[Int],
+ name: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala
new file mode 100644
index 00000000000..981c7340d8e
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class AuthenticationToken (
+ token: Option[String],
+ userId: Option[Long],
+ userSignature: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala
new file mode 100644
index 00000000000..c0a567c4ff9
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Bigram.scala
@@ -0,0 +1,15 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Bigram (
+ count: Option[Long],
+ gram2: Option[String],
+ gram1: Option[String],
+ wlmi: Option[Double],
+ mi: Option[Double])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala
new file mode 100644
index 00000000000..af66bc14753
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Category.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Category (
+ id: Option[Long],
+ name: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala
new file mode 100644
index 00000000000..16f75961500
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Citation.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Citation (
+ cite: Option[String],
+ source: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala
new file mode 100644
index 00000000000..c7832871f7e
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ContentProvider.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ContentProvider (
+ id: Option[Int],
+ name: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala
new file mode 100644
index 00000000000..6274df1aa61
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Definition.scala
@@ -0,0 +1,26 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Definition (
+ extendedText: Option[String],
+ text: Option[String],
+ sourceDictionary: Option[String],
+ citations: Option[Seq[Citation]],
+ labels: Option[Seq[Label]],
+ score: Option[Float],
+ exampleUses: Option[Seq[ExampleUsage]],
+ attributionUrl: Option[String],
+ seqString: Option[String],
+ attributionText: Option[String],
+ relatedWords: Option[Seq[Related]],
+ sequence: Option[String],
+ word: Option[String],
+ notes: Option[Seq[Note]],
+ textProns: Option[Seq[TextPron]],
+ partOfSpeech: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala
new file mode 100644
index 00000000000..28d7d4e239b
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class DefinitionSearchResults (
+ results: Option[Seq[Definition]],
+ totalResults: Option[Int])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala
new file mode 100644
index 00000000000..0d4d52aec98
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Example.scala
@@ -0,0 +1,22 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Example (
+ id: Option[Long],
+ exampleId: Option[Long],
+ title: Option[String],
+ text: Option[String],
+ score: Option[ScoredWord],
+ sentence: Option[Sentence],
+ word: Option[String],
+ provider: Option[ContentProvider],
+ year: Option[Int],
+ rating: Option[Float],
+ documentId: Option[Long],
+ url: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala
new file mode 100644
index 00000000000..bd4494666da
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ExampleSearchResults (
+ facets: Option[Seq[Facet]],
+ examples: Option[Seq[Example]])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala
new file mode 100644
index 00000000000..377ee69f27a
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ExampleUsage (
+ text: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala
new file mode 100644
index 00000000000..80d28578b78
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Facet.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Facet (
+ facetValues: Option[Seq[FacetValue]],
+ name: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala
new file mode 100644
index 00000000000..8a6f5d78cbb
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FacetValue.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class FacetValue (
+ count: Option[Long],
+ value: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala
new file mode 100644
index 00000000000..58c29eb0b12
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Frequency.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Frequency (
+ count: Option[Long],
+ year: Option[Int])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala
new file mode 100644
index 00000000000..3eacadbde71
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala
@@ -0,0 +1,15 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class FrequencySummary (
+ unknownYearCount: Option[Int],
+ totalCount: Option[Long],
+ frequencyString: Option[String],
+ word: Option[String],
+ frequency: Option[Seq[Frequency]])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala
new file mode 100644
index 00000000000..5adba8e3276
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Label.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Label (
+ text: Option[String],
+ `type`: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala
new file mode 100644
index 00000000000..ff0d72524ed
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Note.scala
@@ -0,0 +1,14 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Note (
+ noteType: Option[String],
+ appliesTo: Option[Seq[String]],
+ value: Option[String],
+ pos: Option[Int])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala
new file mode 100644
index 00000000000..182a8974ff6
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class PartOfSpeech (
+ roots: Option[Seq[Root]],
+ storageAbbr: Option[Seq[String]],
+ allCategories: Option[Seq[Category]])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala
new file mode 100644
index 00000000000..5fdd347cb33
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Related.scala
@@ -0,0 +1,17 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Related (
+ label1: Option[String],
+ relationshipType: Option[String],
+ label2: Option[String],
+ label3: Option[String],
+ words: Option[Seq[String]],
+ gram: Option[String],
+ label4: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala
new file mode 100644
index 00000000000..ee134f80340
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Root.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Root (
+ id: Option[Long],
+ name: Option[String],
+ categories: Option[Seq[Category]])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala
new file mode 100644
index 00000000000..7c7b7e9b5ab
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/ScoredWord.scala
@@ -0,0 +1,21 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ScoredWord (
+ position: Option[Int],
+ id: Option[Long],
+ docTermCount: Option[Int],
+ lemma: Option[String],
+ wordType: Option[String],
+ score: Option[Float],
+ sentenceId: Option[Long],
+ word: Option[String],
+ stopword: Option[Boolean],
+ baseWordScore: Option[Double],
+ partOfSpeech: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala
new file mode 100644
index 00000000000..99f7f0400af
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Sentence.scala
@@ -0,0 +1,16 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Sentence (
+ hasScoredWords: Option[Boolean],
+ id: Option[Long],
+ scoredWords: Option[Seq[ScoredWord]],
+ display: Option[String],
+ rating: Option[Int],
+ documentMetadataId: Option[Long])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala
new file mode 100644
index 00000000000..1807123222c
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala
@@ -0,0 +1,14 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class SimpleDefinition (
+ text: Option[String],
+ source: Option[String],
+ note: Option[String],
+ partOfSpeech: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala
new file mode 100644
index 00000000000..4548c2ece38
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/SimpleExample.scala
@@ -0,0 +1,14 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class SimpleExample (
+ id: Option[Long],
+ title: Option[String],
+ text: Option[String],
+ url: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala
new file mode 100644
index 00000000000..bb36fabef8e
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/StringValue.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class StringValue (
+ word: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala
new file mode 100644
index 00000000000..0db80cb840f
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/Syllable.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class Syllable (
+ text: Option[String],
+ seq: Option[Int],
+ `type`: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala
new file mode 100644
index 00000000000..95d17c14fcf
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/TextPron.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class TextPron (
+ raw: Option[String],
+ seq: Option[Int],
+ rawType: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala
new file mode 100644
index 00000000000..421c8f3210b
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/User.scala
@@ -0,0 +1,18 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class User (
+ id: Option[Long],
+ username: Option[String],
+ email: Option[String],
+ status: Option[Int],
+ faceBookId: Option[String],
+ userName: Option[String],
+ displayName: Option[String],
+ password: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala
new file mode 100644
index 00000000000..c46484d5978
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordList.scala
@@ -0,0 +1,21 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordList (
+ id: Option[Long],
+ permalink: Option[String],
+ name: Option[String],
+ createdAt: Option[DateTime],
+ updatedAt: Option[DateTime],
+ lastActivityAt: Option[DateTime],
+ username: Option[String],
+ userId: Option[Long],
+ description: Option[String],
+ numberWordsInList: Option[Long],
+ `type`: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala
new file mode 100644
index 00000000000..062f1fe6a6b
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordListWord.scala
@@ -0,0 +1,17 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordListWord (
+ id: Option[Long],
+ word: Option[String],
+ username: Option[String],
+ userId: Option[Long],
+ createdAt: Option[DateTime],
+ numberCommentsOnWord: Option[Long],
+ numberLists: Option[Long])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala
new file mode 100644
index 00000000000..5f5c1c6a426
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordObject.scala
@@ -0,0 +1,16 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordObject (
+ id: Option[Long],
+ word: Option[String],
+ originalWord: Option[String],
+ suggestions: Option[Seq[String]],
+ canonicalForm: Option[String],
+ vulgar: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala
new file mode 100644
index 00000000000..6b94e34d211
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala
@@ -0,0 +1,22 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordOfTheDay (
+ id: Option[Long],
+ parentId: Option[String],
+ category: Option[String],
+ createdBy: Option[String],
+ createdAt: Option[DateTime],
+ contentProvider: Option[ContentProvider],
+ htmlExtra: Option[String],
+ word: Option[String],
+ definitions: Option[Seq[SimpleDefinition]],
+ examples: Option[Seq[SimpleExample]],
+ note: Option[String],
+ publishDate: Option[DateTime])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala
new file mode 100644
index 00000000000..771fd35b2e8
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordSearchResult (
+ count: Option[Long],
+ lexicality: Option[Double],
+ word: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala
new file mode 100644
index 00000000000..bc2af2a8448
--- /dev/null
+++ b/samples/client/wordnik/akka-scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class WordSearchResults (
+ searchResults: Option[Seq[WordSearchResult]],
+ totalResults: Option[Int])
+ extends ApiModel
+
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/ApiInvoker.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
new file mode 100644
index 00000000000..f4b25de8306
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
@@ -0,0 +1,195 @@
+package io.swagger.client
+
+import com.sun.jersey.api.client.Client
+import com.sun.jersey.api.client.ClientResponse
+import com.sun.jersey.api.client.config.ClientConfig
+import com.sun.jersey.api.client.config.DefaultClientConfig
+import com.sun.jersey.api.client.filter.LoggingFilter
+
+import com.sun.jersey.multipart.FormDataMultiPart
+import com.sun.jersey.multipart.file.FileDataBodyPart
+
+import java.io.File
+import java.net.URLEncoder
+import javax.ws.rs.core.MediaType
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.HashMap
+
+import com.fasterxml.jackson.module.scala.DefaultScalaModule
+import com.fasterxml.jackson.datatype.joda.JodaModule
+import com.fasterxml.jackson.core.JsonGenerator.Feature
+import com.fasterxml.jackson.databind._
+import com.fasterxml.jackson.annotation._
+import com.fasterxml.jackson.databind.annotation.JsonSerialize
+
+object ScalaJsonUtil {
+ def getJsonMapper = {
+ val mapper = new ObjectMapper()
+ mapper.registerModule(new DefaultScalaModule())
+ mapper.registerModule(new JodaModule());
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
+ mapper
+ }
+}
+
+class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
+ httpHeaders: HashMap[String, String] = HashMap(),
+ hostMap: HashMap[String, Client] = HashMap(),
+ asyncHttpClient: Boolean = false,
+ authScheme: String = "",
+ authPreemptive: Boolean = false) {
+
+ var defaultHeaders: HashMap[String, String] = httpHeaders
+
+ def escape(value: String): String = {
+ URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
+ }
+
+ def escape(value: Long): String = value.toString
+ def escape(value: Double): String = value.toString
+ def escape(value: Float): String = value.toString
+
+ def deserialize(json: String, containerType: String, cls: Class[_]) = {
+ if (cls == classOf[String]) {
+ json match {
+ case s: String => {
+ if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2)
+ else s
+ }
+ case _ => null
+ }
+ } else {
+ containerType.toLowerCase match {
+ case "array" => {
+ val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
+ val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
+ response.asScala.toList
+ }
+ case "list" => {
+ val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
+ val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
+ response.asScala.toList
+ }
+ case _ => {
+ json match {
+ case e: String if ("\"\"" == e) => null
+ case _ => mapper.readValue(json, cls)
+ }
+ }
+ }
+ }
+ }
+
+ def serialize(obj: AnyRef): String = {
+ if (obj != null) {
+ obj match {
+ case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
+ case _ => mapper.writeValueAsString(obj)
+ }
+ } else null
+ }
+
+ def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], body: AnyRef, headerParams: Map[String, String], contentType: String): String = {
+ val client = getClient(host)
+
+ val querystring = queryParams.filter(k => k._2 != null).map(k => (escape(k._1) + "=" + escape(k._2))).mkString("?", "&", "")
+ val builder = client.resource(host + path + querystring).accept(contentType)
+ headerParams.map(p => builder.header(p._1, p._2))
+ defaultHeaders.map(p => {
+ headerParams.contains(p._1) match {
+ case true => // override default with supplied header
+ case false => if (p._2 != null) builder.header(p._1, p._2)
+ }
+ })
+
+ val response: ClientResponse = method match {
+ case "GET" => {
+ builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
+ }
+ case "POST" => {
+ if(body != null && body.isInstanceOf[File]) {
+ val file = body.asInstanceOf[File]
+ val form = new FormDataMultiPart()
+ form.field("filename", file.getName())
+ form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
+ builder.post(classOf[ClientResponse], form)
+ }
+ else {
+ if(body == null) builder.post(classOf[ClientResponse], serialize(body))
+ else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
+ }
+ }
+ case "PUT" => {
+ if(body == null) builder.put(classOf[ClientResponse], null)
+ else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
+ }
+ case "DELETE" => {
+ builder.delete(classOf[ClientResponse])
+ }
+ case _ => null
+ }
+ response.getClientResponseStatus().getStatusCode() match {
+ case 204 => ""
+ case code: Int if (Range(200, 299).contains(code)) => {
+ response.hasEntity() match {
+ case true => response.getEntity(classOf[String])
+ case false => ""
+ }
+ }
+ case _ => {
+ val entity = response.hasEntity() match {
+ case true => response.getEntity(classOf[String])
+ case false => "no data"
+ }
+ throw new ApiException(
+ response.getClientResponseStatus().getStatusCode(),
+ entity)
+ }
+ }
+ }
+
+ def getClient(host: String): Client = {
+ hostMap.contains(host) match {
+ case true => hostMap(host)
+ case false => {
+ val client = newClient(host)
+ // client.addFilter(new LoggingFilter())
+ hostMap += host -> client
+ client
+ }
+ }
+ }
+
+ def newClient(host: String): Client = asyncHttpClient match {
+ case true => {
+ import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
+ import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
+ import com.ning.http.client.Realm
+
+ val config: DefaultAhcConfig = new DefaultAhcConfig()
+ if (!authScheme.isEmpty) {
+ val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
+ config.getAsyncHttpClientConfigBuilder
+ .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
+ .setUsePreemptiveAuth(authPreemptive).build)
+ }
+ AhcHttpClient.create(config)
+ }
+ case _ => Client.create()
+ }
+}
+
+object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper,
+ httpHeaders = HashMap(),
+ hostMap = HashMap(),
+ asyncHttpClient = false,
+ authScheme = "",
+ authPreemptive = false)
+
+class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/AccountApi.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/AccountApi.scala
new file mode 100644
index 00000000000..3203f846f27
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/AccountApi.scala
@@ -0,0 +1,201 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.ApiTokenStatus
+import io.swagger.client.model.AuthenticationToken
+import io.swagger.client.model.User
+import io.swagger.client.model.WordList
+import io.swagger.client.ApiInvoker
+import io.swagger.client.ApiException
+
+import java.io.File
+import java.util.Date
+
+import scala.collection.mutable.HashMap
+
+class AccountApi(val defBasePath: String = "https://api.wordnik.com/v4",
+ defApiInvoker: ApiInvoker = ApiInvoker) {
+ var basePath = defBasePath
+ var apiInvoker = defApiInvoker
+
+ def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
+
+
+ def getApiTokenStatus (api_key: String) : Option[ApiTokenStatus] = {
+ // create path and map variables
+ val path = "/account.json/apiTokenStatus".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "api_key" -> api_key
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[ApiTokenStatus]).asInstanceOf[ApiTokenStatus])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def authenticate (username: String, password: String) : Option[AuthenticationToken] = {
+ // create path and map variables
+ val path = "/account.json/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(password) != "null") queryParams += "password" -> password.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[AuthenticationToken]).asInstanceOf[AuthenticationToken])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def authenticatePost (username: String, body: String) : Option[AuthenticationToken] = {
+ // create path and map variables
+ val path = "/account.json/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
+
+
+
+
+ val contentType = {
+ if(body != null && body.isInstanceOf[File] )
+ "multipart/form-data"
+ else "application/json"
+
+
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[AuthenticationToken]).asInstanceOf[AuthenticationToken])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getLoggedInUser (auth_token: String) : Option[User] = {
+ // create path and map variables
+ val path = "/account.json/user".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[User]).asInstanceOf[User])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getWordListsForLoggedInUser (auth_token: String, skip: Integer, limit: Integer) : Option[List[WordList]] = {
+ // create path and map variables
+ val path = "/account.json/wordLists".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "array", classOf[WordList]).asInstanceOf[List[WordList]])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+}
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordApi.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordApi.scala
new file mode 100644
index 00000000000..b6f076a4b43
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordApi.scala
@@ -0,0 +1,438 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordObject
+import io.swagger.client.model.AudioFile
+import io.swagger.client.model.Definition
+import io.swagger.client.model.FrequencySummary
+import io.swagger.client.model.Bigram
+import io.swagger.client.model.Example
+import io.swagger.client.ApiInvoker
+import io.swagger.client.ApiException
+
+import java.io.File
+import java.util.Date
+
+import scala.collection.mutable.HashMap
+
+class WordApi(val defBasePath: String = "https://api.wordnik.com/v4",
+ defApiInvoker: ApiInvoker = ApiInvoker) {
+ var basePath = defBasePath
+ var apiInvoker = defApiInvoker
+
+ def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
+
+
+ def getWord (word: String, useCanonical: String, includeSuggestions: String) : Option[WordObject] = {
+ // create path and map variables
+ val path = "/word.json/{word}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(includeSuggestions) != "null") queryParams += "includeSuggestions" -> includeSuggestions.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordObject]).asInstanceOf[WordObject])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getAudio (word: String, useCanonical: String, limit: Integer) : Option[List[AudioFile]] = {
+ // create path and map variables
+ val path = "/word.json/{word}/audio".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "array", classOf[AudioFile]).asInstanceOf[List[AudioFile]])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getDefinitions (word: String, limit: Integer, partOfSpeech: String, includeRelated: String, sourceDictionaries: List[String], useCanonical: String, includeTags: String) : Option[List[Definition]] = {
+ // create path and map variables
+ val path = "/word.json/{word}/definitions".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+ if(String.valueOf(partOfSpeech) != "null") queryParams += "partOfSpeech" -> partOfSpeech.toString
+ if(String.valueOf(includeRelated) != "null") queryParams += "includeRelated" -> includeRelated.toString
+ if(String.valueOf(sourceDictionaries) != "null") queryParams += "sourceDictionaries" -> sourceDictionaries.toString
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(includeTags) != "null") queryParams += "includeTags" -> includeTags.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "array", classOf[Definition]).asInstanceOf[List[Definition]])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getEtymologies (word: String, useCanonical: String) : Option[List[String]] = {
+ // create path and map variables
+ val path = "/word.json/{word}/etymologies".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "array", classOf[String]).asInstanceOf[List[String]])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getExamples (word: String, includeDuplicates: String, useCanonical: String, skip: Integer, limit: Integer) = {
+ // create path and map variables
+ val path = "/word.json/{word}/examples".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(includeDuplicates) != "null") queryParams += "includeDuplicates" -> includeDuplicates.toString
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getWordFrequency (word: String, useCanonical: String, startYear: Integer, endYear: Integer) : Option[FrequencySummary] = {
+ // create path and map variables
+ val path = "/word.json/{word}/frequency".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(startYear) != "null") queryParams += "startYear" -> startYear.toString
+ if(String.valueOf(endYear) != "null") queryParams += "endYear" -> endYear.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[FrequencySummary]).asInstanceOf[FrequencySummary])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getHyphenation (word: String, useCanonical: String, sourceDictionary: String, limit: Integer) = {
+ // create path and map variables
+ val path = "/word.json/{word}/hyphenation".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(sourceDictionary) != "null") queryParams += "sourceDictionary" -> sourceDictionary.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getPhrases (word: String, limit: Integer, wlmi: Integer, useCanonical: String) : Option[List[Bigram]] = {
+ // create path and map variables
+ val path = "/word.json/{word}/phrases".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+ if(String.valueOf(wlmi) != "null") queryParams += "wlmi" -> wlmi.toString
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "array", classOf[Bigram]).asInstanceOf[List[Bigram]])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getTextPronunciations (word: String, useCanonical: String, sourceDictionary: String, typeFormat: String, limit: Integer) = {
+ // create path and map variables
+ val path = "/word.json/{word}/pronunciations".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(sourceDictionary) != "null") queryParams += "sourceDictionary" -> sourceDictionary.toString
+ if(String.valueOf(typeFormat) != "null") queryParams += "typeFormat" -> typeFormat.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getRelatedWords (word: String, useCanonical: String, relationshipTypes: String, limitPerRelationshipType: Integer) = {
+ // create path and map variables
+ val path = "/word.json/{word}/relatedWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+ if(String.valueOf(relationshipTypes) != "null") queryParams += "relationshipTypes" -> relationshipTypes.toString
+ if(String.valueOf(limitPerRelationshipType) != "null") queryParams += "limitPerRelationshipType" -> limitPerRelationshipType.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getTopExample (word: String, useCanonical: String) : Option[Example] = {
+ // create path and map variables
+ val path = "/word.json/{word}/topExample".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[Example]).asInstanceOf[Example])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+}
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListApi.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListApi.scala
new file mode 100644
index 00000000000..958bc234ab3
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListApi.scala
@@ -0,0 +1,245 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordList
+import io.swagger.client.model.StringValue
+import io.swagger.client.ApiInvoker
+import io.swagger.client.ApiException
+
+import java.io.File
+import java.util.Date
+
+import scala.collection.mutable.HashMap
+
+class WordListApi(val defBasePath: String = "https://api.wordnik.com/v4",
+ defApiInvoker: ApiInvoker = ApiInvoker) {
+ var basePath = defBasePath
+ var apiInvoker = defApiInvoker
+
+ def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
+
+
+ def getWordListByPermalink (permalink: String, auth_token: String) : Option[WordList] = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordList]).asInstanceOf[WordList])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def updateWordList (permalink: String, body: WordList, auth_token: String) = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+ if(body != null && body.isInstanceOf[File] )
+ "multipart/form-data"
+ else "application/json"
+
+
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, body, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def deleteWordList (permalink: String, auth_token: String) = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def deleteWordsFromWordList (permalink: String, body: List[StringValue], auth_token: String) = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}/deleteWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+ if(body != null && body.isInstanceOf[File] )
+ "multipart/form-data"
+ else "application/json"
+
+
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getWordListWords (permalink: String, sortBy: String, sortOrder: String, skip: Integer, limit: Integer, auth_token: String) = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(sortBy) != "null") queryParams += "sortBy" -> sortBy.toString
+ if(String.valueOf(sortOrder) != "null") queryParams += "sortOrder" -> sortOrder.toString
+ if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def addWordsToWordList (permalink: String, body: List[StringValue], auth_token: String) = {
+ // create path and map variables
+ val path = "/wordList.json/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
+
+
+
+
+ val contentType = {
+ if(body != null && body.isInstanceOf[File] )
+ "multipart/form-data"
+ else "application/json"
+
+
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+}
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListsApi.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListsApi.scala
new file mode 100644
index 00000000000..805f62d4be7
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordListsApi.scala
@@ -0,0 +1,57 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordList
+import io.swagger.client.ApiInvoker
+import io.swagger.client.ApiException
+
+import java.io.File
+import java.util.Date
+
+import scala.collection.mutable.HashMap
+
+class WordListsApi(val defBasePath: String = "https://api.wordnik.com/v4",
+ defApiInvoker: ApiInvoker = ApiInvoker) {
+ var basePath = defBasePath
+ var apiInvoker = defApiInvoker
+
+ def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
+
+
+ def createWordList (body: WordList, auth_token: String) : Option[WordList] = {
+ // create path and map variables
+ val path = "/wordLists.json".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+ if(body != null && body.isInstanceOf[File] )
+ "multipart/form-data"
+ else "application/json"
+
+
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+
+
+ headerParams += "auth_token" -> auth_token
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordList]).asInstanceOf[WordList])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+}
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordsApi.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordsApi.scala
new file mode 100644
index 00000000000..6613abb7589
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/api/WordsApi.scala
@@ -0,0 +1,238 @@
+package io.swagger.client.api
+
+import io.swagger.client.model.WordObject
+import io.swagger.client.model.DefinitionSearchResults
+import io.swagger.client.model.WordSearchResults
+import io.swagger.client.model.WordOfTheDay
+import io.swagger.client.ApiInvoker
+import io.swagger.client.ApiException
+
+import java.io.File
+import java.util.Date
+
+import scala.collection.mutable.HashMap
+
+class WordsApi(val defBasePath: String = "https://api.wordnik.com/v4",
+ defApiInvoker: ApiInvoker = ApiInvoker) {
+ var basePath = defBasePath
+ var apiInvoker = defApiInvoker
+
+ def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
+
+
+ def getRandomWord (hasDictionaryDef: String, includePartOfSpeech: String, excludePartOfSpeech: String, minCorpusCount: Integer, maxCorpusCount: Integer, minDictionaryCount: Integer, maxDictionaryCount: Integer, minLength: Integer, maxLength: Integer) : Option[WordObject] = {
+ // create path and map variables
+ val path = "/words.json/randomWord".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(hasDictionaryDef) != "null") queryParams += "hasDictionaryDef" -> hasDictionaryDef.toString
+ if(String.valueOf(includePartOfSpeech) != "null") queryParams += "includePartOfSpeech" -> includePartOfSpeech.toString
+ if(String.valueOf(excludePartOfSpeech) != "null") queryParams += "excludePartOfSpeech" -> excludePartOfSpeech.toString
+ if(String.valueOf(minCorpusCount) != "null") queryParams += "minCorpusCount" -> minCorpusCount.toString
+ if(String.valueOf(maxCorpusCount) != "null") queryParams += "maxCorpusCount" -> maxCorpusCount.toString
+ if(String.valueOf(minDictionaryCount) != "null") queryParams += "minDictionaryCount" -> minDictionaryCount.toString
+ if(String.valueOf(maxDictionaryCount) != "null") queryParams += "maxDictionaryCount" -> maxDictionaryCount.toString
+ if(String.valueOf(minLength) != "null") queryParams += "minLength" -> minLength.toString
+ if(String.valueOf(maxLength) != "null") queryParams += "maxLength" -> maxLength.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordObject]).asInstanceOf[WordObject])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getRandomWords (hasDictionaryDef: String, includePartOfSpeech: String, excludePartOfSpeech: String, minCorpusCount: Integer, maxCorpusCount: Integer, minDictionaryCount: Integer, maxDictionaryCount: Integer, minLength: Integer, maxLength: Integer, sortBy: String, sortOrder: String, limit: Integer) = {
+ // create path and map variables
+ val path = "/words.json/randomWords".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(hasDictionaryDef) != "null") queryParams += "hasDictionaryDef" -> hasDictionaryDef.toString
+ if(String.valueOf(includePartOfSpeech) != "null") queryParams += "includePartOfSpeech" -> includePartOfSpeech.toString
+ if(String.valueOf(excludePartOfSpeech) != "null") queryParams += "excludePartOfSpeech" -> excludePartOfSpeech.toString
+ if(String.valueOf(minCorpusCount) != "null") queryParams += "minCorpusCount" -> minCorpusCount.toString
+ if(String.valueOf(maxCorpusCount) != "null") queryParams += "maxCorpusCount" -> maxCorpusCount.toString
+ if(String.valueOf(minDictionaryCount) != "null") queryParams += "minDictionaryCount" -> minDictionaryCount.toString
+ if(String.valueOf(maxDictionaryCount) != "null") queryParams += "maxDictionaryCount" -> maxDictionaryCount.toString
+ if(String.valueOf(minLength) != "null") queryParams += "minLength" -> minLength.toString
+ if(String.valueOf(maxLength) != "null") queryParams += "maxLength" -> maxLength.toString
+ if(String.valueOf(sortBy) != "null") queryParams += "sortBy" -> sortBy.toString
+ if(String.valueOf(sortOrder) != "null") queryParams += "sortOrder" -> sortOrder.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def reverseDictionary (query: String, findSenseForWord: String, includeSourceDictionaries: String, excludeSourceDictionaries: String, includePartOfSpeech: String, excludePartOfSpeech: String, minCorpusCount: Integer, maxCorpusCount: Integer, minLength: Integer, maxLength: Integer, expandTerms: String, includeTags: String, sortBy: String, sortOrder: String, skip: String, limit: Integer) : Option[DefinitionSearchResults] = {
+ // create path and map variables
+ val path = "/words.json/reverseDictionary".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(query) != "null") queryParams += "query" -> query.toString
+ if(String.valueOf(findSenseForWord) != "null") queryParams += "findSenseForWord" -> findSenseForWord.toString
+ if(String.valueOf(includeSourceDictionaries) != "null") queryParams += "includeSourceDictionaries" -> includeSourceDictionaries.toString
+ if(String.valueOf(excludeSourceDictionaries) != "null") queryParams += "excludeSourceDictionaries" -> excludeSourceDictionaries.toString
+ if(String.valueOf(includePartOfSpeech) != "null") queryParams += "includePartOfSpeech" -> includePartOfSpeech.toString
+ if(String.valueOf(excludePartOfSpeech) != "null") queryParams += "excludePartOfSpeech" -> excludePartOfSpeech.toString
+ if(String.valueOf(minCorpusCount) != "null") queryParams += "minCorpusCount" -> minCorpusCount.toString
+ if(String.valueOf(maxCorpusCount) != "null") queryParams += "maxCorpusCount" -> maxCorpusCount.toString
+ if(String.valueOf(minLength) != "null") queryParams += "minLength" -> minLength.toString
+ if(String.valueOf(maxLength) != "null") queryParams += "maxLength" -> maxLength.toString
+ if(String.valueOf(expandTerms) != "null") queryParams += "expandTerms" -> expandTerms.toString
+ if(String.valueOf(includeTags) != "null") queryParams += "includeTags" -> includeTags.toString
+ if(String.valueOf(sortBy) != "null") queryParams += "sortBy" -> sortBy.toString
+ if(String.valueOf(sortOrder) != "null") queryParams += "sortOrder" -> sortOrder.toString
+ if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[DefinitionSearchResults]).asInstanceOf[DefinitionSearchResults])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def searchWords (query: String, caseSensitive: String, includePartOfSpeech: String, excludePartOfSpeech: String, minCorpusCount: Integer, maxCorpusCount: Integer, minDictionaryCount: Integer, maxDictionaryCount: Integer, minLength: Integer, maxLength: Integer, skip: Integer, limit: Integer) : Option[WordSearchResults] = {
+ // create path and map variables
+ val path = "/words.json/search/{query}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "query" + "\\}",apiInvoker.escape(query))
+
+
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(caseSensitive) != "null") queryParams += "caseSensitive" -> caseSensitive.toString
+ if(String.valueOf(includePartOfSpeech) != "null") queryParams += "includePartOfSpeech" -> includePartOfSpeech.toString
+ if(String.valueOf(excludePartOfSpeech) != "null") queryParams += "excludePartOfSpeech" -> excludePartOfSpeech.toString
+ if(String.valueOf(minCorpusCount) != "null") queryParams += "minCorpusCount" -> minCorpusCount.toString
+ if(String.valueOf(maxCorpusCount) != "null") queryParams += "maxCorpusCount" -> maxCorpusCount.toString
+ if(String.valueOf(minDictionaryCount) != "null") queryParams += "minDictionaryCount" -> minDictionaryCount.toString
+ if(String.valueOf(maxDictionaryCount) != "null") queryParams += "maxDictionaryCount" -> maxDictionaryCount.toString
+ if(String.valueOf(minLength) != "null") queryParams += "minLength" -> minLength.toString
+ if(String.valueOf(maxLength) != "null") queryParams += "maxLength" -> maxLength.toString
+ if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
+ if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordSearchResults]).asInstanceOf[WordSearchResults])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+ def getWordOfTheDay (date: String) : Option[WordOfTheDay] = {
+ // create path and map variables
+ val path = "/words.json/wordOfTheDay".replaceAll("\\{format\\}","json")
+
+
+ val contentType = {
+
+ "application/json"
+ }
+
+ // query params
+ val queryParams = new HashMap[String, String]
+ val headerParams = new HashMap[String, String]
+
+
+
+ if(String.valueOf(date) != "null") queryParams += "date" -> date.toString
+
+
+
+
+ try {
+ apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
+ case s: String =>
+ Some(ApiInvoker.deserialize(s, "", classOf[WordOfTheDay]).asInstanceOf[WordOfTheDay])
+
+ case _ => None
+ }
+ } catch {
+ case ex: ApiException if ex.code == 404 => None
+ case ex: ApiException => throw ex
+ }
+ }
+
+}
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala
new file mode 100644
index 00000000000..9ec5f7cec64
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ApiTokenStatus.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+
+
+
+case class ApiTokenStatus (
+ valid: Boolean,
+ token: String,
+ resetsInMillis: Long,
+ remainingCalls: Long,
+ expiresInMillis: Long,
+ totalRequests: Long)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioFile.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioFile.scala
new file mode 100644
index 00000000000..6a8355c2078
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioFile.scala
@@ -0,0 +1,22 @@
+package io.swagger.client.model
+
+import org.joda.time.DateTime
+
+
+
+case class AudioFile (
+ attributionUrl: String,
+ commentCount: Integer,
+ voteCount: Integer,
+ fileUrl: String,
+ audioType: String,
+ id: Long,
+ duration: Double,
+ attributionText: String,
+ createdBy: String,
+ description: String,
+ createdAt: DateTime,
+ voteWeightedAverage: Float,
+ voteAverage: Float,
+ word: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioType.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioType.scala
new file mode 100644
index 00000000000..1a4e310481a
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AudioType.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class AudioType (
+ id: Integer,
+ name: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala
new file mode 100644
index 00000000000..80d13cc41a5
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/AuthenticationToken.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+
+
+
+case class AuthenticationToken (
+ token: String,
+ userId: Long,
+ userSignature: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Bigram.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Bigram.scala
new file mode 100644
index 00000000000..0ecde0290ef
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Bigram.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+
+
+
+case class Bigram (
+ count: Long,
+ gram2: String,
+ gram1: String,
+ wlmi: Double,
+ mi: Double)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Category.scala
new file mode 100644
index 00000000000..122411e3ff7
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Category.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class Category (
+ id: Long,
+ name: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Citation.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Citation.scala
new file mode 100644
index 00000000000..a8192a80822
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Citation.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class Citation (
+ cite: String,
+ source: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ContentProvider.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ContentProvider.scala
new file mode 100644
index 00000000000..8638e5ae204
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ContentProvider.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class ContentProvider (
+ id: Integer,
+ name: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Definition.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Definition.scala
new file mode 100644
index 00000000000..a4e323ddb29
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Definition.scala
@@ -0,0 +1,29 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.ExampleUsage
+import io.swagger.client.model.Note
+import io.swagger.client.model.Label
+import io.swagger.client.model.Related
+import io.swagger.client.model.Citation
+import io.swagger.client.model.TextPron
+
+
+
+case class Definition (
+ extendedText: String,
+ text: String,
+ sourceDictionary: String,
+ citations: List[Citation],
+ labels: List[Label],
+ score: Float,
+ exampleUses: List[ExampleUsage],
+ attributionUrl: String,
+ seqString: String,
+ attributionText: String,
+ relatedWords: List[Related],
+ sequence: String,
+ word: String,
+ notes: List[Note],
+ textProns: List[TextPron],
+ partOfSpeech: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala
new file mode 100644
index 00000000000..bf7c430ff10
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/DefinitionSearchResults.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Definition
+
+
+
+case class DefinitionSearchResults (
+ results: List[Definition],
+ totalResults: Integer)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Example.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Example.scala
new file mode 100644
index 00000000000..7f9544ad5b4
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Example.scala
@@ -0,0 +1,22 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Sentence
+import io.swagger.client.model.ContentProvider
+import io.swagger.client.model.ScoredWord
+
+
+
+case class Example (
+ id: Long,
+ exampleId: Long,
+ title: String,
+ text: String,
+ score: ScoredWord,
+ sentence: Sentence,
+ word: String,
+ provider: ContentProvider,
+ year: Integer,
+ rating: Float,
+ documentId: Long,
+ url: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala
new file mode 100644
index 00000000000..8d33a90020d
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleSearchResults.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Example
+import io.swagger.client.model.Facet
+
+
+
+case class ExampleSearchResults (
+ facets: List[Facet],
+ examples: List[Example])
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala
new file mode 100644
index 00000000000..4e54562515c
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ExampleUsage.scala
@@ -0,0 +1,8 @@
+package io.swagger.client.model
+
+
+
+
+case class ExampleUsage (
+ text: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Facet.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Facet.scala
new file mode 100644
index 00000000000..4bea80d58ff
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Facet.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.FacetValue
+
+
+
+case class Facet (
+ facetValues: List[FacetValue],
+ name: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FacetValue.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FacetValue.scala
new file mode 100644
index 00000000000..21ec01a8332
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FacetValue.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class FacetValue (
+ count: Long,
+ value: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Frequency.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Frequency.scala
new file mode 100644
index 00000000000..ac1d92e4507
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Frequency.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class Frequency (
+ count: Long,
+ year: Integer)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala
new file mode 100644
index 00000000000..15c4b15ac12
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/FrequencySummary.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Frequency
+
+
+
+case class FrequencySummary (
+ unknownYearCount: Integer,
+ totalCount: Long,
+ frequencyString: String,
+ word: String,
+ frequency: List[Frequency])
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Label.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Label.scala
new file mode 100644
index 00000000000..73644b338f2
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Label.scala
@@ -0,0 +1,9 @@
+package io.swagger.client.model
+
+
+
+
+case class Label (
+ text: String,
+ _type: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Note.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Note.scala
new file mode 100644
index 00000000000..c5424025d3b
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Note.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+
+
+
+case class Note (
+ noteType: String,
+ appliesTo: List[String],
+ value: String,
+ pos: Integer)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala
new file mode 100644
index 00000000000..74d1fa926d7
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/PartOfSpeech.scala
@@ -0,0 +1,12 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Category
+import io.swagger.client.model.Root
+
+
+
+case class PartOfSpeech (
+ roots: List[Root],
+ storageAbbr: List[String],
+ allCategories: List[Category])
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Related.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Related.scala
new file mode 100644
index 00000000000..0207dc96b16
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Related.scala
@@ -0,0 +1,14 @@
+package io.swagger.client.model
+
+
+
+
+case class Related (
+ label1: String,
+ relationshipType: String,
+ label2: String,
+ label3: String,
+ words: List[String],
+ gram: String,
+ label4: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Root.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Root.scala
new file mode 100644
index 00000000000..9210af25f4d
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Root.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.Category
+
+
+
+case class Root (
+ id: Long,
+ name: String,
+ categories: List[Category])
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ScoredWord.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ScoredWord.scala
new file mode 100644
index 00000000000..f74fcba41f7
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/ScoredWord.scala
@@ -0,0 +1,18 @@
+package io.swagger.client.model
+
+
+
+
+case class ScoredWord (
+ position: Integer,
+ id: Long,
+ docTermCount: Integer,
+ lemma: String,
+ wordType: String,
+ score: Float,
+ sentenceId: Long,
+ word: String,
+ stopword: Boolean,
+ baseWordScore: Double,
+ partOfSpeech: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Sentence.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Sentence.scala
new file mode 100644
index 00000000000..04319cd6029
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Sentence.scala
@@ -0,0 +1,14 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.ScoredWord
+
+
+
+case class Sentence (
+ hasScoredWords: Boolean,
+ id: Long,
+ scoredWords: List[ScoredWord],
+ display: String,
+ rating: Integer,
+ documentMetadataId: Long)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala
new file mode 100644
index 00000000000..1071880411c
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleDefinition.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+
+
+
+case class SimpleDefinition (
+ text: String,
+ source: String,
+ note: String,
+ partOfSpeech: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleExample.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleExample.scala
new file mode 100644
index 00000000000..61e9154acfb
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/SimpleExample.scala
@@ -0,0 +1,11 @@
+package io.swagger.client.model
+
+
+
+
+case class SimpleExample (
+ id: Long,
+ title: String,
+ text: String,
+ url: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/StringValue.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/StringValue.scala
new file mode 100644
index 00000000000..1ff8087c817
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/StringValue.scala
@@ -0,0 +1,8 @@
+package io.swagger.client.model
+
+
+
+
+case class StringValue (
+ word: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Syllable.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Syllable.scala
new file mode 100644
index 00000000000..04ca0f802ab
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/Syllable.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+
+
+
+case class Syllable (
+ text: String,
+ seq: Integer,
+ _type: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/TextPron.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/TextPron.scala
new file mode 100644
index 00000000000..582e62b5aa1
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/TextPron.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+
+
+
+case class TextPron (
+ raw: String,
+ seq: Integer,
+ rawType: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/User.scala
new file mode 100644
index 00000000000..4651b6eee71
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/User.scala
@@ -0,0 +1,15 @@
+package io.swagger.client.model
+
+
+
+
+case class User (
+ id: Long,
+ username: String,
+ email: String,
+ status: Integer,
+ faceBookId: String,
+ userName: String,
+ displayName: String,
+ password: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordList.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordList.scala
new file mode 100644
index 00000000000..b37ae05661a
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordList.scala
@@ -0,0 +1,19 @@
+package io.swagger.client.model
+
+import org.joda.time.DateTime
+
+
+
+case class WordList (
+ id: Long,
+ permalink: String,
+ name: String,
+ createdAt: DateTime,
+ updatedAt: DateTime,
+ lastActivityAt: DateTime,
+ username: String,
+ userId: Long,
+ description: String,
+ numberWordsInList: Long,
+ _type: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordListWord.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordListWord.scala
new file mode 100644
index 00000000000..a28fdd0f181
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordListWord.scala
@@ -0,0 +1,15 @@
+package io.swagger.client.model
+
+import org.joda.time.DateTime
+
+
+
+case class WordListWord (
+ id: Long,
+ word: String,
+ username: String,
+ userId: Long,
+ createdAt: DateTime,
+ numberCommentsOnWord: Long,
+ numberLists: Long)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordObject.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordObject.scala
new file mode 100644
index 00000000000..5d3d3a44d7b
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordObject.scala
@@ -0,0 +1,13 @@
+package io.swagger.client.model
+
+
+
+
+case class WordObject (
+ id: Long,
+ word: String,
+ originalWord: String,
+ suggestions: List[String],
+ canonicalForm: String,
+ vulgar: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala
new file mode 100644
index 00000000000..b41e1afc286
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordOfTheDay.scala
@@ -0,0 +1,23 @@
+package io.swagger.client.model
+
+import org.joda.time.DateTime
+import io.swagger.client.model.SimpleDefinition
+import io.swagger.client.model.ContentProvider
+import io.swagger.client.model.SimpleExample
+
+
+
+case class WordOfTheDay (
+ id: Long,
+ parentId: String,
+ category: String,
+ createdBy: String,
+ createdAt: DateTime,
+ contentProvider: ContentProvider,
+ htmlExtra: String,
+ word: String,
+ definitions: List[SimpleDefinition],
+ examples: List[SimpleExample],
+ note: String,
+ publishDate: DateTime)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala
new file mode 100644
index 00000000000..4feb0d31190
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResult.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+
+
+
+case class WordSearchResult (
+ count: Long,
+ lexicality: Double,
+ word: String)
+
diff --git a/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala
new file mode 100644
index 00000000000..bf46436eef2
--- /dev/null
+++ b/samples/client/wordnik/scala/src/main/scala/io/swagger/client/model/WordSearchResults.scala
@@ -0,0 +1,10 @@
+package io.swagger.client.model
+
+import io.swagger.client.model.WordSearchResult
+
+
+
+case class WordSearchResults (
+ searchResults: List[WordSearchResult],
+ totalResults: Integer)
+
diff --git a/samples/html/index.html b/samples/html/index.html
index 1025186dc4b..9d47aa360eb 100644
--- a/samples/html/index.html
+++ b/samples/html/index.html
@@ -69,7 +69,7 @@
status (optional)
-
Query Parameter — Status values that need to be considered for filter
+
Query Parameter — Status values that need to be considered for filter default: available
Return type
@@ -79,11 +79,29 @@
Example data
Content-Type: application/json
- [ {\n "tags" : [ {\n "id" : 123456789,\n "name" : "aeiou"\n } ],\n "id" : 123456789,\n "category" : {\n "id" : 123456789,\n "name" : "aeiou"\n },\n "status" : "aeiou",\n "name" : "doggie",\n "photoUrls" : [ "aeiou" ]\n} ]
+ [ {
+ "tags" : [ {
+ "id" : 123456789,
+ "name" : "aeiou"
+ } ],
+ "id" : 123456789,
+ "category" : {
+ "id" : 123456789,
+ "name" : "aeiou"
+ },
+ "status" : "aeiou",
+ "name" : "doggie",
+ "photoUrls" : [ "aeiou" ]
+} ]
Example data
Content-Type: application/xml
- \n 123456 \n \n 123456 \n string \n \n doggie \n string \n \n 123456 \n string \n \n string \n
+ <Pet>
+ <id>123456</id>
+ <name>doggie</name>
+ <photoUrls>string</photoUrls>
+ <status>string</status>
+</Pet>
@@ -108,11 +126,29 @@
Example data
Content-Type: application/json
- [ {\n "tags" : [ {\n "id" : 123456789,\n "name" : "aeiou"\n } ],\n "id" : 123456789,\n "category" : {\n "id" : 123456789,\n "name" : "aeiou"\n },\n "status" : "aeiou",\n "name" : "doggie",\n "photoUrls" : [ "aeiou" ]\n} ]
+ [ {
+ "tags" : [ {
+ "id" : 123456789,
+ "name" : "aeiou"
+ } ],
+ "id" : 123456789,
+ "category" : {
+ "id" : 123456789,
+ "name" : "aeiou"
+ },
+ "status" : "aeiou",
+ "name" : "doggie",
+ "photoUrls" : [ "aeiou" ]
+} ]
Example data
Content-Type: application/xml
- \n 123456 \n \n 123456 \n string \n \n doggie \n string \n \n 123456 \n string \n \n string \n
+ <Pet>
+ <id>123456</id>
+ <name>doggie</name>
+ <photoUrls>string</photoUrls>
+ <status>string</status>
+</Pet>
@@ -137,11 +173,29 @@
Example data
Content-Type: application/json
- {\n "tags" : [ {\n "id" : 123456789,\n "name" : "aeiou"\n } ],\n "id" : 123456789,\n "category" : {\n "id" : 123456789,\n "name" : "aeiou"\n },\n "status" : "aeiou",\n "name" : "doggie",\n "photoUrls" : [ "aeiou" ]\n}
+ {
+ "tags" : [ {
+ "id" : 123456789,
+ "name" : "aeiou"
+ } ],
+ "id" : 123456789,
+ "category" : {
+ "id" : 123456789,
+ "name" : "aeiou"
+ },
+ "status" : "aeiou",
+ "name" : "doggie",
+ "photoUrls" : [ "aeiou" ]
+}
Example data
Content-Type: application/xml
- \n 123456 \n \n 123456 \n string \n \n doggie \n string \n \n 123456 \n string \n \n string \n
+ <Pet>
+ <id>123456</id>
+ <name>doggie</name>
+ <photoUrls>string</photoUrls>
+ <status>string</status>
+</Pet>
@@ -241,11 +295,13 @@
Example data
Content-Type: application/json
- {\n "key" : 123\n}
+ {
+ "key" : 123
+}
Example data
Content-Type: application/xml
- not implemented com.wordnik.swagger.models.properties.MapProperty@5076b51c
+ not implemented com.wordnik.swagger.models.properties.MapProperty@3e
@@ -270,11 +326,25 @@
Example data
Content-Type: application/json
- {\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-05-12T09:58:06.953+0000"\n}
+ {
+ "id" : 123456789,
+ "petId" : 123456789,
+ "complete" : true,
+ "status" : "aeiou",
+ "quantity" : 123,
+ "shipDate" : "2015-05-21T05:49:06.118+0000"
+}
Example data
Content-Type: application/xml
- \n 123456 \n 123456 \n 0 \n 2015-05-12T05:58:06.956Z \n string \n true \n
+ <Order>
+ <id>123456</id>
+ <petId>123456</petId>
+ <quantity>0</quantity>
+ <shipDate>2015-05-20T22:49:06.120Z</shipDate>
+ <status>string</status>
+ <complete>true</complete>
+</Order>
@@ -299,11 +369,25 @@
Example data
Content-Type: application/json
- {\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-05-12T09:58:06.957+0000"\n}
+ {
+ "id" : 123456789,
+ "petId" : 123456789,
+ "complete" : true,
+ "status" : "aeiou",
+ "quantity" : 123,
+ "shipDate" : "2015-05-21T05:49:06.121+0000"
+}
Example data
Content-Type: application/xml
- \n 123456 \n 123456 \n 0 \n 2015-05-12T05:58:06.957Z \n string \n true \n
+ <Order>
+ <id>123456</id>
+ <petId>123456</petId>
+ <quantity>0</quantity>
+ <shipDate>2015-05-20T22:49:06.122Z</shipDate>
+ <status>string</status>
+ <complete>true</complete>
+</Order>
@@ -415,7 +499,7 @@
Example data
Content-Type: application/json
- "aeiou"
+ "aeiou"
Example data
Content-Type: application/xml
@@ -462,11 +546,16 @@
Example data
Content-Type: application/json
- {\n "id" : 123456789,\n "lastName" : "aeiou",\n "phone" : "aeiou",\n "username" : "aeiou",\n "email" : "aeiou",\n "userStatus" : 123,\n "firstName" : "aeiou",\n "password" : "aeiou"\n}
-
- Example data
- Content-Type: application/xml
- \n 123456 \n string \n string \n string \n string \n string \n string \n 0 \n
+ {
+ "id" : 1,
+ "username" : "johnp",
+ "firstName" : "John",
+ "lastName" : "Public",
+ "email" : "johnp@swagger.io",
+ "password" : "-secret-",
+ "phone" : "0123456789",
+ "userStatus" : 0
+}
diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml
index c928b341b38..b57a4fd416d 100644
--- a/samples/server/petstore/jaxrs/pom.xml
+++ b/samples/server/petstore/jaxrs/pom.xml
@@ -129,7 +129,7 @@
- 1.5.2-M2-SNAPSHOT
+ 1.5.2-M2
9.2.9.v20150224
1.13
1.6.3
diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/PetApi.java
index 8b3b9d40b06..8abaf768136 100644
--- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/PetApi.java
+++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/PetApi.java
@@ -21,12 +21,14 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/pet")
+
+
@com.wordnik.swagger.annotations.Api(value = "/pet", description = "the pet API")
public class PetApi {
@PUT
- @Consumes({ "application/json", "application/xml", })
+ @Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" })
@com.wordnik.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
@com.wordnik.swagger.annotations.ApiResponses(value = {
@@ -45,7 +47,7 @@ public class PetApi {
@POST
- @Consumes({ "application/json", "application/xml", })
+ @Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" })
@com.wordnik.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
@com.wordnik.swagger.annotations.ApiResponses(value = {
@@ -68,7 +70,7 @@ public class PetApi {
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
- public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter") @QueryParam("status") List status)
+ public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status)
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
@@ -113,7 +115,7 @@ public class PetApi {
@POST
@Path("/{petId}")
- @Consumes({ "application/x-www-form-urlencoded", })
+ @Consumes({ "application/x-www-form-urlencoded" })
@Produces({ "application/json", "application/xml" })
@com.wordnik.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
@com.wordnik.swagger.annotations.ApiResponses(value = {
@@ -146,7 +148,7 @@ public class PetApi {
@POST
@Path("/{petId}/uploadImage")
- @Consumes({ "multipart/form-data", })
+ @Consumes({ "multipart/form-data" })
@Produces({ "application/json", "application/xml" })
@com.wordnik.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
@com.wordnik.swagger.annotations.ApiResponses(value = {
diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/StoreApi.java
index d2bde7cf35b..660f6317422 100644
--- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/StoreApi.java
+++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/StoreApi.java
@@ -21,6 +21,8 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/store")
+
+
@com.wordnik.swagger.annotations.Api(value = "/store", description = "the store API")
public class StoreApi {
diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/UserApi.java
index 3f6da2c5d92..d907b8b579b 100644
--- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/UserApi.java
+++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/UserApi.java
@@ -21,6 +21,8 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/user")
+
+
@com.wordnik.swagger.annotations.Api(value = "/user", description = "the user API")
public class UserApi {
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java
index ca48e7b10ff..a39a8e70970 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java
@@ -40,9 +40,11 @@ public class PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied") })
@RequestMapping(value = "",
produces = { "application/json", "application/xml" },
- consumes = { "application/json", "application/xml", },
+ consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT)
- public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
+ public ResponseEntity updatePet(
+
+@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -55,9 +57,11 @@ public class PetApi {
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "",
produces = { "application/json", "application/xml" },
- consumes = { "application/json", "application/xml", },
+ consumes = { "application/json", "application/xml" },
method = RequestMethod.POST)
- public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
+ public ResponseEntity addPet(
+
+@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -73,7 +77,9 @@ public class PetApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter") @RequestParam(value = "status", required = false) List status)
+ public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List status
+
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -89,7 +95,9 @@ public class PetApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags)
+ public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags
+
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -106,7 +114,9 @@ public class PetApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId)
+ public ResponseEntity getPetById(
+@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -119,13 +129,19 @@ public class PetApi {
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/{petId}",
produces = { "application/json", "application/xml" },
- consumes = { "application/x-www-form-urlencoded", },
+ consumes = { "application/x-www-form-urlencoded" },
method = RequestMethod.POST)
- public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId,
+ public ResponseEntity updatePetWithForm(
+@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId
+,
-@ApiParam(value = "Updated name of the pet" )@RequestPart("name") String name,
+
+
+@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name,
-@ApiParam(value = "Updated status of the pet" )@RequestPart("status") String status)
+
+
+@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -140,8 +156,12 @@ public class PetApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.DELETE)
- public ResponseEntity deletePet(@ApiParam(value = "" )@RequestHeader("apiKey") String apiKey,
- @ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId)
+ public ResponseEntity deletePet(
+@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey
+,
+
+@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -154,12 +174,18 @@ public class PetApi {
@ApiResponse(code = 0, message = "successful operation") })
@RequestMapping(value = "/{petId}/uploadImage",
produces = { "application/json", "application/xml" },
- consumes = { "multipart/form-data", },
+ consumes = { "multipart/form-data" },
method = RequestMethod.POST)
- public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
+ public ResponseEntity uploadFile(
+@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId
+,
-@ApiParam(value = "Additional data to pass to server" )@RequestPart("additionalMetadata") String additionalMetadata,
- @ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail)
+
+
+@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
+
+
+@ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java
index 4f3eb963e16..ba6e233ce9c 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java
@@ -56,7 +56,9 @@ public class StoreApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.POST)
- public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
+ public ResponseEntity placeOrder(
+
+@ApiParam(value = "order placed for purchasing the pet" ) Order body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -73,7 +75,9 @@ public class StoreApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId)
+ public ResponseEntity getOrderById(
+@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -89,7 +93,9 @@ public class StoreApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.DELETE)
- public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId)
+ public ResponseEntity deleteOrder(
+@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java
index 25671c6168d..15b170e90a7 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java
@@ -40,7 +40,9 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.POST)
- public ResponseEntity createUser(@ApiParam(value = "Created user object" ) User body)
+ public ResponseEntity createUser(
+
+@ApiParam(value = "Created user object" ) User body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -55,7 +57,9 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.POST)
- public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body)
+ public ResponseEntity createUsersWithArrayInput(
+
+@ApiParam(value = "List of user object" ) List body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -70,7 +74,9 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.POST)
- public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ) List body)
+ public ResponseEntity createUsersWithListInput(
+
+@ApiParam(value = "List of user object" ) List body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -86,8 +92,12 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username,
- @ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password)
+ public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username
+
+,
+ @ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password
+
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -119,7 +129,9 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
- public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username)
+ public ResponseEntity getUserByName(
+@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -135,8 +147,12 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.PUT)
- public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
- @ApiParam(value = "Updated user object" ) User body)
+ public ResponseEntity updateUser(
+@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username
+,
+
+
+@ApiParam(value = "Updated user object" ) User body)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);
@@ -152,7 +168,9 @@ public class UserApi {
produces = { "application/json", "application/xml" },
method = RequestMethod.DELETE)
- public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username)
+ public ResponseEntity deleteUser(
+@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username
+)
throws NotFoundException {
// do some magic!
return new ResponseEntity(HttpStatus.OK);