jmcarp / flask-apispec

MIT License
655 stars 156 forks source link

FieldConverterMixin: ignore/handle non-string metadata keys (desert compatibility) #196

Closed sanzoghenzo closed 4 years ago

sanzoghenzo commented 4 years ago

I'm trying to dynamically build some endpoints starting from an attrs decorated class (similar to a dataclass).

To generate the schema from the class, I use desert; then I pass the schema to use_kwargs.

The problem is desert adds a n item to the fields metadata dictionary using a _DesertSentinel object as key; the FieldConverterMixin.metadata2properties method throws an AttributeError since it expects a string in order to use startswith on it.

I temporarily solved by using str(key) in the two dict comprehension of the method, but I don't know if it's the best solution to this.

sanzoghenzo commented 4 years ago

Sorry, I just realized the problem is in apispec itself, not flask-apispec