-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swagger codegen cli for openspec 3 - java language generation fails #8218
Comments
The issues seems to be in DefaultGenerator.java line 1013 method getHandlebars. The first part of this method has teh logic: if (tempalteFile.startsWith(config.templateDir())) { template file is: v2\Java\model.mustache |
This only happens in Windows for me, and I think has to do with the backslashes being misinterpreted in the I have received the same error reliably in Windows, although the same commands work fine in macOs. swagger-codegen-cli-3.0.0-20180523.181249-69.jar My command line is
And my error message is:
This happens in Windows 7 and Windows 10, JRE 8 or 9. I will try to make a local build and fix the line. |
Replacing the private com.github.jknack.handlebars.Template getHandlebars(String templateFile) throws IOException {
if (templateFile.startsWith(config.templateDir())) {
// templateFile = templateFile.replaceFirst(config.templateDir(), StringUtils.EMPTY);
templateFile = StringUtils.replaceOnce(templateFile, config.templateDir(), StringUtils.EMPTY);
} |
@bigtlb - swagger-codegen 3.0.0 rc1 does not seem to have this fix. Do you know if it made to that release candidate? |
hey @bigtlb @murthy5 can you please try with https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.0 and let me know if there is something wrong? |
I have added a fix for this issue in another GitHub issue which is about the same topic. |
Hello, I am still experiencing this issue with the following versions on Windows: Frustrating that this is still an open issue 3 years later.
|
Description
When I try to generate java stubs from a simple yml api definition I am getting the following error.
I am able to generate using other language types - but were hoping that the "java" language option will yield a set of stubs that are framework agnostic. I would like the generated stubs to be simply the model and an interface for the service.
Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate model 'AppConfig'
at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:409)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:728)
at io.swagger.codegen.cmd.Generate.run(Generate.java:331)
at java.lang.Thread.run(Unknown Source)
Caused by: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3
v2\Java
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.escape(Unknown Source)
at java.util.regex.Pattern.atom(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceFirst(Unknown Source)
at io.swagger.codegen.DefaultGenerator.getHandlebars(DefaultGenerator.java:1014)
at io.swagger.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:744)
at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:396)
... 3 more
Swagger-codegen version
swagger-codegen-cli-3.0.0-20180515.103456-67.jar
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli-3.0.0-20180515.103456-67.jar generate -l java -i sample.yml -o ./dest
Steps to reproduce
Just run the command above.
Related issues/PRs
Suggest a fix/enhancement
The text was updated successfully, but these errors were encountered: