I am using flask-restx for building an API.
My api model is like the following:
myModel = api.model(
'myModel',
{
'id' : fields.Integer(min=1, required=True),
'code' : fields.String(enum=["A", "B", "C"], required=False),
}
)
By doing so, code cannot be null.
But sometimes, the code field is null. If it is not, it must be one of the A
, B
or C
values.
I cannot add None
to the enum list because it is not a string.
How to make it possible to be null ?