Trying to insert data into the auto generated code from a configuration file
So I am editing a mustache file to get the auto generated code to wait for some time before doing an action.
The mustache file looks like: `double wait_time_double = {{wait_time}};' 'int wait_time = (int) (wait_time_double * 1000);' 'Thread.sleep(wait_time)'
I want to allow a user to set wait_time from a cli that I am making separate from swagger. So users never have to deal with the swagger interface for auto generating code. I am able to take the users input and add it to the swagger.json api file so it looks like this:
{"swagger": "2.0", "info": { "description": "A sample applications", "version": "0.0.1", "title": "Hello WebApp", "contact": "name": "Sample application" }
... more api code
"wait_time":"0.1" }
Then i call the code generator by calling: swagger-codegen generate -i swagger.json -t timplate.mustache -l java -o output.java
However; this does not get swagger to give the mustache file the wait_time variable.
Any help would be greatly appeciated
Swagger-codegen version
2.2.2
You can add as additional property to the swagger generate command instead of json.
swagger-codegen-cli generate -i swagger.json -t timplate.mustache -l java -o output.java --additional-properties wait_time=0.1