apache / apache/servicecomb-java-chassis
从CSE 1.X 升级到 CSE 2.X后,接口配置的swagger注解@ApiImplicitParams 参数失效
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 814
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 1
Description
### 问题背景:
从CSE 1.X 升级到 CSE 2.X后,接口配置的swagger注解@ApiImplicitParams 参数失效
接口定义如下:
```java
@RequestMapping(path = "/v1/test", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "x-test-header", dataType = "string", required = false,
paramType = "header", value = "xxx",
allowableValues = "true,false")})
public String testV1(HttpServletRequest request) {
return "ok";
}
```
使用CSE 1.X时,如果传入的header不是true或者false,报错如下:
```json
{
"message": "Parameter is not valid for operation [XXX.XXX.testV1]. Parameter is [x-test-header]. Processor is [header]."
}
```
使用CSE 3.X时,接口无报错
### 问题分析:
通过对比CSE 1.X和2.X的代码,发现org.apache.servicecomb.common.rest.codec.RestCodec#restToArgs将request请求转发为请求对象的过程中,org.apache.servicecomb.common.rest.definition.RestOperationMeta#init中创建Type的代码进行了调整
从
```
Method method = operationMeta.getMethod();
Type[] genericParamTypes = method.getGenericParameterTypes();
```
调整为
```
(Type)operationMeta.getSwaggerProducerOperation().getSwaggerParameterTypes().get(parameter.getName())
```
导致type丢失了枚举信息
请帮忙确认是否需要跟CSE 1.X保持兼容以及其他类似注解是否有相同问题
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at org.apache.servicecomb.common.rest.codec.RestCodec#restToArgs and RestOperationMeta#init, then compare the CSE 1.X and 2.X type-creation paths shown in the issue. Check how Swagger @ApiImplicitParams allowableValues and related annotations are represented in CSE 2.X and 3.X. Done means determining whether 1.X validation compatibility is required and confirming whether similar annotations lose enum information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100