micronaut-projects / micronaut-projects/micronaut-validation

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

Open
#231 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: docs
Dominant language
Java
Stars
9
Forks
8
Avg merge
20h 7m
Merged PRs (30d)
9

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Micronaut 4 upgrade guide and Micronaut Validation guide linked in the issue, and check how their existing migration and validation sections describe introspection. Document @SerdeImport and @Serdeable.Deserializable, including when @Introspected is also needed, then verify both guides explain the migration clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.