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

extra_template_data not working #144

Closed
FlorianLudwig opened this issue Jun 11, 2020 · 6 comments
Closed

extra_template_data not working #144

FlorianLudwig opened this issue Jun 11, 2020 · 6 comments

Comments

@FlorianLudwig
Copy link
Contributor

Describe the bug

custom_template_dir seems to be ignored:

datamodel_code_generator.generate(custom_template_dir="some/path")

Version:

  • datamodel-code-generator Version: git master
@koxudaxi
Copy link
Owner

@FlorianLudwig
Interesting.
It works fine for a simple unittest.
Did you give me some hints? Would you show me custom_template?

@FlorianLudwig
Copy link
Contributor Author

Here a simple way to reproduce this by replacing the BaseModel.jinja2 without having any effect:

mkdir -p template/pydantic
echo "nope" > template/pydantic/BaseModel.jinja2
datamodel-codegen --input datamodel-code-generator/tests/data/openapi/api.yaml --input-file-type openapi --output gen.py --custom-template-dir template
grep nope gen.py

@FlorianLudwig
Copy link
Contributor Author

The example I am working with is this one: https://github.com/FlorianLudwig/pdk8s/tree/7e2479ccb1f25c7173368cb0fef2aef7f4501ae9/pdk8s/template

My build process includes copying this folder inside datamodel-code-generator.

@koxudaxi
Copy link
Owner

koxudaxi commented Jul 28, 2020

@FlorianLudwig
I have understood why the case does not affect results.

$ mkdir -p template/pydantic
$ echo "nope" > template/pydantic/BaseModel.jinja2
$ datamodel-codegen --input tests/data/openapi/api.yaml --input-file-type openapi --output gen.py --custom-template-dir template/pydantic
$ grep nope gen.py  |wc -l
6

We should specify a nested directory.
But, It may not be correct.
We can't use a custom template for Enum.

@FlorianLudwig
Copy link
Contributor Author

oh. okay. I misunderstood how it works then. So not a bug. Closing.

Thanks!

@koxudaxi
Copy link
Owner

@FlorianLudwig
We should explain the feature in documents.
I have created an issue to add a document for a custom template.

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

2 participants