diff --git a/api-test/frontend/src/business/definition/components/body/ApiBody.vue b/api-test/frontend/src/business/definition/components/body/ApiBody.vue index 8ea402f390..9f2bd070cc 100644 --- a/api-test/frontend/src/business/definition/components/body/ApiBody.vue +++ b/api-test/frontend/src/business/definition/components/body/ApiBody.vue @@ -246,6 +246,9 @@ export default { this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw)); } else { let data = MsConvert.format(JSON.parse(this.body.raw)); + if (!this.body.jsonSchema.type) { + this.body.jsonSchema.type = data.type; + } this.body.jsonSchema = this.deepAssign(this.body.jsonSchema, data); } } catch (e) { diff --git a/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue b/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue index e990885535..8e892783fb 100644 --- a/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue +++ b/api-test/frontend/src/business/definition/components/document/components/ApiResponseInfo.vue @@ -122,10 +122,10 @@ export default { } catch (e) { return false; } - } else if (jsonType === 'response' && api.requestBodyStructureData) { + } else if (jsonType === 'response' && api.responseBodyStructureData) { try { - JSON.parse(api.requestBodyStructureData); - api.responseJsonSchema = { raw: api.requestBodyStructureData }; + JSON.parse(api.responseBodyStructureData); + api.responseJsonSchema = { raw: api.responseBodyStructureData }; return true; } catch (e) { return false;