{
    "$id": "https://xwcloudapi.weixin.qq.com/schemas/2021-09/network.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "network",
    "description":"小微对外提供网络相关接口请求基本格式",
    "type":"object",
    "properties":{
        "websocket_req": {
            "type": "object",
            "properties":{
                "cmd":{
                    "description":"预留填0",
                    "const": 0
                },
                "product":{
                    "description":"填写6201",
                    "const": 6201
                },
                "seq":{
                    "description":"非ASR请求填0，具体参见ASR的文档",
                    "type": "integer"
                },
                "http":{
                    "type":"object",
                    "properties":{
                        "method": {
                            "const":"post"
                        },
                        "path":{
                            "description":"请求路径，不同的请求路径代表不同的接口",
                            "type":"string"
                        },
                        "query":{
                            "description":"请求参数，对应http请求？x=y&z=u  部分",
                            "type":"string"
                        },
                        "header":{
                            "type":"object",
                            "description":"使用的微信基础库要求字段，主要字段名称是大写",
                            "properties":{
                                "Host":{
                                    "type":"string",
                                    "const":"xwcloudapi.weixin.qq.com"
                                },
                                "Session":{
                                    "description":"首次请求可以为空，然后使用返回的token, 后续所有的请求必须填写",
                                    "type":"string"
                                },
                                "RequestID":{
                                    "$ref":"https://xwcloudapi.weixin.qq.com/schemas/2021-09/common_schema.json#/properties/query_id"
                                }
                            },
                            "required":["Host", "Session", "RequestID"]
                        }
                    },
                    "required":["method", "path", "header"]
                },
                "content":{
                    "description":"具体请求内容",
                    "type": "string",
                    "format":"uri"
                }
            },
            "required":["cmd", "product", "seq", "http","content"]
        },
        "websocket_resp" :{
            "type": "object",
            "properties":{
                "cmd": {
                    "description":"推送结果类型,参见cmd介绍",
                    "type":"integer"
                },
                "seq": {
                    "description": "非ASR请求结果可以忽略，ASR请求代表语音包序号结果",
                    "type":"integer"
                },
                "encoding": {
                    "description": "可以完全忽略",
                    "type":"string"
                },
                "scene":{
                    "description": "可以完全忽略",
                    "type":"string"
                },
                "content":{
                    "description": "具体请求结果，内容为base64 encode过的，需要先base64 decode",
                    "type":"string"
                }
            },
            "required":["cmd", "seq","content"]
        },
        "authdevice_req" : {
            "description": "申请设备认证的请求体，主要分为两种，单secret 或者，pid(optional)+appuin+sn+licnese ",
            "type": "object",
            "properties":{
                "sceret": {
                    "type":"string"
                },
                "pid": {
                    "type":"integer"
                },
                "appuin":{
                    "type":"integer"
                },
                "license":{
                    "type":"string"
                },
                "sn":{
                    "type":"string"
                }
            },
            "anyof":[
                {
                    "required":["sceret"]
                },
                {
                    "required":["pid", "appuin", "licenese", "sn"]
                }
            ]
        },
        "authdevice_resp": {
            "type": "object",
            "description": "",
            "properties":{
                "code": {
                    "description": "心跳返回状态 0 代表成功，非0 失败,这时不包含token和expire_time字段",
                    "type":"integer"
                },
                "msg": {
                    "description": "失败原因结果简单描述",
                    "type":"string"
                },
                "token":{
                    "description": "失败原因结果简单描述",
                    "type":"string"
                },
                "expire_time":{
                    "description": "token过期时间，单位秒",
                    "type":"integer"
                }
            },
            "required":["code", "msg"]
        },
        "heartbeat_req":{
            "description": "",
            "type": "object",
            "properties":{
                "mstimestamp": {
                    "description": "当时请求的linux时间戳 * 1000",
                    "type":"integer"
                }
            },
            "required":["mstimestamp"]
        },
        "heartbeat_resp":{
            "description": "",
            "type": "object",
            "properties":{
                "code": {
                    "description": "心跳返回状态 0 代表成功，非0 失败",
                    "type":"integer"
                },
                "msg": {
                    "description": "结果简单描述",
                    "type":"string"
                },
                "interval":{
                    "description": "下次心跳间隔的秒数",
                    "type":"integer"
                }
            },
            "required":["code", "msg", "interval"]
        }
    }
}
