Skip to content

Commit 82613df

Browse files
committed
Run bin/ruby-petstore.sh
1 parent 7769ecd commit 82613df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+492
-101
lines changed

Diff for: samples/client/petstore-security-test/ruby/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Generated by: https://github.com/swagger-api/swagger-codegen.git
2-
#
2+
#
33

44
*.gem
55
*.rbc
+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
2+
# Automatically generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen)
3+
AllCops:
4+
TargetRubyVersion: 2.2
5+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
6+
# to ignore them, so only the ones explicitly set in this file are enabled.
7+
DisabledByDefault: true
8+
Exclude:
9+
- '**/templates/**/*'
10+
- '**/vendor/**/*'
11+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
12+
13+
# Prefer &&/|| over and/or.
14+
Style/AndOr:
15+
Enabled: true
16+
17+
# Do not use braces for hash literals when they are the last argument of a
18+
# method call.
19+
Style/BracesAroundHashParameters:
20+
Enabled: true
21+
EnforcedStyle: context_dependent
22+
23+
# Align `when` with `case`.
24+
Layout/CaseIndentation:
25+
Enabled: true
26+
27+
# Align comments with method definitions.
28+
Layout/CommentIndentation:
29+
Enabled: true
30+
31+
Layout/ElseAlignment:
32+
Enabled: true
33+
34+
Layout/EmptyLineAfterMagicComment:
35+
Enabled: true
36+
37+
# In a regular class definition, no empty lines around the body.
38+
Layout/EmptyLinesAroundClassBody:
39+
Enabled: true
40+
41+
# In a regular method definition, no empty lines around the body.
42+
Layout/EmptyLinesAroundMethodBody:
43+
Enabled: true
44+
45+
# In a regular module definition, no empty lines around the body.
46+
Layout/EmptyLinesAroundModuleBody:
47+
Enabled: true
48+
49+
Layout/FirstParameterIndentation:
50+
Enabled: true
51+
52+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
53+
Style/HashSyntax:
54+
Enabled: false
55+
56+
# Method definitions after `private` or `protected` isolated calls need one
57+
# extra level of indentation.
58+
Layout/IndentationConsistency:
59+
Enabled: true
60+
EnforcedStyle: rails
61+
62+
# Two spaces, no tabs (for indentation).
63+
Layout/IndentationWidth:
64+
Enabled: true
65+
66+
Layout/LeadingCommentSpace:
67+
Enabled: true
68+
69+
Layout/SpaceAfterColon:
70+
Enabled: true
71+
72+
Layout/SpaceAfterComma:
73+
Enabled: true
74+
75+
Layout/SpaceAroundEqualsInParameterDefault:
76+
Enabled: true
77+
78+
Layout/SpaceAroundKeyword:
79+
Enabled: true
80+
81+
Layout/SpaceAroundOperators:
82+
Enabled: true
83+
84+
Layout/SpaceBeforeComma:
85+
Enabled: true
86+
87+
Layout/SpaceBeforeFirstArg:
88+
Enabled: true
89+
90+
Style/DefWithParentheses:
91+
Enabled: true
92+
93+
# Defining a method with parameters needs parentheses.
94+
Style/MethodDefParentheses:
95+
Enabled: true
96+
97+
Style/FrozenStringLiteralComment:
98+
Enabled: false
99+
EnforcedStyle: always
100+
101+
# Use `foo {}` not `foo{}`.
102+
Layout/SpaceBeforeBlockBraces:
103+
Enabled: true
104+
105+
# Use `foo { bar }` not `foo {bar}`.
106+
Layout/SpaceInsideBlockBraces:
107+
Enabled: true
108+
109+
# Use `{ a: 1 }` not `{a:1}`.
110+
Layout/SpaceInsideHashLiteralBraces:
111+
Enabled: true
112+
113+
Layout/SpaceInsideParens:
114+
Enabled: true
115+
116+
# Check quotes usage according to lint rule below.
117+
#Style/StringLiterals:
118+
# Enabled: true
119+
# EnforcedStyle: single_quotes
120+
121+
# Detect hard tabs, no hard tabs.
122+
Layout/Tab:
123+
Enabled: true
124+
125+
# Blank lines should not have any spaces.
126+
Layout/TrailingBlankLines:
127+
Enabled: true
128+
129+
# No trailing whitespace.
130+
Layout/TrailingWhitespace:
131+
Enabled: false
132+
133+
# Use quotes for string literals when they are enough.
134+
Style/UnneededPercentQ:
135+
Enabled: true
136+
137+
# Align `end` with the matching keyword or starting expression except for
138+
# assignments, where it should be aligned with the LHS.
139+
Lint/EndAlignment:
140+
Enabled: true
141+
EnforcedStyleAlignWith: variable
142+
AutoCorrect: true
143+
144+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
145+
Lint/RequireParentheses:
146+
Enabled: true
147+
148+
Style/RedundantReturn:
149+
Enabled: true
150+
AllowMultipleReturnValues: true
151+
152+
Style/Semicolon:
153+
Enabled: true
154+
AllowAsExpressionSeparator: true
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.0-SNAPSHOT
1+
2.4.42-SNAPSHOT

Diff for: samples/client/petstore-security-test/ruby/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ require 'petstore'
5757
api_instance = Petstore::FakeApi.new
5858

5959
opts = {
60-
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
60+
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
6161
}
6262

6363
begin

Diff for: samples/client/petstore-security-test/ruby/docs/FakeApi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require 'petstore'
2020
api_instance = Petstore::FakeApi.new
2121

2222
opts = {
23-
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
23+
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
2424
}
2525

2626
begin

Diff for: samples/client/petstore-security-test/ruby/git_push.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ git_remote=`git remote`
3939
if [ "$git_remote" = "" ]; then # git remote not defined
4040

4141
if [ "$GIT_TOKEN" = "" ]; then
42-
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
42+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
4343
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
4444
else
4545
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git

Diff for: samples/client/petstore-security-test/ruby/lib/petstore.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
77
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.3.0-SNAPSHOT
9+
Swagger Codegen version: 2.4.42-SNAPSHOT
1010
1111
=end
1212

Diff for: samples/client/petstore-security-test/ruby/lib/petstore/api/fake_api.rb

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
77
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.3.0-SNAPSHOT
9+
Swagger Codegen version: 2.4.42-SNAPSHOT
1010
1111
=end
1212

13-
require "uri"
13+
require 'uri'
1414

1515
module Petstore
1616
class FakeApi
@@ -19,28 +19,25 @@ class FakeApi
1919
def initialize(api_client = ApiClient.default)
2020
@api_client = api_client
2121
end
22-
2322
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
24-
#
2523
# @param [Hash] opts the optional parameters
2624
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
2725
# @return [nil]
2826
def test_code_inject____end__rn_n_r(opts = {})
2927
test_code_inject____end__rn_n_r_with_http_info(opts)
30-
return nil
28+
nil
3129
end
3230

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

4542
# query parameters
4643
query_params = {}
@@ -54,7 +51,7 @@ def test_code_inject____end__rn_n_r_with_http_info(opts = {})
5451

5552
# form parameters
5653
form_params = {}
57-
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?
54+
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?
5855

5956
# http body (model)
6057
post_body = nil

Diff for: samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb

+14-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
77
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.3.0-SNAPSHOT
9+
Swagger Codegen version: 2.4.42-SNAPSHOT
1010
1111
=end
1212

@@ -15,7 +15,7 @@
1515
require 'logger'
1616
require 'tempfile'
1717
require 'typhoeus'
18-
require 'uri'
18+
require 'addressable/uri'
1919

2020
module Petstore
2121
class ApiClient
@@ -33,7 +33,7 @@ def initialize(config = Configuration.default)
3333
@config = config
3434
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
3535
@default_headers = {
36-
'Content-Type' => "application/json",
36+
'Content-Type' => 'application/json',
3737
'User-Agent' => @user_agent
3838
}
3939
end
@@ -63,7 +63,7 @@ def call_api(http_method, path, opts = {})
6363
:message => response.return_message)
6464
else
6565
fail ApiError.new(:code => response.code,
66-
:response_headers => response.headers,
66+
:response_headers => response.headers.to_h,
6767
:response_body => response.body),
6868
response.status_message
6969
end
@@ -112,6 +112,8 @@ def build_request(http_method, path, opts = {})
112112
:verbose => @config.debugging
113113
}
114114

115+
req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"
116+
115117
# set custom cert, if provided
116118
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
117119

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

143145
# Deserialize the response to the given return type.
@@ -201,12 +203,12 @@ def convert_to_type(data, return_type)
201203
when /\AArray<(.+)>\z/
202204
# e.g. Array<Pet>
203205
sub_type = $1
204-
data.map {|item| convert_to_type(item, sub_type) }
206+
data.map { |item| convert_to_type(item, sub_type) }
205207
when /\AHash\<String, (.+)\>\z/
206208
# e.g. Hash<String, Integer>
207209
sub_type = $1
208210
{}.tap do |hash|
209-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
211+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
210212
end
211213
else
212214
# models, e.g. Pet
@@ -228,7 +230,7 @@ def download_file(request)
228230
encoding = nil
229231
request.on_headers do |response|
230232
content_disposition = response.headers['Content-Disposition']
231-
if content_disposition and content_disposition =~ /filename=/i
233+
if content_disposition && content_disposition =~ /filename=/i
232234
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
233235
prefix = sanitize_filename(filename)
234236
else
@@ -264,7 +266,7 @@ def sanitize_filename(filename)
264266
def build_request_url(path)
265267
# Add leading and trailing slashes to path
266268
path = "/#{path}".gsub(/\/+/, '/')
267-
URI.encode(@config.base_url + path)
269+
Addressable::URI.encode(@config.base_url + path)
268270
end
269271

270272
# Builds the HTTP request body
@@ -327,7 +329,7 @@ def select_header_accept(accepts)
327329
return nil if accepts.nil? || accepts.empty?
328330
# use JSON when present, otherwise use all of the provided
329331
json_accept = accepts.find { |s| json_mime?(s) }
330-
return json_accept || accepts.join(',')
332+
json_accept || accepts.join(',')
331333
end
332334

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

344346
# Convert object (array, hash, object, etc) to JSON string.
@@ -348,7 +350,7 @@ def object_to_http_body(model)
348350
return model if model.nil? || model.is_a?(String)
349351
local_body = nil
350352
if model.is_a?(Array)
351-
local_body = model.map{|m| object_to_hash(m) }
353+
local_body = model.map { |m| object_to_hash(m) }
352354
else
353355
local_body = object_to_hash(model)
354356
end

Diff for: samples/client/petstore-security-test/ruby/lib/petstore/api_error.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
77
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
88
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.3.0-SNAPSHOT
9+
Swagger Codegen version: 2.4.42-SNAPSHOT
1010
1111
=end
1212

0 commit comments

Comments
 (0)