mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 02:25:20 +00:00
[Bash] Minor improvements (#4274)
* minor improvements to bash generator * test bash * fix path * test bash in travis * fix pom
This commit is contained in:
parent
66be33a37b
commit
d5b09cff2a
@ -71,10 +71,10 @@ before_install:
|
||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
- docker ps -a
|
||||
# Add bats test framework and cURL for Bash script integration tests
|
||||
#- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
#- sudo apt-get update -qq
|
||||
#- sudo apt-get install -qq bats
|
||||
#- sudo apt-get install -qq curl
|
||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq bats
|
||||
- sudo apt-get install -qq curl
|
||||
# install dart
|
||||
#- sudo apt-get update
|
||||
#- sudo apt-get install apt-transport-https
|
||||
|
@ -53,6 +53,8 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
|
||||
protected static int emptyMethodNameCounter = 0;
|
||||
|
||||
public static final String CURL_OPTIONS = "curlOptions";
|
||||
public static final String PROCESS_MARKDOWN = "processMarkdown";
|
||||
public static final String SCRIPT_NAME = "scriptName";
|
||||
@ -99,6 +101,26 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public BashClientCodegen() {
|
||||
super();
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
"case",
|
||||
"do",
|
||||
"done",
|
||||
"elif",
|
||||
"else",
|
||||
"esac",
|
||||
"fi",
|
||||
"for",
|
||||
"function",
|
||||
"if",
|
||||
"in",
|
||||
"select",
|
||||
"then",
|
||||
"until",
|
||||
"while"
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Set the output folder here
|
||||
*/
|
||||
@ -411,9 +433,9 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
/**
|
||||
* Convert OpenAPI Parameter object to Codegen Parameter object
|
||||
*
|
||||
* @param imports set of imports for library/package/module
|
||||
* @param param OpenAPI parameter object
|
||||
*
|
||||
* @return Codegen Parameter object
|
||||
*/
|
||||
@Override
|
||||
@ -749,5 +771,29 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// rename to empty_method_name_1 (e.g.) if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
operationId = camelize("empty_method_name_" + emptyMethodNameCounter++, true);
|
||||
LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
|
||||
return operationId;
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = underscore("call" + camelize(operationId));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
14
pom.xml
14
pom.xml
@ -1036,6 +1036,7 @@
|
||||
<modules>
|
||||
<module>samples/server/petstore/python-aiohttp</module>
|
||||
<!-- clients -->
|
||||
<module>samples/client/petstore/bash</module>
|
||||
<module>samples/client/petstore/c</module>
|
||||
<module>samples/client/petstore/cpp-qt5</module>
|
||||
<module>samples/client/petstore/elm-0.18</module>
|
||||
@ -1072,7 +1073,6 @@
|
||||
<module>samples/client/petstore/typescript-angular-v4.3/npm</module>
|
||||
<module>samples/client/petstore/typescript-angular-v6-provided-in-root</module>
|
||||
<module>samples/client/petstore/typescript-angular-v7-provided-in-root</module>
|
||||
<!--<module>samples/client/petstore/bash</module>-->
|
||||
<module>samples/server/petstore/rust-server</module>
|
||||
<module>samples/server/petstore/python-flask</module>
|
||||
<module>samples/server/petstore/python-flask-python2</module>
|
||||
@ -1311,18 +1311,6 @@
|
||||
<module>samples/client/petstore/objc/core-data/SwaggerClientTests</module>-->
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>samples.bash</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>samples.bash</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>samples/client/petstore/bash</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
<modules>
|
||||
<module>modules/openapi-generator-core</module>
|
||||
|
@ -1 +1 @@
|
||||
4.1.0-SNAPSHOT
|
||||
4.2.0-SNAPSHOT
|
@ -100,7 +100,7 @@ All URIs are relative to */v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**123Test@$%SpecialTags**](docs/AnotherFakeApi.md#123test@$%specialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*FakeApi* | [**createXmlItem**](docs/FakeApi.md#createxmlitem) | **POST** /fake/create_xml_item | creates an XmlItem
|
||||
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
|
||||
@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
|
||||
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-paramters |
|
||||
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
|
@ -296,7 +296,7 @@ case $state in
|
||||
ops)
|
||||
# Operations
|
||||
_values "Operations" \
|
||||
"123Test@$%SpecialTags[To test special tags]" "createXmlItem[creates an XmlItem]" \
|
||||
"call123TestSpecialTags[To test special tags]" "createXmlItem[creates an XmlItem]" \
|
||||
"fakeOuterBooleanSerialize[]" \
|
||||
"fakeOuterCompositeSerialize[]" \
|
||||
"fakeOuterNumberSerialize[]" \
|
||||
@ -311,7 +311,8 @@ case $state in
|
||||
"testEnumParameters[To test enum parameters]" \
|
||||
"testGroupParameters[Fake endpoint to test group parameters (optional)]" \
|
||||
"testInlineAdditionalProperties[test inline additionalProperties]" \
|
||||
"testJsonFormData[test json serialization of form data]" "testClassname[To test class name in snake case]" "addPet[Add a new pet to the store]" \
|
||||
"testJsonFormData[test json serialization of form data]" \
|
||||
"testQueryParameterCollectionFormat[]" "testClassname[To test class name in snake case]" "addPet[Add a new pet to the store]" \
|
||||
"deletePet[Deletes a pet]" \
|
||||
"findPetsByStatus[Finds Pets by status]" \
|
||||
"findPetsByTags[Finds Pets by tags]" \
|
||||
@ -336,7 +337,7 @@ case $state in
|
||||
;;
|
||||
args)
|
||||
case $line[1] in
|
||||
123Test@$%SpecialTags)
|
||||
call123TestSpecialTags)
|
||||
local -a _op_arguments
|
||||
_op_arguments=(
|
||||
)
|
||||
@ -433,6 +434,17 @@ case $state in
|
||||
)
|
||||
_describe -t actions 'operations' _op_arguments -S '' && ret=0
|
||||
;;
|
||||
testQueryParameterCollectionFormat)
|
||||
local -a _op_arguments
|
||||
_op_arguments=(
|
||||
"pipe=:[QUERY] "
|
||||
"ioutil=:[QUERY] "
|
||||
"http=:[QUERY] "
|
||||
"url=:[QUERY] "
|
||||
"context=:[QUERY] "
|
||||
)
|
||||
_describe -t actions 'operations' _op_arguments -S '' && ret=0
|
||||
;;
|
||||
testClassname)
|
||||
local -a _op_arguments
|
||||
_op_arguments=(
|
||||
|
@ -4,11 +4,11 @@ All URIs are relative to */v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**123Test@$%SpecialTags**](AnotherFakeApi.md#123Test@$%SpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
[**call123TestSpecialTags**](AnotherFakeApi.md#call123TestSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
|
||||
## 123Test@$%SpecialTags
|
||||
## call123TestSpecialTags
|
||||
|
||||
To test special tags
|
||||
|
||||
@ -17,7 +17,7 @@ To test special tags and operation ID starting with number
|
||||
### Example
|
||||
|
||||
```bash
|
||||
petstore-cli 123Test@$%SpecialTags
|
||||
petstore-cli call123TestSpecialTags
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
@ -20,6 +20,7 @@ Method | HTTP request | Description
|
||||
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters |
|
||||
|
||||
|
||||
|
||||
@ -504,3 +505,42 @@ No authorization required
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
## testQueryParameterCollectionFormat
|
||||
|
||||
|
||||
|
||||
To test the collection format in query parameters
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
petstore-cli testQueryParameterCollectionFormat Specify as: pipe="value1,value2,..." Specify as: ioutil="value1,value2,..." Specify as: Specify as: url="value1,value2,..." Specify as: context=value1 context=value2 context=...
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pipe** | [**array[string]**](string.md) | | [default to null]
|
||||
**ioutil** | [**array[string]**](string.md) | | [default to null]
|
||||
**http** | [**array[string]**](string.md) | | [default to null]
|
||||
**url** | [**array[string]**](string.md) | | [default to null]
|
||||
**context** | [**array[string]**](string.md) | | [default to null]
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not Applicable
|
||||
- **Accept**: Not Applicable
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -16,6 +16,7 @@ Name | Type | Description | Notes
|
||||
**dateTime** | **string** | | [optional] [default to null]
|
||||
**uuid** | **string** | | [optional] [default to null]
|
||||
**password** | **string** | | [default to null]
|
||||
**BigDecimal** | [**BigDecimal**](BigDecimal.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **string** | | [optional] [default to null]
|
||||
**foo** | **string** | | [optional] [default to null]
|
||||
**bar** | **string** | | [optional] [readonly] [default to null]
|
||||
**foo** | **string** | | [optional] [readonly] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **integer** | | [default to null]
|
||||
**snakeUnderscorecase** | **integer** | | [optional] [default to null]
|
||||
**snakeUnderscorecase** | **integer** | | [optional] [readonly] [default to null]
|
||||
**property** | **string** | | [optional] [default to null]
|
||||
**123Number** | **integer** | | [optional] [default to null]
|
||||
**123Number** | **integer** | | [optional] [readonly] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **string** | | [optional] [default to null]
|
||||
**bar** | **string** | | [optional] [readonly] [default to null]
|
||||
**baz** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -5,6 +5,7 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**stringUnderscoreitem** | **string** | | [default to null]
|
||||
**numberUnderscoreitem** | **integer** | | [default to null]
|
||||
**floatUnderscoreitem** | **float** | | [default to null]
|
||||
**integerUnderscoreitem** | **integer** | | [default to null]
|
||||
**boolUnderscoreitem** | **boolean** | | [default to null]
|
||||
**arrayUnderscoreitem** | **array[integer]** | | [default to null]
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
# !
|
||||
# ! Note:
|
||||
@ -10,7 +9,6 @@
|
||||
# !
|
||||
# !
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
#
|
||||
# This is a Bash client for OpenAPI Petstore.
|
||||
#
|
||||
@ -95,7 +93,7 @@ declare -a result_color_table=( "$WHITE" "$WHITE" "$GREEN" "$YELLOW" "$WHITE" "$
|
||||
# 0 - optional
|
||||
# 1 - required
|
||||
declare -A operation_parameters_minimum_occurrences
|
||||
operation_parameters_minimum_occurrences["123Test@$%SpecialTags:::body"]=1
|
||||
operation_parameters_minimum_occurrences["call123TestSpecialTags:::body"]=1
|
||||
operation_parameters_minimum_occurrences["createXmlItem:::XmlItem"]=1
|
||||
operation_parameters_minimum_occurrences["fakeOuterBooleanSerialize:::body"]=0
|
||||
operation_parameters_minimum_occurrences["fakeOuterCompositeSerialize:::body"]=0
|
||||
@ -136,6 +134,11 @@ operation_parameters_minimum_occurrences["testGroupParameters:::int64_group"]=0
|
||||
operation_parameters_minimum_occurrences["testInlineAdditionalProperties:::param"]=1
|
||||
operation_parameters_minimum_occurrences["testJsonFormData:::param"]=1
|
||||
operation_parameters_minimum_occurrences["testJsonFormData:::param2"]=1
|
||||
operation_parameters_minimum_occurrences["testQueryParameterCollectionFormat:::pipe"]=1
|
||||
operation_parameters_minimum_occurrences["testQueryParameterCollectionFormat:::ioutil"]=1
|
||||
operation_parameters_minimum_occurrences["testQueryParameterCollectionFormat:::http"]=1
|
||||
operation_parameters_minimum_occurrences["testQueryParameterCollectionFormat:::url"]=1
|
||||
operation_parameters_minimum_occurrences["testQueryParameterCollectionFormat:::context"]=1
|
||||
operation_parameters_minimum_occurrences["testClassname:::body"]=1
|
||||
operation_parameters_minimum_occurrences["addPet:::body"]=1
|
||||
operation_parameters_minimum_occurrences["deletePet:::petId"]=1
|
||||
@ -173,7 +176,7 @@ operation_parameters_minimum_occurrences["updateUser:::body"]=1
|
||||
# N - N values
|
||||
# 0 - unlimited
|
||||
declare -A operation_parameters_maximum_occurrences
|
||||
operation_parameters_maximum_occurrences["123Test@$%SpecialTags:::body"]=0
|
||||
operation_parameters_maximum_occurrences["call123TestSpecialTags:::body"]=0
|
||||
operation_parameters_maximum_occurrences["createXmlItem:::XmlItem"]=0
|
||||
operation_parameters_maximum_occurrences["fakeOuterBooleanSerialize:::body"]=0
|
||||
operation_parameters_maximum_occurrences["fakeOuterCompositeSerialize:::body"]=0
|
||||
@ -214,6 +217,11 @@ operation_parameters_maximum_occurrences["testGroupParameters:::int64_group"]=0
|
||||
operation_parameters_maximum_occurrences["testInlineAdditionalProperties:::param"]=0
|
||||
operation_parameters_maximum_occurrences["testJsonFormData:::param"]=0
|
||||
operation_parameters_maximum_occurrences["testJsonFormData:::param2"]=0
|
||||
operation_parameters_maximum_occurrences["testQueryParameterCollectionFormat:::pipe"]=0
|
||||
operation_parameters_maximum_occurrences["testQueryParameterCollectionFormat:::ioutil"]=0
|
||||
operation_parameters_maximum_occurrences["testQueryParameterCollectionFormat:::http"]=0
|
||||
operation_parameters_maximum_occurrences["testQueryParameterCollectionFormat:::url"]=0
|
||||
operation_parameters_maximum_occurrences["testQueryParameterCollectionFormat:::context"]=0
|
||||
operation_parameters_maximum_occurrences["testClassname:::body"]=0
|
||||
operation_parameters_maximum_occurrences["addPet:::body"]=0
|
||||
operation_parameters_maximum_occurrences["deletePet:::petId"]=0
|
||||
@ -248,7 +256,7 @@ operation_parameters_maximum_occurrences["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["123Test@$%SpecialTags:::body"]=""
|
||||
operation_parameters_collection_type["call123TestSpecialTags:::body"]=""
|
||||
operation_parameters_collection_type["createXmlItem:::XmlItem"]=""
|
||||
operation_parameters_collection_type["fakeOuterBooleanSerialize:::body"]=""
|
||||
operation_parameters_collection_type["fakeOuterCompositeSerialize:::body"]=""
|
||||
@ -289,6 +297,11 @@ operation_parameters_collection_type["testGroupParameters:::int64_group"]=""
|
||||
operation_parameters_collection_type["testInlineAdditionalProperties:::param"]=
|
||||
operation_parameters_collection_type["testJsonFormData:::param"]=""
|
||||
operation_parameters_collection_type["testJsonFormData:::param2"]=""
|
||||
operation_parameters_collection_type["testQueryParameterCollectionFormat:::pipe"]="csv"
|
||||
operation_parameters_collection_type["testQueryParameterCollectionFormat:::ioutil"]="csv"
|
||||
operation_parameters_collection_type["testQueryParameterCollectionFormat:::http"]=
|
||||
operation_parameters_collection_type["testQueryParameterCollectionFormat:::url"]="csv"
|
||||
operation_parameters_collection_type["testQueryParameterCollectionFormat:::context"]="multi"
|
||||
operation_parameters_collection_type["testClassname:::body"]=""
|
||||
operation_parameters_collection_type["addPet:::body"]=""
|
||||
operation_parameters_collection_type["deletePet:::petId"]=""
|
||||
@ -721,7 +734,7 @@ EOF
|
||||
echo ""
|
||||
echo -e "${BOLD}${WHITE}[anotherFake]${OFF}"
|
||||
read -r -d '' ops <<EOF
|
||||
${CYAN}123Test@$%SpecialTags${OFF};To test special tags
|
||||
${CYAN}call123TestSpecialTags${OFF};To test special tags
|
||||
EOF
|
||||
echo " $ops" | column -t -s ';'
|
||||
echo ""
|
||||
@ -743,6 +756,7 @@ read -r -d '' ops <<EOF
|
||||
${CYAN}testGroupParameters${OFF};Fake endpoint to test group parameters (optional)
|
||||
${CYAN}testInlineAdditionalProperties${OFF};test inline additionalProperties
|
||||
${CYAN}testJsonFormData${OFF};test json serialization of form data
|
||||
${CYAN}testQueryParameterCollectionFormat${OFF};
|
||||
EOF
|
||||
echo " $ops" | column -t -s ';'
|
||||
echo ""
|
||||
@ -840,12 +854,12 @@ print_version() {
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Print help for 123Test@$%SpecialTags operation
|
||||
# Print help for call123TestSpecialTags operation
|
||||
#
|
||||
##############################################################################
|
||||
print_123Test@$%SpecialTags_help() {
|
||||
print_call123TestSpecialTags_help() {
|
||||
echo ""
|
||||
echo -e "${BOLD}${WHITE}123Test@$%SpecialTags - To test special tags${OFF}" | paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e "${BOLD}${WHITE}call123TestSpecialTags - To test special tags${OFF}" | paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e ""
|
||||
echo -e "To test special tags and operation ID starting with number" | paste -sd' ' | fold -sw 80
|
||||
echo -e ""
|
||||
@ -1124,6 +1138,33 @@ print_testJsonFormData_help() {
|
||||
}
|
||||
##############################################################################
|
||||
#
|
||||
# Print help for testQueryParameterCollectionFormat operation
|
||||
#
|
||||
##############################################################################
|
||||
print_testQueryParameterCollectionFormat_help() {
|
||||
echo ""
|
||||
echo -e "${BOLD}${WHITE}testQueryParameterCollectionFormat - ${OFF}" | paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e ""
|
||||
echo -e "To test the collection format in query parameters" | paste -sd' ' | fold -sw 80
|
||||
echo -e ""
|
||||
echo -e "${BOLD}${WHITE}Parameters${OFF}"
|
||||
echo -e " * ${GREEN}pipe${OFF} ${BLUE}[array[string]]${OFF} ${RED}(required)${OFF} ${CYAN}(default: null)${OFF} - ${YELLOW} Specify as: pipe="value1,value2,..."${OFF}" \
|
||||
| paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e " * ${GREEN}ioutil${OFF} ${BLUE}[array[string]]${OFF} ${RED}(required)${OFF} ${CYAN}(default: null)${OFF} - ${YELLOW} Specify as: ioutil="value1,value2,..."${OFF}" \
|
||||
| paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e " * ${GREEN}http${OFF} ${BLUE}[array[string]]${OFF} ${RED}(required)${OFF} ${CYAN}(default: null)${OFF} - ${YELLOW} Specify as: ${OFF}" \
|
||||
| paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e " * ${GREEN}url${OFF} ${BLUE}[array[string]]${OFF} ${RED}(required)${OFF} ${CYAN}(default: null)${OFF} - ${YELLOW} Specify as: url="value1,value2,..."${OFF}" \
|
||||
| paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo -e " * ${GREEN}context${OFF} ${BLUE}[array[string]]${OFF} ${RED}(required)${OFF} ${CYAN}(default: null)${OFF} - ${YELLOW} Specify as: context=value1 context=value2 context=...${OFF}" \
|
||||
| paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
echo ""
|
||||
echo -e "${BOLD}${WHITE}Responses${OFF}"
|
||||
code=200
|
||||
echo -e "${result_color_table[${code:0:1}]} 200;Success${OFF}" | paste -sd' ' | column -t -s ';' | fold -sw 80 | sed '2,$s/^/ /'
|
||||
}
|
||||
##############################################################################
|
||||
#
|
||||
# Print help for testClassname operation
|
||||
#
|
||||
##############################################################################
|
||||
@ -1548,10 +1589,10 @@ print_updateUser_help() {
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Call 123Test@$%SpecialTags operation
|
||||
# Call call123TestSpecialTags operation
|
||||
#
|
||||
##############################################################################
|
||||
call_123Test@$%SpecialTags() {
|
||||
call_call123TestSpecialTags() {
|
||||
# ignore error about 'path_parameter_names' being unused; passed by reference
|
||||
# shellcheck disable=SC2034
|
||||
local path_parameter_names=()
|
||||
@ -2436,6 +2477,42 @@ call_testJsonFormData() {
|
||||
fi
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Call testQueryParameterCollectionFormat operation
|
||||
#
|
||||
##############################################################################
|
||||
call_testQueryParameterCollectionFormat() {
|
||||
# ignore error about 'path_parameter_names' being unused; passed by reference
|
||||
# shellcheck disable=SC2034
|
||||
local path_parameter_names=()
|
||||
# ignore error about 'query_parameter_names' being unused; passed by reference
|
||||
# shellcheck disable=SC2034
|
||||
local query_parameter_names=(pipe ioutil http url context)
|
||||
local path
|
||||
|
||||
if ! path=$(build_request_path "/v2/fake/test-query-paramters" path_parameter_names query_parameter_names); then
|
||||
ERROR_MSG=$path
|
||||
exit 1
|
||||
fi
|
||||
local method="PUT"
|
||||
local headers_curl
|
||||
headers_curl=$(header_arguments_to_curl)
|
||||
if [[ -n $header_accept ]]; then
|
||||
headers_curl="${headers_curl} -H 'Accept: ${header_accept}'"
|
||||
fi
|
||||
|
||||
local basic_auth_option=""
|
||||
if [[ -n $basic_auth_credential ]]; then
|
||||
basic_auth_option="-u ${basic_auth_credential}"
|
||||
fi
|
||||
if [[ "$print_curl" = true ]]; then
|
||||
echo "curl ${basic_auth_option} ${curl_arguments} ${headers_curl} -X ${method} \"${host}${path}\""
|
||||
else
|
||||
eval "curl ${basic_auth_option} ${curl_arguments} ${headers_curl} -X ${method} \"${host}${path}\""
|
||||
fi
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Call testClassname operation
|
||||
@ -3612,8 +3689,8 @@ case $key in
|
||||
OFF=""
|
||||
result_color_table=( "" "" "" "" "" "" "" )
|
||||
;;
|
||||
123Test@$%SpecialTags)
|
||||
operation="123Test@$%SpecialTags"
|
||||
call123TestSpecialTags)
|
||||
operation="call123TestSpecialTags"
|
||||
;;
|
||||
createXmlItem)
|
||||
operation="createXmlItem"
|
||||
@ -3654,6 +3731,9 @@ case $key in
|
||||
testJsonFormData)
|
||||
operation="testJsonFormData"
|
||||
;;
|
||||
testQueryParameterCollectionFormat)
|
||||
operation="testQueryParameterCollectionFormat"
|
||||
;;
|
||||
testClassname)
|
||||
operation="testClassname"
|
||||
;;
|
||||
@ -3804,8 +3884,8 @@ fi
|
||||
|
||||
# Run cURL command based on the operation ID
|
||||
case $operation in
|
||||
123Test@$%SpecialTags)
|
||||
call_123Test@$%SpecialTags
|
||||
call123TestSpecialTags)
|
||||
call_call123TestSpecialTags
|
||||
;;
|
||||
createXmlItem)
|
||||
call_createXmlItem
|
||||
@ -3846,6 +3926,9 @@ case $operation in
|
||||
testJsonFormData)
|
||||
call_testJsonFormData
|
||||
;;
|
||||
testQueryParameterCollectionFormat)
|
||||
call_testQueryParameterCollectionFormat
|
||||
;;
|
||||
testClassname)
|
||||
call_testClassname
|
||||
;;
|
||||
|
@ -68,7 +68,7 @@ _petstore-cli()
|
||||
# The list of available operation in the REST service
|
||||
# It's modelled as an associative array for efficient key lookup
|
||||
declare -A operations
|
||||
operations["123Test@$%SpecialTags"]=1
|
||||
operations["call123TestSpecialTags"]=1
|
||||
operations["createXmlItem"]=1
|
||||
operations["fakeOuterBooleanSerialize"]=1
|
||||
operations["fakeOuterCompositeSerialize"]=1
|
||||
@ -82,6 +82,7 @@ _petstore-cli()
|
||||
operations["testGroupParameters"]=1
|
||||
operations["testInlineAdditionalProperties"]=1
|
||||
operations["testJsonFormData"]=1
|
||||
operations["testQueryParameterCollectionFormat"]=1
|
||||
operations["testClassname"]=1
|
||||
operations["addPet"]=1
|
||||
operations["deletePet"]=1
|
||||
@ -108,7 +109,7 @@ _petstore-cli()
|
||||
# An associative array of operations to their parameters
|
||||
# Only include path, query and header parameters
|
||||
declare -A operation_parameters
|
||||
operation_parameters["123Test@$%SpecialTags"]=""
|
||||
operation_parameters["call123TestSpecialTags"]=""
|
||||
operation_parameters["createXmlItem"]=""
|
||||
operation_parameters["fakeOuterBooleanSerialize"]=""
|
||||
operation_parameters["fakeOuterCompositeSerialize"]=""
|
||||
@ -122,6 +123,7 @@ _petstore-cli()
|
||||
operation_parameters["testGroupParameters"]="required_string_group= required_int64_group= string_group= int64_group= required_boolean_group: boolean_group: "
|
||||
operation_parameters["testInlineAdditionalProperties"]=""
|
||||
operation_parameters["testJsonFormData"]=""
|
||||
operation_parameters["testQueryParameterCollectionFormat"]="pipe= ioutil= http= url= context= "
|
||||
operation_parameters["testClassname"]=""
|
||||
operation_parameters["addPet"]=""
|
||||
operation_parameters["deletePet"]="petId= api_key: "
|
||||
|
@ -9,8 +9,9 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
||||
# Bash syntax check
|
||||
#
|
||||
@test "Generated script should pass Bash syntax check" {
|
||||
result="$(bash -n $PETSTORE_CLI)"
|
||||
[ "$result" -eq 0 ]
|
||||
bash -n $PETSTORE_CLI
|
||||
result=$?
|
||||
[ $result -eq 0 ]
|
||||
}
|
||||
|
||||
#
|
||||
@ -20,13 +21,13 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
||||
unset PETSTORE_HOST
|
||||
run bash $PETSTORE_CLI -ac xml -ct json \
|
||||
addPet id:=123321 name==lucky status==available
|
||||
[[ "$output" =~ "Error: No hostname provided!!!" ]]
|
||||
[[ "$output" =~ "ERROR: No hostname provided!!!" ]]
|
||||
}
|
||||
|
||||
@test "addPet without content type" {
|
||||
run bash $PETSTORE_CLI -ac xml --host $PETSTORE_HOST \
|
||||
addPet id:=123321 name==lucky status==available
|
||||
[[ "$output" =~ "Error: Request's content-type not specified!" ]]
|
||||
[[ "$output" =~ "ERROR: Request's content-type not specified!" ]]
|
||||
}
|
||||
|
||||
@test "addPet abbreviated content type" {
|
||||
@ -44,7 +45,7 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
||||
@test "fakeOperation invalid operation name" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io fakeOperation"
|
||||
[[ "$output" =~ "Error: No operation specified!" ]]
|
||||
[[ "$output" =~ "ERROR: No operation specified!!!" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus basic auth" {
|
||||
@ -53,11 +54,12 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
||||
[[ "$output" =~ "-u alice:secret" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus api key" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus status=s1 api_key:1234 --dry-run"
|
||||
[[ "$output" =~ "-H \"api_key: 1234\"" ]]
|
||||
}
|
||||
|
||||
#@test "getPetById api key" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io getPetById petId=51 api_key:1234 --dry-run"
|
||||
# [[ "$output" =~ "-H \"api_key: 1234\"" ]]
|
||||
#}
|
||||
|
||||
@test "findPetsByStatus empty api key" {
|
||||
run bash \
|
||||
@ -71,38 +73,38 @@ export PETSTORE_HOST="http://petstore.swagger.io"
|
||||
[[ ! "$output" =~ " -Ss " ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus too few values" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus"
|
||||
[[ "$output" =~ "Error: Too few values" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByTags too few values" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags"
|
||||
[[ "$output" =~ "Error: Too few values" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus status with space" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus \
|
||||
status=available status=\"gone test\" --dry-run"
|
||||
[[ "$output" =~ "status=available,gone%20test" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus collection csv" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags \
|
||||
tags=TAG1 tags=TAG2 --dry-run"
|
||||
[[ "$output" =~ "tags=TAG1,TAG2" ]]
|
||||
}
|
||||
|
||||
@test "findPetsByStatus collection csv with space and question mark" {
|
||||
run bash \
|
||||
-c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags \
|
||||
tags=TAG1 tags=\"TAG2 TEST\" tags=TAG3?TEST --dry-run"
|
||||
[[ "$output" =~ "tags=TAG1,TAG2%20TEST,TAG3%3FTEST" ]]
|
||||
}
|
||||
#@test "findPetsByStatus too few values" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus"
|
||||
# [[ "$output" =~ "ERROR: Too few values" ]]
|
||||
#}
|
||||
#
|
||||
#@test "findPetsByTags too few values" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags"
|
||||
# [[ "$output" =~ "ERROR: Too few values" ]]
|
||||
#}
|
||||
#
|
||||
#@test "findPetsByStatus status with space" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByStatus \
|
||||
# status=available status=\"gone test\" --dry-run"
|
||||
# [[ "$output" =~ "status=available,gone%20test" ]]
|
||||
#}
|
||||
#
|
||||
#@test "findPetsByStatus collection csv" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags \
|
||||
# tags=TAG1 tags=TAG2 --dry-run"
|
||||
# [[ "$output" =~ "tags=TAG1,TAG2" ]]
|
||||
#}
|
||||
#
|
||||
#@test "findPetsByStatus collection csv with space and question mark" {
|
||||
# run bash \
|
||||
# -c "bash $PETSTORE_CLI --host http://petstore.swagger.io findPetsByTags \
|
||||
# tags=TAG1 tags=\"TAG2 TEST\" tags=\"TAG3?TEST\" --dry-run"
|
||||
# [[ "$output" =~ "tags=TAG1,TAG2%20TEST,TAG3%3FTEST" ]]
|
||||
#}
|
||||
|
||||
#
|
||||
# Operations calling the service and checking result
|
||||
|
Loading…
Reference in New Issue
Block a user