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

Implement controller generator #47

Closed
1 task done
Tracked by #53
rszamszur opened this issue Feb 11, 2022 · 1 comment · Fixed by #70
Closed
1 task done
Tracked by #53

Implement controller generator #47

rszamszur opened this issue Feb 11, 2022 · 1 comment · Fixed by #70
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rszamszur
Copy link
Member

rszamszur commented Feb 11, 2022

  • I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

Add base implementation for controller generator (similar to Rails):
fastapi-mvc generate controller Comments

This would create:

  • a file comments.py under package_name.app.models.controllers.v1 submodule
  • a unit test file
  • maybe a view file for custom JSON responses?

Similar to #45

@rszamszur rszamszur added the enhancement New feature or request label Feb 11, 2022
@rszamszur rszamszur mentioned this issue Feb 15, 2022
58 tasks
@rszamszur rszamszur self-assigned this Apr 8, 2022
@rszamszur rszamszur added this to the 0.11.0 milestone Apr 11, 2022
@rszamszur
Copy link
Member Author

Currently, I've decided to use cookiecutter to generate code parts as well. Initially jinja2 was chosen, but it's another dependency and tool for users to learn. Even though at first glance it's easy to use, having complex multi-file templates might be more difficult to implement (and test). Cookiecutter on the other hand is already being used for new project generation, also should be more versatile and flexible when it comes to templating.

Some issues to consider:

  • Technically cookiecutter doesn't allow single file templates, so code generators will be sort of patches that will override/add to the current fastapi-mvc project directory. Not sure how this plays out.
  • It seems that after generation in template dir __init__.py empty files will be created (where they aren't) which can override __init__.py files already existing in the project directory that can have some logic inside. The easiest workaround could be via hooks - pre_gen_hook. However, I'm not sure if this issue is caused by cookiecuter or if I just messed something up. Will follow up on this later.

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

Successfully merging a pull request may close this issue.

1 participant