diff --git a/samples/client/petstore-security-test/ruby/.gitignore b/samples/client/petstore-security-test/ruby/.gitignore index 522134fcdd3a..4b91271a6d5c 100644 --- a/samples/client/petstore-security-test/ruby/.gitignore +++ b/samples/client/petstore-security-test/ruby/.gitignore @@ -1,16 +1,5 @@ # Generated by: https://github.com/swagger-api/swagger-codegen.git # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. *.gem *.rbc diff --git a/samples/client/petstore-security-test/ruby/Gemfile b/samples/client/petstore-security-test/ruby/Gemfile new file mode 100644 index 000000000000..d255a3ab238d --- /dev/null +++ b/samples/client/petstore-security-test/ruby/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +gemspec + +group :development, :test do + gem 'rake', '~> 12.0.0' +end diff --git a/samples/client/petstore-security-test/ruby/README.md b/samples/client/petstore-security-test/ruby/README.md index 29455303d532..02148d502584 100644 --- a/samples/client/petstore-security-test/ruby/README.md +++ b/samples/client/petstore-security-test/ruby/README.md @@ -8,8 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r - Package version: 1.0.0 -- Build date: 2016-08-29T14:24:34.432-07:00 -- Build package: class io.swagger.codegen.languages.RubyClientCodegen +- Build package: io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -87,6 +86,12 @@ Class | Method | HTTP request | Description ## Documentation for Authorization +### api_key + +- **Type**: API key +- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r +- **Location**: HTTP header + ### petstore_auth - **Type**: OAuth @@ -96,9 +101,3 @@ Class | Method | HTTP request | Description - write:pets: modify pets in your account */ ' \" =_end -- \\r\\n \\n \\r - read:pets: read your pets */ ' \" =_end -- \\r\\n \\n \\r -### api_key - -- **Type**: API key -- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r -- **Location**: HTTP header - diff --git a/samples/client/petstore-security-test/ruby/Rakefile b/samples/client/petstore-security-test/ruby/Rakefile new file mode 100644 index 000000000000..d52c3e317539 --- /dev/null +++ b/samples/client/petstore-security-test/ruby/Rakefile @@ -0,0 +1,8 @@ +begin + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new(:spec) + task default: :spec +rescue LoadError + # no rspec available +end diff --git a/samples/client/petstore-security-test/ruby/git_push.sh b/samples/client/petstore-security-test/ruby/git_push.sh index 7e44b9aade1a..7cb1edb122bc 100644 --- a/samples/client/petstore-security-test/ruby/git_push.sh +++ b/samples/client/petstore-security-test/ruby/git_push.sh @@ -2,18 +2,6 @@ # # Generated by: https://github.com/swagger-api/swagger-codegen.git # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" diff --git a/samples/client/petstore-security-test/ruby/lib/petstore.rb b/samples/client/petstore-security-test/ruby/lib/petstore.rb index 415b6587c885..c85b301c423e 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end # Common files diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore-security-test/ruby/lib/petstore/api/fake_api.rb index 0c985ea308eb..9c15fc51e884 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/api/fake_api.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end require "uri" @@ -51,21 +39,17 @@ module Petstore @api_client.config.logger.debug "Calling API: FakeApi.test_code_inject____end__rn_n_r ..." end # resource path - local_var_path = "/fake".sub('{format}','json') + local_var_path = "/fake" # query parameters query_params = {} # header parameters header_params = {} - # HTTP header 'Accept' (if needed) - local_header_accept = ['application/json', '*/ \" =_end -- '] - local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result - + header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/ \" =_end -- ']) # HTTP header 'Content-Type' - local_header_content_type = ['application/json', '*/ \" =_end -- '] - header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', '*/ \" =_end -- ']) # form parameters form_params = {} diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb b/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb index 176f301b171a..8695f6e89c1a 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end require 'date' @@ -142,10 +130,11 @@ module Petstore # application/json # application/json; charset=UTF8 # APPLICATION/JSON + # */* # @param [String] mime MIME # @return [Boolean] True if the MIME is application/json def json_mime?(mime) - !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil? + (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? end # Deserialize the response to the given return type. diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/api_error.rb b/samples/client/petstore-security-test/ruby/lib/petstore/api_error.rb index bb13b3a440de..27fc3cf9ad40 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/api_error.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/api_error.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end module Petstore @@ -32,12 +20,14 @@ module Petstore # ApiError.new(:code => 404, :message => "Not Found") def initialize(arg = nil) if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) + else + super arg + end + arg.each do |k, v| - if k.to_s == 'message' - super v - else - instance_variable_set "@#{k}", v - end + instance_variable_set "@#{k}", v end else super arg diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb b/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb index 57ecfab010be..630b1dd66813 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end require 'uri' @@ -201,13 +189,6 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'petstore_auth' => - { - type: 'oauth2', - in: 'header', - key: 'Authorization', - value: "Bearer #{access_token}" - }, 'api_key' => { type: 'api_key', @@ -215,6 +196,13 @@ module Petstore key: 'api_key */ ' " =end -- \r\n \n \r', value: api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r') }, + 'petstore_auth' => + { + type: 'oauth2', + in: 'header', + key: 'Authorization', + value: "Bearer #{access_token}" + }, } end end diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore-security-test/ruby/lib/petstore/models/model_return.rb index 3c348cab3dca..9c4d50023c74 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/models/model_return.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end require 'date' @@ -97,7 +85,7 @@ module Petstore 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 type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -128,7 +116,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false @@ -139,7 +127,7 @@ module Petstore when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+), (?.+)>\z/ + when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/version.rb b/samples/client/petstore-security-test/ruby/lib/petstore/version.rb index 231de777b40c..4b5eadf50a16 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/version.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/version.rb @@ -7,18 +7,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end module Petstore diff --git a/samples/client/petstore-security-test/ruby/petstore.gemspec b/samples/client/petstore-security-test/ruby/petstore.gemspec index e07446df1c72..eb2a20c66079 100644 --- a/samples/client/petstore-security-test/ruby/petstore.gemspec +++ b/samples/client/petstore-security-test/ruby/petstore.gemspec @@ -9,18 +9,6 @@ OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r Generated by: https://github.com/swagger-api/swagger-codegen.git -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - =end $:.push File.expand_path("../lib", __FILE__) @@ -35,7 +23,9 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/swagger-api/swagger-codegen" s.summary = "Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r Ruby Gem" s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end -- " - s.license = "Apache 2.0 */ ' \" =_end -- \\r\\n \\n \\r" + # TODO uncommnet and update below with a proper license + #s.license = "Apache 2.0" + s.required_ruby_version = ">= 1.9" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'