* 获取一个测试用例详情 * @interface /col/case * @method GET * @category col * @foldnumber 10 * @param {String} caseid * @returns {Object} * @example
(ctx)
| 619 | */ |
| 620 | |
| 621 | async getCase(ctx) { |
| 622 | try { |
| 623 | let id = ctx.query.caseid; |
| 624 | let result = await this.caseModel.get(id); |
| 625 | if (!result) { |
| 626 | return (ctx.body = yapi.commons.resReturn(null, 400, '不存在的case')); |
| 627 | } |
| 628 | result = result.toObject(); |
| 629 | let data = await this.interfaceModel.get(result.interface_id); |
| 630 | if (!data) { |
| 631 | return (ctx.body = yapi.commons.resReturn(null, 400, '找不到对应的接口,请联系管理员')); |
| 632 | } |
| 633 | data = data.toObject(); |
| 634 | |
| 635 | let projectData = await this.projectModel.getBaseInfo(data.project_id); |
| 636 | result.path = projectData.basepath + data.path; |
| 637 | result.method = data.method; |
| 638 | result.req_body_type = data.req_body_type; |
| 639 | result.req_headers = yapi.commons.handleParamsValue(data.req_headers, result.req_headers); |
| 640 | result.res_body = data.res_body; |
| 641 | result.res_body_type = data.res_body_type; |
| 642 | result.req_body_form = yapi.commons.handleParamsValue( |
| 643 | data.req_body_form, |
| 644 | result.req_body_form |
| 645 | ); |
| 646 | result.req_query = yapi.commons.handleParamsValue(data.req_query, result.req_query); |
| 647 | result.req_params = yapi.commons.handleParamsValue(data.req_params, result.req_params); |
| 648 | result.interface_up_time = data.up_time; |
| 649 | result.req_body_is_json_schema = data.req_body_is_json_schema; |
| 650 | result.res_body_is_json_schema = data.res_body_is_json_schema; |
| 651 | ctx.body = yapi.commons.resReturn(result); |
| 652 | } catch (e) { |
| 653 | ctx.body = yapi.commons.resReturn(null, 400, e.message); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * 更新一个接口集name或描述 |
nothing calls this directly
no test coverage detected