You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Codegen throws a NPE when generating code for a buggy declaration that has parameters without a name. Happens at least with nodejs-server and python-flask, but not with any client codegens I've tried, so maybe this is a server-only issue?
$ java -jar swagger-codegen-cli.jar generate -i bug.yml -l nodejs-server
[main] INFO io.swagger.parser.Swagger20Parser - reading from bug.yml
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: default
Operation: foo
Resource: get /
Definitions: {}
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:808)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:700)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:377)
at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.<init>(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at io.swagger.codegen.DefaultCodegen.camelize(DefaultCodegen.java:2875)
at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1385)
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2227)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:1993)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:756)
... 4 more
Suggest a Fix
Should probably ignore parameters without a name, and output a warning message about them (along with input filename, linenumber if possible). Or fail with a descriptive message.
The text was updated successfully, but these errors were encountered:
Agreed that the NPE should be handled with a better error message.
Btw, "name" in the parameter object is a required field so please update your spec accordingly and you can leverage tools like https://editor.swagger.io to verify the spec.
Description
Codegen throws a NPE when generating code for a buggy declaration that has parameters without a name. Happens at least with nodejs-server and python-flask, but not with any client codegens I've tried, so maybe this is a server-only issue?
Swagger-codegen version
Current master
Swagger declaration file content or url
Steps to reproduce
Suggest a Fix
Should probably ignore parameters without a name, and output a warning message about them (along with input filename, linenumber if possible). Or fail with a descriptive message.
The text was updated successfully, but these errors were encountered: