-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
492 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
154 changes: 154 additions & 0 deletions
154
samples/client/petstore-security-test/ruby/.rubocop.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 1 addition & 1 deletion
2
samples/client/petstore-security-test/ruby/.swagger-codegen/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.0-SNAPSHOT | ||
2.4.42-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 = {} | ||
|
@@ -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 */ ' " =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 */ ' " =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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -15,7 +15,7 @@ | |
require 'logger' | ||
require 'tempfile' | ||
require 'typhoeus' | ||
require 'uri' | ||
require 'addressable/uri' | ||
|
||
module Petstore | ||
class ApiClient | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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. | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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. | ||
|
@@ -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. | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
Oops, something went wrong.