mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-30 09:43:43 -04:00 
			
		
		
		
	* fix ts types * feat(code-generation): ♻️ update code-generation formats * new scope * add step button * fix linter error * update code-generation tags * feat(backend): ✨ start multi-tenant support * feat(backend): ✨ group invitation token generation and signup * refactor(backend): ♻️ move group admin actions to admin router * set url base to include `/admin` * feat(frontend): ✨ generate user sign-up links * test(backend): ✅ refactor test-suite to further decouple tests (WIP) * feat(backend): 🐛 assign owner on backup import for recipes * fix(backend): 🐛 assign recipe owner on migration from other service Co-authored-by: hay-kot <hay-kot@pm.me>
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import json
 | |
| from typing import Any
 | |
| 
 | |
| from _gen_utils import render_python_template
 | |
| from _open_api_parser import OpenAPIParser
 | |
| from _static import CodeDest, CodeTemplates
 | |
| from rich.console import Console
 | |
| 
 | |
| from mealie.app import app
 | |
| 
 | |
| """
 | |
| This code is used for generating route objects for each route in the OpenAPI Specification.
 | |
| Currently, they are NOT automatically injected into the test suite. As such, you'll need to copy
 | |
| the relavent contents of the generated file into the test suite where applicable. I am slowly
 | |
| migrating the test suite to use this new generated file and this process will be "automated" in the
 | |
| future.
 | |
| """
 | |
| 
 | |
| console = Console()
 | |
| 
 | |
| 
 | |
| def write_dict_to_file(file_name: str, data: dict[str, Any]):
 | |
|     with open(file_name, "w") as f:
 | |
|         f.write(json.dumps(data, indent=4))
 | |
| 
 | |
| 
 | |
| def main():
 | |
|     print("Starting...")
 | |
|     open_api = OpenAPIParser(app)
 | |
|     modules = open_api.get_by_module()
 | |
| 
 | |
|     mods = []
 | |
| 
 | |
|     for mod, value in modules.items():
 | |
| 
 | |
|         routes = []
 | |
|         existings = set()
 | |
|         # Reduce routes by unique py_route attribute
 | |
|         for route in value:
 | |
|             if route.py_route not in existings:
 | |
|                 existings.add(route.py_route)
 | |
|                 routes.append(route)
 | |
| 
 | |
|         module = {"name": mod, "routes": routes}
 | |
|         mods.append(module)
 | |
| 
 | |
|     render_python_template(CodeTemplates.pytest_routes, CodeDest.pytest_routes, {"mods": mods})
 | |
| 
 | |
|     print("Finished...")
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     main()
 |