openapi-codegen icon indicating copy to clipboard operation
openapi-codegen copied to clipboard

nodejs template: kebab-case component schema name creates invalid JavaScript

Open laurence-myers opened this issue 3 years ago • 1 comments

e.g.

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/foo-bar-baz'

The generate API files have code like this:


module.exports.do_foo = function do_foo (req, res, next) {
  var foo-bar-baz = req.swagger.params['foo-bar-baz'].value;
  // ...
}

- is not a valid identifier character in JavaScript, because it's used as a mathematic operator foo - bar - baz.

The identifier is also used in the generated impl/API service:

exports.do_foo = function(foo-bar-baz) {
  // ...
}

laurence-myers avatar Feb 03 '21 23:02 laurence-myers

Note: look at interaction of variableNamingConvention and modelPropertyNaming and see if one should affect parameter naming.

MikeRalphson avatar Feb 04 '21 08:02 MikeRalphson