mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-07 05:22:18 -07:00
fix: sync locales in user registration validation (#3278)
* Add ability to inject into Python files * Update outdated references to gen_global_components.py * Add code gen for registration locale validation * sort validators * update for pydantic 2 * run generator again --------- Co-authored-by: Gasper Gril <gasper@gril.si> Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
parent
02da2114f9
commit
b54cdf6425
8 changed files with 108 additions and 88 deletions
|
@ -3,8 +3,8 @@ from pathlib import Path
|
|||
|
||||
from fastapi import FastAPI
|
||||
from jinja2 import Template
|
||||
from pydantic import BaseModel
|
||||
from utils import PROJECT_DIR, CodeTemplates, HTTPRequest, RouteObject
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from utils import PROJECT_DIR, CodeTemplates, HTTPRequest, RouteObject, RequestType
|
||||
|
||||
CWD = Path(__file__).parent
|
||||
|
||||
|
@ -12,23 +12,25 @@ OUTFILE = PROJECT_DIR / "tests" / "utils" / "api_routes" / "__init__.py"
|
|||
|
||||
|
||||
class PathObject(BaseModel):
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
route_object: RouteObject
|
||||
http_verbs: list[HTTPRequest]
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
|
||||
def get_path_objects(app: FastAPI):
|
||||
paths = []
|
||||
|
||||
for key, value in app.openapi().items():
|
||||
if key == "paths":
|
||||
for key, value in value.items():
|
||||
for key, value2 in value.items():
|
||||
verbs = []
|
||||
for k, v in value2.items():
|
||||
verbs.append(HTTPRequest(request_type=k, **v))
|
||||
|
||||
paths.append(
|
||||
PathObject(
|
||||
route_object=RouteObject(key),
|
||||
http_verbs=[HTTPRequest(request_type=k, **v) for k, v in value.items()],
|
||||
http_verbs=verbs,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue