Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Ability to return classname for custom type (TypeDecorator) in metadata #431

Open
jdimmerman opened this issue Mar 15, 2022 · 0 comments

Comments

@jdimmerman
Copy link

Hey! Thanks for the library. I have what may be a naive question:

I have a scenario in which I'm

  • using marshmallow-sqlalchemy SQLAlchemySchema along with auto_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_function to add middleware which modifies the openapi spec in certain circumstances. add_attribute_function takes an argument of the marshmallow field (of type Field).

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant