Skip to content

Improve blank line break handling in generated code #7173

@nemecec

Description

@nemecec
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions