Skip to content

Conversation

@HadyBazzi
Copy link
Contributor

Problem

The Swagger-generated code looks like this due to OpenAPI contracts from eBay:

# Generated code has:
all_params = ['content_type']  # Missing 'files' parameter
local_var_files = {}  # Always empty, no file handling

This causes an issue as is pointed out in #60 (solved by this patch)

Solution

The patch modifies the generate_code.py script to automatically fix file upload methods after Swagger code generation.

What the Patch Does

  1. Adds 'files' to allowed parameters: Modifies all_params list to include 'files'
  2. Enables file handling: Populates local_var_files with actual file data

Affected Methods

The patch targets these file upload methods:

  • create_image_from_file (Media API)
  • upload_file (Feed API)
  • create_video (Media API)
  • upload_video (Media API)

Usage

After the patch is applied, you can use file upload methods like this:

# Upload an image file
result = api.commerce_media_create_image_from_file(
    content_type="multipart/form-data",
    files={"image": "path/to/your/image.jpg"}  # ✅ Now works!
)

and

# Upload a feed file
result = api.sell_feed_upload_file(
    task_id="your-task-id",
    content_type="multipart/form-data",
    files={"file": "path/to/your/feed.xml"}  # ✅ Now works!
)

Remaining Issue: Unit Tests

I could not get the unit tests properly implemented in time but from my manual testing, these patches work perfectly!


Thanks,
Hady

@matecsaj matecsaj merged commit 983052d into matecsaj:main Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants