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

Array of Array is not supported #37

Closed
gilles-yvetot opened this issue Jan 21, 2022 · 5 comments
Closed

Array of Array is not supported #37

gilles-yvetot opened this issue Jan 21, 2022 · 5 comments

Comments

@gilles-yvetot
Copy link

When generating the json schema, I got the following error:

TypeError: Cannot read property 'required' of undefined
    at SchemaArray.array_jsonSchema [as jsonSchema] (/~/Documents/models/node_modules/mongoose-schema-jsonschema/lib/types.js:102:53)

It comes from this.schemaOptions.required, it looks like schemaOptions is not always defined. Especially with the following schema

const mongoose = require(`mongoose`)
const VariableSchema = require(`./VariableSchema.js`)

const ElementPathSchema = new mongoose.Schema({
  paths: {
   paths: {
      type: [[VariableSchema]],
      validate: {
        validator: function validateTemplate(arrayOfVariables) {
          return arrayOfVariables.every((variables) =>
            VariableSchema.statics.validateTemplate(variables, `elementQuery`),
          )
        },
        message: `elementPath.paths not valid`,
      },
    }
  },
})
@DScheglov
Copy link
Owner

Hey, @gilles-yvetot
Thank you for registering the issue.
I've fixed it with a quick patch: See v2.0.2.

Feel free to reopen the issue if it doesn't work for you.

@gilles-yvetot
Copy link
Author

@DScheglov thanks a lot. I opened a PR to fix this issue and even added a test but I guess I will close it.

@gilles-yvetot
Copy link
Author

For future reference, here is the commit that fixes this bug

@DScheglov
Copy link
Owner

@gilles-yvetot ,
oh, thank you.

Sorry for not using your PR.
The coveralls reported that coverage was reduced, so ...
And it seems your IDE overrides project linting settings -- your commit contains several linting changes.

@gilles-yvetot
Copy link
Author

No problem at all, we got a fix and that's what matter.
I was suggesting that you can maybe add an .editorconfig , prettier config and eslint config to be more IDE agnostic. I am sure it would help other people bringing PRs in

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