You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Micronaut 4 Upgrade guide and Micronaut Validation documentation should contain information about @SerdeImport/@Serdeable.Deserializable annotations as they're required for validation and were absent in Micronaut 3.
So previously we used this class to mark our DTO as introspected beans (they're in another module):
@Introspected(classes = Product.class)
public class BeanValidationConfiguration {
}
However after upgrade we received an exception in our tests:
Caused by: io.micronaut.http.codec.CodecException: Error encoding object [com.example.Product@6971bc23] to JSON: No serializable introspection present for type Product. Consider adding Serdeable. Serializable annotate to type Product. Alternatively if you are not in control of the project's source code, you can use @SerdeImport(Product.class) to enable serialization of this type.
The exception message is correct but it's not absolutely correct. @serializable is meta-information and contains @introspected annotation so we can put only @serializable on the Product class.
But @SerdeImport doesn't contain @introspected so we should use both here:
@SerdeImport(Product.class)
@Introspected(classes = Product.class)
public class BeanValidationConfiguration {
}
Expected Behavior
Micronaut 4 Upgrade guide and Micronaut Validation documentation should contain information about @SerdeImport/@Serdeable.Deserializable annotations as they're required for validation and were absent in Micronaut 3.
Actual Behaviour
Hi
We tried to migrate from Micronaut 3 to Micronaut 4 and found that migration guide (https://micronaut.io/2023/05/09/upgrade-to-micronaut-framework-4-0-0/) contains no information about new @SerdeImport/@Serdeable.Deserializable annotations.
So previously we used this class to mark our DTO as introspected beans (they're in another module):
However after upgrade we received an exception in our tests:
Caused by: io.micronaut.http.codec.CodecException: Error encoding object [com.example.Product@6971bc23] to JSON: No serializable introspection present for type Product. Consider adding Serdeable. Serializable annotate to type Product. Alternatively if you are not in control of the project's source code, you can use @SerdeImport(Product.class) to enable serialization of this type.
The exception message is correct but it's not absolutely correct. @serializable is meta-information and contains @introspected annotation so we can put only @serializable on the Product class.
But @SerdeImport doesn't contain @introspected so we should use both here:
I guess this is important point however Micronaut Validation documentation(https://micronaut-projects.github.io/micronaut-validation/snapshot/guide/) doesn't contain anything about @SerdeImport and @Deserializable.
Steps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version
4.1.4
The text was updated successfully, but these errors were encountered: