This is an automated email from the ASF dual-hosted git repository.
likeguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new f235b826 [ISSUE #293] Api doc view (#294)
f235b826 is described below
commit f235b826e3f67cde26eb2e518cd8c17cd46a3176
Author: VampireAchao <[email protected]>
AuthorDate: Tue Jul 18 10:22:01 2023 +0800
[ISSUE #293] Api doc view (#294)
* add system/resource searcher to search menu with name
* api doc optimize
---
src/locales/en-US.json | 2 ++
src/locales/zh-CN.json | 2 ++
src/routes/Document/components/ApiDebug.js | 39 ++++++++++++++++++++++++++---
src/routes/Document/components/ApiInfo.js | 7 +++---
src/routes/Document/components/SearchApi.js | 5 ++--
5 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 39f93c68..c351c8d9 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -299,6 +299,8 @@
"SHENYU.MENU.DOCUMENT.APIDOC": "API Doc",
"SHENYU.DOCUMENT.APIDOC.SEARCH.PLACEHOLDER":
"Support interface address and document title",
+ "SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_MODULE": "+ Module",
+ "SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_ROOT_MODULE": "+ Application",
"SHENYU.DOCUMENT.APIDOC.INFO.INTERFACE.ADDRESS": "Interface Address",
"SHENYU.DOCUMENT.APIDOC.INFO.DESCRIPTION": "Interface Description",
"SHENYU.DOCUMENT.APIDOC.INFO.ADDRESS": "Request Address",
diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json
index a630056a..29f2e7ce 100644
--- a/src/locales/zh-CN.json
+++ b/src/locales/zh-CN.json
@@ -289,6 +289,8 @@
"SHENYU.MENU.DOCUMENT": "文档说明",
"SHENYU.MENU.DOCUMENT.APIDOC": "API文档",
"SHENYU.DOCUMENT.APIDOC.SEARCH.PLACEHOLDER": "支持接口地址、文档标题",
+ "SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_MODULE": "+ 模块",
+ "SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_ROOT_MODULE": "+ 应用",
"SHENYU.DOCUMENT.APIDOC.INFO.INTERFACE.ADDRESS": "接口地址",
"SHENYU.DOCUMENT.APIDOC.INFO.DESCRIPTION": "接口描述",
"SHENYU.DOCUMENT.APIDOC.INFO.ADDRESS": "请求地址",
diff --git a/src/routes/Document/components/ApiDebug.js
b/src/routes/Document/components/ApiDebug.js
index bec3b219..4d52437a 100644
--- a/src/routes/Document/components/ApiDebug.js
+++ b/src/routes/Document/components/ApiDebug.js
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import {Button, Col, Empty, Form, Icon, Input, message, Row, Tabs, Typography}
from "antd";
+import {Button, Col, Empty, Form, Icon, Input, message, Row, Select, Tabs,
Typography} from "antd";
import React, {createRef, forwardRef, useContext, useEffect,
useImperativeHandle, useState} from "react";
import ReactJson from "react-json-view";
import fetch from "dva/fetch";
@@ -34,6 +34,7 @@ import {Method} from "./globalData";
const { Title, Text, Paragraph } = Typography;
const { TabPane } = Tabs;
const FormItem = Form.Item;
+const InputGroup = Input.Group
const FCForm = forwardRef(({ form, onSubmit }, ref) => {
useImperativeHandle(ref, () => ({
@@ -42,7 +43,8 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
const {
apiDetail,
- apiMock
+ apiMock,
+ apiData: {envProps = []}
} = useContext(ApiContext);
const [questJson, setRequestJson] = useState(JSON.parse(apiMock.body ||
'{}'));
const [initialValue, setInitialValue] = useState({
@@ -197,7 +199,38 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
pattern: /^https?:\/\/([^:]+):(\d+)(\/.+)$/
}
]
- })(<Input allowClear />)}
+ })(
+ <InputGroup compact>
+ <Select
+ style={{width: '40%'}}
+ onChange={host => {
+ const url = new URL(host);
+ host = `${url.protocol}//${url.hostname}:${url.port || '80'}`;
+ setInitialValue({...initialValue, host})
+ const requestUrl = `${host}${initialValue.url ?? ""}`
+ form.setFieldsValue({requestUrl})
+ }}
+ value={initialValue.host}
+ >
+ {Object.values(envProps).map((e, i) => {
+ return (
+ <Select.Option key={`${e.addressUrl} ${i}`}
value={e.addressUrl}>
+ {`${e.envLabel} ${e.addressUrl}`}
+ </Select.Option>
+ );
+ })}
+ </Select>
+ <Input
+ style={{width: '60%'}}
+ value={initialValue.url}
+ onChange={e => {
+ setInitialValue({...initialValue, url: e.target.value})
+ const requestUrl = `${initialValue.host ??
""}${e.target.value}`
+ form.setFieldsValue({requestUrl})
+ }}
+ />
+ </InputGroup>
+ )}
</FormItem>
<FormItem label="Headers">
diff --git a/src/routes/Document/components/ApiInfo.js
b/src/routes/Document/components/ApiInfo.js
index 44011d2d..6f5678a3 100644
--- a/src/routes/Document/components/ApiInfo.js
+++ b/src/routes/Document/components/ApiInfo.js
@@ -28,7 +28,7 @@ function ApiInfo(props) {
const {
apiData: { envProps = [] },
apiDetail,
- apiDetail: { document, responseParameters, requestHeaders }
+ apiDetail: { document, requestParameters, responseParameters,
requestHeaders }
} = useContext(ApiContext);
const { handleUpdate, handleDelete } = props;
@@ -55,8 +55,7 @@ function ApiInfo(props) {
},
{
title: getIntlContent("SHENYU.COMMON.TYPE"),
- dataIndex: "type",
- render: (_, record) => record?.schema?.type
+ dataIndex: "type"
},
{
title: getIntlContent("SHENYU.COMMON.REQUIRED"),
@@ -239,7 +238,7 @@ function ApiInfo(props) {
size="small"
rowKey="id"
bordered
- dataSource={documentJSON.parameters || []}
+ dataSource={requestParameters || []}
pagination={false}
childrenColumnName="refs"
columns={columns}
diff --git a/src/routes/Document/components/SearchApi.js
b/src/routes/Document/components/SearchApi.js
index 9fef08b4..27667822 100644
--- a/src/routes/Document/components/SearchApi.js
+++ b/src/routes/Document/components/SearchApi.js
@@ -23,6 +23,7 @@ import { getRootTag, getParentTagId, getApi } from
"../../../services/api";
import { Method } from "./globalData";
import AddAndUpdateTag from "./AddAndUpdateTag";
import AddAndUpdateApiDoc from "./AddAndUpdateApiDoc";
+import {getIntlContent} from "../../../utils/IntlUtils";
const { Text } = Typography;
@@ -122,7 +123,7 @@ const SearchApi = React.forwardRef((props, ref) => {
})
}
>
- + Tag
+ {getIntlContent("SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_MODULE")}
</Button>
</Col>
)}
@@ -224,7 +225,7 @@ const SearchApi = React.forwardRef((props, ref) => {
type="dashed"
onClick={() => addOrUpdateTag({ parentTagId: "0" })}
>
- Add Root Tag
+ {getIntlContent("SHENYU.DOCUMENT.APIDOC.SEARCH.ADD_ROOT_MODULE")}
</Button>
<AddAndUpdateTag
visible={openTag}