swagger-api / swagger-api/swagger-codegen
Trying to insert data into the auto generated code from a configuration file
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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
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 template and the swagger.json passed to swagger-codegen generate, then check how version 2.2.2 exposes definition fields to Mustache templates. Confirm whether the top-level wait_time value is available during Java generation; done means the generated output contains the configured value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100