Skip to content

A way to descibe enumeration values #520

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

Closed
mitar opened this issue Dec 13, 2017 · 4 comments
Closed

A way to descibe enumeration values #520

mitar opened this issue Dec 13, 2017 · 4 comments

Comments

@mitar
Copy link

mitar commented Dec 13, 2017

So enumeration can be a long list of values, which are often some constants used by a machine. I think there should be a way to attach description to each of those values.

@dlax
Copy link
Member

dlax commented Dec 13, 2017

One way to achieve this is to use a oneOf array with const and title (and maybe description):

{
  "oneOf": [
    {"const": "choice1", "title": "this is choice 1"},
    {"const": "choice2", "title": "this is choice 2"}
  ]
}

See #57 for reference.

@mitar
Copy link
Author

mitar commented Dec 14, 2017

And for v4 JSON schema this probably means I could do something like:

{
  "oneOf": [
    {"enum": ["choice1"], "title": "this is choice 1"},
    {"enum": ["choice2"], "title": "this is choice 2"}
  ]
}

No? Hm, maybe this can be an approach. Thanks.

@handrews
Copy link
Contributor

@mitar yes, that's the correct option in draft-04. const in draft-06 just makes the intent more clear. Sounds like we can close this, please LMK if you weren't done with the issue :-)

@mitar
Copy link
Author

mitar commented Dec 14, 2017

Thanks!

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

3 participants