20 | 20 |
$bundled = $jv->bundle({
|
21 | 21 |
replace => 1,
|
22 | 22 |
schema => {
|
23 | |
name => {'$ref' => '#/definitions/name'},
|
24 | |
definitions => {name => {type => 'string'}}
|
|
23 |
definitions => {name => {type => 'string'}},
|
|
24 |
surname => {'$ref' => '#/definitions/name'},
|
25 | 25 |
},
|
26 | 26 |
});
|
27 | 27 |
|
28 | |
is $bundled->{name}{type}, 'string', "[$n] replace=1";
|
|
28 |
is $bundled->{surname}{type}, 'string', "[$n] replace=1";
|
29 | 29 |
|
30 | 30 |
note "[$n] replace=0";
|
31 | 31 |
$bundled = $jv->schema({
|
32 | |
name => {'$ref' => '#/definitions/name'},
|
33 | |
age => {'$ref' => 'b.json#/definitions/age'},
|
|
32 |
surname => {'$ref' => '#/definitions/name'},
|
|
33 |
age => {'$ref' => 'b.json#/definitions/years'},
|
34 | 34 |
definitions => {name => {type => 'string'}},
|
35 | |
B => {id => 'b.json', definitions => {age => {type => 'integer'}}},
|
|
35 |
B => {id => 'b.json', definitions => {years => {type => 'integer'}}},
|
36 | 36 |
})->bundle;
|
|
37 |
ok $bundled->{definitions}{name},
|
|
38 |
"[$n] definitions/name still in definitions";
|
37 | 39 |
is $bundled->{definitions}{name}{type}, 'string',
|
38 | |
"[$n] name still in definitions";
|
39 | |
is $bundled->{definitions}{age}{type}, 'integer', "[$n] added to definitions";
|
40 | |
isnt $bundled->{age}, $jv->schema->get('/age'), "[$n] new age ref";
|
41 | |
is $bundled->{name}, $jv->schema->get('/name'), "[$n] same name ref";
|
42 | |
is $bundled->{age}{'$ref'}, '#/definitions/age',
|
43 | |
"[$n] age \$ref point to /definitions/age";
|
44 | |
is $bundled->{name}{'$ref'}, '#/definitions/name',
|
45 | |
"[$n] name \$ref point to /definitions/name";
|
|
40 |
"[$n] definitions/name/type still in definitions";
|
|
41 |
is $bundled->{definitions}{years}{type}, 'integer',
|
|
42 |
"[$n] added to definitions";
|
|
43 |
isnt $bundled->{age}, $jv->schema->get('/age'), "[$n] new age ref";
|
|
44 |
is $bundled->{surname}, $jv->schema->get('/surname'), "[$n] same surname ref";
|
|
45 |
is $bundled->{age}{'$ref'}, '#/definitions/years',
|
|
46 |
"[$n] age \$ref point to /definitions/years";
|
|
47 |
is $bundled->{surname}{'$ref'}, '#/definitions/name',
|
|
48 |
"[$n] surname \$ref point to /definitions/name";
|
46 | 49 |
}
|
47 | 50 |
|
48 | |
is $jv->get([qw(name type)]), 'string', 'get /name/$ref';
|
49 | |
is $jv->get('/name/type'), 'string', 'get /name/type';
|
50 | |
is $jv->get('/name/$ref'), undef, 'get /name/$ref';
|
51 | |
is $jv->schema->get('/name/type'), 'string', 'schema get /name/type';
|
52 | |
is $jv->schema->get('/name/$ref'), '#/definitions/name',
|
53 | |
'schema get /name/$ref';
|
|
51 |
is $jv->get([qw(surname type)]), 'string', 'get /surname/$ref';
|
|
52 |
is $jv->get('/surname/type'), 'string', 'get /surname/type';
|
|
53 |
is $jv->get('/surname/$ref'), undef, 'get /surname/$ref';
|
|
54 |
is $jv->schema->get('/surname/type'), 'string', 'schema get /surname/type';
|
|
55 |
is $jv->schema->get('/surname/$ref'), '#/definitions/name',
|
|
56 |
'schema get /surname/$ref';
|
54 | 57 |
|
55 | 58 |
$bundled = $jv->schema('data://main/bundled.json')->bundle;
|
56 | 59 |
is_deeply [sort keys %{$bundled->{definitions}}], ['objtype'],
|
|
66 | 69 |
is_deeply [sort map { s!^[a-z0-9]{10}!SHA!; $_ }
|
67 | 70 |
keys %{$bundled->{definitions}}],
|
68 | 71 |
[qw(
|
69 | |
SHA-age_json
|
70 | |
SHA-unit_json
|
71 | |
SHA-weight_json
|
72 | |
height
|
73 | |
)],
|
|
72 |
SHA-age_json
|
|
73 |
SHA-unit_json
|
|
74 |
SHA-weight_json
|
|
75 |
height
|
|
76 |
)],
|
74 | 77 |
'right definitions in disk spec'
|
75 | 78 |
or diag explain $bundled->{definitions};
|
76 | 79 |
}
|