Skip to content

Conversation

@pheus
Copy link
Contributor

@pheus pheus commented Sep 21, 2025

Fixes: #20365

  • Implement get_internal_type() on custom fields for Django introspection.
  • Annotate id/name path params and add explicit operation_ids for queues/workers/tasks
  • Provide get_serializer_class() and get_serializer_context() on the RQ base viewset

@pheus pheus marked this pull request as ready for review September 22, 2025 19:57
@jnovinger jnovinger requested review from a team, bctiemann and jeremystretch and removed request for a team and jeremystretch September 23, 2025 11:52
@jeremystretch jeremystretch requested review from jeremystretch and removed request for bctiemann September 29, 2025 17:41


class BaseRQViewSet(viewsets.ViewSet):
class BaseRQViewSet(viewsets.GenericViewSet):
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it makes sense to employ GenericViewSet here as it adds methods such as get_queryset() which aren't applicable, as the view doesn't use a model. Could we instead just add declare a get_serializer_class() method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the thoughtful review!

You’re absolutely right.
My initial pass was to add get_serializer_class(), but the custom get_serializer() also expects get_serializer_context(). To avoid re‑implementing both, I tried GenericViewSet as a shortcut, though I agree it broadens the API surface unnecessarily.

I’ll revert the base class to viewsets.ViewSet and add minimal helpers for the serializer class/context locally.
Thanks again for the guidance!

@extend_schema(responses={200: OpenApiTypes.OBJECT})
@extend_schema(
operation_id='core_background_tasks_retrieve_by_id',
parameters=[OpenApiParameter(name='pk', type=OpenApiTypes.STR, location=OpenApiParameter.PATH)],
Copy link
Member

Choose a reason for hiding this comment

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

Is this redundant to line 192 above? (Also, here we call the parameter pk but above it's named id.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that!

You’re right on both points: the second annotation is redundant with line 192, and the parameter name mismatch (pk vs id) is my oversight. I’ll remove the duplicate, and standardize on id across the view methods (and the serializer’s HyperlinkedIdentityField) to match the route kwarg and keep the OpenAPI output consistent.

Appreciate the careful review!

Add `get_internal_type()` to custom field classes for Django compatibility,
annotate path parameters and operation IDs for background endpoints, and
provide serializer context on the RQ base viewset to clear schema warnings.

Fixes netbox-community#20365
@pheus pheus force-pushed the 20365-fix-openapi-schema-generation-warnings-and-errors branch from ae274a8 to ff29107 Compare September 30, 2025 09:34
@pheus pheus requested a review from jeremystretch September 30, 2025 09:56
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Thanks @pheus!

@jeremystretch jeremystretch merged commit 9e75a2f into netbox-community:main Sep 30, 2025
7 checks passed
@pheus pheus deleted the 20365-fix-openapi-schema-generation-warnings-and-errors branch September 30, 2025 14:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generating OpenAPI schema triggers multiple warnings and errors

2 participants