Skip to content

Need option to produce non-flattened schemas (cannot currently handle tree structures) #2

Description

@rage-shadowman

Currently, shapeshifter generates flattened schemas which cannot define anything with a self reference (such as a tree structure, where a "Branch" may contain other "Branch" objects as well as "Leaf" objects).

However, JSON Schema allows for self referencing schemas via "$ref" property:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Tree",
  "oneOf": [ {
      "$ref": "#/definitions/Leaf"
    }, {
      "$ref": "#/definitions/Branch"
    }
  ],
  "definitions": {
    "Leaf": {
      "title": "Leaf",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "required": [ "name" ]
    },
    "Branch": {
      "title": "Branch",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string" },
        "nodes": {
          "type": "array",
          "items": {
            "oneOf": [ {
                "$ref": "#/definitions/Leaf"
              }, {
                "$ref": "#/definitions/Branch"
              }
            ]
          }
        }
      },
      "required": [ "name" ]
    }
  }
}

It would be nice if we could somehow tell shapeshifter to generate reference-based schemas instead of flattened schemas in order to accommodate such structures.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions