@@ -1478,7 +1478,7 @@ test1:
14781478
14791479 expect ( completion . items . length ) . equal ( 1 ) ;
14801480 expect ( completion . items [ 0 ] . insertText ) . to . be . equal ( '${1:property}: ' ) ;
1481- expect ( completion . items [ 0 ] . documentation ) . to . be . equal ( ' Property Description') ;
1481+ expect ( completion . items [ 0 ] . documentation ) . to . be . deep . equal ( { kind : 'markdown' , value : ' Property Description' } ) ;
14821482 } ) ;
14831483 it ( 'should not suggest propertyNames with doNotSuggest' , async ( ) => {
14841484 const schema : JSONSchema = {
@@ -1515,6 +1515,103 @@ test1:
15151515 expect ( completion . items [ 1 ] . insertText ) . to . be . equal ( '"NO"' ) ;
15161516 } ) ;
15171517
1518+ it ( 'should suggest propertyNames keys from definitions $ref' , async ( ) => {
1519+ const schema : JSONSchema = {
1520+ definitions : {
1521+ EventName : {
1522+ type : 'string' ,
1523+ title : 'EventName' ,
1524+ enum : [ 'None' , 'Event1' , 'Event2' ] ,
1525+ } ,
1526+ } ,
1527+ type : 'object' ,
1528+ properties : {
1529+ events : {
1530+ type : 'object' ,
1531+ propertyNames : { $ref : '#/definitions/EventName' } ,
1532+ } ,
1533+ } ,
1534+ required : [ 'events' ] ,
1535+ } ;
1536+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1537+ const completion = await parseSetup ( 'events:\n ' , 1 , 2 ) ;
1538+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'None' , 'Event1' , 'Event2' ] ) ;
1539+ } ) ;
1540+
1541+ it ( 'should suggest propertyNames candidates from const' , async ( ) => {
1542+ const schema : JSONSchema = {
1543+ type : 'object' ,
1544+ propertyNames : {
1545+ const : 'Event0' ,
1546+ } ,
1547+ } ;
1548+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1549+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1550+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'Event0' ] ) ;
1551+ } ) ;
1552+
1553+ it ( 'should suggest propertyNames candidates from enum' , async ( ) => {
1554+ const schema : JSONSchema = {
1555+ type : 'object' ,
1556+ additionalProperties : true ,
1557+ propertyNames : {
1558+ enum : [ 'Event1' , 'Event2' , 'Event3' ] ,
1559+ } ,
1560+ } ;
1561+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1562+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1563+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'Event1' , 'Event2' , 'Event3' ] ) ;
1564+ } ) ;
1565+
1566+ it ( 'should suggest propertyNames candidates from oneOf' , async ( ) => {
1567+ const schema : JSONSchema = {
1568+ type : 'object' ,
1569+ propertyNames : {
1570+ oneOf : [ { const : 'Event1' } , { const : 'Event2' } ] ,
1571+ } ,
1572+ } ;
1573+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1574+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1575+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'Event1' , 'Event2' ] ) ;
1576+ } ) ;
1577+
1578+ it ( 'should suggest propertyNames candidates from anyOf' , async ( ) => {
1579+ const schema : JSONSchema = {
1580+ type : 'object' ,
1581+ propertyNames : {
1582+ anyOf : [ { const : 'Event1' } , { enum : [ 'Event2' , 'Event3' ] } ] ,
1583+ } ,
1584+ } ;
1585+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1586+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1587+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'Event1' , 'Event2' , 'Event3' ] ) ;
1588+ } ) ;
1589+
1590+ it ( 'should suggest only the intersected propertyNames candidate from allOf (const + enum)' , async ( ) => {
1591+ const schema : JSONSchema = {
1592+ type : 'object' ,
1593+ propertyNames : {
1594+ allOf : [ { const : 'One' } , { enum : [ 'One' , 'Two' ] } ] ,
1595+ } ,
1596+ } ;
1597+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1598+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1599+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . have . members ( [ 'One' ] ) ;
1600+ expect ( completion . items . map ( ( i ) => i . label ) ) . to . not . include ( 'Two' ) ;
1601+ } ) ;
1602+
1603+ it ( 'should not suggest any propertyNames when allOf makes keys impossible (const + const)' , async ( ) => {
1604+ const schema : JSONSchema = {
1605+ type : 'object' ,
1606+ propertyNames : {
1607+ allOf : [ { const : 'One' } , { const : 'Two' } ] ,
1608+ } ,
1609+ } ;
1610+ schemaProvider . addSchema ( SCHEMA_ID , schema ) ;
1611+ const completion = await parseSetup ( '' , 0 , 0 ) ;
1612+ expect ( completion . items ) . to . be . empty ;
1613+ } ) ;
1614+
15181615 describe ( 'String scalar completion comprehensive tests' , ( ) => {
15191616 const STRING_CASES : {
15201617 value : string ;
0 commit comments