apache / apache/servicecomb-java-chassis

使用@path@post注解时,请求参数中存在Boolean类型时会把Boolean类型识别为Body

Open
#2,735 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.9k
Forks
814
Avg merge
8d 23h
Merged PRs (30d)
1

Description

bool值isSync、isGray定义在IntentRequestHeaders 实体类中
```
public CompletableFuture executeSkill(
@BeanParam @NotNull IntentRequestHeaders intentRequestHeaders,
@RequestBody @NotNull IntentRequest intentRequest) {}
```
```
@HeaderParam("x-is-sync")
private Boolean isSync;
@HeaderParam("x-is-gray")
private Boolean isGray;
```

报错信息:
_java.lang.IllegalStateException: defined 3 body parameter.
at org.apache.servicecomb.swagger.generator.core.AbstractOperationGenerator.initParameterGenerators(AbstractOperationGenerator.java:222)
at org.apache.servicecomb.swagger.generator.core.AbstractOperationGenerator.scanMethodParameters(AbstractOperationGenerator.java:192)
at org.apache.servicecomb.swagger.generator.core.AbstractOperationGenerator.generate(AbstractOperationGenerator.java:152)
at org.apache.servicecomb.swagger.generator.core.AbstractSwaggerGenerator.scanMethods(AbstractSwaggerGenerator.java:297)_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with AbstractOperationGenerator.java, especially initParameterGenerators, scanMethodParameters, and generate, then trace how @BeanParam, @RequestBody, and Boolean @HeaderParam fields are classified for the shown executeSkill method. Reproduce the Swagger generation failure and verify that the two header parameters are not counted as body parameters and no longer produce the defined 3 body parameter exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.