@@ -1452,6 +1452,47 @@ describe('compatibility', () => {
14521452 expect ( req ! . url ) . toBe ( '/injection' )
14531453 } )
14541454
1455+ it ( 'router-based implementation skips null and undefined contract entries' , async ( ) => {
1456+ const ping = oc . meta ( openapi ( { path : '/ping' } ) )
1457+ const nestedPing = oc . meta ( openapi ( { path : '/nested/ping' } ) )
1458+ const contract : any = {
1459+ ping,
1460+ missing : undefined ,
1461+ empty : null ,
1462+ nested : { ping : nestedPing , missing : undefined , empty : null } ,
1463+ }
1464+
1465+ @Controller ( )
1466+ class ImplController {
1467+ @Implement ( contract )
1468+ sparse ( ) {
1469+ return {
1470+ ping : implement ( ping ) . handler ( ( ) => 'pong' ) ,
1471+ nested : { ping : implement ( nestedPing ) . handler ( ( ) => 'nested pong' ) } ,
1472+ }
1473+ }
1474+ }
1475+
1476+ expect ( Object . getOwnPropertyNames ( ImplController . prototype ) ) . not . toEqual (
1477+ expect . arrayContaining ( [ expect . stringMatching ( / _ ( m i s s i n g | e m p t y ) / ) ] ) ,
1478+ )
1479+
1480+ const moduleRef = await Test . createTestingModule ( {
1481+ controllers : [ ImplController ] ,
1482+ } ) . compile ( )
1483+
1484+ const app = moduleRef . createNestApplication ( )
1485+ await app . init ( )
1486+
1487+ const res = await supertest ( app . getHttpServer ( ) ) . post ( '/ping' )
1488+ expect ( res . status ) . toBe ( 200 )
1489+ expect ( res . text ) . toContain ( 'pong' )
1490+
1491+ const nestedRes = await supertest ( app . getHttpServer ( ) ) . post ( '/nested/ping' )
1492+ expect ( nestedRes . status ) . toBe ( 200 )
1493+ expect ( nestedRes . text ) . toContain ( 'nested pong' )
1494+ } )
1495+
14551496 it ( 'router-based implementation controller can handle conflict method names and reflect all metadata on new methods regardless of decorator order' , async ( ) => {
14561497 const contract = {
14571498 ping : oc . meta ( openapi ( { path : '/ping' } ) ) ,
0 commit comments