Exemplo n.º 1
0
        /// <summary>
        /// 获取Json请求样例字符串
        /// </summary>
        /// <returns></returns>
        public string GetRequestSampleJsonString()
        {
            // wandelfor:有的方法参数列表为空
            if (!ApiDescription.ParameterDescriptions.Any())
            {
                return(string.Empty);
            }
            var sampleObject = ApiDocumentManager.GetSampleObject(ApiDescription.ParameterDescriptions[0].ParameterDescriptor.ParameterType, true);

            if (sampleObject != null)
            {
                return(Newtonsoft.Json.JsonConvert.SerializeObject(sampleObject, Newtonsoft.Json.Formatting.Indented));
            }
            return(string.Empty);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取Json响应结果样例字符串
        /// </summary>
        /// <returns></returns>
        public string GetResponseSampleJsonString()
        {
            var sampleObject = ApiDocumentManager.GetSampleObject(_mReturnType);

            return(Newtonsoft.Json.JsonConvert.SerializeObject(sampleObject, Newtonsoft.Json.Formatting.Indented));
        }