You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In upgrading from 5.0.1 to 5.1.0 I found that the types changed for arrays with uniqueItems=True from Set to list. For us, this was a breaking change as we rely upon type hints.
Describe the solution you'd like
IMO, Set should be mapped to set in python, rather than to list. The tradeoff is that the array is not ordered, but it enforces (or rather easily allows us to enforce when deserializing using the supplied type) the uniqueItems constraint.
Describe alternatives you've considered
Alternatively, we don't marshall with set, and alter to the templates to handle duplicate values with uniqueItems.
Additional context
The refactor to add a python ABC in essence added a Set to list mapping to the AbstractPythonConnexionServerCodegen class via AbstractPythonCodegen, whereas previously it assumed a model of Set. This worked well as we could from typing import Set.
We then had custom templates that looked at __origin__ and applied mutations. As of 5.1 Set is now mapped to list and no longer allows us to do so.
uniqueItems has been added to the python-experimental generator in #8325
The data type was kept as tuple to allow other schemas with type list->(enforced as tuple) lacking uniqueItems to correctly validate against a list payload with unique items.
That way data like
[0, 1]
will validate against: ListWithUniqueItems + ListWithMinItems + SomeComposedSchema
Is your feature request related to a problem? Please describe.
In upgrading from 5.0.1 to 5.1.0 I found that the types changed for arrays with
uniqueItems=True
fromSet
tolist
. For us, this was a breaking change as we rely upon type hints.Describe the solution you'd like
IMO,
Set
should be mapped toset
in python, rather than tolist
. The tradeoff is that the array is not ordered, but it enforces (or rather easily allows us to enforce when deserializing using the supplied type) theuniqueItems
constraint.Describe alternatives you've considered
Alternatively, we don't marshall with set, and alter to the templates to handle duplicate values with
uniqueItems
.Additional context
The refactor to add a python ABC in essence added a
Set
tolist
mapping to theAbstractPythonConnexionServerCodegen
class viaAbstractPythonCodegen
, whereas previously it assumed a model ofSet
. This worked well as we couldfrom typing import Set
.We then had custom templates that looked at
__origin__
and applied mutations. As of 5.1Set
is now mapped tolist
and no longer allows us to do so.Additionally, when using the python-flask templates,
Set
is currently mapped tolist
whereasarray
is currently mapped toList
.See also #8784
The text was updated successfully, but these errors were encountered: