Skip to content

Commit

Permalink
Bugfix: Handle all different types of security
Browse files Browse the repository at this point in the history
The only special handling was for security definition type `apiKey`
in `query`. All the other security configurations should result in the
same generated code.
Moves the handling of the special query parameters outside of the
`parameters without specific cardinality` section.
To cover the scenario where `elif` was being used, simply leverage the
builtin `continue` statement to stop processing the specific query
parameter and continue to the next available query parameter, if any.

Manually test with multiple different combinations.

Resolves: swagger-api#6526
  • Loading branch information
kenjones-cisco committed Sep 20, 2017
1 parent 7f6bccb commit 2c6f542
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions modules/swagger-codegen/src/main/resources/bash/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,7 @@ build_request_path() {
query_request_part+="&"
fi
fi

#
# Append parameters without specific cardinality
#
local collection_type="${operation_parameters_collection_type["${operation}:::${qparam}"]}"
{{#hasAuthMethods}}
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInQuery}}
{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
if [[ ${qparam} == "{{keyParamName}}" ]]; then
if [[ -n "${parameter_values[@]}" ]]; then
parameter_value+="${qparam}=${parameter_values}"
Expand All @@ -431,8 +423,14 @@ build_request_path() {
echo "Missing ApiKey!!! {{#x-codegen-apikey-env}}Define env variable {{x-codegen-apikey-env}} like 'export {{x-codegen-apikey-env}}=...' or{{/x-codegen-apikey-env}}{{^x-codegen-apikey-env}}You have to{{/x-codegen-apikey-env}} provide on command line option '{{keyParamName}}=...'"
exit 1
fi
elif{{/isKeyInQuery}}{{^isKeyInQuery}}
if{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} [[ "${collection_type}" == "" ]]; then
continue
fi{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}}

#
# Append parameters without specific cardinality
#
local collection_type="${operation_parameters_collection_type["${operation}:::${qparam}"]}"
if [[ "${collection_type}" == "" ]]; then
local vcount=0
for qvalue in "${parameter_values[@]}"; do
if [[ $((vcount++)) -gt 0 ]]; then
Expand Down

0 comments on commit 2c6f542

Please sign in to comment.