Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Jan 5, 2024
1 parent 3d0a72e commit 2a4333f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ private function _requestToApi($method, $url, $request, $json_array)
$content_array['request']['params']['mode'] = 'json';
$content_array['request']['params']['json'] = $json_str;
$content_array['request']['params']['jsonDesc'] = $json_array;
}
// 如果in字段是header的话,则说明该参数是放在header里面的
if ($value["in"] == 'header') {
$content_array['request']['headers'][] = array(
"name" => $value["name"],
"type" => 'string',
"value" => $value["example"] ? $value["example"] : '',
"require" => (!$value["required"]) ? "0" : '1',
"remark" => $value["description"],
);
} else {
$content_array['request']['params']['formdata'][] = array(
"name" => $value["name"],
Expand All @@ -222,6 +232,34 @@ private function _requestToApi($method, $url, $request, $json_array)
}
}

// 把请求参数写进requestBody的情况
if ($request['requestBody']['content']) {
// 参数为 form-data 的场景
if ($request['requestBody']['content']['application/json']) {
$properties_tmp = $request['requestBody']['content']['application/json']['schema']['properties'];
$re_json = [];
foreach ($properties_tmp as $key => $value) {
$re_json[$key] = '';
}
$content_array['request']['params']['mode'] = 'json';
$content_array['request']['params']['json'] = json_encode($re_json);
}
// 参数为 form-data 的场景
if ($request['requestBody']['content']["multipart/form-data"]) {
$content_array['request']['params']['mode'] = 'formdata';
$properties_tmp = $request['requestBody']['content']['multipart/form-data']['schema']['properties'];
foreach ($properties_tmp as $key => $value) {
$content_array['request']['params']['formdata'][] = array(
"name" => $key,
"type" => $value["type"],
"value" => $value["example"] ? $value["example"] : '',
"require" => (!$value["required"]) ? "0" : '1',
"remark" => $value["description"] ? $value["description"] : '',
);
}
}
}

//处理返回结果情况
if ($request['responses'] && $request['responses']['200']) {
$ref_array = array();
Expand Down
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
'../server/index.php?s=',
// "lang" :'en'
lang: 'zh-cn'
}</script><link href=./static/css/app.a79b72a3d4206013dd25f8cff9ad1d90.css rel=stylesheet></head><body class=grey-bg><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.339f5a1f86786a88b9d4.js></script><script type=text/javascript src=./static/js/app.57a5542c88fd0f6f6949.js></script></body></html>
}</script><link href=./static/css/app.74e873b9239931a6e17cf1f328f8408f.css rel=stylesheet></head><body class=grey-bg><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.339f5a1f86786a88b9d4.js></script><script type=text/javascript src=./static/js/app.d6a1649553531ec72eaf.js></script></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion web_src/src/components/item/import/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:onCancel="callback"
:title="$t('import')"
width="400px"
:onOK="onSubmit"
:showOk="false"
>
<div>
<div class="ml-6">
Expand Down Expand Up @@ -65,9 +65,11 @@ export default {
methods: {
uploadCallback(data) {
if (this.importToItemId > 0) {
window.location.reload()
} else {
this.$router.push({ path: '/item/index' })
window.location.reload()
}
}
},
Expand Down

0 comments on commit 2a4333f

Please sign in to comment.