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

Summary/Description Generation Issue with Multiline First Sentences. #942

Closed
dadepo opened this issue May 22, 2024 · 3 comments · Fixed by #947
Closed

Summary/Description Generation Issue with Multiline First Sentences. #942

dadepo opened this issue May 22, 2024 · 3 comments · Fixed by #947

Comments

@dadepo
Copy link

dadepo commented May 22, 2024

In 5aa9749 a change was introduced to skip the first line in the description.

The only downside to this is that, when the first line spans more than one line, the generated openapi is made meaningless because the first line is removed.

For example given:

/// A very long text describing the function that is being documented, but it is
/// quite complicated the first sentence spans to the second line.

The generated spec will be

  summary: A very long text describing the function that is being documented, but it is
  description: |-
       quite complicated the first sentence spans to the second line.

Making both the summary and description meaningless.

@juhaku juhaku moved this to Todo in utoipa kanban May 22, 2024
@juhaku
Copy link
Owner

juhaku commented May 22, 2024

Thanks for noticing, it seems that long paragraphs are not taken in account when separating the description and summary in that specific commit. I'll add it to the todo list and fix this as one of the next things.

juhaku added a commit that referenced this issue May 23, 2024
Priot to this PR the summary and description was blindly split by the
first line of the doc comment of path operaiton. This caused long
multi line summaries to be split from illogically bleeding part of the
summary to the description. More context can be found from issue #942.

This commit fixes this as from now one comments as follows will be
correctly split by paragraph. Where first paragraph will resolve to
summary and rest will become the description.
```rust
 /// This is test operation long multiline
 /// summary. That need to be correctly split.
 ///
 /// Additional info in long description
 ///
 /// With more info on separate lines
 /// containing text.
 ///
 /// Yeah
```

Follow up for #881 and #439

Fixes #942
@juhaku juhaku moved this from Todo to In Progress in utoipa kanban May 23, 2024
juhaku added a commit that referenced this issue May 23, 2024
Priot to this PR the summary and description was blindly split by the
first line of the doc comment of path operaiton. This caused long
multi line summaries to be split from illogically bleeding part of the
summary to the description. More context can be found from issue #942.

This commit fixes this as from now one comments as follows will be
correctly split by paragraph. Where first paragraph will resolve to
summary and rest will become the description.
```rust
 /// This is test operation long multiline
 /// summary. That need to be correctly split.
 ///
 /// Additional info in long description
 ///
 /// With more info on separate lines
 /// containing text.
 ///
 /// Yeah
```

Follow up for #881 and #439

Fixes #942
@github-project-automation github-project-automation bot moved this from In Progress to Done in utoipa kanban May 23, 2024
@Thomasdezeeuw
Copy link

Thanks for the quick fix @juhaku

@Thomasdezeeuw
Copy link

The problem seems to be back/not fixed. Using Utoipa v4.2.3, utoipa-gen v4.3.0.

The following Rust:

/// Reset ping counts for all reviewers. It will recalculate the ping counts for
/// all reviewers, not considering spent pings.
#[utoipa::path(
  // ...
)]
#[post("/api/v0/repositories/{repo_id}/reset-pings")]
pub async fn reset_pings()

Creates:

  /api/v0/repositories/{repo_id}/reset-pings:
    post:
      tags:
      - repositories
      summary: Reset ping counts for all reviewers. It will recalculate the ping counts for
      description: |-
        all reviewers, not considering spent pings.

The summary is cut off at the line end, but the sentence continues on the next line.

@juhaku juhaku moved this from Done to Released in utoipa kanban Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

3 participants