Skip to content

Add endpoint_collections_by_tag and openapi to the templating globals #689

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

Merged
merged 2 commits into from
Nov 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions openapi_python_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def __init__(
package_version=self.version,
project_name=self.project_name,
project_dir=self.project_dir,
openapi=self.openapi,
endpoint_collections_by_tag=self.openapi.endpoint_collections_by_tag,
)
self.errors: List[GeneratorError] = []

Expand Down Expand Up @@ -264,18 +266,13 @@ def _build_api(self) -> None:
client_path.write_text(client_template.render(), encoding=self.file_encoding)

# Generate endpoints
endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag
api_dir = self.package_dir / "api"
api_dir.mkdir()
api_init_path = api_dir / "__init__.py"
api_init_template = self.env.get_template("api_init.py.jinja")
api_init_path.write_text(
api_init_template.render(
endpoint_collections_by_tag=endpoint_collections_by_tag,
),
encoding=self.file_encoding,
)
api_init_path.write_text(api_init_template.render(), encoding=self.file_encoding)

endpoint_collections_by_tag = self.openapi.endpoint_collections_by_tag
endpoint_template = self.env.get_template(
"endpoint_module.py.jinja", globals={"isbool": lambda obj: obj.get_base_type_string() == "bool"}
)
Expand Down