Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !4274

[Bash] Minor improvements

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged William Cheng requested to merge bash_improve into master 5 years ago
  • Overview 0
  • Commits 5
  • Pipelines 0
  • Changes 16
  • re-enable test cases in Travis
  • fix minor test issues
  • better handling of method naming
  • better handling of reserved words

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Compare
  • master (base)

and
  • latest version
    b2aa7e7a
    5 commits, 2 years ago

16 files
+ 266
- 90

    Preferences

    File browser
    Compare changes
modules/…/…/…/…‎/…/…/…/languages‎
BashClientC‎odegen.java‎ +47 -1
samples/client‎/petstore/bash‎
.openapi-‎generator‎
VER‎SION‎ +1 -1
do‎cs‎
AnotherF‎akeApi.md‎ +3 -3
FakeA‎pi.md‎ +40 -0
Format‎Test.md‎ +1 -0
HasOnlyRe‎adOnly.md‎ +2 -2
Nam‎e.md‎ +2 -2
ReadOnly‎First.md‎ +1 -1
TypeHolder‎Example.md‎ +1 -0
te‎sts‎
petstore‎_test.sh‎ +44 -42
READ‎ME.md‎ +2 -1
_petst‎ore-cli‎ +15 -3
petsto‎re-cli‎ +98 -15
petstore-cli.b‎ash-completion‎ +4 -2
.trav‎is.yml‎ +4 -4
pom‎.xml‎ +1 -13
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/BashClientCodegen.java
+ 47
- 1
  • View file @ b2aa7e7a

  • Edit in single-file editor

  • Open in Web IDE


@@ -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);
}
}
samples/client/petstore/bash/.openapi-generator/VERSION
+ 1
- 1
  • View file @ b2aa7e7a

  • Edit in single-file editor

  • Open in Web IDE

4.1.0-SNAPSHOT
\ No newline at end of file
4.2.0-SNAPSHOT
\ No newline at end of file
samples/client/petstore/bash/docs/AnotherFakeApi.md
+ 3
- 3
  • View file @ b2aa7e7a

  • Edit in single-file editor

  • Open in Web IDE


@@ -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
samples/client/petstore/bash/docs/FakeApi.md
+ 40
- 0
  • View file @ b2aa7e7a

  • Edit in single-file editor

  • Open in Web IDE


@@ -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)
samples/client/petstore/bash/docs/FormatTest.md
+ 1
- 0
  • View file @ b2aa7e7a

  • Edit in single-file editor

  • Open in Web IDE


@@ -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)
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
3.2.1
3.2.1 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: OpenAPITools/openapi-generator!807
Source branch: bash_improve

Menu

Explore Projects Groups Snippets