diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache index f71a066b74f..a3f0bccc642 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache @@ -18,7 +18,10 @@ Method | HTTP request | Description {{notes}}{{/notes}} ### Example -```ruby{{#hasAuthMethods}} +```ruby +require '{{{gemName}}}' +{{#hasAuthMethods}} + {{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}} # Configure HTTP basic authorization: {{{name}}} config.username = 'YOUR USERNAME' @@ -41,7 +44,8 @@ opts = { {{#allParams}}{{^required}} }{{/hasOptionalParams}}{{/hasParams}} begin - {{#returnType}}result = {{/returnType}}api.{{{operationId}}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} + {{#returnType}}result = {{/returnType}}api.{{{operationId}}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}}{{#returnType}} + p result{{/returnType}} rescue {{{moduleName}}}::ApiError => e puts "Exception when calling {{{operationId}}}: #{e}" end diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9ec5c8ccc69..f708fabd397 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-11T18:59:01.854+08:00 +- Build date: 2016-03-14T15:33:44.953+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -108,6 +108,7 @@ Class | Method | HTTP request | Description - [Petstore::Category](docs/Category.md) - [Petstore::InlineResponse200](docs/InlineResponse200.md) - [Petstore::ModelReturn](docs/ModelReturn.md) + - [Petstore::Name](docs/Name.md) - [Petstore::Order](docs/Order.md) - [Petstore::Pet](docs/Pet.md) - [Petstore::SpecialModelName](docs/SpecialModelName.md) @@ -145,6 +146,10 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header +### test_http_basic + +- **Type**: HTTP basic authentication + ### test_api_key_query - **Type**: API key diff --git a/samples/client/petstore/ruby/docs/Name.md b/samples/client/petstore/ruby/docs/Name.md new file mode 100644 index 00000000000..0fa18840f0c --- /dev/null +++ b/samples/client/petstore/ruby/docs/Name.md @@ -0,0 +1,8 @@ +# Petstore::Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index b0dc8f82cee..d1ce71a0e06 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -26,6 +26,8 @@ Add a new pet to the store ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -74,6 +76,8 @@ Fake endpoint to test byte array in body parameter for adding a new pet to the s ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -122,6 +126,8 @@ Deletes a pet ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -173,6 +179,8 @@ Multiple status values can be provided with comma separated strings ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -186,6 +194,7 @@ opts = { begin result = api.find_pets_by_status(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling find_pets_by_status: #{e}" end @@ -221,6 +230,8 @@ Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -234,6 +245,7 @@ opts = { begin result = api.find_pets_by_tags(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling find_pets_by_tags: #{e}" end @@ -269,6 +281,8 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -286,6 +300,7 @@ pet_id = 789 # [Integer] ID of pet that needs to be fetched begin result = api.get_pet_by_id(pet_id) + p result rescue Petstore::ApiError => e puts "Exception when calling get_pet_by_id: #{e}" end @@ -321,6 +336,8 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -338,6 +355,7 @@ pet_id = 789 # [Integer] ID of pet that needs to be fetched begin result = api.get_pet_by_id_in_object(pet_id) + p result rescue Petstore::ApiError => e puts "Exception when calling get_pet_by_id_in_object: #{e}" end @@ -373,6 +391,8 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -390,6 +410,7 @@ pet_id = 789 # [Integer] ID of pet that needs to be fetched begin result = api.pet_pet_idtesting_byte_arraytrue_get(pet_id) + p result rescue Petstore::ApiError => e puts "Exception when calling pet_pet_idtesting_byte_arraytrue_get: #{e}" end @@ -425,6 +446,8 @@ Update an existing pet ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -473,6 +496,8 @@ Updates a pet in the store with form data ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" @@ -526,6 +551,8 @@ uploads an image ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure OAuth2 access token for authorization: petstore_auth config.access_token = "YOUR ACCESS TOKEN" diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 071a42e08ff..f3bab7e3d69 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -21,6 +21,8 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or ### Example ```ruby +require 'petstore' + api = Petstore::StoreApi.new order_id = "order_id_example" # [String] ID of the order that needs to be deleted @@ -63,6 +65,8 @@ A single status value can be provided as a string ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure API key authorization: test_api_client_id config.api_key['x-test_api_client_id'] = "YOUR API KEY" @@ -83,6 +87,7 @@ opts = { begin result = api.find_orders_by_status(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling find_orders_by_status: #{e}" end @@ -118,6 +123,8 @@ Returns a map of status codes to quantities ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure API key authorization: api_key config.api_key['api_key'] = "YOUR API KEY" @@ -129,6 +136,7 @@ api = Petstore::StoreApi.new begin result = api.get_inventory + p result rescue Petstore::ApiError => e puts "Exception when calling get_inventory: #{e}" end @@ -161,6 +169,8 @@ Returns an arbitrary object which is actually a map of status codes to quantitie ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure API key authorization: api_key config.api_key['api_key'] = "YOUR API KEY" @@ -172,6 +182,7 @@ api = Petstore::StoreApi.new begin result = api.get_inventory_in_object + p result rescue Petstore::ApiError => e puts "Exception when calling get_inventory_in_object: #{e}" end @@ -204,6 +215,8 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure API key authorization: test_api_key_query config.api_key['test_api_key_query'] = "YOUR API KEY" @@ -223,6 +236,7 @@ order_id = "order_id_example" # [String] ID of pet that needs to be fetched begin result = api.get_order_by_id(order_id) + p result rescue Petstore::ApiError => e puts "Exception when calling get_order_by_id: #{e}" end @@ -258,6 +272,8 @@ Place an order for a pet ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure API key authorization: test_api_client_id config.api_key['x-test_api_client_id'] = "YOUR API KEY" @@ -278,6 +294,7 @@ opts = { begin result = api.place_order(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling place_order: #{e}" end diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md index b7dbb9c69aa..c629e696410 100644 --- a/samples/client/petstore/ruby/docs/UserApi.md +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -23,6 +23,8 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -66,6 +68,8 @@ Creates list of users with given input array ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -109,6 +113,8 @@ Creates list of users with given input array ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -152,6 +158,14 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + +Petstore.configure do |config| + # Configure HTTP basic authorization: test_http_basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + api = Petstore::UserApi.new username = "username_example" # [String] The name that needs to be deleted @@ -176,7 +190,7 @@ nil (empty response body) ### Authorization -No authorization required +[test_http_basic](../README.md#test_http_basic) ### HTTP reuqest headers @@ -194,6 +208,8 @@ Get user by user name ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. @@ -201,6 +217,7 @@ username = "username_example" # [String] The name that needs to be fetched. Use begin result = api.get_user_by_name(username) + p result rescue Petstore::ApiError => e puts "Exception when calling get_user_by_name: #{e}" end @@ -236,6 +253,8 @@ Logs user into the system ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -245,6 +264,7 @@ opts = { begin result = api.login_user(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling login_user: #{e}" end @@ -281,6 +301,8 @@ Logs out current logged in user session ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new begin @@ -317,6 +339,8 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new username = "username_example" # [String] name that need to be deleted diff --git a/samples/client/petstore/ruby/git_push.sh b/samples/client/petstore/ruby/git_push.sh index 1a36388db02..6ca091b49d9 100644 --- a/samples/client/petstore/ruby/git_push.sh +++ b/samples/client/petstore/ruby/git_push.sh @@ -8,17 +8,17 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi if [ "$release_note" = "" ]; then - release_note="Minor update" + release_note="" echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 29f631a983e..4a5d45d766c 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -360,7 +360,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['petstore_auth', 'api_key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -420,7 +420,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['petstore_auth', 'api_key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -480,7 +480,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['petstore_auth', 'api_key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 11bdfaadf62..7bdfd013bf6 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -301,7 +301,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['test_api_key_header', 'test_api_key_query'] + auth_names = ['test_api_key_query', 'test_api_key_header'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 0a295335eda..54d943bdc44 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -238,7 +238,7 @@ module Petstore # http body (model) post_body = nil - auth_names = [] + auth_names = ['test_http_basic'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index e5f39898027..a5c37d54e9c 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -157,26 +157,12 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'test_api_key_header' => + 'petstore_auth' => { - type: 'api_key', + type: 'oauth2', in: 'header', - key: 'test_api_key_header', - value: api_key_with_prefix('test_api_key_header') - }, - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key', - value: api_key_with_prefix('api_key') - }, - 'test_api_client_secret' => - { - type: 'api_key', - in: 'header', - key: 'x-test_api_client_secret', - value: api_key_with_prefix('x-test_api_client_secret') + key: 'Authorization', + value: "Bearer #{access_token}" }, 'test_api_client_id' => { @@ -185,6 +171,27 @@ module Petstore key: 'x-test_api_client_id', value: api_key_with_prefix('x-test_api_client_id') }, + 'test_api_client_secret' => + { + type: 'api_key', + in: 'header', + key: 'x-test_api_client_secret', + value: api_key_with_prefix('x-test_api_client_secret') + }, + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key', + value: api_key_with_prefix('api_key') + }, + 'test_http_basic' => + { + type: 'basic', + in: 'header', + key: 'Authorization', + value: basic_auth_token + }, 'test_api_key_query' => { type: 'api_key', @@ -192,12 +199,12 @@ module Petstore key: 'test_api_key_query', value: api_key_with_prefix('test_api_key_query') }, - 'petstore_auth' => + 'test_api_key_header' => { - type: 'oauth2', + type: 'api_key', in: 'header', - key: 'Authorization', - value: "Bearer #{access_token}" + key: 'test_api_key_header', + value: api_key_with_prefix('test_api_key_header') }, } end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index 190170f18eb..a793250e45b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -18,34 +18,34 @@ require 'date' module Petstore class InlineResponse200 - attr_accessor :tags + attr_accessor :photo_urls + + attr_accessor :name attr_accessor :id attr_accessor :category + attr_accessor :tags + # pet status in the store attr_accessor :status - attr_accessor :name - - attr_accessor :photo_urls - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'tags' => :'tags', + :'photo_urls' => :'photoUrls', + + :'name' => :'name', :'id' => :'id', :'category' => :'category', - :'status' => :'status', + :'tags' => :'tags', - :'name' => :'name', - - :'photo_urls' => :'photoUrls' + :'status' => :'status' } end @@ -53,12 +53,12 @@ module Petstore # Attribute type mapping. def self.swagger_types { - :'tags' => :'Array', + :'photo_urls' => :'Array', + :'name' => :'String', :'id' => :'Integer', :'category' => :'Object', - :'status' => :'String', - :'name' => :'String', - :'photo_urls' => :'Array' + :'tags' => :'Array', + :'status' => :'String' } end @@ -70,12 +70,16 @@ module Petstore attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'tags'] - if (value = attributes[:'tags']).is_a?(Array) - self.tags = value + if attributes[:'photoUrls'] + if (value = attributes[:'photoUrls']).is_a?(Array) + self.photo_urls = value end end + if attributes[:'name'] + self.name = attributes[:'name'] + end + if attributes[:'id'] self.id = attributes[:'id'] end @@ -84,20 +88,16 @@ module Petstore self.category = attributes[:'category'] end + if attributes[:'tags'] + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + if attributes[:'status'] self.status = attributes[:'status'] end - if attributes[:'name'] - self.name = attributes[:'name'] - end - - if attributes[:'photoUrls'] - if (value = attributes[:'photoUrls']).is_a?(Array) - self.photo_urls = value - end - end - end # Custom attribute writer method checking allowed values (enum). @@ -113,12 +113,12 @@ module Petstore def ==(o) return true if self.equal?(o) self.class == o.class && - tags == o.tags && + photo_urls == o.photo_urls && + name == o.name && id == o.id && category == o.category && - status == o.status && - name == o.name && - photo_urls == o.photo_urls + tags == o.tags && + status == o.status end # @see the `==` method @@ -128,7 +128,7 @@ module Petstore # Calculate hash code according to all attributes. def hash - [tags, id, category, status, name, photo_urls].hash + [photo_urls, name, id, category, tags, status].hash end # build the object from hash diff --git a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb index 6010167fe8d..241a2ded1d1 100644 --- a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb +++ b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb @@ -36,8 +36,17 @@ describe 'InlineResponse200' do @instance.should be_a(Petstore::InlineResponse200) end end - - describe 'test attribute "tags"' do + describe 'test attribute "photo_urls"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + describe 'test attribute "name"' do it 'should work' do # assertion here # should be_a() @@ -67,6 +76,16 @@ describe 'InlineResponse200' do end end + describe 'test attribute "tags"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + describe 'test attribute "status"' do it 'should work' do # assertion here @@ -77,25 +96,5 @@ describe 'InlineResponse200' do end end - describe 'test attribute "name"' do - it 'should work' do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - describe 'test attribute "photo_urls"' do - it 'should work' do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - end diff --git a/samples/client/petstore/ruby/spec/models/model_return_spec.rb b/samples/client/petstore/ruby/spec/models/model_return_spec.rb index 4081c495457..018798b47e3 100644 --- a/samples/client/petstore/ruby/spec/models/model_return_spec.rb +++ b/samples/client/petstore/ruby/spec/models/model_return_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::ModelReturn # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'ModelReturn' do