Uploaded image for project: 'Suggestion Box'
  1. Suggestion Box
  2. SUGGEST-202

Configuration mappable to a JSON Schema

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Labels:

      Description

      The idea is that configuration can be described using a JSON schema.

      The names decided by developers or users of the system should only occur at the highest level of the configuration. At the registry of the new item. For example, the name of the template, app, renderer, etc. All node names below that "top level" node are fixed.

      For example, the actions configuration of a dialog currently has this format:

      actions:
        commit:
          class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
        cancel:
          class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition
      

      The names commit and cancel are nodes. Their names are arbitrarily decided. It's difficult to realize this configuration as a JSON schema.

      However, if actions was expecting a list instead of a map then there would be a way to translate that.
      Consider the following:

      actions:
        - name: commit
          class: info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
        - name: cancel
          class: info.magnolia.ui.admincentral.dialog.action.CancelDialogActionDefinition
      

      The configuration in JSON notation:

      {
          "actions": {
              "items": [
                  { 
                      "type": "object",
                      "properties": {
                        "class": { "type": "string" },
                        "name": { "type": "string" }
                  }
              ]
          }
      }
      

      I'm interested to know what other people might think about this and it's feasibility? The end goal is to have a schema representation of all configurations registries in order to enable intellisense features of IDEs which support such things. See https://code.visualstudio.com/docs/languages/json

      In the above example of dialog it seems like we might be able to make a change in the Map2BeanTransformer which checks if a List was supplied when a Map was expected. If so, call the List supporting set method for actions.

      public void setActions(List<ActionDefinition> actions) {
          for (ActionDefinition action : actions)
              this.actions.put(action.getName(), action);
      }
      

      This version of setActions() simply converts the List into a Map keeping backwards compatibility.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rgange Richard Gange
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Date of First Response: