Use JSON schema title as name for the root object if defined (see #635)
This commit is contained in:
parent
4813cd79a1
commit
10daf40b56
|
@ -8,6 +8,7 @@ https://github.com/josdejong/jsoneditor
|
|||
- Breaking change: upgraded dependency `ajv@6.10.0`, supporting JSON schema
|
||||
draft-07 alongside draft-06 and draft-04.
|
||||
- Upgraded dependency `vanilla-picker@2.8.1`.
|
||||
- Use JSON schema title as name for the root object if defined (see #635).
|
||||
|
||||
|
||||
## 2019-06-08, version 5.34.0
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
|
||||
<script>
|
||||
var schema = {
|
||||
"title": "Example Schema",
|
||||
"title": "Employee",
|
||||
"description": "Object containing employee details",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"firstName": {
|
||||
|
|
|
@ -2483,7 +2483,7 @@ Node.prototype.updateField = function (field) {
|
|||
* indexes of the node will be updated too. False by
|
||||
* default.
|
||||
*/
|
||||
Node.prototype.updateDom = function (options) {
|
||||
Node.prototype.updateDom = function(options) {
|
||||
// update level indentation
|
||||
var domTree = this.dom.tree;
|
||||
if (domTree) {
|
||||
|
@ -2512,11 +2512,18 @@ Node.prototype.updateDom = function (options) {
|
|||
else if (this.field != undefined) {
|
||||
fieldText = this.field;
|
||||
}
|
||||
else if (this._hasChilds()) {
|
||||
fieldText = this.type;
|
||||
}
|
||||
else {
|
||||
fieldText = '';
|
||||
var schema = Node._findSchema(this.editor.options.schema,this.editor.options.schemaRefs || {}, this.getPath());
|
||||
|
||||
if (schema && schema.title) {
|
||||
fieldText = schema.title;
|
||||
}
|
||||
else if (this._hasChilds()) {
|
||||
fieldText = this.type;
|
||||
}
|
||||
else {
|
||||
fieldText = '';
|
||||
}
|
||||
}
|
||||
domField.innerHTML = this._escapeHTML(fieldText);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
var container = document.getElementById('jsoneditor');
|
||||
|
||||
var schema = {
|
||||
"title": "Example Schema",
|
||||
"title": "User",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"firstName": {
|
||||
|
|
Loading…
Reference in New Issue