Error decoding JSON stream for type [B]: Failed to narrow type when trying to deserialize subtype #447
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
renovate
renovate-manager
cargo
renovate-manager
dockerfile
renovate-manager
git-submodules
renovate-manager
gomod
renovate-manager
kustomize
renovate-manager
kustomize
renovate-manager
maven
renovate-manager
maven
renovate-manager
npm
renovate-manager
pip_requirements
renovate-manager
regex
renovate-manager
renovate-config-presets
renovate-manager
woodpecker
renovate-type
bump
renovate-type
digest
renovate-type
lockFileMaintenance
renovate-type
major
renovate-type
minor
renovate-type
patch
renovate-type
pin
renovate-type
pinDigest
renovate-type
replacement
renovate-type
rollback
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
kokuwaio/micronaut-openapi-codegen#447
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Using this simple schema (using inheritance without discriminator):
When calling the controller method in a testcase, the following exception is thrown:
The reason is that all classes implementing the interface
Parentare deserialized asParentDefault(due to theJsonDeserialize(as = ParentDefault.class)annotation on theParentinterface). This also applies to theChildclass since annotations of parent interfaces are taken into consideration as well.I created a simple reproducer project here: https://github.com/gschlueter-jaconi/generator-polymorphism-demo
The
ChildControllerTestthere will fail while theChildControllerWorkingTestwill succeed. This test contains a potential solution by adding the following annotation to theChildmodel explicitly:@JsonDeserialize(as = Child.class). This could also be done by the generator (if no discriminator is used).Released as 4.4.3