Skip to content

Instantly share code, notes, and snippets.

@jamessa
Last active March 3, 2025 23:45
Show Gist options
  • Select an option

  • Save jamessa/00792b95f0293c77d274b48a719d31c5 to your computer and use it in GitHub Desktop.

Select an option

Save jamessa/00792b95f0293c77d274b48a719d31c5 to your computer and use it in GitHub Desktop.

上傳 null.jpg 的回應為例

Schema 用來定義 JSON 內容

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "retcode": {"type": "integer", "description": "返回碼,0 表示成功,其他數值可能表示錯誤"},
        "msg": {"type": "string", "description": "訊息內容,通常用於錯誤或狀態描述"},
        "data": {
            "type": "object",
            "properties": {
                "files": {
                    "type": "array",
                    "items": {"type": "string", "format": "uri", "description": "文件的 URL(可能經過 URL 編碼)"},
                    "description": "包含文件 URL 的列表"
                }
            },
            "required": ["files"],
            "description": "回應的數據內容"
        },
        "errors": {
            "type": "array",
            "items": {"type": "string", "description": "錯誤訊息(若有)"},
            "description": "錯誤訊息列表"
        }
    },
    "required": ["retcode", "msg", "data"]
}

範例資料

{
	"retcode": 0,
	"msg": "",
	"data": {
		"files": [
			"https://taiwan.alcolog.io/s/pgdh07jnuty_109/Frecords/202503/6928_2025-03-03-19-26-41_edge10822_35709_.log"
		]
	},
	"errors": []
}

Demo

https://www.jsonschemavalidator.net/s/RPQ3AxWT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment