Skip to content

splitSummaryAndBody

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/libs/parser-core/src/openapi/doc-annotations.ts

Split authored text into the one-line summary and everything after it.

The split point is the first sentence end or the first line break, whichever comes first — which is how every doc-comment convention in every language here already reads.

The description === undefined case is the important one. @ApiOperation({ summary: 'Get the current user' }) is a single sentence with nothing after it, and echoing it into both fields makes the reader render the same words twice, which looks like a generator bug rather than like documentation. So a body with no remainder yields a summary and NOTHING else.

Signature

ts
function splitSummaryAndBody(text: string): { summary?: string; description?: string }

Parameters

NameType
textstring

Returns: { summary?: string; description?: string }

Was this page helpful?

Download as PDF