Skip to content

Commit 1625877

Browse files
docs(api): add endpoint status (#54)
* docs(api): add endpoint status * docs(api): update swagger icons
1 parent 3657d08 commit 1625877

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { applyDecorators } from '@nestjs/common';
2+
import { ApiOperation, ApiResponse } from '@nestjs/swagger';
3+
4+
export enum ImplementationStatus {
5+
IMPLEMENTED = 'implemented',
6+
IN_PROGRESS = 'in-progress',
7+
NOT_IMPLEMENTED = 'not-implemented',
8+
}
9+
10+
interface IImplementationStatusOptions {
11+
status: ImplementationStatus;
12+
summary: string;
13+
notes?: string;
14+
expectedDate?: string;
15+
}
16+
17+
/**
18+
* Decorator to indicate implementation status of an endpoint in Swagger documentation
19+
* Adds a small status indicator at the end of the summary
20+
* @param options - Configuration object with status and summary
21+
*/
22+
export const ApiImplementationStatus = (options: IImplementationStatusOptions) => {
23+
const status_config = {
24+
[ImplementationStatus.IMPLEMENTED]: {
25+
icon: '✅',
26+
label: 'Ready',
27+
},
28+
[ImplementationStatus.IN_PROGRESS]: {
29+
icon: '🚧',
30+
label: 'In Progress',
31+
},
32+
[ImplementationStatus.NOT_IMPLEMENTED]: {
33+
icon: '❌',
34+
label: 'Not Implemented',
35+
},
36+
};
37+
38+
const config = status_config[options.status];
39+
40+
// Add status icon at the end of summary
41+
const summary = `${options.summary} ${config.icon}`;
42+
43+
// Build detailed description
44+
let description = `**Status:** ${config.label}`;
45+
46+
if (options.notes) {
47+
description += `\n\n${options.notes}`;
48+
}
49+
50+
if (options.expectedDate) {
51+
description += `\n\n**Expected:** ${options.expectedDate}`;
52+
}
53+
54+
const decorators = [
55+
ApiOperation({
56+
summary,
57+
description,
58+
}),
59+
];
60+
61+
return applyDecorators(...decorators);
62+
};

src/timeline/timeline.controller.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from 'src/decorators/swagger-error-responses.decorator';
2222
import { timeline_swagger } from './timeline.swagger';
2323
import { ResponseMessage } from 'src/decorators/response-message.decorator';
24+
import { ApiImplementationStatus, ImplementationStatus } from 'src/decorators/api-status.decorator';
2425

2526
@ApiBearerAuth('JWT-auth')
2627
@UseGuards(JwtAuthGuard)
@@ -29,6 +30,10 @@ import { ResponseMessage } from 'src/decorators/response-message.decorator';
2930
export class TimelineController {
3031
constructor(private readonly timelineService: TimelineService) {}
3132

33+
@ApiImplementationStatus({
34+
status: ImplementationStatus.IN_PROGRESS,
35+
summary: timeline_swagger.for_you.operation.summary,
36+
})
3237
@ApiOperation(timeline_swagger.for_you.operation)
3338
@ApiQuery(timeline_swagger.api_query.limit)
3439
@ApiQuery(timeline_swagger.api_query.cursor)
@@ -44,7 +49,10 @@ export class TimelineController {
4449
) {
4550
return await this.timelineService.getForyouTimeline(user_id, pagination);
4651
}
47-
52+
@ApiImplementationStatus({
53+
status: ImplementationStatus.IMPLEMENTED,
54+
summary: timeline_swagger.following.operation.summary,
55+
})
4856
@ApiOperation(timeline_swagger.following.operation)
4957
@ApiQuery(timeline_swagger.api_query.limit)
5058
@ApiQuery(timeline_swagger.api_query.cursor)

0 commit comments

Comments
 (0)