Skip to content

Object with "oneOf" property displays only description, but not title or constraints. #283

@hujon

Description

@hujon

When an object property can take multiple values specified by "oneOf", the resulting view for selection contains only the "description" and no other fields such as "type" or constraints like "minimum".

Context

When used in the JSON Scheme, the view for the object property is seriously limited. If the "oneOf" option has "title" defined, it is not even possible to know the property type.

Minimal working example schema:

{
  "type": "object",
  "properties": {
    "test": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 5,
          "description": "The minimum is not displayed."
        },
        {
          "type": "string",
          "title": "Guess type",
          "description": "The type is not displayed."
        }
      ]
    }
  },
  "title": "Test",
  "description": "Demonstrates the shortcomings of the 'oneOf' view in the object."
}

Current Behavior

Only the descriptions are displayed instead of full schema information.

String property with "Guess type?" title.
Integer property with minimum.

Expected Behavior

Full information shall be displayed, such as if the "oneOf" is used in top level.

Minimal working example schema:

{
  "oneOf": [
    {
      "type": "integer",
      "minimum": 5,
      "description": "The minimum is not displayed."
    },
    {
      "type": "string",
      "title": "Guess type",
      "description": "The type is not displayed."
    }
  ]
}

String with "Guess type?".
Integer with minimum.

Possible Workaround

The only workaround I know of as for now is to not define "title", so the type is visible at least in the options select. I know of no workaround for constraints other than writing them in description.

Moreover, when I use "$ref" in any of the options, the "type" is not used in the options select when no "title" is defined and the name of the reference (the URI part after last / ) is used instead.

Steps to Reproduce

  1. Use https://stoplightio.github.io/json-schema-viewer/
  2. Enter my schemas
  3. Check the resulting json-schema-viewer representations

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