marshmallow-sqlalchemy
marshmallow-sqlalchemy copied to clipboard
Question: Ability to return classname for custom type (TypeDecorator) in metadata
Hey! Thanks for the library. I have what may be a naive question:
I have a scenario in which I'm
- using marshmallow-sqlalchemy
SQLAlchemySchemaalong withauto_field - using a custom type, defined creating a class that inherits from sql alchemy's
TypeDecorator - using apispec to publish a swagger doc based on the marshmallow schemas
- using apispec's
marshmallow_plugin.converter.add_attribute_functionto add middleware which modifies the openapi spec in certain circumstances.add_attribute_functiontakes an argument of the marshmallow field (of typeField).
For the most part, this works great. However, I'd like to modify the openapi schema docs when I encounter one of my custom sql alchemy types. However, the following code seems to hide the original type from the downstream consumers when auto_field() is used. Is it possible to somehow identify what the source TypeDecorator class is for an auto_field?
https://github.com/marshmallow-code/marshmallow-sqlalchemy/pull/83/files
if hasattr(data_type, 'impl'):
return self._get_field_class_for_data_type(data_type.impl)
For now, I can stop using auto_field in these cases.
Thanks!