Skip to content
GitLab
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
  • Issues
  • #5007
Closed
Open
Issue created Jan 15, 2020 by Administrator@rootContributor4 of 4 checklist items completed4/4 checklist items

[BUG] [Bash] HTTP Headers passed as `key:value` are not detected as such

Created by: Anvil

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

In the generated bash script --help, one can read read this:

  my_api.sh [-h|--help] [-V|--version] [--about] [<curl-options>]
           [-ac|--accept <mime-type>] [-ct,--content-type <mime-type>]
           [--host <url>] [--dry-run] [-nc|--no-colors] <operation> [-h|--help]
           [<headers>] [<parameters>] [<body-parameters>]
[...]
  - <headers> - HTTP headers can be passed in the form HEADER:VALUE
[...]

According to that, I should be able to declare HTTP headers using the following syntax:

./my_api.sh --host example.com collectionGet header_name:header_value

And it does not work because the pattern used to match header_name:header_value is incorect.

openapi-generator version

I've checked the master branch (as of 2020/01/15) , the problem is there.

OpenAPI declaration file content or url

N/A

Command line used for generation
    docker run --rm  openapitools/openapi-generator-cli \
	   generate --skip-validate-spec -i swagger_file -g bash \
	   -o /data --additional-properties=scriptName=my_api.sh
Steps to reproduce
  1. ./my_api.sh --dry-run --host https://example.com collectionGet Authorization:xxxx

reports

curl     -X GET "https://example.com/v0/collection"

While it should report

curl   -H "Authorization:xxxx"   -X GET "https://example.com/v0/collection"
Related issues/PRs

Looked for bash in issues. Found none related.

Suggest a fix

The fix is kinda trivial. The parentheses in the pattern have been incorrectly back-slashed. Just un-back-slash them. See https://github.com/OpenAPITools/openapi-generator/commit/88c2fdbecde7c024e614ab63f78ee1b0a0c540d8

It's a regression that has been brought in commit 8b61b1d4, apparently to satisfy an incomplete shell syntax checker.

cc: @frol @bkryza @kenjones-cisco

Assignee
Assign to
Time tracking