josdejong / jsoneditor

A web-based tool to view, edit, format, and validate JSON
http://jsoneditoronline.org
Apache License 2.0
11.23k stars 2.02k forks source link

oneOf issue #1548

Open sgurin opened 8 months ago

sgurin commented 8 months ago

Hi.

Take a look on the example https://sgurin.github.io/jsoneditor/examples/26_autocomplete_by_schema.html

When I am trying to set profession -> level there is only one option available

image

but schema contains 3 refs

  "profession": {
    "oneOf": [
      {
        "$ref": "junior"
      },
      {
        "$ref": "experienced"
      },
      {
        "$ref": "senior"
      },
    ]
  },

Looks like refs don't work

josdejong commented 8 months ago

Yes you are right, thanks for bringing this up. So to fix this, the code that creates the enum should proabably merge multiple enums in a case like oneOf. And maybe when there is a conflict and one of the options of oneOf does not contain an enum for that field, it should not create an enum.

Anyone interested in improving this?