stoplightio / elements

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
https://stoplight.io/open-source/elements/
Apache License 2.0
1.83k stars 207 forks source link

Multiple Depths of oneOf/anyOf #713

Open philsturgeon opened 4 years ago

philsturgeon commented 4 years ago

During the work on #667 we discovered a complex edge case which we have decided to address in a followup.

Try clicking on the campaigns menu and the item_id menu. These are meant to demonstrate how things might function for the schema below.

NOTE that our new context menu component is not ready - please just use the blueprint js context menu component in the meantime. It's OK that the styling is different for that, we'll replace the menu component later (it's not the hard part of this issue :)).

Also it's been quite a while since I was in the JSV codebase, and it is possible that the UX being asked for here is not possible. At the very least, I think this issue is going to be quite tricky and complex to get right - hopefully it's doable, but let us know if we need to re-think UX to make implementation easier if it turns out to be really really complicated. @mpodlasin you might need to coordinate with @P0lip to brainstorm implementation if it turns out to be really difficult.

LMK what you think of design + example below, and if you have questions.

{
  "type": "object",
  "properties": {
    "campaigns": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "number"
              }
            },

            "oneOf": [
              {
                "title": "Print Campaign",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              },
              {
                "title": "Numeric Campaign",
                "properties": {
                  "age": {
                    "type": "number"
                  }
                }
              }
            ]
          }    
        ]
      }
    },
    "item_id": {
      "oneOf": [
        {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "type": "string"
        }
      ]
    }
  }
}

Originally posted by @marbemac in https://github.com/stoplightio/elements/issues/667#issuecomment-722615927

mnaumanali94 commented 3 years ago

@mpodlasin @domagojk @wmhilton @paulatulis @mmiask Hey team! Can you please add your planning poker estimates with ZenHub