Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this tool support self referential json files? #31

Open
jack-fin opened this issue Feb 1, 2017 · 0 comments
Open

Does this tool support self referential json files? #31

jack-fin opened this issue Feb 1, 2017 · 0 comments

Comments

@jack-fin
Copy link

jack-fin commented Feb 1, 2017

Hello,

I was reviewing this project. I was hoping that it would support a JSON file which contains references to itself. This is valid in JSON Schema, but it appears that this tool will take those references and always look to another json file in the project rather than see if that is a self reference. https://github.com/salesking/json_schema_tools/blob/master/lib/schema_tools/ref_resolver.rb#L32

Here is an example of a self referential JSON Schema:

{
   "title":"Application Dashboards",
   "type":"object",
   "properties":{
      "version":{
         "type":{
            "enum":[
               1.0
            ]
         }
      },
      "dashboards":{
         "type":"array",
         "minItems":1,
         "items":{
            "type":"object",
            "properties":{
               "name":{
                  "type":"string"
               },
               "team":{
                  "$ref":"#/definitions/team"
               },
               "services":{
                  "type":"array",
                  "items":{
                     "$ref":"#/definitions/service"
                  }
               },
               "layout":{
                  "$ref":"#/definitions/layout"
               }
            },
            "required":[
               "name",
               "layout",
               "services"
            ]
         }
      }
   },
   "required":[
      "dashboards",
      "version"
   ],
   "definitions":{
      "layout":{
         "type":"object",
         "oneOf":[
            {
               "title":"Quadrant Dashboard Layout",
               "type":"object",
               "properties":{
                  "type":{
                     "enum":[
                        "grid"
                     ]
                  },
                  "widgets":{
                     "type":"array",
                     "items":{
                        "properties":{
                           "widget_id":{
                              "description":"The unique id that references a specific widget",
                              "type":"string"
                           },
                           "x":{
                              "description":"The grid column on which to place this widget. Origin is upper-left",
                              "type":"integer"
                           },
                           "y":{
                              "description":"The grid row on which to place this widget. Origin is upper-left",
                              "type":"integer"
                           },
                           "span_x":{
                              "description":"How many columns this widget will span",
                              "type":"integer"
                           },
                           "span_y":{
                              "description":"How many rows this widget will span",
                              "type":"integer"
                           }
                        },
                        "required":[
                           "widget_id",
                           "x",
                           "y",
                           "span_x",
                           "span_y"
                        ]
                     }
                  }
               },
               "required":[
                  "type",
                  "widgets"
               ]
            }
         ]
      },
      "team":{
         "description":"The information about the team that supports this dashboard",
         "type":"object",
         "properties":{
            "name":{
               "description":"The name of this team",
               "type":"string"
            },
            "email":{
               "description":"The best contact email address for this team, usually a distribution list",
               "type":"string",
               "format":"email"
            },
            "defects":{
               "description":"A URL to JIRA to input tickets for defects for this team",
               "type":"string",
               "format":"uri"
            },
            "slack":{
               "description":"The slack chat room where a user can get support for this team",
               "type":"string",
               "pattern":"^\\#[a-z-]{1,21}$"
            },
            "pager_duty":{
               "description":"The email @hanoc.pagerduty.com to trigger a PD alert for this team",
               "type":"string",
               "format":"email"
            }
         },
         "required":[
            "name",
            "email"
         ]
      },
      "service":{
         "description":"The information about the service that this dashboard reflects",
         "type":"object",
         "properties":{
            "name":{
               "description":"The name of this application",
               "type":"string"
            },
            "portfolio":{
               "description":"The portfolio that this application supports",
               "type":"string"
            },
            "product":{
               "description":"The product that this application supports",
               "type":"string"
            },
            "slack":{
               "description":"The slack chat room where a user can get support for this application",
               "type":"string",
               "pattern":"^\\#[a-z-]{1,21}$"
            },
            "repositories":{
               "description":"An array of repositories that contribute to this application",
               "type":"array",
               "items":{
                  "type":"object",
                  "properties":{
                     "url":{
                        "description":"The url of the github repo for this application",
                        "type":"string",
                        "format":"uri"
                     }
                  },
                  "required":[
                     "url"
                  ]
               },
               "minItems":1,
               "uniqueItems":true
            }
         },
         "required":[
            "name",
            "repositories",
            "portfolio",
            "product"
         ]
      }
   }
}

Its possible I am missing something, does this project support references?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant