fork of hey-api/openapi-ts because I need some additional things
1import type { IR } from '@hey-api/shared';
2import { escapeComment } from '@hey-api/shared';
3
4export function createOperationComment(
5 operation: IR.OperationObject,
6): ReadonlyArray<string> | undefined {
7 const comments: Array<string> = [];
8
9 if (operation.summary) {
10 comments.push(escapeComment(operation.summary));
11 }
12
13 if (operation.description) {
14 if (comments.length) {
15 comments.push(''); // Add an empty line between summary and description
16 }
17
18 comments.push(escapeComment(operation.description));
19 }
20
21 if (operation.deprecated) {
22 if (comments.length) {
23 comments.push(''); // Add an empty line before deprecated
24 }
25
26 // TODO: smarter deprecation message
27 comments.push('Deprecated.');
28 }
29
30 return comments.length ? comments : undefined;
31}