Giter VIP home page Giter VIP logo

mongoose-schema-jsonschema's Introduction

Build Status Coverage Status npm downloads NPM

mongoose-schema-jsonschema

The module allows to create json schema from Mongoose schema by adding jsonSchema method to mongoose.Schema, mongoose.Model and mongoose.Query classes

Contents


Installation

npm install mongoose-schema-jsonschema

Schema Build Configuration

Since v1.4.0 it is able to configure how jsonSchema() works.

To do that package was extended with config function.

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

config({
  // ... options go here
});

Currently there are two options that affects build process:

  • forceRebuild: boolean -- mongoose-schema-jsonschema caches json schemas built for mongoose schemas. That means we cannot built updated jsonSchema after some updates were made in the mongoose schema that already has jsonSchema. To resolve this issue the forceRebuild was added (see sample bellow)

  • fieldOptionsMapping: { [key: string]: string } | Array<string|[string, string]> - allows to specify how to convert some custom options specified in the mongoose field definition.

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

const { Schema } = mongoose;

const BookSchema = new Schema({
  title: { type: String, required: true, notes: 'Book Title' },
  year: Number,
  author: { type: String, required: true },
});

const fieldOptionsMapping = {
  notes: 'x-notes',
};

config({ fieldOptionsMapping });
console.dir(BookSchema.jsonSchema(), { depth: null });

config({ fieldOptionsMapping: [], forceRebuild: true }); // reset
console.dir(BookSchema.jsonSchema(), { depth: null });

Output:

{
  type: 'object',
  properties: {
    title: { type: 'string', 'x-notes': 'Book Title' },
    year: { type: 'number' },
    author: { type: 'string' },
    _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' }
  },
  required: [ 'title', 'author' ]
}
{
  type: 'object',
  properties: {
    title: { type: 'string' },
    year: { type: 'number' },
    author: { type: 'string' },
    _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' }
  },
  required: [ 'title', 'author' ]
}

Samples

Let's build json schema from simple mongoose schema

const mongoose = require('mongoose');
require('mongoose-schema-jsonschema')(mongoose);

const Schema = mongoose.Schema;

const BookSchema = new Schema({
  title: { type: String, required: true },
  year: Number,
  author: { type: String, required: true },
});

const jsonSchema = BookSchema.jsonSchema();

console.dir(jsonSchema, { depth: null });

Output:

{
  type: 'object',
  properties: {
    title: { type: 'string' },
    year: { type: 'number' },
    author: { type: 'string' },
    _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' }
   },
  required: [ 'title', 'author' ]
}

The mongoose.Model.jsonSchema method allows to build json schema considering the field selection and population

const mongoose = require('mongoose');
require('mongoose-schema-jsonschema')(mongoose);

const Schema = mongoose.Schema;

const BookSchema = new Schema({
  title: { type: String, required: true },
  year: Number,
  author: { type: Schema.Types.ObjectId, required: true, ref: 'Person' }
});

const PersonSchema = new Schema({
  firstName: { type: String, required: true },
  lastName: { type: String, required: true },
  dateOfBirth: Date
});

const Book = mongoose.model('Book', BookSchema);
const Person = mongoose.model('Person', PersonSchema)

console.dir(Book.jsonSchema('title year'), { depth: null });
console.dir(Book.jsonSchema('', 'author'), { depth: null });

Output:

{
  title: 'Book',
  type: 'object',
  properties: {
    title: { type: 'string'  },
    year: { type: 'number'  },
    _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' }
  }
}
{
  title: 'Book',
  type: 'object',
  properties: {
    title: { type: 'string'  },
    year: { type: 'number'  },
    author: {
      title: 'Person',
      type: 'object',
      properties: {
        firstName: { type: 'string'  },
        lastName: { type: 'string'  },
        dateOfBirth: { type: 'string', format: 'date-time'  },
        _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$'  },
        __v: { type: 'number' }
       },
      required: [ 'firstName', 'lastName' ],
      'x-ref': 'Person',
      description: 'Refers to Person'
     },
    _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$'  },
    __v: { type: 'number' }
   },
  required: [ 'title', 'author' ]
}
const mongoose = require('mongoose');
const extendMongoose = require('mongoose-schema-jsonschema');

extendMongoose(mongoose);

const { Schema } = mongoose;

const BookSchema = new Schema({
  title: { type: String, required: true  },
  year: Number,
  author: { type: Schema.Types.ObjectId, required: true, ref: 'Person' }
});

const Book = mongoose.model('Book', BookSchema);
const Q = Book.find().select('title').limit(5);


console.dir(Q.jsonSchema(), { depth: null });

