run/results: align API v2 OpenAPI schemas with run/result responses#337
run/results: align API v2 OpenAPI schemas with run/result responses#337ol-zayatsm wants to merge 4 commits into
Conversation
ec7f2f9 to
ed20ef7
Compare
| response=RunListItemSerializer(many=True), | ||
| description='Runs were successfully retrieved', | ||
| ), | ||
| 404: OpenApiResponse( |
There was a problem hiding this comment.
This 404 doesn't actually happen for list. RunViewSet.list() just paginates get_queryset() and returns 200 with an empty results array when no runs match the filters — there's no code path here that raises a not-found error. Please drop this 404 response.
| response=RunStatsResponseSerializer, | ||
| description='Run statistics were successfully retrieved', | ||
| ), | ||
| 404: OpenApiResponse( |
There was a problem hiding this comment.
This 404 doesn't match actual behavior: GET /run/{id}/stats/ returns 500 instead, because stats() calls TestIterationResult.objects.get(id=pk) directly instead of going through RunService.get_run(). Please fix the lookup to use RunService.get_run() so it returns 404 as documented.
| response=ResultArtifactsAndVerdictsResponseSerializer, | ||
| description='Artifacts and verdicts were successfully retrieved', | ||
| ), | ||
| 404: OpenApiResponse( |
There was a problem hiding this comment.
This 404 doesn't match actual behavior: GET /result/{id}/artifacts_and_verdicts/ returns 200 with empty lists instead, because get_result_artifacts_and_verdicts() never checks whether the result exists. Please add a ResultService.get_result(result_id) call so it returns 404 as documented.
| class ResultViewSet(ModelViewSet): | ||
| serializer_class = TestIterationResultSerializer | ||
| filter_backends: ClassVar[list] = [] | ||
| pagination_class = None |
There was a problem hiding this comment.
Since this commit removed pagination_class from ResultViewSet, drf-spectacular's list action auto-wraps the response in an array (_is_list_view() defaults to True for any ViewSet's list action without a paginator), so the generated schema shows an array of ResultListResponseSerializer instead of the actual single object {"results": [...]}. @extend_schema_serializer(many=False) on ResultListResponseSerializer should fix it without reintroducing pagination.
Use the run lookup path shared by detail endpoints before reading project-specific defaults, so missing run IDs are handled consistently. Signed-off-by: Mikhail Zayats <mikhail.zayats@oktetlabs.ru>
Use the shared result lookup before collecting artifacts and verdicts, so missing result IDs are handled consistently by detail endpoints. Signed-off-by: Mikhail Zayats <mikhail.zayats@oktetlabs.ru>
Ensure consistency between OpenAPI schemas and API responses by introducing explicit request/response serializers and binding them via drf-spectacular. Signed-off-by: Mikhail Zayats <mikhail.zayats@oktetlabs.ru>
Ensure consistency between OpenAPI schemas and API responses by introducing explicit request/response serializers and binding them via drf-spectacular. Signed-off-by: Mikhail Zayats <mikhail.zayats@oktetlabs.ru>
ed20ef7 to
f31329e
Compare
Description
Summary
Update API v2 OpenAPI schema definitions so run and result endpoint
documentation matches the current response payloads.
Changes
default_columns.source, status, details, and NOK distribution responses.