Interface desarialization doesn't work
Open
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
I have the following schema:
union ValidationRule = MinimumCharacterRule
type MinimumCharacterRule {
value: Int!
}
It will generate the following classes:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "__typename"
)
@JsonSubTypes(@JsonSubTypes.Type(value = MinimumCharacterRule.class, name = "MinimumCharacterRule"))
public interface ValidationRule {
}
@JsonTypeInfo(
use = JsonTypeInfo.Id.NONE
)
public class MinimumCharacterRule implements ValidationRule {
...
}
If I try to deserialize the MinimumCharacterRule class I will get the following error:
Could not resolve subtype of [simple type, class com.example.ValidationRule ]: missing type id property '__typename'
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 provides the schema and generated ValidationRule and MinimumCharacterRule classes but names no repository file or test. Start by reproducing deserialization of MinimumCharacterRule and inspect how the generated Jackson annotations handle __typename; done means the generated types deserialize without the reported missing type-id error, with regression coverage if the relevant test area is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100