Output:

{
  title: 'List of books',
  type: 'array',
  items: {
    type: 'object',
    properties: {
      title: { type: 'string'  },
      _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' }
    }
   },
  maxItems: 5
}

Validation tools

Created by mongoose-schema-jsonschema json-schema's could be used for document validation with:

Specifications

mongoose.Schema.prototype.jsonSchema

Builds the json schema based on the Mongoose schema. if schema has been already built the method returns new deep copy

Method considers the schema.options.toJSON.virtuals to included the virtual paths (without detailed description)

Declaration:

function schema_jsonSchema(name) { ... }

Parameters:

  • name: String - Name of the object
  • Returns Object - json schema

mongoose.Model.jsonSchema

Builds json schema for model considering the selection and population

if fields specified the method removes required constraints

Declaration:

function model_jsonSchema(fields, populate) { ... }

Parameters:

  • fields: String|Array|Object - mongoose selection object
  • populate: String|Object - mongoose population options
  • Returns Object - json schema

mongoose.Query.prototype.jsonSchema

Builds json schema considering the query type and query options. The method returns the schema for array if query type is find and the schema for single document if query type is findOne or findOneAnd*.

In case when the method returns schema for array the collection name is used to form title of the resulting schema. In findOne* case the title is the name of the appropriate model.

Declaration:

function query_jsonSchema() { ... }

Parameters:

  • Returns Object - json schema

Custom Schema Types Support

If you use custom Schema Types you should define the jsonSchema method for your type-class(es).

The base functionality is accessible from your code by calling base-class methods:

newSchemaType.prototype.jsonSchema = function() {
  // Simple types (strings, numbers, bools):
  const jsonSchema = mongoose.SchemaType.prototype.jsonSchema.call(this);

  // Date:
  const jsonSchema = Types.Date.prototype.jsonSchema.call(this);

  // ObjectId
  const jsonSchema = Types.ObjectId.prototype.jsonSchema.call(this);

  // for Array (or DocumentArray)
  const jsonSchema = Types.Array.prototype.jsonSchema.call(this);

  // for Embedded documents
  const jsonSchema = Types.Embedded.prototype.jsonSchema.call(this);

  // for Mixed documents:
  const jsonSchema = Types.Mixed.prototype.jsonSchema.call(this);

  /*
   *
   * Place your code instead of this comment
   *
   */

   return jsonSchema;
}

Releases

  • version 1.0 - Basic functionality
  • version 1.1 - Mongoose.Query support implemented
  • version 1.1.5 - uuid issue fixed, ajv compliance verified
  • version 1.1.8 - Schema.Types.Mixed issue fixed
  • version 1.1.9 - readonly settings support added
  • version 1.1.11 - required issue fixed issue#2
  • version 1.1.12 - mixed-type fields description and title support added (fix for issue: issue#3)
  • version 1.1.15 - support for [email protected] ensured issue#8
  • version 1.3.0
    • nullable types support (as union: [type, 'null'])
    • examples option support issue#14
    • support for fields dynamicly marked as required issue#16
    • Node support restricted to 8.x, 9.x, 10.x, 12.x
    • Mongoose support restricted to 5.x
    • Development:
      • migrated from mocha + istanbul to jest
      • added eslint
  • version 1.3.1 - support minlenght and maxlength issue#21
  • version 1.4.0 - broken - schema build configurations (forceRebuild and fieldOptionsMapping)
  • version 1.4.2 - fix for broken version 1.4.0 issue#22
  • version 1.4.4 - fix for field constraints issue#25
  • version 2.0.0 - Support for [email protected]. Node v8.x.x, v9.x.x are no longer supported (use v1.4.7 of the lib)
  • version 2.1.0 - Support for [email protected] and Node v14.x, v16.x, v18.x
  • version 2.2.0 - Support for [email protected] and Node v20.x. Node v14.x is no longer supported (use v2.1.0 of the lib)

Supported versions

  • node.js: 16.x, 18.x, 20.x
  • mongoose: 5.x, 6.x, 7.x, 8.x

mongoose-schema-jsonschema's People

Contributors

dscheglov avatar kalvinarts avatar romy-piche avatar simonecorsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mongoose-schema-jsonschema's Issues

Mongoose validators are converted incorrectly

I have this mongoose schema:

name: {
    type: String,
    maxlength: [256, 'Why name is too long?'] // Mongoose validator: https://mongoosejs.com/docs/validation.html#built-in-validators
},

Calling jsonSchema() give me the output with maxLength is an array.

Expected result:

maxLength: 256

Description not picked up for array type

Hi,
It looks like description will not be picked up when type is array, for example:

new mongoose.Schema(
{
name: String,
inputs: {type: [String], index: true, description: "Information operated on by rule"},
outputs: {description: "Information produced by rule", type: [String]},
}
);

Add support for "example" field

Hi. Is it possible to add support for "example" field to the generated json schema which will come from the "example" field from the mongoose schema? Same as current behavior of "description" field which gets its value from the mongoose schema

Mongoose "Map" field mapping

I have a Mongoose schema defined with the "map" field type. Looks like-

    let richMetaDataItemSchema = mongoose.Schema({
        name: { type: String },
        language: {
            type: Map,
            of: { type: String }
        }
    });

Right now its getting transformed into a schema that looks like-

 "summary": {
      "title": "summary",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "language": {
          "type": "map",
          "properties": {
            "$*": {
              "type": "string"
            }
          }
        }
      },

Problem is the type: "map" isnt a valid type(Or not that I can find in the docs).
I am also using the tool-https://uniforms.tools/
And that also has a problem with that field type...

Any ideas, or possible to support a valid JSONSchema construct?

Support mongoose 6.0.2

Mongoose 6.0.2 renames Types.Embedded to Types.Subdocument.

I opened PR #31 to fix the issue, but a more elegant solution would be appreciated, in order to keep support for previous mongoose versions.

Proposal: using the npm list command to get a list of all installed packages, find mongoose in the output and extract version. Compare major version and if greater than 6, apply fix.

In the meanwhile, please update the package as latest version should be the one supported.

Have a great day!

Format uuid is invalid

Hi, i'm using your module as depends. I validate the schema by ajv, but the result is invalid.
ObjectId is not a uuid, so the format uuid make it validate failed.
Thank you.

Bug in sub object property with required keyword

Hi, i find a bug of the schema which has sub object with required property.
Such as, manage has a required field startAt and endAt, but i get the jsonschema with required properties name,internalName,startAt,endAt at the top level.
This will make validation failed to JSON-SCHEMA 4.
Do you have time to fix it?
Thanks.

// mongoose schema
{
    name: {
        type: String,
        required: true,
        unique: true,
    },
    description: {
        type: String,
    },
    internalName: {
        type: String,
        required: true,
        unique: true,
    },
    manage: {
       offline: { 
            type: Boolean,
            default: true,
        },
        startAt: {
            type: Date,
            required: true,
        },
        endAt: {
            type: Date,
            required: true,
        },
    },
}
// jsonschema
{
    "title": "book",
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        },
        "description": {
            "type": "string"
        },
        "internalName": {
            "type": "string"
        },
        "manage": {
            "title": "manage",
            "type": "object",
            "properties": {
                "offline": {
                    "type": "boolean",
                    "default": true
                },
                "startAt": {
                    "type": "string",
                    "format": "date-time"
                },
                "endAt": {
                    "type": "string",
                    "format": "date-time"
                }
            }
        }
    },
    "required": [
        "name",
        "internalName",
        "startAt",
        "endAt"
    ]
}

Usage in NestJS with SchemaFactory.createForClass

Hello,
so I would like to use this library but there is a main point I'm not able to resolve and maybe there is a gap in what I'm trying to achieve.
I have a NestJS application using Mongoose.
Schemas are created as follows:

`
import { PartialType } from '@nestjs/mapped-types';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ApiProperty } from '@nestjs/swagger';
import { Document } from 'mongoose';

export type CatDocument = Cat & Document;

@Schema()
export class Cat {

@ApiProperty()
@prop()
name: string;

@ApiProperty()
@prop()
age: number;

@ApiProperty()
@prop()
breed: string;
}

export const CatSchema = SchemaFactory.createForClass(Cat)
export class UpdateCat extends PartialType(Cat) {}
`

As you can see SchemaFactory.createForClass is invoked to obtain a schema object.
So I thought I could use it with this library but this object doesn't expose the jsonSchema().

When I create as an instance of mongoose Schema then it works.

Is this an incompatibility with NestJS SchemaFactory?

Thanks and best regards

Behaviour of __removeRequired when using selection

When using the jsonSchema function on the mongoose model together with a selection, the required property is completely removed. Wouldn't it be better to check, which properties are going to be included and only delete those from the required field, that are excluded?

Example:

const BookSchema = new Schema({
 title: { type: String, required: true },
 year: { type: Number, required: true }
});
const Book = mongoose.model('Book', BookSchema);
Book.jsonSchema('title');

Response would look like:

{
  title: 'Book',
  type: 'object',
  properties: {
    title: { type: 'string'  },
  },
 required: [ 'title' ]
}

instead of

{
  title: 'Book',
  type: 'object',
  properties: {
    title: { type: 'string'  },
  }
}

exclude

thanks for module, saved my time! one question, is it possible to exclude some fields? would be really useful if we'll be able to exclude some certain fields like ids, pw, keys etc. thanks!

additionalProperties configuration

Hi, didn't find any docs / example related to additionalProperties. By default, MongoDB keeps this as true.

How can make it additionalProperties: false globally, so that child objects are also validated.
Is this possible

Feature Request: Add interface to be more static JsonSchema(mongooseModel)

i think it would be less error prone to have an option for passing the model to a function, without having the need for extending all the mongoose types.
e.g. i have my models in a different package than the schema-creation script. now i need to include mongoose, for schema creation and it seems, there is something off with peerDependencies or so, because the .jsonSchema function does not exist.

so instead of

mongooseModel.jsonSchema();

i would like to do:

const JsonSChema =require("mongoose-schema-jsonschema");
JsonSchema(mongooseModel);

npm warns mongoose@^5.0.0 required

When using mongoose 6.x.x npm install warns that mongoose-schema-jsonschema requires mongoose@^5.0.0.

Should your package.json dependencies be updated to "mongoose": "^6.0.0", or am I missing something?

Description for mixed

The description field is not picked up for mongoose.Schema.Types.Mixed properties.

The description is actually pretty useful in these cases as these properties can get pretty complex.

Overriding peer dependency - [email protected]

Can this mess up the npm project?

$ npm i mongoose
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/mongoose
npm WARN   mongoose@"^7.2.1" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer mongoose@"^5.0.0 || ^6.0.0" from [email protected]
npm WARN node_modules/mongoose-schema-jsonschema
npm WARN   mongoose-schema-jsonschema@"^2.0.2" from the root project

up to date, audited 32 packages in 761ms

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

getters and setters, does not show up in json

var BookSchema = new Schema({
    title: {type: String, required: true},
    year: Number,
    author: {type: String, required: true, get: function() { return 123; }}
});

returns:

{ type: 'object',
  properties: 
   { title: { type: 'string' },
     year: { type: 'number' },
     author: { type: 'string' },
     _id: { type: 'string', pattern: '^[0-9a-fA-F]{24}$' } },
  required: [ 'title', 'author' ] }

as you can see the object does not include the get function.

Using a schema with PatternProperties

Hello, I've run into a problem using AutoField with my schema.

I have this object in my schema:

"discrete_components": { "type": "object", "patternProperties": { ".+": { "type": "object", "properties": { "name": { "type": "string", "maxLength": 255, "minLength": 1 }, "components": { "type": "array", "maxItems": 512, "minItems": 1, "items": { "type": "object", "required": [ "type", "range_start", "range_end" ], "properties": { "type": { "type": "string", "enum": [ "OPEN", "CLOSED", ] }, "range_start": { "type": "integer", "maximum": 255 }, "range_end": { "type": "integer", "maximum": 255 } } } } } } } }

I'm trying to use AutoField like this <AutoField name="discrete_components.someId"/> which doesn't work because AutoField looks up the field with useField, which ultimately uses the getField function from the JSONSchemaBridge class and the getField function doesn't handle patternProperties. Is this something you'd consider adding to the JSONSchemaBridge class?

I tried to extend the class but I couldn't get it working properly and this is quite a messy solution:

`
class CustomJSONSchemaBridge extends JSONSchemaBridge {

fieldInvariant = (name: string, condition: boolean) => {
invariant(condition, "Field not found in schema: "%s"", name)
}

partialNames = ["allOf", "anyOf", "oneOf"]

resolveRefIfNeeded (
partial: UnknownObject,
schema: UnknownObject,
): UnknownObject {
if (!("$ref" in partial)) {
return partial
}

const { $ref, ...partialWithoutRef } = partial
return this.resolveRefIfNeeded(
  // @ts-expect-error The `partial` and `schema` should be typed more precisely.
  Object.assign({}, partialWithoutRef, resolveRef($ref, schema)),
  schema,
)

}

getField (name: string) {
return joinName(null, name).reduce((definition, next, index, array) => {
const prevName = joinName(array.slice(0, index))
const nextName = joinName(prevName, next)
const definitionCache = (this._compiledSchema[nextName] ??= {})
definitionCache.isRequired = !!(
definition.required?.includes(next) ||
this._compiledSchema[prevName].required?.includes(next)
)

  if (next === "$" || next === "" + parseInt(next, 10)) {
    this.fieldInvariant(name, definition.type === "array")
    definition = Array.isArray(definition.items)
      ? definition.items[parseInt(next, 10)]
      : definition.items
    this.fieldInvariant(name, !!definition)
  } else if (definition.type === "object") {
    this.fieldInvariant(name, !!definition.properties)
    definition = definition.properties[joinName.unescape(next)]
    this.fieldInvariant(name, !!definition)
  } else {
    let nextFound = false
    this.partialNames.forEach(partialName => {
      definition[partialName]?.forEach((partialElement: any) => {
        if (!nextFound) {
          partialElement = this.resolveRefIfNeeded(partialElement, this.schema)
          if (next in partialElement.properties) {
            definition = partialElement.properties[next]
            nextFound = true
          }
        }
      })
    })

    // Check if 'patternProperties' is defined in the current definition
    if (definition.patternProperties) {
      for (const pattern of Object.keys(definition.patternProperties)) {
        const regex = new RegExp(pattern)
        if (regex.test(next)) {
          definition = definition.patternProperties[pattern]
          nextFound = true
          break
        }
      }
    }

    this.fieldInvariant(name, nextFound)
  }

  definition = this.resolveRefIfNeeded(definition, this.schema)

  // Naive computation of combined type, properties, and required.
  const required = definition.required ? definition.required.slice() : []
  const properties = definition.properties
    ? Object.assign({}, definition.properties)
    : {}

  this.partialNames.forEach(partialName => {
    definition[partialName]?.forEach((partial: any) => {
      partial = this.resolveRefIfNeeded(partial, this.schema)

      if (partial.required) {
        required.push(...partial.required)
      }

      Object.assign(properties, partial.properties)

      if (!definitionCache.type && partial.type) {
        definitionCache.type = partial.type
      }
    })
  })

  if (required.length > 0) {
    definitionCache.required = required
  }

  if (!isEmpty(properties)) {
    definitionCache.properties = properties
  }

  return definition
}, this.schema)

}
}
`

Or is there a better approach that I haven't thought of?

Thank you for your help!

Populate and fields

Hi, I use this package to make development of an API using typescript, typegoose and other packages as simple as possbile.

During my developments I stumbled over a small problem with schema creation, referenced models and field exclusion. After some debugging, I identified the problem in this function:

function model_jsonSchema(fields, populate, readonly) {
  var jsonSchema = this.schema.jsonSchema(this.modelName);

  __excludedPaths(this.schema, fields).forEach(
    __delPath.bind(null, jsonSchema)
  );

  if (populate != null) {
    jsonSchema = __populate.call(this, jsonSchema, populate);
  };

  if (readonly) {
    __excludedReadonlyPaths(jsonSchema, readonly);
  }

  if (fields) __removeRequired(jsonSchema);

  return jsonSchema;
};

Do you think it is possible to switch logic for populate and excludes like this:

function model_jsonSchema(fields, populate, readonly) {
  var jsonSchema = this.schema.jsonSchema(this.modelName);

  if (populate != null) {
    jsonSchema = __populate.call(this, jsonSchema, populate);
  };

  __excludedPaths(this.schema, fields).forEach(
    __delPath.bind(null, jsonSchema)
  );

  if (readonly) {
    __excludedReadonlyPaths(jsonSchema, readonly);
  }

  if (fields) __removeRequired(jsonSchema);

  return jsonSchema;
};

With this order population happens first and after that exclusions can be done on subdocuments like this, which is an example from my code:

const pageSchema = require("../classes/models/server/Page")
        .jsonSchema(
            "-__v -author.password -author.__v -modifiedBy.password -modifiedBy.__v -category.__v",
            "author modifiedBy category",
        );

author, modifiedBy and category are referenced schemas which are populated and after that I remove some properties.

If you have any questions, feel free to ask.

I am not sure how to user custom types

Maybe this is me but I have a custom type that looks a bit like that [[Mixed]] and I do not understand how to use custom type with your package, the readme is not very clear to me

Thanks for this repo!!!!

Add custom options from mongoose schema to json schema

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.

Array of Array is not supported

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`,
      },
    }
  },
})

1.4.0 - Error: Cannot find module '../config'

Everything was fine with the earlier version, but suddenly my tests started failing then had a look at the version and it's 1.4.0 now.
Verified downgrading the version and my tests passed.

Throwing error "Cannot find module '../config'.

Exclude fields using config

Hey,

I'd like to be able to mark fields for exclusion from the generated schema.
Some of my models have sensitive data which is not sent to end users via my API. Adding excludeFromJSONSchema: true or something similar in my model definitions would cover this use case ๐Ÿ‘

If you can provide a hint about how you'd want this implemented I'm happy to make a pull request.

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.