swagger-api / swagger-api/swagger-core
ToString和@JsonValue 冲突 。toString失去作用
Open
Nobody has claimed this yet.
backlog
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
我想通过重写ToString方法的形式自动生成枚举描述,但是不起作用,我将@JsonValue放在ToString方法上面但是影响了入参的解析。我应该怎么自定义展示描述,自动生成的方式?
`@Getter
@AllArgsConstructor
public enum DayTypeEnum {
自然日(0),
工作日(1),
;
@EnumValue
@JsonValue
private final Integer key;
@Override
public String toString() {
return "{value:'" + key + "',label:'" + name() + "'}";
}
}`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files, tests, or entry points; it only provides a Java enum using @JsonValue, @EnumValue, and an overridden toString(). Start by locating enum serialization and deserialization handling in swagger-core, then reproduce the reported conflict. Done should define how custom display output and input parsing coexist.
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
- Needs clarification
- Newbie friendliness
- 20/100