API: OpenAPI schema does not match live responses (breaks strict output validation)

Đang mở
#7,679 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
openapi, python

Hướng nghiên cứu

Bắt đầu với /api/v1/swagger.json đã được công bố và so sánh các schema của những endpoint phân trang, trả về mảng, tài nguyên bên ngoài của feature, owners và group_owners được liệt kê với các phản hồi thực tế tương ứng. Sử dụng quy trình crawl read-endpoint được gắn thẻ MCP và xác thực đầu ra FastMCP from_openapi làm đường dẫn kiểm tra; hoàn tất khi các schema đã khai báo xác thực được những phản hồi đó để có thể bật lại validate_output.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The published OpenAPI schema (/api/v1/swagger.json) disagrees with actual API responses in several systematic ways. Any client that validates responses against the schema (e.g. the Flagsmith MCP server, which uses FastMCP's from_openapi output validation) fails on most endpoints. Found by crawling the MCP-tagged read endpoints against SaaS and validating each response against its declared schema.

1. Pagination next/previous typed string, returned null

Paginated responses declare next and previous as non-nullable string, but the API returns null when there is no adjacent page. Should be string, nullable (anyOf: [string, "null"]).

Affected: list_organizations, list_organization_groups, list_organization_invites, list_organization_roles, list_environments, list_project_features, list_project_segments, list_project_change_requests, list_feature_multivariate_options, list_feature_segments, get_environment_feature_versions (likely all paginated list endpoints).

2. Array-returning endpoints declared as a single object

The 200 response schema is the singular item serializer, but the endpoint returns a JSON array. Should be type: array, items: <object>.

  • GET /organisations/{id}/projects/ (list_projects_in_organization)
  • GET /projects/{id}/environments/ (list_project_environments)
  • GET /projects/{project_pk}/features/{feature_pk}/code-references/
  • GET /projects/{project_pk}/features/{id}/evaluation-data/
3. get_feature_external_resources: missing count

GET …/feature-external-resources/ returns {"results": []} but the schema marks count as required. Either the response should include the full pagination envelope or the schema should not require count.

4. owners / group_owners typed as integer IDs but expanded in responses

Read responses expand these to nested user objects ({id,email,first_name,last_name,last_login,uuid}), while the schema types them as array<integer>. Affects get_feature_flag and list_project_features (results[].owners[]); likely anywhere a feature is serialised for read.

Impact / workaround

The MCP server currently sets validate_output=False to avoid rejecting valid responses. We'd like to re-enable output validation once the schema matches reality.

Ngôn ngữ chính
Python
Star
9.9k
Fork
658
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
168

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Flagsmith/flagsmith

Tất cả issue của Flagsmith/flagsmith

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.