feat: API docs for service api (#24425)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN-
2025-08-25 09:26:54 +08:00
committed by GitHub
parent 846b6bd14e
commit b7466f8b65
31 changed files with 1724 additions and 627 deletions

View File

@@ -1,4 +1,4 @@
from flask_restx import fields
from flask_restx import Api, Namespace, fields
from libs.helper import TimestampField
@@ -11,6 +11,19 @@ upload_config_fields = {
"workflow_file_upload_limit": fields.Integer,
}
def build_upload_config_model(api_or_ns: Api | Namespace):
"""Build the upload config model for the API or Namespace.
Args:
api_or_ns: Flask-RestX Api or Namespace instance
Returns:
The registered model
"""
return api_or_ns.model("UploadConfig", upload_config_fields)
file_fields = {
"id": fields.String,
"name": fields.String,
@@ -22,12 +35,37 @@ file_fields = {
"preview_url": fields.String,
}
def build_file_model(api_or_ns: Api | Namespace):
"""Build the file model for the API or Namespace.
Args:
api_or_ns: Flask-RestX Api or Namespace instance
Returns:
The registered model
"""
return api_or_ns.model("File", file_fields)
remote_file_info_fields = {
"file_type": fields.String(attribute="file_type"),
"file_length": fields.Integer(attribute="file_length"),
}
def build_remote_file_info_model(api_or_ns: Api | Namespace):
"""Build the remote file info model for the API or Namespace.
Args:
api_or_ns: Flask-RestX Api or Namespace instance
Returns:
The registered model
"""
return api_or_ns.model("RemoteFileInfo", remote_file_info_fields)
file_fields_with_signed_url = {
"id": fields.String,
"name": fields.String,
@@ -38,3 +76,15 @@ file_fields_with_signed_url = {
"created_by": fields.String,
"created_at": TimestampField,
}
def build_file_with_signed_url_model(api_or_ns: Api | Namespace):
"""Build the file with signed URL model for the API or Namespace.
Args:
api_or_ns: Flask-RestX Api or Namespace instance
Returns:
The registered model
"""
return api_or_ns.model("FileWithSignedUrl", file_fields_with_signed_url)