Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only schema for top level keys generated #38

Open
johnfrancisgit opened this issue Nov 26, 2023 · 1 comment
Open

Only schema for top level keys generated #38

johnfrancisgit opened this issue Nov 26, 2023 · 1 comment

Comments

@johnfrancisgit
Copy link

Is it correct that this only creates the schema from top level keys?
E.g

{
  extra: {
    point: {
      value: null,
      name: 'Bob',
    },
  },
}

has schema:

{
  type: 'object',
  properties: {
    extra: { type: 'object', properties: [Object], required: [Array] }
  },
  required: [ 'extra' ]
}

Is it possible to also generate populate the schema for nested fields point, value, name?

@sbarre
Copy link

sbarre commented Feb 9, 2024

@johnfrancisgit Are you doing a console log here? There is a limit to the depth that console.log will output. That [Object] and [Array] is a giveaway that there's more data you're not seeing.

The util.inspect method can be used in conjunction with console.log() for this kind of thing.

Try this to see the full object (assuming a variable called schema that contains your schema):

const { inspect } = require('util');

console.log(inspect(schema, false, 10, true));

10 is the depth you want to expand in the object you're inspecting, adjust as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants