Skip to content

Handle optional enum properties #400

@lepinay

Description

@lepinay

I have a schema where one of the property can optionally be set to "male" or "female" (similary to http://jeremydorn.com/json-editor/ example).

    "gender": {
      "type": "string",
      "enum": [
        "male",
        "female"
      ]
    }

With the current implementation I HAVE to pick a choice, but according to my schema since this property is not required the user should have the possibility to not set this field. So the UI is forcing me to make a choice whilst this field is not mandatory.

One workaround is introduce a third choice like "other" and that's fine if you have control over the schema but in my case I can't modify the schema just to "please" the UI.

Is there a way to cover this scenario without altering the original json schema ?

This would help integrating the following PR: swagger-api/swagger-ui#1088 I've been working on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions