[PR #31979] refactor: migrate feature.py from Flask-RESTX to FastOpenAPI #33494

Open
opened 2026-02-21 20:53:23 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31979

State: open
Merged: No


Summary

Part of #31456.

  • Converted /features and /system-features endpoints from class-based Flask-RESTX resources to function-based FastOpenAPI routes
  • Uses FeatureModel and SystemFeatureModel from feature_service as Pydantic response models directly, removing the need for manual .model_dump() calls and fields.Raw definitions
  • Registered the feature module in ext_fastopenapi.py so routes are picked up by the FastOpenAPI router
  • Added unit tests for /system-features covering both the normal path and the Unauthorized fallback when no auth token is present
  • Preserved the existing authentication decorators and the NOTE(QuantumGhost) comment explaining the try-catch pattern

Test plan

  • pytest api/tests/unit_tests/controllers/console/test_fastopenapi_feature.py passes
  • Existing /features and /system-features behavior unchanged (same JSON response shape)
  • OpenAPI schema at /fastopenapi/openapi.json includes the two new endpoints
**Original Pull Request:** https://github.com/langgenius/dify/pull/31979 **State:** open **Merged:** No --- ## Summary Part of #31456. - Converted `/features` and `/system-features` endpoints from class-based Flask-RESTX resources to function-based FastOpenAPI routes - Uses `FeatureModel` and `SystemFeatureModel` from `feature_service` as Pydantic response models directly, removing the need for manual `.model_dump()` calls and `fields.Raw` definitions - Registered the feature module in `ext_fastopenapi.py` so routes are picked up by the FastOpenAPI router - Added unit tests for `/system-features` covering both the normal path and the `Unauthorized` fallback when no auth token is present - Preserved the existing authentication decorators and the `NOTE(QuantumGhost)` comment explaining the try-catch pattern ## Test plan - [ ] `pytest api/tests/unit_tests/controllers/console/test_fastopenapi_feature.py` passes - [ ] Existing `/features` and `/system-features` behavior unchanged (same JSON response shape) - [ ] OpenAPI schema at `/fastopenapi/openapi.json` includes the two new endpoints
yindo added the pull-request label 2026-02-21 20:53:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33494