Add media client and models for eBay media API; implement image and video handling methods
This commit is contained in:
parent
e99937cc43
commit
1307d5691a
9 changed files with 615 additions and 1 deletions
|
|
@ -20,6 +20,11 @@ class ApiSpec:
|
|||
|
||||
|
||||
API_SPECS = {
|
||||
"media": ApiSpec(
|
||||
name="media",
|
||||
spec_path=ROOT / "commerce_media_v1_beta_oas3.yaml",
|
||||
output_path=GENERATED_ROOT / "media",
|
||||
),
|
||||
"notification": ApiSpec(
|
||||
name="notification",
|
||||
spec_path=ROOT / "commerce_notification_v1_oas3.yaml",
|
||||
|
|
@ -90,12 +95,24 @@ def run_generation(spec: ApiSpec, *, fail_on_warning: bool) -> None:
|
|||
command.append("--disable-warnings")
|
||||
|
||||
subprocess.run(command, check=True, cwd=str(ROOT))
|
||||
normalize_generated_module(spec.output_path / "models.py")
|
||||
(spec.output_path / "__init__.py").write_text(
|
||||
'"""Generated Pydantic models from the OpenAPI contract."""\n\nfrom .models import *\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
def normalize_generated_module(file_path: Path) -> None:
|
||||
raw_bytes = file_path.read_bytes()
|
||||
try:
|
||||
content = raw_bytes.decode("utf-8")
|
||||
except UnicodeDecodeError:
|
||||
content = raw_bytes.decode("cp1252")
|
||||
|
||||
content = content.replace("\u00a0", " ")
|
||||
file_path.write_text(content, encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = parse_args()
|
||||
specs = [API_SPECS[args.api]] if args.api else [API_SPECS[name] for name in sorted(API_SPECS)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue