dredd: Enums can't be nullable
Problems with nullable enums were reported by multiple users in https://github.com/apiaryio/mson/issues/61. We should investigate the problem.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 1
- Comments: 17 (11 by maintainers)
Commits related to this issue
- Moves this to the base model so that we can work around the nullable enum issue. https://github.com/apiaryio/dredd/issues/507 — committed to PerformanceHorizonGroup/apidocs by deleted user 8 years ago
I’ve got an example reproducing this issue. I believe it is the generated JSON schema that is incorrect.
My apib file:
Generated schema versus the tested response: https://jsonschemalint.com/#/version/draft-04/markup/json?gist=86082c8c39b53359fe6835163fc65569
If I add null (without quotes) as one of the possible enum types, the generated JSON schema includes “null” (with quotes) as a possible enum type.
So, this:
results in this generate schema versus the tested response: https://jsonschemalint.com/#/version/draft-04/markup/json?gist=f80347a08900d60c4d264b9c8bd1ca79
Finally, I’d like to conclude with a working combination: https://jsonschemalint.com/#/version/draft-04/markup/json?gist=458a3729bd732bd5109dbe1fc5d93619
@andybarilla I’ve prepared a fix in https://github.com/apiaryio/api-elements.js/pull/59, I hope you don’t mind that I’ve taken parts of your example Swagger 2 document to reproduce in our test fixtures.
Yes,
x-nullableby default would meannullinenum. But when you provide a differentenum, then they would contradict andenumgets priority since it is actually directly JSON Schema instead of an extension.This was fixed in Drafter. Soon it should propagate to Dredd.