Skip to content

chore: fix API docs warnings#2269

Merged
nicomiguelino merged 1 commit intoScreenly:masterfrom
nicomiguelino:resolve-api-docs-warnings
Apr 17, 2025
Merged

chore: fix API docs warnings#2269
nicomiguelino merged 1 commit intoScreenly:masterfrom
nicomiguelino:resolve-api-docs-warnings

Conversation

@nicomiguelino
Copy link
Contributor

Issues Fixed

Given that I'm starting Anthias in development mode, I'm getting the following output when I access http://localhost:8000/api/docs/ from my browser:

anthias-server-1  | 2025-04-17T20:41:04.204481706Z [17/Apr/2025 20:41:04] "GET /api/docs/ HTTP/1.0" 200 727
anthias-server-1  | 2025-04-17T20:41:04.255157863Z /usr/src/app/api/serializers/v2.py: Warning [AssetListViewV2 > AssetSerializerV2]: unable to resolve type hint for function "is_active". Consider using a type hint or @extend_schema_field. Defaulting to string.
anthias-server-1  | 2025-04-17T20:41:04.259849129Z /usr/src/app/api/views/v2.py: Error [PlaylistOrderViewV2]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
anthias-server-1  | 2025-04-17T20:41:04.260066282Z /usr/src/app/api/views/v2.py: Error [BackupViewV2]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
anthias-server-1  | 2025-04-17T20:41:04.261682795Z /usr/src/app/api/views/v2.py: Error [RebootViewV2]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
anthias-server-1  | 2025-04-17T20:41:04.262123007Z /usr/src/app/api/views/v2.py: Error [ShutdownViewV2]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.
anthias-server-1  | 2025-04-17T20:41:04.275034013Z [17/Apr/2025 20:41:04] "GET /api/schema/ HTTP/1.0" 200 13873

Description

Provide a brief description of the changes that you have made.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

@sonarqubecloud
Copy link

@nicomiguelino nicomiguelino marked this pull request as ready for review April 17, 2025 20:48
@nicomiguelino nicomiguelino requested a review from a team as a code owner April 17, 2025 20:48
@nicomiguelino nicomiguelino requested a review from Copilot April 17, 2025 20:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses API docs warnings by updating the serializer usage in API view mixins and enhancing type hints for API serializers. Key changes include:

  • Importing and using serializer mixins (BackupViewSerializerMixin, PlaylistOrderSerializerMixin, etc.) in API views.
  • Introducing a SerializerMethodField with an extend_schema_field decorator for the is_active field in AssetSerializerV2.
  • Refactoring PlaylistOrderViewMixin’s request schema to use a dedicated serializer mixin.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
api/views/mixins.py Updated mixins to use serializer mixins for backup, reboot, shutdown, and playlist order views.
api/serializers/v2.py Added a SerializerMethodField and extend_schema_field on is_active.
api/serializers/mixins.py Defined serializer mixins for playlist order, backup, reboot, and shutdown views.
Comments suppressed due to low confidence (2)

api/views/mixins.py:59

  • Consider using a consistent approach for serializer injection across view mixins. For example, using the serializer_class attribute (as in RebootViewMixin and ShutdownViewMixin) instead of passing the serializer mixin via the extend_schema's request parameter could improve clarity.
request=BackupViewSerializerMixin,

api/views/mixins.py:250

  • Consider matching the serializer injection pattern used in other view mixins (e.g., using serializer_class) for consistency across your API views.
request=PlaylistOrderSerializerMixin,

@nicomiguelino nicomiguelino merged commit 16ca60e into Screenly:master Apr 17, 2025
8 checks passed
@nicomiguelino nicomiguelino deleted the resolve-api-docs-warnings branch April 18, 2025 02:49
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