Skip to content

Cannot run basic example #42

Description

@andreipopi

Hi Evgeny,

I am trying to run your library, but upon fixing basic missing errors (with let cb,pre,post;), I still get errors when I run the basic example provided under "Usage". The error I get is:

`json-schema-traverse/index.js:11
  var pre = (typeof cb == 'function') ? cb : cb.pre || function() {};
                                                ^
TypeError: Cannot read properties of undefined (reading 'pre')`

The following is the code I'm using:

const traverse = require('json-schema-traverse');
const schema = {
  properties: {
    foo: {type: 'string'},
    bar: {type: 'integer'}
  }
};

let cb:any;
let pre:any;
let post:any;
traverse(schema, {cb});

What would be a suggestion to solve this issue?

In addition, I am interested in using the library in order to traverse arbitrary json schemas? Is this library able to deal with json-schemas of arbitrary shapes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions