Skip to content

extenstions/jsonSchema - consider returning just the schema #2

Description

@neonstalwart

it's hard to use extensions/jsonSchema with a custom base Model. e.g. i have a base Model for all my models which is something like this:

define(function (require) {
    var Model = require('dmodel/Model');

    return Model.createSubclass({
        rpc: function (method) {
            var params = Array.prototype.slice.call(arguments, 1);

            return this._store._rpc(this._store.target + this._store.getIdentity(this), method, params);
        }
    });
});

then each of my models just depend on that module and define their own schemas.

BaseModel.createSubcalss({
  schema: ...
});

trying to use extensions/jsonSchema causes a lot of friction because it takes a schema and returns a Model. i would have to do something like using AMD map config to map my own model as dmodel/Model into dmodel/extensions/jsonSchema or use model.prototype.schema as the schema to pass to another Model.

it would be easier if the extension took a json-schema and returned the dmodel schema so that it is used like so:

Model.createSubclass({
  schema: jsonSchema(...)
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions