swagger-api / swagger-api/swagger-codegen
Improve blank line break handling in generated code
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Limiting number of empty line breaks in Mustache output is a known issue and it seems there will be no "fix" for that coming from Mustache team.
Example (generated with latest master):
/**
* Unique identifier for this bid. Read-only.
* @return id
**/
@ApiModelProperty(value = "Unique identifier for this bid. Read-only.")
public Long getId() {
return id;
}
This is clearly broken.
While Mustache is unable to fix this issue themselves (due to the way it generates output), Swagger Codegen can roll its own fix, following the example as outlined in that same issue.
Short summary: use some special non-whitespace character to represent line break in all templates. Post-process output from Mustache, removing all line breaks (\n) and replacing the special character with line breaks instead.
Swagger-codegen version
All versions so far.
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 by locating the Mustache rendering path and the templates that produce the extra blank lines. Review the linked Mustache workaround, then verify that generated output removes unintended empty line breaks while preserving intended line breaks; the issue names no specific files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100