Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including the '\r\n' newline in a description results in non-compiling code #143

Closed
MacFriis opened this issue Jul 26, 2023 · 3 comments · Fixed by #169
Closed

Including the '\r\n' newline in a description results in non-compiling code #143

MacFriis opened this issue Jul 26, 2023 · 3 comments · Fixed by #169
Assignees
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)

Comments

@MacFriis
Copy link

MacFriis commented Jul 26, 2023

using asp.net to write a web api, with Swashbuckle to document the api. the swagger.yaml files puts in \r\n if the documentation is on multiple lines
C# - .net

/// <summary>
/// get all words within the category and language
/// if the user is registered, this list will include words from other users
/// </summary>
/// <param name="category"></param>
/// <param name="language"></param>
/// <returns></returns>
[HttpGet, AllowAnonymous]
public async Task<ActionResult<List<Word>>> GetWords(
   [FromQuery] string category = "general",
   [FromHeader] string language = "en"
   ) ...

the resulting yaml file will have this

 get:
      tags:
        - Words
      summary: "get all words within the category and language\r\nif the user is registered, this list will include words from other users"
      parameters:
        - name: category
          in: query
          description: ''
          style: form
          schema:
            type: string
            default: general
        - name: language
         ...

This result in a compile error:

1157: }
1158: }
1159: }
---
514:153: expected ')' to end parameter clause
===
514:153: expected ')' to end parameter clause
Command PhaseScriptExecution failed with a nonzero exit code
@czechboy0 czechboy0 added the status/triage Collecting information required to triage the issue. label Jul 26, 2023
@czechboy0
Copy link
Contributor

Hi @MacFriis, thanks for filing the issue. Could you paste a formatted (using the ``` markdown syntax) snippet of the YAML and the generated Swift? That'll make it easier for us to understand what the issue is. Thanks 🙏

@czechboy0 czechboy0 changed the title NewLines \r\n not supported in descriptions Including the '\r' character in a description results in non-compiling code Aug 3, 2023
@czechboy0
Copy link
Contributor

Thanks, turns out the \r character wasn't being handled correctly.

@czechboy0
Copy link
Contributor

#169

@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.) and removed status/triage Collecting information required to triage the issue. labels Aug 3, 2023
@czechboy0 czechboy0 self-assigned this Aug 3, 2023
@czechboy0 czechboy0 changed the title Including the '\r' character in a description results in non-compiling code Including the '\r\n' newline in a description results in non-compiling code Aug 4, 2023
czechboy0 added a commit that referenced this issue Aug 4, 2023
[Bug] Handle the '\r\n' newline correctly

### Motivation

Fixes #143, which tracks including the '\r\n' newline in a description in the OpenAPI document.

### Modifications

Replaces the '\r\n' character with '\n' before rendering comments, as '\n' is handled properly.

### Result

OpenAPI documents that include '\r\n' in a description produce compiling code now.

### Test Plan

Added a unit test for this case.


Reviewed by: simonjbeaumont

Builds:
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants