@@ -383,6 +383,138 @@ export const generateOpenAPISpec = () => {
383383 }
384384 }
385385 }
386+ } ,
387+ '/api/v1/search' : {
388+ get : {
389+ tags : [ 'Search' ] ,
390+ summary : 'Search songs' ,
391+ description : 'Search for songs across title, artist name, and lyrics content. Supports Sinhala and English text.' ,
392+ parameters : [
393+ {
394+ name : 'all' ,
395+ in : 'query' ,
396+ description : 'Search across song title, artist name, and lyrics (Sinhala or English)' ,
397+ required : false ,
398+ schema : { type : 'string' }
399+ } ,
400+ {
401+ name : 'artist' ,
402+ in : 'query' ,
403+ description : 'Search by artist name (Sinhala or English)' ,
404+ required : false ,
405+ schema : { type : 'string' }
406+ } ,
407+ {
408+ name : 'title' ,
409+ in : 'query' ,
410+ description : 'Search by song title (Sinhala or English)' ,
411+ required : false ,
412+ schema : { type : 'string' }
413+ } ,
414+ {
415+ name : 'lyrics' ,
416+ in : 'query' ,
417+ description : 'Search by lyrics content (Sinhala or English)' ,
418+ required : false ,
419+ schema : { type : 'string' }
420+ } ,
421+ {
422+ name : 'page' ,
423+ in : 'query' ,
424+ description : 'Page number' ,
425+ required : false ,
426+ schema : { type : 'string' , example : '1' , default : '1' }
427+ } ,
428+ {
429+ name : 'limit' ,
430+ in : 'query' ,
431+ description : 'Items per page (max: 100)' ,
432+ required : false ,
433+ schema : { type : 'string' , example : '10' , default : '10' }
434+ } ,
435+ {
436+ name : 'sortBy' ,
437+ in : 'query' ,
438+ description : 'Sort field' ,
439+ required : false ,
440+ schema : { type : 'string' , default : 'ViewCount' }
441+ } ,
442+ {
443+ name : 'sortOrder' ,
444+ in : 'query' ,
445+ description : 'Sort order (asc/desc)' ,
446+ required : false ,
447+ schema : { type : 'string' , enum : [ 'asc' , 'desc' ] , default : 'desc' }
448+ }
449+ ] ,
450+ responses : {
451+ '200' : {
452+ description : 'Search results retrieved successfully' ,
453+ content : {
454+ 'application/json' : {
455+ schema : {
456+ type : 'object' ,
457+ properties : {
458+ success : { type : 'boolean' , example : true } ,
459+ data : {
460+ type : 'array' ,
461+ items : { $ref : '#/components/schemas/SearchResult' }
462+ } ,
463+ pagination : {
464+ type : 'object' ,
465+ properties : {
466+ page : { type : 'number' , example : 1 } ,
467+ limit : { type : 'number' , example : 10 } ,
468+ total : { type : 'number' , example : 50 } ,
469+ totalPages : { type : 'number' , example : 5 }
470+ }
471+ }
472+ }
473+ }
474+ }
475+ }
476+ } ,
477+ '400' : {
478+ description : 'No search parameters provided' ,
479+ content : {
480+ 'application/json' : {
481+ schema : {
482+ type : 'object' ,
483+ properties : {
484+ success : { type : 'boolean' , example : false } ,
485+ message : { type : 'string' , example : 'No search parameters provided.' }
486+ }
487+ }
488+ }
489+ }
490+ } ,
491+ '500' : {
492+ description : 'Internal server error' ,
493+ content : {
494+ 'application/json' : {
495+ schema : { $ref : '#/components/schemas/ErrorResponse' }
496+ }
497+ }
498+ }
499+ }
500+ }
501+ } ,
502+ '/api/v1/search/health' : {
503+ get : {
504+ tags : [ 'Search' ] ,
505+ summary : 'Check search service health' ,
506+ description : 'Health check endpoint for the search service' ,
507+ responses : {
508+ '200' : {
509+ description : 'Service is healthy' ,
510+ content : {
511+ 'application/json' : {
512+ schema : { $ref : '#/components/schemas/HealthCheck' }
513+ }
514+ }
515+ }
516+ }
517+ }
386518 }
387519 } ,
388520 components : {
@@ -435,7 +567,7 @@ export const generateOpenAPISpec = () => {
435567 properties : {
436568 ArtistID : { type : 'string' , example : 'ART-00001' } ,
437569 ArtistName : { type : 'string' , example : 'John Doe' } ,
438- ArtistNameSinhala : { type : 'string' , example : 'ජොන් ඩෝ' } ,
570+ ArtistNameSinhala : { type : 'string' , example : 'ජෝන් ඩෝ' } ,
439571 Songs : {
440572 type : 'array' ,
441573 items : {
@@ -460,6 +592,82 @@ export const generateOpenAPISpec = () => {
460592 LyricContentSinhala : { type : 'string' , example : 'සම්පූර්ණ ගී පද...' }
461593 }
462594 } ,
595+ SearchResult : {
596+ type : 'object' ,
597+ properties : {
598+ SongID : {
599+ type : 'string' ,
600+ example : 'SNG-00001' ,
601+ description : 'Unique identifier for the song'
602+ } ,
603+ SongName : {
604+ type : 'string' ,
605+ example : 'Beautiful Song' ,
606+ description : 'Song title in English'
607+ } ,
608+ SongNameSinhala : {
609+ type : 'string' ,
610+ example : 'ලස්සන ගීතය' ,
611+ description : 'Song title in Sinhala'
612+ } ,
613+ Duration : {
614+ type : 'number' ,
615+ example : 240 ,
616+ description : 'Song duration in seconds'
617+ } ,
618+ ReleaseYear : {
619+ type : 'number' ,
620+ example : 2024 ,
621+ description : 'Year the song was released'
622+ } ,
623+ Composer : {
624+ type : 'string' ,
625+ example : 'John Doe' ,
626+ description : 'Name of the music composer'
627+ } ,
628+ Lyricist : {
629+ type : 'string' ,
630+ example : 'Jane Smith' ,
631+ description : 'Name of the lyricist'
632+ } ,
633+ ViewCount : {
634+ type : 'number' ,
635+ example : 1000 ,
636+ description : 'Number of times the song has been viewed'
637+ } ,
638+ ArtistID : {
639+ type : 'string' ,
640+ example : 'ART-00001' ,
641+ description : 'Unique identifier for the artist'
642+ } ,
643+ ArtistName : {
644+ type : 'string' ,
645+ example : 'John Doe' ,
646+ description : 'Artist name in English'
647+ } ,
648+ ArtistNameSinhala : {
649+ type : 'string' ,
650+ example : 'ජෝන් ඩෝ' ,
651+ description : 'Artist name in Sinhala'
652+ } ,
653+ LyricID : {
654+ type : 'string' ,
655+ example : 'LYR-00001' ,
656+ description : 'Unique identifier for the lyrics'
657+ } ,
658+ LyricContent : {
659+ type : 'string' ,
660+ example : 'Full lyrics in English...' ,
661+ description : 'Complete lyrics content in English'
662+ } ,
663+ LyricContentSinhala : {
664+ type : 'string' ,
665+ example : 'සම්පූර්ණ ගී පද...' ,
666+ description : 'Complete lyrics content in Sinhala'
667+ }
668+ } ,
669+ description : 'Search result combining song, artist, and lyrics information'
670+ } ,
463671 HealthCheck : {
464672 type : 'object' ,
465673 properties : {
0 commit comments