Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#8960 closed defect (fixed)

dojox.json.ref not using properties from parent schema object

Reported by: Jarrod Carlson Owned by: Kris Zyp
Priority: high Milestone: 1.4
Component: Dojox Version: 1.3.0b3
Keywords: json ref schema Cc:
Blocked By: Blocking:

Description

When executing dojox.json.ref.resolveJson(), if the schema object passed in extends another schema object, the resolveJson() method does not ascend into the parent schemas.

dojo.require("dojox.json.ref");
dojo.require("dojo.date.stamp");

var schemas = {
    "/publications/": {
        "id": "publications",
        "type": "object",
        "properties": {
            "publish_date": {
                "type": "string",
                "format": "date-time"
            },
            "isbn": {
                "type": "integer"
            }
        }
    },
    "/books/": {
        "id": "books",
        "type": "object",
        "extends": {
            "$ref": "publications"
        },
        "properties": {
            "author": {
                "type": "string"
            }
        }
    }
};
dojox.json.ref.resolveJson(schemas);

var publication1 = {
    "id": "/publications/1",
    "publish_date": "2009-03-22T18:00:00Z",
    "isbn": 0987654321
}
dojox.json.ref.resolveJson(publication1, {
    schemas: schemas
});
// publish_date was converted from ISO string to date object
console.log(publication1.publish_date instanceof Date);


var book1 = {
    "id": "/books/2",
    "publish_date": "2009-03-22T18:00:00Z",
    "author": "Bob Smith",
    "isbn": 1234567890
}
dojox.json.ref.resolveJson(book1, {
    schemas: schemas
});
// publish_date was NOT converted from ISO string to date object
// publish_date was specified in a super-schema, so it wasn't looked at
console.log(book1.publish_date instanceof Date);

Change History (4)

comment:1 Changed 10 years ago by Adam Peller

Owner: changed from Adam Peller to Kris Zyp

comment:2 Changed 10 years ago by bill

Milestone: 1.3tbd

comment:3 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [18467]) Look through super-schemas for date-time information, fixes #8960

comment:4 Changed 10 years ago by Adam Peller

Milestone: tbd1.4
Note: See TracTickets for help on using tickets.