@@ -2173,7 +2173,7 @@ describe('schema', function() {
21732173 const keys = Object . keys ( SchemaStringOptions . prototype ) .
21742174 filter ( key => key !== 'constructor' && key !== 'populate' ) ;
21752175 const functions = Object . keys ( Schema . Types . String . prototype ) .
2176- filter ( key => [ 'constructor' , 'cast' , 'castForQuery' , 'checkRequired' ] . indexOf ( key ) === - 1 ) ;
2176+ filter ( key => [ 'constructor' , 'cast' , 'castForQuery' , 'checkRequired' , 'toJSONSchema' ] . indexOf ( key ) === - 1 ) ;
21772177 assert . deepEqual ( keys . sort ( ) , functions . sort ( ) ) ;
21782178 } ) ;
21792179
@@ -3344,7 +3344,7 @@ describe('schema', function() {
33443344 }
33453345 } , { autoCreate : false , autoIndex : false } ) ;
33463346
3347- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3347+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
33483348 required : [ 'name' , '_id' ] ,
33493349 properties : {
33503350 _id : {
@@ -3363,7 +3363,7 @@ describe('schema', function() {
33633363 }
33643364 } ) ;
33653365
3366- assert . deepStrictEqual ( schema . jsonSchema ( ) , {
3366+ assert . deepStrictEqual ( schema . toJSONSchema ( ) , {
33673367 type : 'object' ,
33683368 required : [ 'name' , '_id' ] ,
33693369 properties : {
@@ -3385,7 +3385,7 @@ describe('schema', function() {
33853385
33863386 await db . createCollection ( collectionName , {
33873387 validator : {
3388- $jsonSchema : schema . jsonSchema ( { useBsonType : true } )
3388+ $jsonSchema : schema . toJSONSchema ( { useBsonType : true } )
33893389 }
33903390 } ) ;
33913391 const Test = db . model ( 'Test' , schema , collectionName ) ;
@@ -3414,7 +3414,7 @@ describe('schema', function() {
34143414 ) ;
34153415
34163416 const ajv = new Ajv ( ) ;
3417- const validate = ajv . compile ( schema . jsonSchema ( ) ) ;
3417+ const validate = ajv . compile ( schema . toJSONSchema ( ) ) ;
34183418
34193419 assert . ok ( validate ( { _id : 'test' , name : 'Taco' } ) ) ;
34203420 assert . ok ( validate ( { _id : 'test' , name : 'Billy' , age : null , ageSource : null } ) ) ;
@@ -3438,7 +3438,7 @@ describe('schema', function() {
34383438 int32 : 'Int32'
34393439 } ) ;
34403440
3441- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3441+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
34423442 required : [ '_id' ] ,
34433443 properties : {
34443444 num : {
@@ -3480,7 +3480,7 @@ describe('schema', function() {
34803480 }
34813481 } ) ;
34823482
3483- assert . deepStrictEqual ( schema . jsonSchema ( ) , {
3483+ assert . deepStrictEqual ( schema . toJSONSchema ( ) , {
34843484 type : 'object' ,
34853485 required : [ '_id' ] ,
34863486 properties : {
@@ -3531,7 +3531,7 @@ describe('schema', function() {
35313531 docArr : [ new Schema ( { field : Date } , { _id : false } ) ]
35323532 } ) ;
35333533
3534- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3534+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
35353535 required : [ '_id' ] ,
35363536 properties : {
35373537 tags : {
@@ -3564,7 +3564,7 @@ describe('schema', function() {
35643564
35653565 await db . createCollection ( collectionName , {
35663566 validator : {
3567- $jsonSchema : schema . jsonSchema ( { useBsonType : true } )
3567+ $jsonSchema : schema . toJSONSchema ( { useBsonType : true } )
35683568 }
35693569 } ) ;
35703570 const Test = db . model ( 'Test' , schema , collectionName ) ;
@@ -3575,7 +3575,7 @@ describe('schema', function() {
35753575 await Test . create ( { tags : 'javascript' , coordinates : [ [ 0 , 0 ] ] , docArr : [ { } ] } ) ;
35763576
35773577 const ajv = new Ajv ( ) ;
3578- const validate = ajv . compile ( schema . jsonSchema ( ) ) ;
3578+ const validate = ajv . compile ( schema . toJSONSchema ( ) ) ;
35793579
35803580 assert . ok ( validate ( { _id : 'test' , tags : [ 'javascript' ] , coordinates : [ [ 0 , 0 ] ] , docArr : [ { field : '2023-07-16' } ] } ) ) ;
35813581 assert . ok ( validate ( { _id : 'test' , tags : [ 'javascript' ] , coordinates : [ [ 0 , 0 ] ] , docArr : [ { } ] } ) ) ;
@@ -3592,7 +3592,7 @@ describe('schema', function() {
35923592 } , { _id : false } )
35933593 } ) ;
35943594
3595- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3595+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
35963596 required : [ '_id' ] ,
35973597 properties : {
35983598 name : {
@@ -3615,7 +3615,7 @@ describe('schema', function() {
36153615 }
36163616 } ) ;
36173617
3618- assert . deepStrictEqual ( schema . jsonSchema ( ) , {
3618+ assert . deepStrictEqual ( schema . toJSONSchema ( ) , {
36193619 required : [ '_id' ] ,
36203620 type : 'object' ,
36213621 properties : {
@@ -3641,7 +3641,7 @@ describe('schema', function() {
36413641
36423642 await db . createCollection ( collectionName , {
36433643 validator : {
3644- $jsonSchema : schema . jsonSchema ( { useBsonType : true } )
3644+ $jsonSchema : schema . toJSONSchema ( { useBsonType : true } )
36453645 }
36463646 } ) ;
36473647 const Test = db . model ( 'Test' , schema , collectionName ) ;
@@ -3650,7 +3650,7 @@ describe('schema', function() {
36503650 await Test . create ( { name : { first : 'Mike' , last : 'James' } , subdoc : { prop : 42 } } ) ;
36513651
36523652 const ajv = new Ajv ( ) ;
3653- const validate = ajv . compile ( schema . jsonSchema ( ) ) ;
3653+ const validate = ajv . compile ( schema . toJSONSchema ( ) ) ;
36543654
36553655 assert . ok ( validate ( { _id : 'test' , name : { last : 'James' } , subdoc : { } } ) ) ;
36563656 assert . ok ( validate ( { _id : 'test' , name : { first : 'Mike' , last : 'James' } , subdoc : { prop : 42 } } ) ) ;
@@ -3686,7 +3686,7 @@ describe('schema', function() {
36863686 }
36873687 } ) ;
36883688
3689- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3689+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
36903690 required : [ 'props' , '_id' ] ,
36913691 properties : {
36923692 props : {
@@ -3746,7 +3746,7 @@ describe('schema', function() {
37463746
37473747 await db . createCollection ( collectionName , {
37483748 validator : {
3749- $jsonSchema : schema . jsonSchema ( { useBsonType : true } )
3749+ $jsonSchema : schema . toJSONSchema ( { useBsonType : true } )
37503750 }
37513751 } ) ;
37523752 const Test = db . model ( 'Test' , schema , collectionName ) ;
@@ -3783,7 +3783,7 @@ describe('schema', function() {
37833783 ) ;
37843784
37853785 const ajv = new Ajv ( ) ;
3786- const validate = ajv . compile ( schema . jsonSchema ( ) ) ;
3786+ const validate = ajv . compile ( schema . toJSONSchema ( ) ) ;
37873787
37883788 assert . ok ( validate ( {
37893789 _id : 'test' ,
@@ -3829,7 +3829,7 @@ describe('schema', function() {
38293829 }
38303830 } ) ;
38313831
3832- assert . deepStrictEqual ( schema . jsonSchema ( { useBsonType : true } ) , {
3832+ assert . deepStrictEqual ( schema . toJSONSchema ( { useBsonType : true } ) , {
38333833 required : [ '_id' ] ,
38343834 properties : {
38353835 props : {
@@ -3844,7 +3844,7 @@ describe('schema', function() {
38443844 }
38453845 } ) ;
38463846
3847- assert . deepStrictEqual ( schema . jsonSchema ( ) , {
3847+ assert . deepStrictEqual ( schema . toJSONSchema ( ) , {
38483848 type : 'object' ,
38493849 required : [ '_id' ] ,
38503850 properties : {
@@ -3866,7 +3866,7 @@ describe('schema', function() {
38663866 name : { type : String , enum : [ 'Edwald' , 'Tobi' ] , required : true }
38673867 } ) ;
38683868
3869- assert . deepStrictEqual ( RacoonSchema . jsonSchema ( { useBsonType : true } ) , {
3869+ assert . deepStrictEqual ( RacoonSchema . toJSONSchema ( { useBsonType : true } ) , {
38703870 required : [ 'name' , '_id' ] ,
38713871 properties : {
38723872 name : {
@@ -3885,8 +3885,8 @@ describe('schema', function() {
38853885 mixed : mongoose . Mixed
38863886 } ) ;
38873887
3888- assert . throws ( ( ) => schema . jsonSchema ( { useBsonType : true } ) , / u n s u p p o r t e d S c h e m a T y p e t o J S O N S c h e m a : M i x e d / ) ;
3889- assert . throws ( ( ) => schema . jsonSchema ( ) , / u n s u p p o r t e d S c h e m a T y p e t o J S O N S c h e m a : M i x e d / ) ;
3888+ assert . throws ( ( ) => schema . toJSONSchema ( { useBsonType : true } ) , / u n s u p p o r t e d S c h e m a T y p e t o J S O N S c h e m a : M i x e d / ) ;
3889+ assert . throws ( ( ) => schema . toJSONSchema ( ) , / u n s u p p o r t e d S c h e m a T y p e t o J S O N S c h e m a : M i x e d / ) ;
38903890 } ) ;
38913891 } ) ;
38923892} ) ;
0 commit comments