1+ import { openAPIConfig } from './openapi.config' ;
2+
3+ export const generateOpenAPISpec = ( ) => {
4+ return {
5+ ...openAPIConfig ,
6+ paths : {
7+ '/api/v1/songs' : {
8+ get : {
9+ tags : [ 'Songs' ] ,
10+ summary : 'Get all songs' ,
11+ description : 'Get a paginated list of all songs with optional filters' ,
12+ parameters : [
13+ {
14+ name : 'page' ,
15+ in : 'query' ,
16+ description : 'Page number' ,
17+ required : false ,
18+ schema : { type : 'string' , example : '1' }
19+ } ,
20+ {
21+ name : 'limit' ,
22+ in : 'query' ,
23+ description : 'Items per page' ,
24+ required : false ,
25+ schema : { type : 'string' , example : '10' }
26+ } ,
27+ {
28+ name : 'artistId' ,
29+ in : 'query' ,
30+ description : 'Filter by artist ID (example: ART-00001)' ,
31+ required : false ,
32+ schema : { type : 'string' }
33+ } ,
34+ {
35+ name : 'releaseYear' ,
36+ in : 'query' ,
37+ description : 'Filter by release year (example: 2024)' ,
38+ required : false ,
39+ schema : { type : 'string' }
40+ } ,
41+ {
42+ name : 'search' ,
43+ in : 'query' ,
44+ description : 'Search in song names (example: love)' ,
45+ required : false ,
46+ schema : { type : 'string' }
47+ } ,
48+ {
49+ name : 'sortBy' ,
50+ in : 'query' ,
51+ description : 'Sort field (example: ViewCount)' ,
52+ required : false ,
53+ schema : { type : 'string' }
54+ } ,
55+ {
56+ name : 'sortOrder' ,
57+ in : 'query' ,
58+ description : 'Sort order (example: asc/desc)' ,
59+ required : false ,
60+ schema : { type : 'string' }
61+ }
62+ ] ,
63+ responses : {
64+ '200' : {
65+ description : 'Songs retrieved successfully' ,
66+ content : {
67+ 'application/json' : {
68+ schema : {
69+ type : 'object' ,
70+ properties : {
71+ success : { type : 'boolean' , example : true } ,
72+ data : {
73+ type : 'array' ,
74+ items : { type : 'object' }
75+ } ,
76+ pagination : {
77+ type : 'object' ,
78+ properties : {
79+ page : { type : 'number' , example : 1 } ,
80+ limit : { type : 'number' , example : 10 } ,
81+ total : { type : 'number' , example : 100 } ,
82+ totalPages : { type : 'number' , example : 10 }
83+ }
84+ }
85+ }
86+ }
87+ }
88+ }
89+ } ,
90+ '500' : {
91+ description : 'Internal server error' ,
92+ content : {
93+ 'application/json' : {
94+ schema : { $ref : '#/components/schemas/ErrorResponse' }
95+ }
96+ }
97+ }
98+ }
99+ }
100+ } ,
101+ '/api/v1/songs/health' : {
102+ get : {
103+ tags : [ 'Songs' ] ,
104+ summary : 'Check songs service health' ,
105+ description : 'Health check endpoint for the songs service' ,
106+ responses : {
107+ '200' : {
108+ description : 'Service is healthy' ,
109+ content : {
110+ 'application/json' : {
111+ schema : {
112+ type : 'object' ,
113+ properties : {
114+ status : { type : 'string' , example : 'OK' } ,
115+ timestamp : { type : 'string' , example : '2025-11-08T10:30:00.000Z' } ,
116+ environment : { type : 'string' , example : 'Production' } ,
117+ version : { type : 'string' , example : '1.0.0' }
118+ }
119+ }
120+ }
121+ }
122+ }
123+ }
124+ }
125+ }
126+ } ,
127+ components : {
128+ schemas : {
129+ ErrorResponse : {
130+ type : 'object' ,
131+ properties : {
132+ status : { type : 'number' , example : 404 } ,
133+ code : { type : 'string' , example : 'SONG_NOT_FOUND' } ,
134+ message : { type : 'string' , example : 'Song not found' } ,
135+ details : { type : 'string' , example : 'Song with ID SNG-9999999 does not exist' } ,
136+ path : { type : 'string' , example : '/api/v1/songs/SNG-9999999' } ,
137+ timestamp : { type : 'string' , example : '2025-11-08T10:30:00' }
138+ }
139+ }
140+ }
141+ }
142+ } ;
143+ } ;
0 commit comments