Skip to content

fix(API): Declare list responses as arrays in the OpenAPI schema - #9225

Open
anishmehta24 wants to merge 1 commit into
Flagsmith:mainfrom
anishmehta24:fix/openapi-list-responses
Open

anishmehta24 wants to merge 1 commit into
Flagsmith:mainfrom
anishmehta24:fix/openapi-list-responses

Conversation

@anishmehta24

Copy link
Copy Markdown

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature. (Not needed: responses are unchanged.)
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #7679 (point 2).

These endpoints return a JSON array, but the OpenAPI schema declared a single object, so the MCP tools built from it carry the wrong output schema:

  • list_projects_in_organization: declared OrganisationSerializerFull, returns a list of ProjectList
  • list_project_environments: declared ProjectList, returns a list of EnvironmentSerializerLight
  • get_feature_code_references: returns a list of FeatureFlagCodeReferencesRepositorySummary
  • get_feature_evaluation_data: returns a list of FeatureEvaluationData

Each one now declares its serializer with many=True. pagination_class=None stops drf-spectacular from wrapping the array in a paginated envelope, since none of these views paginate. API responses don't change.

openapi.yaml and mcp/src/flagsmith_mcp/openapi.json are updated to match. make generate-full-openapi needs the private packages, so I diffed manage.py spectacular output before and after the change (only these four responses differ), applied that to openapi.yaml, then ran make generate-mcp-openapi. Worth re-running make generate-docs-private on your side to confirm there's no drift.

How did you test this code?

  • Added test_api_documentation_specification__endpoint_returns_a_list__documents_array_response to tests/integration/test_api_documentation.py. It fails on main for all four endpoints and passes with the change.
  • pytest tests/integration/test_api_documentation.py tests/unit/api tests/unit/projects tests/unit/organisations/test_unit_organisations_views.py tests/unit/features/test_unit_features_views.py passes (Linux, Postgres 16).
  • MCP make test and mypy pass with the regenerated openapi.json.
  • ruff check, ruff format --check and mypy on the changed Python files are clean.

list_projects_in_organization, list_project_environments,
get_feature_code_references and get_feature_evaluation_data return a
JSON array, but the schema declared a single object.
@anishmehta24
anishmehta24 requested review from a team as code owners December 3, 2026 03:26
@anishmehta24
anishmehta24 requested review from khvn26 and removed request for a team December 3, 2026 03:26
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

@anishmehta24 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval skipped because this PR is from an external contributor.

Re-trigger cubic

This branch has not been deployed

No deployments
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.

1 participant