Declare array of bsonType in mongoDb schema

How to declare an array of different types in mongoDb schemas?

I have a value in a document which can be a double or an int and I tried declaring it like this:

"numberOf": {
                "bsonType": ["long", "int"]
              },

And I received that error:

property “numberOf” has invalid type: type [long,int] is not supported

In the doc they say that you can declare an array of bsonTypes or types like that:

"type": "<JSON Type>" | ["<JSON Type>", ...],
"bsonType": "<BSON Type>" | ["<BSON Type>", ...],

I also tried:

"numberOf": {
                "type": "number"
              },

And I can’t save my schema getting this:

I don’t know what I missed. :thinking: