Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micronaut 4 documentation misses @SerdeImport/@Serdeable.Deserializable annotations #231

Open
sergey-morenets opened this issue Oct 17, 2023 · 0 comments

Comments

@sergey-morenets
Copy link

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):

@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 {
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant