@kubb/plugin-oas
Version:
OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.
17 lines (15 loc) • 609 B
text/typescript
import { URLPath } from '@internals/utils'
import type { Operation } from '@kubb/oas'
export function getComments(operation: Operation): string[] {
return [
operation.getDescription() && `@description ${operation.getDescription()}`,
operation.getSummary() && `@summary ${operation.getSummary()}`,
operation.path && `{@link ${new URLPath(operation.path).URL}}`,
operation.isDeprecated() && '@deprecated',
]
.filter((x): x is string => Boolean(x))
.flatMap((text) => {
return text.split(/\r?\n/).map((line) => line.trim())
})
.filter((x): x is string => Boolean(x))
}