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

Add custom options from mongoose schema to json schema #17

Closed
vaggeliskls opened this issue Nov 21, 2019 · 2 comments
Closed

Add custom options from mongoose schema to json schema #17

vaggeliskls opened this issue Nov 21, 2019 · 2 comments

Comments

@vaggeliskls
Copy link

vaggeliskls commented Nov 21, 2019

I am trying to validate (with custom ajv keywords) the uniqueness and existence of specific properties of a mongoose model.
It would be a nice feature to enrich the __processOptions function in types.js with options types: exists: true|false and unique: true|false or enable a optional input of a predefined array of custom options.
Example: required('mongoose-schema-jsonschema')(mongoose, ['unique', 'exists'] )
Very nice work. Thank you.

@DScheglov
Copy link
Owner

DScheglov commented Apr 16, 2020

Hi, @vaggeliskls

I think about something like that:

const config = required('mongoose-schema-jsonschema/config');

config({
  schemaFieldsMapping: [
    'unique',
    'exists',
    {
      mongoose: 'some-field-from-mongoose',
      jsonSchema: 'some-field-to-jsonSchems',
    }
  ]
});

@DScheglov
Copy link
Owner

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