-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
27 lines (21 loc) · 811 Bytes
/
Copy pathgenerator.py
File metadata and controls
27 lines (21 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Legacy compatibility shim.
Use `openapi_python.generator.generate_client` for new code.
"""
from pathlib import Path
from typing import Any
from openapi_python.generator import GenerationRequest, generate_client
def generate_from_dict(spec: dict[str, Any], out_dir: Path, package_name: str) -> None:
"""Generate a client package from an in-memory OpenAPI document."""
import json
import tempfile
with tempfile.TemporaryDirectory() as tmp:
spec_path = Path(tmp) / "openapi.json"
spec_path.write_text(json.dumps(spec), encoding="utf-8")
generate_client(
GenerationRequest(
spec_source=str(spec_path),
output_dir=out_dir,
package_name=package_name,
overwrite=True,
)
)