Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants