Skip to content

run/results: align API v2 OpenAPI schemas with run/result responses#337

Open
ol-zayatsm wants to merge 4 commits into
ts-factory:mainfrom
ol-zayatsm:run_openapi_schemas_split
Open

run/results: align API v2 OpenAPI schemas with run/result responses#337
ol-zayatsm wants to merge 4 commits into
ts-factory:mainfrom
ol-zayatsm:run_openapi_schemas_split

Conversation

@ol-zayatsm

Copy link
Copy Markdown
Contributor

Description

Summary

Update API v2 OpenAPI schema definitions so run and result endpoint
documentation matches the current response payloads.

Changes

  • Add and update run endpoint request/response serializers.
  • Document run stats responses, including default_columns.
  • Document run charts, comments, compromised status, requirements,
    source, status, details, and NOK distribution responses.
  • Add and update result endpoint response schemas.
  • Keep OpenAPI definitions aligned with DTO-backed service responses.

@ol-zayatsm ol-zayatsm force-pushed the run_openapi_schemas_split branch 2 times, most recently from ec7f2f9 to ed20ef7 Compare June 29, 2026 06:28
Comment thread bublik/interfaces/api_v2/run/schemas.py Outdated
response=RunListItemSerializer(many=True),
description='Runs were successfully retrieved',
),
404: OpenApiResponse(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

response=RunStatsResponseSerializer,
description='Run statistics were successfully retrieved',
),
404: OpenApiResponse(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

response=ResultArtifactsAndVerdictsResponseSerializer,
description='Artifacts and verdicts were successfully retrieved',
),
404: OpenApiResponse(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

class ResultViewSet(ModelViewSet):
serializer_class = TestIterationResultSerializer
filter_backends: ClassVar[list] = []
pagination_class = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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>
@ol-zayatsm ol-zayatsm force-pushed the run_openapi_schemas_split branch from ed20ef7 to f31329e Compare July 1, 2026 14:29
@ol-nata ol-nata self-requested a review July 3, 2026 18:28
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