mirror of
https://github.com/langgenius/dify.git
synced 2026-06-24 00:07:41 +08:00
Complete the request/response contract unification (GareArc review followup): the remaining handlers that returned a model via manual `.model_dump(mode="json")` now return the bare model behind `@returns`, so every openapi handler references its response model once and doc == runtime. Migrated: version, health, account info/session-revoke (x2), file upload, task stop, human-input form submit, and workspaces list/detail/switch/invite/remove/ role. Handlers returning a bare dict (account info, version, health) now go through `@returns` → `(body, status)`; HTTP behavior is unchanged. Health/task-stop/form-submit now construct their advertised model instead of a hand-built dict.
25 lines
841 B
Python
25 lines
841 B
Python
"""Meta endpoint: `GET /openapi/v1/_version` — no auth.
|
|
|
|
Returns the server's project version and edition so the difyctl CLI can probe
|
|
compatibility without needing to be logged in. Mirrors the `_health` endpoint
|
|
in `index.py`.
|
|
"""
|
|
|
|
from flask_restx import Resource
|
|
|
|
from configs import dify_config
|
|
from controllers.openapi import openapi_ns
|
|
from controllers.openapi._contract import returns
|
|
from controllers.openapi._models import ServerVersionResponse
|
|
|
|
|
|
@openapi_ns.route("/_version")
|
|
class VersionApi(Resource):
|
|
@returns(200, ServerVersionResponse, description="Server version")
|
|
def get(self):
|
|
edition = dify_config.EDITION if dify_config.EDITION in ("SELF_HOSTED", "CLOUD") else "SELF_HOSTED"
|
|
return ServerVersionResponse(
|
|
version=dify_config.project.version,
|
|
edition=edition,
|
|
)
|