brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
607 stars 168 forks source link

Improvement: Titles for object whose content is referenced to a definition #70

Closed ychyrski closed 7 years ago

ychyrski commented 7 years ago

Firts of all i would like to thank you for all the work you did. I appreciate this project. So i have another query. Having

{
  "$schema": "http://json-schema.org/draft-03/schema#",
  "definitions": {
    "fld": {
      "title": "Global title",
      "type": "object",
      "properties": {
        "a": {
          "type": "string",
          "title": "Nested Title",
        }
      }
    }
  },
  "type": "object",
  "properties": {
    "fld1": {
      "title": "Real title 1",
      "$ref": "#/definitions/fld"
    },
    "fld2": {
    "title": "Real title 2",
      "$ref": "#/definitions/fld"
    },
    "fld3": {
      "title": "Real title 3",
      "$ref": "#/definitions/fld"
    }
  }
}

I get fld[1-3] titled as "Global title". I understand that you always resolve title from the object definition itself so it is logical that you get it from "#/definitions/fld/title". But as you can see from the example above if schema has multiple fields referring to the same object end user might be confused seeng the same labels. Please consider loading title field not from the referenced object but from the object defining the model.

My goal was to have exact 3 fields having the same structure but named differently. If you think that the change i request is something which will not add value to the project please let me know whether there are other ways to achive it.

idelvall commented 7 years ago

Yeah that makes sense, the possibility of overwriting certain properties when using refs. I'll work on it.

ychyrski commented 7 years ago

Cool, thank you !

idelvall commented 7 years ago

http://brutusin.org/json-forms/#11

idelvall commented 7 years ago

both title and description can be overwritten