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
  • #7389
Closed
Open
Issue created Sep 10, 2020 by Administrator@rootContributor2 of 6 checklist items completed2/6 checklist items

[BUG][nodejs-express-server] HTTP headers with hyphens

Created by: NathanHazout

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When the spec includes HTTP headers with hyphens (my-header), as is the standard, the generated service correctly converts the variable name to camelCase (myHeader), however at runtime, the requestParams object still uses the hyphen version (params['my-header']).

Therefore, the variable does not correctly map the value.

openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "my-header",
            "required": true
          }
        ]
Generation Details

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/api/api.json -t /local/core/swagger/mustache/nodejs-express-server/ -g nodejs-express-server -o /local/server/ --skip-validate-spec

Steps to reproduce
  • Create an API specs with required HTTP headers, the header name must include a hyphen
  • Generate a nodejs server
  • Put a breakpoint in the generate Service, see that the variable is always undefined.
Suggest a fix

Whatever algorithm is used to transform the variable names, should be used when mapping the request params at run time.

Assignee
Assign to
Time tracking