forked from loafle/openapi-generator-original
[Bash] Bugfix default curl options fix (#4832)
* Fixed default cURL parameter handling * Fixed iterator increments in JSON body Bash generator * Added tests for content type and default cURL params * Fixed generated Dockerfile Bash script access rights * Generated test sample client * Updated Bash generator README
This commit is contained in:
parent
167b2f59b8
commit
1b1767e489
@ -194,11 +194,10 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
String curlopts = "";
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CURL_OPTIONS)) {
|
if (additionalProperties.containsKey(CURL_OPTIONS)) {
|
||||||
setCurlOptions(additionalProperties.get(CURL_OPTIONS).toString());
|
setCurlOptions(additionalProperties.get(CURL_OPTIONS).toString());
|
||||||
additionalProperties.put("x-codegen-curl-options", curlopts);
|
additionalProperties.put("x-codegen-curl-options", this.curlOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(PROCESS_MARKDOWN)) {
|
if (additionalProperties.containsKey(PROCESS_MARKDOWN)) {
|
||||||
|
@ -6,7 +6,7 @@ RUN apt-get install -y bash-completion zsh curl cowsay git vim bsdmainutils
|
|||||||
ADD {{scriptName}} /usr/bin/{{scriptName}}
|
ADD {{scriptName}} /usr/bin/{{scriptName}}
|
||||||
ADD _{{scriptName}} /usr/local/share/zsh/site-functions/_{{scriptName}}
|
ADD _{{scriptName}} /usr/local/share/zsh/site-functions/_{{scriptName}}
|
||||||
ADD {{scriptName}}.bash-completion /etc/bash-completion.d/{{scriptName}}
|
ADD {{scriptName}}.bash-completion /etc/bash-completion.d/{{scriptName}}
|
||||||
|
RUN chmod 755 /usr/bin/{{scriptName}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install oh-my-zsh
|
# Install oh-my-zsh
|
||||||
|
@ -28,7 +28,7 @@ $ git clone https://github.com/swagger-api/swagger-codegen
|
|||||||
|
|
||||||
Build the codegen:
|
Build the codegen:
|
||||||
```shell
|
```shell
|
||||||
$ mvn assembly:assembly -DdescriptorId=jar-with-dependencies
|
$ mvn package
|
||||||
```
|
```
|
||||||
|
|
||||||
Define custom codegen properties in a Json file, e.g.:
|
Define custom codegen properties in a Json file, e.g.:
|
||||||
@ -47,14 +47,15 @@ Define custom codegen properties in a Json file, e.g.:
|
|||||||
|
|
||||||
Generate the client:
|
Generate the client:
|
||||||
```shell
|
```shell
|
||||||
$ java -cp target/bash-swagger-codegen-1.0.0.jar io.swagger.codegen.SwaggerCodegen generate -l bash -i http://petstore.swagger.io/v2/swagger.json -o output -c resources/example-config.json
|
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l bash -o generated/bash/petstore -c modules/swagger-codegen/src/test/resources/2_0/bash-config.json
|
||||||
|
|
||||||
$ chmod +x output/petstore-cli
|
$ chmod +x generated/bash/petstore/petstore-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
Enjoy:
|
Enjoy:
|
||||||
```shell
|
```shell
|
||||||
$ output/petstore-cli -h
|
$ cd generated/bash/petstore
|
||||||
|
$ ./petstore-cli -h
|
||||||
|
|
||||||
Swagger Petstore command line client (API version 1.0.0)
|
Swagger Petstore command line client (API version 1.0.0)
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ body_parameters_to_json() {
|
|||||||
if [[ $count -lt $body_parameter_count-1 ]]; then
|
if [[ $count -lt $body_parameter_count-1 ]]; then
|
||||||
body_json+=", "
|
body_json+=", "
|
||||||
fi
|
fi
|
||||||
count+=1
|
((count+=1))
|
||||||
done
|
done
|
||||||
body_json+="}'"
|
body_json+="}'"
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "multi" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "multi" ]]; then
|
||||||
local vcount=0
|
local vcount=0
|
||||||
@ -372,7 +372,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "csv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "csv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -383,7 +383,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+=","
|
path_template+=","
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "ssv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "ssv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -393,7 +393,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+=" "
|
path_template+=" "
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "tsv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "tsv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -403,7 +403,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="\t"
|
path_template+="\t"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo -e ""
|
echo -e ""
|
||||||
@ -416,7 +416,7 @@ validate_request_parameters() {
|
|||||||
if [[ $count -lt $query_parameter_count-1 ]]; then
|
if [[ $count -lt $query_parameter_count-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
count+=1
|
((count+=1))
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -484,7 +484,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="&"
|
parameter_value+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'mutli' collections i.e. param=value1¶m=value2&...
|
# Append parameters specified as 'mutli' collections i.e. param=value1¶m=value2&...
|
||||||
@ -497,7 +497,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="&"
|
parameter_value+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'csv' collections i.e. param=value1,value2,...
|
# Append parameters specified as 'csv' collections i.e. param=value1,value2,...
|
||||||
@ -511,7 +511,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+=","
|
parameter_value+=","
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'ssv' collections i.e. param="value1 value2 ..."
|
# Append parameters specified as 'ssv' collections i.e. param="value1 value2 ..."
|
||||||
@ -525,7 +525,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+=" "
|
parameter_value+=" "
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'tsv' collections i.e. param="value1\tvalue2\t..."
|
# Append parameters specified as 'tsv' collections i.e. param="value1\tvalue2\t..."
|
||||||
@ -539,7 +539,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="\t"
|
parameter_value+="\t"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -551,8 +551,7 @@ build_request_path() {
|
|||||||
query_request_part+="&"
|
query_request_part+="&"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count+=1
|
((count+=1))
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
61
samples/client/petstore/bash/Dockerfile
Normal file
61
samples/client/petstore/bash/Dockerfile
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
FROM ubuntu:16.10
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt-get full-upgrade -y
|
||||||
|
RUN apt-get install -y bash-completion zsh curl cowsay git vim bsdmainutils
|
||||||
|
|
||||||
|
ADD petstore-cli /usr/bin/petstore-cli
|
||||||
|
ADD _petstore-cli /usr/local/share/zsh/site-functions/_petstore-cli
|
||||||
|
ADD petstore-cli.bash-completion /etc/bash-completion.d/petstore-cli
|
||||||
|
RUN chmod 755 /usr/bin/petstore-cli
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install oh-my-zsh
|
||||||
|
#
|
||||||
|
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" || true
|
||||||
|
|
||||||
|
#
|
||||||
|
# Enable bash completion
|
||||||
|
#
|
||||||
|
RUN echo '\n\
|
||||||
|
. /etc/bash_completion\n\
|
||||||
|
source /etc/bash-completion.d/petstore-cli\n\
|
||||||
|
' >> ~/.bashrc
|
||||||
|
|
||||||
|
#
|
||||||
|
# Setup prompt
|
||||||
|
#
|
||||||
|
RUN echo 'export PS1="[Swagger Petstore] \$ "' >> ~/.bashrc
|
||||||
|
RUN echo 'export PROMPT="[Swagger Petstore] \$ "' >> ~/.zshrc
|
||||||
|
|
||||||
|
#
|
||||||
|
# Setup a welcome message with basic instruction
|
||||||
|
#
|
||||||
|
RUN echo 'cat << EOF\n\
|
||||||
|
\n\
|
||||||
|
This Docker provides preconfigured environment for running the command\n\
|
||||||
|
line REST client for $(tput setaf 6)Swagger Petstore$(tput sgr0).\n\
|
||||||
|
\n\
|
||||||
|
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_BASIC_AUTH$(tput sgr0) - basic authentication credentials, e.g.: "username:password"\n\
|
||||||
|
\n\
|
||||||
|
$(tput setaf 7)Basic usage:$(tput sgr0)\n\
|
||||||
|
\n\
|
||||||
|
$(tput setaf 3)Print the list of operations available on the service$(tput sgr0)\n\
|
||||||
|
$ petstore-cli -h\n\
|
||||||
|
\n\
|
||||||
|
$(tput setaf 3)Print the service description$(tput sgr0)\n\
|
||||||
|
$ petstore-cli --about\n\
|
||||||
|
\n\
|
||||||
|
$(tput setaf 3)Print detailed information about specific operation$(tput sgr0)\n\
|
||||||
|
$ petstore-cli <operationId> -h\n\
|
||||||
|
\n\
|
||||||
|
By default you are logged into Zsh with full autocompletion for your REST API,\n\
|
||||||
|
but you can switch to Bash, where basic autocompletion is also supported.\n\
|
||||||
|
\n\
|
||||||
|
EOF\n\
|
||||||
|
' | tee -a ~/.bashrc ~/.zshrc
|
||||||
|
|
||||||
|
ENTRYPOINT ["zsh"]
|
@ -10,7 +10,7 @@
|
|||||||
# !
|
# !
|
||||||
# ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl
|
# ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl
|
||||||
# !
|
# !
|
||||||
# ! Generated on: 2017-02-06T21:48:13.013+01:00
|
# ! Generated on: 2017-02-22T08:48:10.130+01:00
|
||||||
# !
|
# !
|
||||||
# !
|
# !
|
||||||
# ! Installation:
|
# ! Installation:
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
|
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
|
||||||
# ! FROM SWAGGER SPECIFICATION IN JSON.
|
# ! FROM SWAGGER SPECIFICATION IN JSON.
|
||||||
# !
|
# !
|
||||||
# ! Generated on: 2017-02-06T21:48:13.013+01:00
|
# ! Generated on: 2017-02-22T08:48:10.130+01:00
|
||||||
# !
|
# !
|
||||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ declare -A body_parameters
|
|||||||
|
|
||||||
##
|
##
|
||||||
# These arguments will be directly passed to cURL
|
# These arguments will be directly passed to cURL
|
||||||
curl_arguments=""
|
curl_arguments="-sS --tlsv1.2"
|
||||||
|
|
||||||
##
|
##
|
||||||
# The host for making the request
|
# The host for making the request
|
||||||
@ -387,7 +387,7 @@ body_parameters_to_json() {
|
|||||||
if [[ $count -lt $body_parameter_count-1 ]]; then
|
if [[ $count -lt $body_parameter_count-1 ]]; then
|
||||||
body_json+=", "
|
body_json+=", "
|
||||||
fi
|
fi
|
||||||
count+=1
|
((count+=1))
|
||||||
done
|
done
|
||||||
body_json+="}'"
|
body_json+="}'"
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "multi" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "multi" ]]; then
|
||||||
local vcount=0
|
local vcount=0
|
||||||
@ -467,7 +467,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "csv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "csv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -478,7 +478,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+=","
|
path_template+=","
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "ssv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "ssv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -488,7 +488,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+=" "
|
path_template+=" "
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "tsv" ]]; then
|
elif [[ "${operation_parameters_collection_type["${operation}:::${qparam}"]}" == "tsv" ]]; then
|
||||||
path_template+="${qparam}="
|
path_template+="${qparam}="
|
||||||
@ -498,7 +498,7 @@ validate_request_parameters() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
path_template+="\t"
|
path_template+="\t"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo -e ""
|
echo -e ""
|
||||||
@ -511,7 +511,7 @@ validate_request_parameters() {
|
|||||||
if [[ $count -lt $query_parameter_count-1 ]]; then
|
if [[ $count -lt $query_parameter_count-1 ]]; then
|
||||||
path_template+="&"
|
path_template+="&"
|
||||||
fi
|
fi
|
||||||
count+=1
|
((count+=1))
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -579,7 +579,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="&"
|
parameter_value+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'mutli' collections i.e. param=value1¶m=value2&...
|
# Append parameters specified as 'mutli' collections i.e. param=value1¶m=value2&...
|
||||||
@ -592,7 +592,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="&"
|
parameter_value+="&"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'csv' collections i.e. param=value1,value2,...
|
# Append parameters specified as 'csv' collections i.e. param=value1,value2,...
|
||||||
@ -606,7 +606,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+=","
|
parameter_value+=","
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'ssv' collections i.e. param="value1 value2 ..."
|
# Append parameters specified as 'ssv' collections i.e. param="value1 value2 ..."
|
||||||
@ -620,7 +620,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+=" "
|
parameter_value+=" "
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
#
|
#
|
||||||
# Append parameters specified as 'tsv' collections i.e. param="value1\tvalue2\t..."
|
# Append parameters specified as 'tsv' collections i.e. param="value1\tvalue2\t..."
|
||||||
@ -634,7 +634,7 @@ build_request_path() {
|
|||||||
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
if [[ $vcount -lt ${#parameter_values[@]}-1 ]]; then
|
||||||
parameter_value+="\t"
|
parameter_value+="\t"
|
||||||
fi
|
fi
|
||||||
vcount+=1
|
((vcount+=1))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -646,8 +646,7 @@ build_request_path() {
|
|||||||
query_request_part+="&"
|
query_request_part+="&"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count+=1
|
((count+=1))
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
|
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
|
||||||
# ! FROM SWAGGER SPECIFICATION IN JSON.
|
# ! FROM SWAGGER SPECIFICATION IN JSON.
|
||||||
# !
|
# !
|
||||||
# ! Generated on: 2017-02-06T21:48:13.013+01:00
|
# ! Generated on: 2017-02-22T08:48:10.130+01:00
|
||||||
# !
|
# !
|
||||||
# !
|
# !
|
||||||
# ! System wide installation:
|
# ! System wide installation:
|
||||||
|
@ -22,6 +22,18 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
|||||||
[[ "$output" =~ "Error: Request's content-type not specified!" ]]
|
[[ "$output" =~ "Error: Request's content-type not specified!" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "addPet abbreviated content type" {
|
||||||
|
run bash $PETSTORE_CLI -ct json -ac xml --host $PETSTORE_HOST \
|
||||||
|
addPet id:=123321 name==lucky status==available --dry-run
|
||||||
|
[[ "$output" =~ "Content-type: application/json" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "addPet unabbreviated content type" {
|
||||||
|
run bash $PETSTORE_CLI -ct userdefined/custom -ac xml --host $PETSTORE_HOST \
|
||||||
|
addPet id:=123321 name==lucky status==available --dry-run
|
||||||
|
[[ "$output" =~ "Content-type: userdefined/custom" ]]
|
||||||
|
}
|
||||||
|
|
||||||
@test "fakeOperation invalid operation name" {
|
@test "fakeOperation invalid operation name" {
|
||||||
run bash \
|
run bash \
|
||||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io fakeOperation"
|
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io fakeOperation"
|
||||||
@ -46,8 +58,11 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
|||||||
[[ ! "$output" =~ "-H \"api_key:" ]]
|
[[ ! "$output" =~ "-H \"api_key:" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "findPetsByStatus has default cURL parameters" {
|
||||||
|
run bash \
|
||||||
|
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus status=s1 --dry-run"
|
||||||
|
[[ ! "$output" =~ " -Ss " ]]
|
||||||
|
}
|
||||||
|
|
||||||
@test "findPetsByStatus too few values" {
|
@test "findPetsByStatus too few values" {
|
||||||
run bash \
|
run bash \
|
||||||
@ -97,6 +112,3 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
|||||||
bash $PETSTORE_CLI -ct json -ac xml addPet -"
|
bash $PETSTORE_CLI -ct json -ac xml addPet -"
|
||||||
[[ "$output" =~ "<id>37567</id>" ]]
|
[[ "$output" =~ "<id>37567</id>" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user