swagger-api / swagger-api/swagger-codegen

Keep linebreaks in the contract in generated Java code

Open
#4,714 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Line-breaks in yaml contracts currently get lost in the javadoc comment (they are replaced by a blank).
To keep line-breaks also in dynamically generated contracts, they should be replaced by \n.

Swagger-codegen version

2.2.2

Swagger declaration file content or url

Example (adapted 2.0\petstore.yaml)

paths:
  /pet:
    post:
      tags:
        - pet
      summary: 'Add a new pet to the store
      test second line'

output:

    @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store test second line", notes = "", response = Void.class, authorizations = {
...
Suggest a Fix
  1. Keep line breaks by generating \n instead of " " for line breaks
  2. To also keep line breaks in dynamically generated contracts, an escaped line break needs to be added ("\n").

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the YAML contract example and inspect the Java generation path that produces the ApiOperation Javadoc values. Confirm that embedded line breaks are represented as escaped \n in the generated Java output, and add coverage if the relevant generation test area is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.