Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type: feature] Add support for ApiMockRequest Insert Update Delete. #262

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,17 @@
"SHENYU.COMMON.MAX.LENGTH": "Max Length",
"SHENYU.COMMON.MAX.EXAMPLE": "Example",
"SHENYU.COMMON.MAX.ENVIRONMENT": "Environment",
"SHENYU.COMMON.HTTP.METHOD": "HttpMethod"
"SHENYU.COMMON.HTTP.METHOD": "HttpMethod",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.HOST": "Host",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.PORT": "Port",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.URL": "Request Path",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.PATH_VARIABLE": "Path Variable",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.QUERY": "Query",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.HEADER": "Header",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.BODY": "Body",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.SAVE": "Save",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.RESET": "Reset",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADD.HEADER": "Add header",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADD.QUERY": "Add Query",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADDRESS.VALIDATE": "Request Address format error."
}
14 changes: 13 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,17 @@
"SHENYU.COMMON.MAX.LENGTH": "最大长度",
"SHENYU.COMMON.MAX.EXAMPLE": "示例值",
"SHENYU.COMMON.MAX.ENVIRONMENT": "环境类型",
"SHENYU.COMMON.HTTP.METHOD": "请求方法"
"SHENYU.COMMON.HTTP.METHOD": "请求方法",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.HOST": "请求域名或IP",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.PORT": "端口",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.URL": "路由地址",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.PATH_VARIABLE": "路由参数",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.QUERY": "请求参数",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.HEADER": "请求头",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.BODY": "请求体",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.SAVE": "保存",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.RESET": "重置",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADD.HEADER": "添加请求头参数",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADD.QUERY": "添加查询参数",
"SHENYU.DOCUMENT.APIDOC.DEBUG.MOCK.ADDRESS.VALIDATE": "请求地址格式错误."
}
13 changes: 11 additions & 2 deletions src/routes/Document/ApiDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import React, { useEffect, useState } from "react";
import SearchApi from "./components/SearchApi";
import AddAndUpdateApiDoc from "./components/AddAndUpdateApiDoc";
import ApiInfo from "./components/ApiInfo";
import { getDocMenus, getApiDetail, addApi, updateApi, deleteApi } from "../../services/api";
import { getDocMenus, getApiDetail, addApi, updateApi, deleteApi, getApiMockRequest} from "../../services/api";
import ApiContext from "./components/ApiContext";

function ApiDoc() {
const [apiDetail, setApiDetail] = useState({});
const [apiData, setApiData] = useState({});
const [apiMock, setApiMock] = useState({});
const [open, setOpen] = useState(false);
const [flag, setflag] = useState('add');

Expand Down Expand Up @@ -93,6 +94,13 @@ function ApiDoc() {
id
});
setApiDetail(data);

const { code: mockCode, message: mockMsg, data: mockData} = await getApiMockRequest(id);
if (mockCode !== 200) {
message.error(mockMsg);
return;
}
setApiMock(mockData);
};
const handleAddApi = (targetId) => {
setflag('add')
Expand Down Expand Up @@ -133,7 +141,8 @@ function ApiDoc() {
<ApiContext.Provider
value={{
apiDetail,
apiData
apiData,
apiMock
}}
>
<Card style={{ margin: 24 }}>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/Document/components/ApiContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ import { createContext } from "react";

export default createContext({
apiDetail: {},
apiData: {}
apiData: {},
apiMock: {}
});
Loading