diff --git a/modules/swagger-codegen/src/main/resources/bash/client.mustache b/modules/swagger-codegen/src/main/resources/bash/client.mustache index e4c7ee2b61e..d351fbd213d 100644 --- a/modules/swagger-codegen/src/main/resources/bash/client.mustache +++ b/modules/swagger-codegen/src/main/resources/bash/client.mustache @@ -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}" @@ -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 diff --git a/samples/client/petstore/bash/Dockerfile b/samples/client/petstore/bash/Dockerfile index 2d4a88cdfd0..71dcb96ed5b 100644 --- a/samples/client/petstore/bash/Dockerfile +++ b/samples/client/petstore/bash/Dockerfile @@ -39,6 +39,7 @@ For convenience, you can export the following environment variables:\n\ \n\ $(tput setaf 3)PETSTORE_HOST$(tput sgr0) - server URL, e.g. https://example.com:8080\n\ $(tput setaf 3)PETSTORE_API_KEY$(tput sgr0) - access token, e.g. "ASDASHJDG63456asdASSD"\n\ +$(tput setaf 3)PETSTORE_API_KEY$(tput sgr0) - access token, e.g. "ASDASHJDG63456asdASSD"\n\ $(tput setaf 3)PETSTORE_BASIC_AUTH$(tput sgr0) - basic authentication credentials, e.g.: "username:password"\n\ \n\ $(tput setaf 7)Basic usage:$(tput sgr0)\n\ diff --git a/samples/client/petstore/bash/_petstore-cli b/samples/client/petstore/bash/_petstore-cli index dc33ceaabf8..37565241a91 100644 --- a/samples/client/petstore/bash/_petstore-cli +++ b/samples/client/petstore/bash/_petstore-cli @@ -296,7 +296,7 @@ case $state in ops) # Operations _values "Operations" \ - "fakeOuterBooleanSerialize[]" \ + "testSpecialTags[To test special tags]" "fakeOuterBooleanSerialize[]" \ "fakeOuterCompositeSerialize[]" \ "fakeOuterNumberSerialize[]" \ "fakeOuterStringSerialize[]" \ @@ -330,6 +330,12 @@ case $state in ;; args) case $line[1] in + testSpecialTags) + local -a _op_arguments + _op_arguments=( + ) + _describe -t actions 'operations' _op_arguments -S '' && ret=0 + ;; fakeOuterBooleanSerialize) local -a _op_arguments _op_arguments=( diff --git a/samples/client/petstore/bash/petstore-cli b/samples/client/petstore/bash/petstore-cli index bbf14fc9e01..d3e6720e1fc 100755 --- a/samples/client/petstore/bash/petstore-cli +++ b/samples/client/petstore/bash/petstore-cli @@ -95,6 +95,7 @@ declare -a result_color_table=( "$WHITE" "$WHITE" "$GREEN" "$YELLOW" "$WHITE" "$ # 0 - optional # 1 - required declare -A operation_parameters_minimum_occurences +operation_parameters_minimum_occurences["testSpecialTags:::body"]=1 operation_parameters_minimum_occurences["fakeOuterBooleanSerialize:::body"]=0 operation_parameters_minimum_occurences["fakeOuterCompositeSerialize:::body"]=0 operation_parameters_minimum_occurences["fakeOuterNumberSerialize:::body"]=0 @@ -158,6 +159,7 @@ operation_parameters_minimum_occurences["updateUser:::body"]=1 # N - N values # 0 - unlimited declare -A operation_parameters_maximum_occurences +operation_parameters_maximum_occurences["testSpecialTags:::body"]=0 operation_parameters_maximum_occurences["fakeOuterBooleanSerialize:::body"]=0 operation_parameters_maximum_occurences["fakeOuterCompositeSerialize:::body"]=0 operation_parameters_maximum_occurences["fakeOuterNumberSerialize:::body"]=0 @@ -218,6 +220,7 @@ operation_parameters_maximum_occurences["updateUser:::body"]=0 # The type of collection for specifying multiple values for parameter: # - multi, csv, ssv, tsv declare -A operation_parameters_collection_type +operation_parameters_collection_type["testSpecialTags:::body"]="" operation_parameters_collection_type["fakeOuterBooleanSerialize:::body"]="" operation_parameters_collection_type["fakeOuterCompositeSerialize:::body"]="" operation_parameters_collection_type["fakeOuterNumberSerialize:::body"]="" @@ -527,11 +530,22 @@ build_request_path() { fi fi + if [[ ${qparam} == "api_key_query" ]]; then + if [[ -n "${parameter_values[@]}" ]]; then + parameter_value+="${qparam}=${parameter_values}" + elif [[ -n "$MATRIX_API_KEY" ]]; then + parameter_value+="${qparam}=$PETSTORE_API_KEY" + else + echo "Missing ApiKey!!! Define env variable PETSTORE_API_KEY like 'export PETSTORE_API_KEY=...' or provide on command line option 'api_key_query=...'" + exit 1 + fi + continue + fi + # # 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 @@ -648,6 +662,8 @@ EOF echo -e "" echo -e " - ${BLUE}Api-key${OFF} - add '${RED}api_key:${OFF}' after ${YELLOW}${OFF}" echo -e " or export ${RED}PETSTORE_API_KEY=''${OFF}" + echo -e " - ${BLUE}Api-key${OFF} - add '${RED}api_key_query=${OFF}' after ${YELLOW}${OFF}" + echo -e " or export ${RED}PETSTORE_API_KEY=''${OFF}" echo -e " - ${BLUE}Basic AUTH${OFF} - add '-u :' before ${YELLOW}${OFF}" echo -e " or export ${RED}PETSTORE_BASIC_AUTH=':'${OFF}" echo -e " - ${MAGENTA}OAuth2 (flow: implicit)${OFF}" @@ -658,6 +674,12 @@ EOF echo -e " * read:pets - read your pets" echo "" echo -e "${BOLD}${WHITE}Operations (grouped by tags)${OFF}" + echo "" + echo -e "${BOLD}${WHITE}[anotherFake]${OFF}" +read -d '' ops <