Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize generated gemspec with current bundler template #12414

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ Gem::Specification.new do |s|
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'

s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
s.test_files = `find spec/*`.split("\n")
gemspec = File.basename(__FILE__)
spec.files = IO.popen(%w[find * -print0], chdir: __dir__, err: IO::NULL) do |ls|
ls.readlines("\x0", chomp: true).reject do |f|
(f == gemspec) ||
f.start_with?(*%w[bin/ test/ spec/ features/ .git Gemfile]) ||
f.end_with?(".gem")
end
end
s.executables = []
s.require_paths = ["lib"]
end
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#
#

*.gem
*.rbc
Expand Down
154 changes: 154 additions & 0 deletions samples/client/petstore-security-test/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen)
AllCops:
TargetRubyVersion: 2.2
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'

# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true

# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
EnforcedStyle: context_dependent

# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true

# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true

Layout/ElseAlignment:
Enabled: true

Layout/EmptyLineAfterMagicComment:
Enabled: true

# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true

# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true

# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true

Layout/FirstParameterIndentation:
Enabled: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: false

# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails

# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true

Layout/LeadingCommentSpace:
Enabled: true

Layout/SpaceAfterColon:
Enabled: true

Layout/SpaceAfterComma:
Enabled: true

Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true

Layout/SpaceAroundKeyword:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceBeforeComma:
Enabled: true

Layout/SpaceBeforeFirstArg:
Enabled: true

Style/DefWithParentheses:
Enabled: true

# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: always

# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true

# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true

# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true

Layout/SpaceInsideParens:
Enabled: true

# Check quotes usage according to lint rule below.
#Style/StringLiterals:
# Enabled: true
# EnforcedStyle: single_quotes

# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true

# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Enabled: true

# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: false

# Use quotes for string literals when they are enough.
Style/UnneededPercentQ:
Enabled: true

# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Lint/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true

# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true

Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true

Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.4.42-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require 'petstore'
api_instance = Petstore::FakeApi.new

opts = {
test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
test_code_inject____end____rn_n_r: 'test_code_inject____end____rn_n_r_example' # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
}

begin
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require 'petstore'
api_instance = Petstore::FakeApi.new

opts = {
test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
test_code_inject____end____rn_n_r: 'test_code_inject____end____rn_n_r_example' # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
}

begin
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/git_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore-security-test/ruby/lib/petstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
Swagger Codegen version: 2.4.42-SNAPSHOT

=end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
Swagger Codegen version: 2.4.42-SNAPSHOT

=end

require "uri"
require 'uri'

module Petstore
class FakeApi
Expand All @@ -19,28 +19,25 @@ class FakeApi
def initialize(api_client = ApiClient.default)
@api_client = api_client
end

# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
#
# @param [Hash] opts the optional parameters
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
# @return [nil]
def test_code_inject____end__rn_n_r(opts = {})
test_code_inject____end__rn_n_r_with_http_info(opts)
return nil
nil
end

# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
#
# @param [Hash] opts the optional parameters
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_code_inject____end__rn_n_r_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_code_inject____end__rn_n_r ..."
@api_client.config.logger.debug 'Calling API: FakeApi.test_code_inject____end__rn_n_r ...'
end
# resource path
local_var_path = "/fake"
local_var_path = '/fake'

# query parameters
query_params = {}
Expand All @@ -54,7 +51,7 @@ def test_code_inject____end__rn_n_r_with_http_info(opts = {})

# form parameters
form_params = {}
form_params["test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r"] = opts[:'test_code_inject____end____rn_n_r'] if !opts[:'test_code_inject____end____rn_n_r'].nil?
form_params['test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r'] = opts[:'test_code_inject____end____rn_n_r'] if !opts[:'test_code_inject____end____rn_n_r'].nil?

# http body (model)
post_body = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
Swagger Codegen version: 2.4.42-SNAPSHOT

=end

Expand All @@ -15,7 +15,7 @@
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
require 'addressable/uri'

module Petstore
class ApiClient
Expand All @@ -33,7 +33,7 @@ def initialize(config = Configuration.default)
@config = config
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
@default_headers = {
'Content-Type' => "application/json",
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
}
end
Expand Down Expand Up @@ -63,7 +63,7 @@ def call_api(http_method, path, opts = {})
:message => response.return_message)
else
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_headers => response.headers.to_h,
:response_body => response.body),
response.status_message
end
Expand Down Expand Up @@ -112,6 +112,8 @@ def build_request(http_method, path, opts = {})
:verbose => @config.debugging
}

req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"

# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert

Expand All @@ -137,7 +139,7 @@ def build_request(http_method, path, opts = {})
# @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json
def json_mime?(mime)
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end

# Deserialize the response to the given return type.
Expand Down Expand Up @@ -201,12 +203,12 @@ def convert_to_type(data, return_type)
when /\AArray<(.+)>\z/
# e.g. Array<Pet>
sub_type = $1
data.map {|item| convert_to_type(item, sub_type) }
data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer>
sub_type = $1
{}.tap do |hash|
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
# models, e.g. Pet
Expand All @@ -228,7 +230,7 @@ def download_file(request)
encoding = nil
request.on_headers do |response|
content_disposition = response.headers['Content-Disposition']
if content_disposition and content_disposition =~ /filename=/i
if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else
Expand Down Expand Up @@ -264,7 +266,7 @@ def sanitize_filename(filename)
def build_request_url(path)
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
URI.encode(@config.base_url + path)
Addressable::URI.encode(@config.base_url + path)
end

# Builds the HTTP request body
Expand Down Expand Up @@ -327,7 +329,7 @@ def select_header_accept(accepts)
return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) }
return json_accept || accepts.join(',')
json_accept || accepts.join(',')
end

# Return Content-Type header based on an array of content types provided.
Expand All @@ -338,7 +340,7 @@ def select_header_content_type(content_types)
return 'application/json' if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) }
return json_content_type || content_types.first
json_content_type || content_types.first
end

# Convert object (array, hash, object, etc) to JSON string.
Expand All @@ -348,7 +350,7 @@ def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
local_body = nil
if model.is_a?(Array)
local_body = model.map{|m| object_to_hash(m) }
local_body = model.map { |m| object_to_hash(m) }
else
local_body = object_to_hash(model)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT
Swagger Codegen version: 2.4.42-SNAPSHOT

=end

Expand Down
Loading