Open paulyoung opened 4 years ago
This works as expected, since_1 is required:
_1
required
data Foo = Bar { _1 :: LText }
{ "swagger": "2.0", "info": { "version": "", "title": "" }, "definitions": { "Foo": { "required": [ "_1" ], "type": "object", "properties": { "_1": { "type": "string" } } } }, "paths": {} }
So does this, since _1 is not required:
data Foo = Bar { _1 :: Maybe LText }
{ "swagger": "2.0", "info": { "version": "", "title": "" }, "definitions": { "Foo": { "type": "object", "properties": { "_1": { "type": "string" } } } }, "paths": {} }
But this does not, since _2 should not be required:
_2
data Foo = Bar { _1 :: LText } | Baz { _2 :: Maybe LText } deriving (Generic, ToJSON, ToSchema)
{ "swagger": "2.0", "info": { "version": "", "title": "" }, "definitions": { "Foo": { "minProperties": 1, "maxProperties": 1, "type": "object", "properties": { "Bar": { "required": [ "_1" ], "type": "object", "properties": { "_1": { "type": "string" } } }, "Baz": { "required": [ "_2" ], "type": "object", "properties": { "_2": { "type": "string" } } } } } }, "paths": {} }
looks like a legitimate bug to me. do you have time to work on fixing this?
This works as expected, since
_1
isrequired
:So does this, since
_1
is notrequired
:But this does not, since
_2
should not berequired
: