kristianmandrup/schema-to-yup

Using `anyOf` inside a schema results in an error

Opened this issue · 0 comments

Using the anyOf operator inside a JSONSchema doesn't seem to work in the library:

import { buildYup } from "schema-to-yup";
let schema = {
      "type": "object",
      "properties": {
        "a": {
          "anyOf": [
            {
              "type": "string",
            },
            {
              "type": "number"
            }
          ]
        },
      }
    }
console.log(buildYup(schema))

Results in the following error:

TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
    at at.error (<anonymous>:1408:61)
    at at.toEntry (<anonymous>:1413:18)
    at Object.ot [as createYupSchemaEntry] (<anonymous>:1421:27)
    at ct.createYupSchemaEntry (<anonymous>:1519:30)
    at ct.propToYupSchemaEntry (<anonymous>:1516:23)
    at ct.reducePropToShape (<anonymous>:1512:27)
    at <anonymous>:1509:40
    at ct.objPropsToShape (<anonymous>:1509:21)

Should anyOf be working at all or am I missing something obvious?