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

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

Open
hujon opened this issue Nov 29, 2024 · 0 comments

Comments

@hujon
Copy link

hujon commented Nov 29, 2024

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
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