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:refactor]Split the document field of the apidoc detail interface,and add fields such as requestHeaders and responseParameters. #4865

Merged
merged 100 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
1de4c09
apidoc sql
Jun 8, 2022
943536e
refact
Jun 21, 2022
43a3e04
commit
Jun 22, 2022
058677d
[Task] Shenyu-admin: Fix API document failed to build because of NPE.
Jun 22, 2022
8412561
[Task] Shenyu-admin: Fix API document failed to build because of NPE.
Jun 22, 2022
36d90f9
Merge branch 'refact' into 3603
Jun 23, 2022
1991e45
Merge branch 'apidoc-sql' into 3603
Jun 23, 2022
22dfce6
Merge branch 'master' of https://github.com/apache/incubator-shenyu i…
Jun 24, 2022
d2ebf48
solve conficts,modify LICENSE.
Jun 24, 2022
5230091
Merge branch '3603-BACK'
Jun 25, 2022
0c63d0c
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jun 26, 2022
e569cfa
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jul 1, 2022
12d9797
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jul 3, 2022
6671f90
delete useless code.
Jul 4, 2022
4b0e879
delete useless code.
Jul 4, 2022
0522fbf
commit
Jul 4, 2022
c7b535f
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jul 4, 2022
77e0b9a
Merge branch 'header'
Jul 4, 2022
d37ae8a
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jul 19, 2022
0df6f18
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Jul 20, 2022
a1e05c9
Merge branch 'master' of https://github.com/apache/incubator-shenyu
Aug 12, 2022
a62545a
[ISSUE #3843]admin apidoc fix: the required attribute prompt is incor…
Aug 13, 2022
daad095
commit
Aug 13, 2022
9c54200
Merge branch 'master' into 3843
Aug 13, 2022
c1b13a6
[shenyu-examples]add swagger to the example project to test the apido…
Aug 13, 2022
eba290f
Merge branch 'master' of https://github.com/apache/shenyu into exampl…
Aug 13, 2022
da2d8ba
commit
Aug 13, 2022
3d31495
commit
Aug 14, 2022
dee2616
commit
Aug 14, 2022
2bbf088
Merge branch 'apache:master' into master
lianjunwei Aug 31, 2022
83aa04c
Merge branch 'apache:master' into master
lianjunwei Sep 14, 2022
950d23c
Merge branch 'apache:master' into master
lianjunwei Sep 22, 2022
b7886c0
Merge branch 'apache:master' into master
lianjunwei Sep 29, 2022
646af38
Merge branch 'apache:master' into master
lianjunwei Nov 7, 2022
be38ab3
Merge branch 'apache:master' into master
lianjunwei Nov 8, 2022
433dd44
Merge branch 'apache:master' into master
lianjunwei Nov 9, 2022
5b61de4
Merge branch 'apache:master' into master
lianjunwei Nov 13, 2022
6d91b73
Merge branch 'apache:master' into master
lianjunwei Jan 8, 2023
eb22b39
Merge branch 'apache:master' into master
lianjunwei Jan 17, 2023
9192e47
Merge branch 'apache:master' into master
lianjunwei Jan 28, 2023
e181701
Merge branch 'apache:master' into master
lianjunwei Apr 7, 2023
cccfada
Merge branch 'apache:master' into master
lianjunwei May 10, 2023
4db5386
Merge branch 'apache:master' into master
lianjunwei May 17, 2023
356a19f
Merge branch 'apache:master' into master
lianjunwei May 28, 2023
153b00e
Merge branch 'apache:master' into master
lianjunwei May 30, 2023
459adff
Merge branch 'apache:master' into master
lianjunwei May 31, 2023
f9383f8
[ISSUE #4690]Supports gzip compression in response to HTTP requests.
May 31, 2023
56901ae
Merge branch 'master' into 4690
lianjunwei Jun 1, 2023
4f27bea
Merge branch 'apache:master' into master
lianjunwei Jun 1, 2023
3584275
Merge branch 'master' into 4690
loongs-zhang Jun 3, 2023
31e2283
Merge branch 'apache:master' into master
lianjunwei Jun 4, 2023
5740490
Merge branch 'master' into 4690
Jun 4, 2023
2a66dcc
Merge remote-tracking branch 'origin/4690' into 4690
Jun 4, 2023
88fe30a
Merge branch 'apache:master' into master
lianjunwei Jun 5, 2023
43999b4
Merge branch '4690'
Jun 5, 2023
be6b36b
Merge branch 'apache:master' into master
lianjunwei Jun 6, 2023
44b3e70
Merge remote-tracking branch 'origin/master'
Jun 6, 2023
b523445
Merge branch 'apache:master' into master
lianjunwei Jun 7, 2023
1c59c48
Merge remote-tracking branch 'origin/master'
Jun 7, 2023
5bd6308
Merge branch 'apache:master' into master
lianjunwei Jun 9, 2023
14be36b
Merge branch 'apache:master' into master
lianjunwei Jun 9, 2023
e6eefd8
Merge branch 'master' into example-add-swagger
Jun 9, 2023
1a4376e
[examples]Add Swagger sample project to demonstrate automatic pull in…
Jun 10, 2023
83e31aa
Merge branch 'apache:master' into master
lianjunwei Jun 26, 2023
37f2036
Merge remote-tracking branch 'origin/master'
Jun 26, 2023
70002c9
Merge branch 'apache:master' into master
lianjunwei Jun 27, 2023
704507a
Merge remote-tracking branch 'origin/master'
Jun 27, 2023
6f7978e
Merge branch 'apache:master' into master
lianjunwei Jul 1, 2023
b0a0876
Merge remote-tracking branch 'origin/master'
Jul 1, 2023
24efdb6
Merge branch 'apache:master' into master
lianjunwei Jul 9, 2023
40a0bd4
Merge remote-tracking branch 'origin/master'
Jul 9, 2023
47ce929
delete exapmple
Jul 13, 2023
e397046
delete useless code.
Jul 13, 2023
1298f6e
delete useless code.
Jul 13, 2023
ca1f6b5
swagger apidoc from local cache to database persistence.
Jul 14, 2023
c70f2fc
Storage adjustment for swagger type documents :from local cache to da…
Jul 15, 2023
cecc554
fix get httpMethod
Jul 15, 2023
ae6f0b0
Merge branch 'master' into 4848-task1
lianjunwei Jul 15, 2023
426ae3c
Merge branch 'apache:master' into master
lianjunwei Jul 15, 2023
1405442
Fix unit testing.
Jul 15, 2023
17dfa53
Fix unit testing.
Jul 15, 2023
7593ac2
Merge remote-tracking branch 'origin/4848-task1' into 4848-task1
Jul 15, 2023
b65d3d4
The field splitting of apidoc details API, add requestHeaders, respon…
Jul 15, 2023
7372cf7
Fix unit testing.
Jul 15, 2023
ecfcc0c
code style.
Jul 15, 2023
179dbcd
Fix unit testing.
Jul 15, 2023
b5d10bf
delete unused imports.
Jul 15, 2023
5cbf22d
fix JSON data for testing.
Jul 16, 2023
bae7368
Merge branch '4848-task1' into 4848-task2
Jul 16, 2023
a408203
Merge branch 'apache:master' into master
lianjunwei Jul 16, 2023
07a4f0f
Merge branch 'master' into 4848-task1
yu199195 Jul 16, 2023
54ac805
Merge remote-tracking branch 'origin/4848-task1' into 4848-task2
Jul 16, 2023
7ab44d5
Merge branch 'apache:master' into master
lianjunwei Jul 17, 2023
74585bc
Merge branch 'apache:master' into master
lianjunwei Jul 17, 2023
a4d120e
Merge branch 'master' into 4848-task2
Jul 17, 2023
345fe6c
commit
Jul 17, 2023
3655a8d
commit
Jul 17, 2023
68bf021
Merge branch 'apache:master' into master
lianjunwei Jul 18, 2023
f645210
Merge branch 'master' into 4848-task2
Jul 18, 2023
431d6e6
commit
Jul 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.shenyu.admin.model.vo;

import org.apache.shenyu.admin.model.bean.CustomCode;
import org.apache.shenyu.admin.model.bean.DocParameter;
import org.apache.shenyu.admin.model.entity.ApiDO;

import java.io.Serializable;
Expand Down Expand Up @@ -105,6 +107,14 @@ public class ApiVO implements Serializable {
*/
private String documentMd5;

private List<DocParameter> requestHeaders;

private List<DocParameter> requestParameters;

private List<DocParameter> responseParameters;

private List<CustomCode> bizCustomCodeList;

/**
* create time.
*/
Expand Down Expand Up @@ -390,6 +400,76 @@ public void setDocumentMd5(final String documentMd5) {
this.documentMd5 = documentMd5;
}

/**
* get requestHeaders.
*
* @return request headers
*/
public List<DocParameter> getRequestHeaders() {
return requestHeaders;
}

/**
* set requestHeaders.
*
* @param requestHeaders requestHeaders
*/
public void setRequestHeaders(final List<DocParameter> requestHeaders) {
this.requestHeaders = requestHeaders;
}

/**
* get requestParameters.
*
* @return List
*/
public List<DocParameter> getRequestParameters() {
return requestParameters;
}

/**
* set requestParameters.
*
* @param requestParameters requestParameters
*/
public void setRequestParameters(final List<DocParameter> requestParameters) {
this.requestParameters = requestParameters;
}

/**
* get responseParameters.
*
* @return List
*/
public List<DocParameter> getResponseParameters() {
return responseParameters;
}

/**
* set responseParameters.
*
* @param responseParameters responseParameters
*/
public void setResponseParameters(final List<DocParameter> responseParameters) {
this.responseParameters = responseParameters;
}

/**
* get bizCustomCodeList.
* @return List
*/
public List<CustomCode> getBizCustomCodeList() {
return bizCustomCodeList;
}

/**
* set bizCustomCodeList.
* @param bizCustomCodeList bizCustomCodeList
*/
public void setBizCustomCodeList(final List<CustomCode> bizCustomCodeList) {
this.bizCustomCodeList = bizCustomCodeList;
}

/**
* getDateCreated.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.shenyu.admin.mapper.ApiMapper;
import org.apache.shenyu.admin.mapper.TagMapper;
import org.apache.shenyu.admin.mapper.TagRelationMapper;
import org.apache.shenyu.admin.model.bean.DocItem;
import org.apache.shenyu.admin.model.dto.ApiDTO;
import org.apache.shenyu.admin.model.entity.ApiDO;
import org.apache.shenyu.admin.model.entity.TagDO;
Expand All @@ -37,6 +38,8 @@
import org.apache.shenyu.admin.model.vo.RuleVO;
import org.apache.shenyu.admin.model.vo.TagVO;
import org.apache.shenyu.admin.service.ApiService;
import org.apache.shenyu.common.enums.ApiSourceEnum;
import org.apache.shenyu.common.utils.JsonUtils;
import org.apache.shenyu.common.utils.ListUtil;
import org.apache.shenyu.admin.service.MetaDataService;
import org.apache.shenyu.admin.service.RuleService;
Expand Down Expand Up @@ -65,11 +68,11 @@
public class ApiServiceImpl implements ApiService {

private final SelectorService selectorService;

private final RuleService ruleService;

private final MetaDataService metaDataService;

private final ApiMapper apiMapper;

private final TagRelationMapper tagRelationMapper;
Expand Down Expand Up @@ -159,7 +162,7 @@ private String create(final ApiDTO apiDTO) {
}
return ShenyuResultMessage.CREATE_SUCCESS;
}

private void unregister(final ApiDO apiDO) {
final String path = apiDO.getApiPath();
RuleQueryCondition condition = new RuleQueryCondition();
Expand All @@ -185,7 +188,7 @@ private void unregister(final ApiDO apiDO) {
Optional.ofNullable(metaDataService.findByPath(path))
.ifPresent(metaDataDO -> metaDataService.delete(Lists.newArrayList(metaDataDO.getId())));
}

private void register(final ApiDO apiDO) {
//register selector/rule/metadata if necessary
final ApiDocRegisterDTO.ApiExt ext = GsonUtils.getInstance().fromJson(apiDO.getExt(), ApiDocRegisterDTO.ApiExt.class);
Expand Down Expand Up @@ -220,7 +223,7 @@ private void register(final ApiDO apiDO) {
.rpcType(apiDO.getRpcType())
.build());
}

@Override
@Transactional(rollbackFor = Exception.class)
public String delete(final List<String> ids) {
Expand All @@ -243,12 +246,21 @@ public ApiVO findById(final String id) {
return Optional.ofNullable(apiMapper.selectByPrimaryKey(id)).map(item -> {
List<TagRelationDO> tagRelations = tagRelationMapper.selectByQuery(TagRelationQuery.builder().apiId(item.getId()).build());
List<String> tagIds = tagRelations.stream().map(TagRelationDO::getTagId).collect(Collectors.toList());
List<TagVO> tagVOS = Lists.newArrayList();
List<TagVO> tagVOs = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(tagIds)) {
List<TagDO> tagDOS = tagMapper.selectByIds(tagIds);
tagVOS = tagDOS.stream().map(TagVO::buildTagVO).collect(Collectors.toList());
tagVOs = tagDOS.stream().map(TagVO::buildTagVO).collect(Collectors.toList());
}
return ApiVO.buildApiVO(item, tagVOS);
ApiVO apiVO = ApiVO.buildApiVO(item, tagVOs);
if (apiVO.getApiSource().equals(ApiSourceEnum.SWAGGER.getValue())) {
DocItem docItem = JsonUtils.jsonToObject(apiVO.getDocument(), DocItem.class);
apiVO.setRequestHeaders(docItem.getRequestHeaders());
apiVO.setRequestParameters(docItem.getRequestParameters());
apiVO.setResponseParameters(docItem.getResponseParameters());
apiVO.setBizCustomCodeList(docItem.getBizCodeList());
}
return apiVO;

}).orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void setUp() {
.rpcType("/dubbo")
.state(0)
.apiSource(0)
.document("document")
.document("{}")
.build();
SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ private ApiDTO buildApiDTO(final String id) {
apiDTO.setApiOwner("string");
apiDTO.setApiDesc("string");
apiDTO.setApiSource(0);
apiDTO.setDocument("document");
apiDTO.setDocument("{}");
return apiDTO;
}

private void testUpdate(final String id) {
ApiDTO apiDTO = new ApiDTO();
apiDTO.setId(id);
apiDTO.setApiPath("test");
apiDTO.setDocument("testDocument");
apiDTO.setDocument("{\n"
+ " \"module\":\"http-test-controller\"\n"
+ "}");
assertEquals(ShenyuResultMessage.UPDATE_SUCCESS, this.apiService.createOrUpdate(apiDTO));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public class SwaggerDocParserTest {
+ " }\n"
+ " },\n"
+ " \"deprecated\":false\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " \"/test/payment\":{\n"
+ " \"post\":{\n"
Expand Down Expand Up @@ -142,7 +143,6 @@ public class SwaggerDocParserTest {
+ " },\n"
+ " \"deprecated\":false\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " },\n"
+ " \"definitions\":{\n"
Expand Down Expand Up @@ -200,6 +200,6 @@ public void testParseJson() {
JsonObject docRoot = GsonUtils.getInstance().fromJson(DOC_INFO_JSON, JsonObject.class);
docRoot.addProperty("basePath", "/" + "testClusterName");
DocInfo docInfo = swaggerDocParser.parseJson(docRoot);
assert docInfo.getDocModuleList().get(0).getModule().equals("shenyu-examples-http-swagger2 API");
assert docInfo.getDocModuleList().get(0).getModule().equals("Order API");
}
}