@@ -239,15 +239,30 @@ def _build_api(self) -> None:
239239 client_path .write_text (client_template .render (), encoding = self .file_encoding )
240240
241241 # Generate endpoints
242+ endpoint_collections_by_tag = self .openapi .endpoint_collections_by_tag .items ()
242243 api_dir = self .package_dir / "api"
243244 api_dir .mkdir ()
244- api_init = api_dir / "__init__.py"
245- api_init .write_text ('""" Contains methods for accessing the API """' , encoding = self .file_encoding )
245+ api_init_path = api_dir / "__init__.py"
246+ api_init_template = self .env .get_template ("api_init.py.jinja" )
247+ api_init_path .write_text (
248+ api_init_template .render (
249+ package_name = self .package_name ,
250+ endpoint_collections_by_tag = endpoint_collections_by_tag ,
251+ ),
252+ encoding = self .file_encoding ,
253+ )
246254
247255 endpoint_template = self .env .get_template ("endpoint_module.py.jinja" )
248- for tag , collection in self . openapi . endpoint_collections_by_tag . items () :
256+ for tag , collection in endpoint_collections_by_tag :
249257 tag_dir = api_dir / tag
250258 tag_dir .mkdir ()
259+
260+ endpoint_init_path = tag_dir / "__init__.py"
261+ endpoint_init_template = self .env .get_template ("endpoint_init.py.jinja" )
262+ endpoint_init_path .write_text (
263+ endpoint_init_template .render (package_name = self .package_name , tag = tag , endpoints = collection .endpoints ),
264+ encoding = self .file_encoding ,
265+ )
251266 (tag_dir / "__init__.py" ).touch ()
252267
253268 for endpoint in collection .endpoints :
0 commit comments