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

pass models & enums as lists so custom templates can use them #1189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eli-bl
Copy link
Collaborator

@eli-bl eli-bl commented Jan 7, 2025

Resolves #1188.

The change is simply to store a list, rather than a generator expression.

The new models_init.py.jinja template in the end-to-end tests shows that this now works. Without the fix in openapi.py, this template is rendered with nothing under the Using "openapi.models" and Using "openapi.enums" headings.

This fix is somewhat important for our use case, because we need to put some code in models/__init__.py that is aware of what the model class names and modules are. Without the fix, the only way to get this would be to iterate over imports, which gives you strings like from .module_name import ClassName, and then parse those strings, which is workable but pretty clunky.

@eli-bl eli-bl requested a review from dbanty January 7, 2025 00:34
@eli-bl eli-bl force-pushed the issue1188-models-enums-iterable branch from f0c8b78 to 6b34737 Compare January 7, 2025 00:51
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

Successfully merging this pull request may close these issues.

"openapi.models" and "openapi.enums" aren't usable in custom templates
1 participant