dify/api/controllers/service_api/index.py
Stephen Zhou 92016aa139
fix(api): align Service API OpenAPI contract (#41248)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-25 10:54:14 +00:00

29 lines
926 B
Python

from flask_restx import Resource
from configs import dify_config
from controllers.common.schema import register_response_schema_models
from controllers.service_api import service_api_ns
from fields.base import ResponseModel
class IndexInfoResponse(ResponseModel):
welcome: str
api_version: str
server_version: str
register_response_schema_models(service_api_ns, IndexInfoResponse)
@service_api_ns.route("/", endpoint="root")
class IndexApi(Resource):
@service_api_ns.doc("get_index_api", security=[])
@service_api_ns.response(200, "Success", service_api_ns.models[IndexInfoResponse.__name__])
def get(self) -> dict[str, str]:
"""Return public Service API metadata without requiring an API key."""
return IndexInfoResponse(
welcome="Dify OpenAPI",
api_version="v1",
server_version=dify_config.project.version,
).model_dump(mode="json")