swagger-api / swagger-api/swagger-codegen
Error running custom generator
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Running through the steps in this doc for how to create a custom generator. I've created the basic sample project in output/myLibrary, compiled it with mvn package, although I had to add
<repositories>
<repository>
<id>swagger-codegen-repo</id>
<url>file://${basedir}/swagger-codegen-repo</url>
</repository>
</repositories>
to the pom.xml file (as well as possibly other minor changes that were necessary) in order to get mvn package to compile successfully. The io.swagger.swagger-modules dependency also had to be added in order to get to the stage I am currently at.
I have made no changes to the MyclientcodegenGenerator.java file.
Swagger-codegen version
This occurs on both Windows (running in Power Shell) and Linux (Ubuntu Bash through WSL), with the latest version of swagger-codegen.
Command line used for generation
When I execute
java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
io.swagger.codegen.SwaggerCodegen generate -l com.my.company.codegen.MyclientcodegenGenerator \
-i http://petstore.swagger.io/v2/swagger.json \
-o myClient
(or the equivalent modified for Windows), the output is
Exception in thread "main" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
templateFile: myFile.mustache
folder:
destinationFilename: myFile.sample
Using the -jar method described elsewhere results in
Exception in thread "main" io.airlift.airline.ParseArgumentsUnexpectedException: Found unexpected parameters: [io.swagger.codegen.SwaggerCodegen, generate, -l, com.my.company.codegen.MyclientcodegenGenerator, -i, http://petstore.swagger.io/v2/swagger.json, -o, myClient]
Related issues/PRs
Appears to be very similar to #1566, the error that @xhh was having right at the end.
Suggest a fix/enhancement
It seems as if myFile.mustache is not being produced and/or placed in the right location by swagger-codegen-cli.jar meta, or that the README produced (and the guide on GitHub) do not adequately explain the need to create a myFile.mustache file and how to go about that.
Thanks in advance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the custom-generator instructions, output/myLibrary/pom.xml, MyclientcodegenGenerator.java, and the SwaggerCodegen generate and cli.jar meta entry points. Reproduce the command against petstore.swagger.io/v2/swagger.json and compare the result with issue #1566. Done means the documented custom generator builds and runs without the supporting-file or argument-parsing errors, with the required template and README guidance clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100