Skip to content

Commit

Permalink
Merge pull request koxudaxi#384 from notpushkin/patch-1
Browse files Browse the repository at this point in the history
Allow modular output with custom templates
  • Loading branch information
koxudaxi authored Sep 7, 2023
2 parents 71723ee + dd4a6ae commit ca1d434
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fastapi_code_generator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ def generate_code(
if not output_dir.exists():
output_dir.mkdir(parents=True)
if generate_routers:
template_dir = BUILTIN_MODULAR_TEMPLATE_DIR
Path(output_dir / "routers").mkdir(parents=True, exist_ok=True)
if not template_dir:
template_dir = BUILTIN_TEMPLATE_DIR
template_dir = (
BUILTIN_MODULAR_TEMPLATE_DIR if generate_routers else BUILTIN_TEMPLATE_DIR
)
if enum_field_as_literal:
parser = OpenAPIParser(input_text, enum_field_as_literal=enum_field_as_literal)
else:
Expand Down Expand Up @@ -195,7 +196,7 @@ def generate_code(
set(tag.strip() for tag in str(specify_tags).split(","))
)

for target in BUILTIN_MODULAR_TEMPLATE_DIR.rglob("routers.*"):
for target in template_dir.rglob("routers.*"):
relative_path = target.relative_to(template_dir)
for router, tag in zip(routers, sorted_tags):
if (
Expand Down

0 comments on commit ca1d434

Please sign in to comment.