Skip to content

Commit cacfd86

Browse files
committed
not loading any schemas by default
1 parent 3a2b6ec commit cacfd86

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

app.js

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
var schema = {
2-
"title": "Example Schema",
3-
"type": "object",
4-
"properties": {
5-
"firstName": {
6-
"type": "string"
7-
},
8-
"lastName": {
9-
"type": "string"
10-
},
11-
"age": {
12-
"description": "Age in years",
13-
"type": "integer",
14-
"minimum": 0
15-
}
16-
},
17-
"required": ["firstName", "lastName"]
18-
};
19-
201
Vue.component('json-textarea', {
212
template: '{{content}}',
223
created: function() {
@@ -63,18 +44,23 @@ Vue.component('schema-links', {
6344
var app = new Vue({
6445
el: '#editor',
6546
data: {
66-
schema: schema
47+
schema: {}
6748
},
6849
computed: {
6950
output: {
7051
$get: function() {
7152
var self = this;
7253
var rv = {};
73-
var keys = Object.keys(self.schema.properties);
74-
keys.forEach(function(key) {
75-
rv[key] = self.schema.properties[key].value;
76-
});
77-
return JSON.stringify(rv, null, "\t");
54+
var keys = {};
55+
if (self.schema && self.schema.properties) {
56+
keys = Object.keys(self.schema.properties);
57+
keys.forEach(function(key) {
58+
rv[key] = self.schema.properties[key].value;
59+
});
60+
return JSON.stringify(rv, null, "\t");
61+
} else {
62+
return {};
63+
}
7864
}
7965
}
8066
},

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
v-on="click: setHref">{{$key}}</a></li>
1313
</ul>
1414
<div id="input">
15+
<div v-if="!schema.properties"><em>Pick a schema. Any schema!</em>
16+
<br /><small>Or paste one in the textarea below.</small></div>
1517
<h1>{{schema.title}}</h1>
1618
<div v-repeat="schema.properties">
1719
<label for="{{$key}}">{{$key}}</label>

0 commit comments

Comments
 (0)