Skip to content

fix: Fix Swagger document image upload #3182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025
Merged

Conversation

shaohuzhang1
Copy link
Contributor

fix: Fix Swagger document image upload

Copy link

f2c-ci-robot bot commented Jun 4, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

f2c-ci-robot bot commented Jun 4, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

class UploadedImageField(serializers.ImageField):
def __init__(self, **kwargs):
super().__init__(**kwargs)

def to_representation(self, value):
return value


class UploadedFileField(serializers.FileField):
def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code contains several minor improvements, such as adding docstrings for methods and using proper type annotation with typing. It also imports extends_schema_field from drf_spectacular, which is useful for generating API documentation.

Here are some general comments:

  1. Imports: Ensure that all necessary modules and types are imported at the beginning of the file. The current import statement seems fine.

  2. Type Annotations: While type annotations are beneficial (e.g., def to_representation(self, value): -> Any), they do not significantly enhance readability unless used consistently throughout the application.

  3. Comments: Add detailed comments if additional explanation or context is needed. However, since the description is already provided in a docstring, simple docstrings might be sufficient.

  4. API Documentation: Although you haven't directly specified how these changes affect API documentation generation, extending schematics should help in creating more informative schemas if integrated into an openapi-generator setup.

Overall, maintaining clean code and clear structure while ensuring type hints can improve its maintainability and readiness for larger projects.

@zhanweizhang7 zhanweizhang7 merged commit 596dbed into v2 Jun 4, 2025
3 of 5 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_swagger_image branch June 4, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants