`null` in enum list
danilvalov opened this issue · 8 comments
I have MSON:
- options (enum, nullable, required)
- (object)
- type: `example` (string, required)
- (object)
- preview: `http://preview.com` (string, required)
- detail: `http://preview.com` (string, required)
And if field options
returns null
i receive error message from dredd:
At '/options' - Data does not match any schemas from "anyOf"
I tested other options:
- options (enum, required)
- (object, nullable)
- type: `example` (string, required)
- (object, nullable)
- preview: `http://preview.com` (string, required)
- detail: `http://preview.com` (string, required)
- options (enum, required)
- (object)
- type: `example` (string, required)
- (object)
- preview: `http://preview.com` (string, required)
- detail: `http://preview.com` (string, required)
- (nullable)
- options (enum, required)
- (object)
- type: `example` (string, required)
- (object)
- preview: `http://preview.com` (string, required)
- detail: `http://preview.com` (string, required)
- (string, nullable)
It's all doesn't work for me.
@honzajavorek Is nullable
supported in dredd yet?
@pksunkara Dredd should support nullable
. It was officially announced as supported and it also occurs in some tests. It's not heavily tested because Dredd just relies on Drafter-generated JSON Schema, so there's not much to test on Dredd side except of integration and regressions.
The question is how the JSON Schema looks like, it probably is incorrect if dredd complains
I've got the same problem. Seems like enums can't be nullable.
I filed Dredd-specific issue here: apiaryio/dredd#507 Any outcomes from trying to reproduce and debug the problem will be reported there. If we find out it's not Dredd issue, it may be parser issue since parser generates the JSON Schema. But in any case, it seems like from MSON specification perspective, there's nothing to fix - the thing should work as declared.
@kiwiholmberg I do not think this is the case. nullable
can be used everywhere where a value is expected. If used it should ready as "this value MAY be null".
Care to elaborate a bit more on your use case?
Here's an example blueprint. I want to express that the field "data" in Report can be null, or any of the report types VATReportData, PayeReportData. Dredd fails on the field "data" with message "Data does not match any schemas from "anyOf".
FORMAT: 1A
HOST: http://example.com/
# Example API
## Report
+ created_at: `2015-12-07T08:52:46.581Z` (string, optional) - The date the report was created.
+ updated_at: `2015-12-07T08:52:46.581Z` (string, optional) - The date the report was last updated.
+ data (ReportData, required, nullable) - Data for this report, will vary depending on the type of report
## ReportData (enum)
+ (VATReportData)
+ (PayeReportData)
## VATReportData
+ block_a (object, required) - Sales or self-supply liable to VAT, exclusive of VAT
+ box_05 (number, required) - Sales liable to VAT not included in other boxes below
+ box_06 (number, required) - Self-supply liable to VAT
+ box_07 (number, required) - Tax assessment basis for profit margin taxation
+ box_08 (number, required) - Rental income - voluntary tax liability
## PayeReportData
+ block_a (object, required) - Sales or self-supply liable to VAT, exclusive of VAT
+ box_05 (number, required) - Sales liable to VAT not included in other boxes below
+ box_06 (number, required) - Self-supply liable to VAT
+ box_07 (number, required) - Tax assessment basis for profit margin taxation
+ box_08 (number, required) - Rental income - voluntary tax liability
I can confirm that the JSON Schema produces does contain null
for data
. This most probably is a dredd issue. /cc @honzajavorek