mirror of
https://github.com/langgenius/dify.git
synced 2026-05-22 01:48:39 +08:00
Four per-app GETs (/apps/<id>, /info, /parameters, /describe) repeated the same SSO-guard / app-load / membership-check pattern. Hoist into _AppReadResource with method_decorators=[require_scope, validate_bearer] plus _load(app_id) -> (App, AuthContext). Subclasses now 3-line bodies. Eliminates the per-method # type: ignore[reportUntypedFunctionDecorator] suppression by relocating the decorator chain to the class attribute. Endpoints now build typed AppInfoResponse / AppDescribeResponse and .model_dump() at the boundary.
14 lines
475 B
Python
14 lines
475 B
Python
"""GET /openapi/v1/apps/<app_id>/info — port of service_api/app/app.py:AppInfoApi."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from controllers.openapi import openapi_ns
|
|
from controllers.openapi.apps import _AppReadResource, app_info_payload # pyright: ignore[reportPrivateUsage]
|
|
|
|
|
|
@openapi_ns.route("/apps/<string:app_id>/info")
|
|
class AppInfoApi(_AppReadResource):
|
|
def get(self, app_id: str):
|
|
app, _ = self._load(app_id)
|
|
return app_info_payload(app), 200
|