dojo / dojo/dojo1-dmodel

extenstions/jsonSchema - consider returning just the schema

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
30
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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:

``` js
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.

``` js
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:

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the extensions/jsonSchema module and the Model.createSubclass API to understand the current return value and schema handling. Check any tests for the extension, if present; done means a JSON Schema can be passed to jsonSchema and its returned dmodel schema can be used in Model.createSubclass without replacing the custom base model.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.