Mermade / openapi-codegen

OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
https://mermade.github.io/openapi-codegen
Apache License 2.0
294 stars 47 forks source link

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

Open laurence-myers opened 3 years ago

laurence-myers commented 3 years ago

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) {
  // ...
}
MikeRalphson commented 3 years ago

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