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

Separate description per allowableValue #1012

Closed
cowwoc opened this issue Apr 27, 2015 · 7 comments
Closed

Separate description per allowableValue #1012

cowwoc opened this issue Apr 27, 2015 · 7 comments

Comments

@cowwoc
Copy link

cowwoc commented Apr 27, 2015

It's not clear how to document enums in a scalable manner. I want to provide users with a list of all possible enum values, and for each value provide a description of its meaning.

Ideally, I would like to link to the enum from the REST method that returns it and then provide a separate description (annotation) per value.

@ApiModelProperty(dataType = "string", allowableValues = "Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday", value = "description", notes = "notes") is not a good fit because:

  1. The documentation falls out of date if an enum value is added or removed.
  2. I am forced to dump the description for all values in a single notes field. This clutters the code and is hard to maintain.

Any ideas?

@cowwoc cowwoc changed the title Not clear how to document enums Separate description per allowableValue Apr 27, 2015
@webron
Copy link
Contributor

webron commented Apr 27, 2015

The spec doesn't really provide a way to give a description per enum value. Without going too much into details, that's pretty much a limitation of JSON Schema. The only way to provide such a documentation would be via the notes field. As for the values of the enum, if the type of the property is an enum on its own, the enum should be parsed automatically to enum values and you should not need to declare those manually (so no need to maintain the list).

@cowwoc
Copy link
Author

cowwoc commented Apr 27, 2015

@webron Is this a limitation of the Swagger schema? Or the limitation of the JSON protocol?

@webron
Copy link
Contributor

webron commented Apr 28, 2015

Not JSON protocol but JSON Schema. It's a bit of a limitation of both. JSON Schema doesn't allow it, and we didn't provide an alternative solution in the spec.

@webron
Copy link
Contributor

webron commented Apr 29, 2015

@cowwoc - don't think we can do much more here.

@cowwoc
Copy link
Author

cowwoc commented Apr 29, 2015

@webron Okay, please provide an alternative solution in the spec as you mentioned (change this issue to a feature request).

@webron
Copy link
Contributor

webron commented Apr 29, 2015

You can open an issue on swagger-spec with a detailed request if you'd like it to be considered for a future version of the spec.

For now, you'd have to document it manually in the notes field

@cowwoc
Copy link
Author

cowwoc commented Apr 29, 2015

Done. Closing this issue.

@cowwoc cowwoc closed this as completed Apr 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants