import for the `.class` parameter to an annotation isn't added
mjparme opened this issue · 1 comments
mjparme commented
If we have a mapping that aims to add a JsonDeserialize
annotation to some of the generated classes, like this:
- type: SomeClass @ com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.SomeClassDeserializer.class)
The JsonDeserialize annotation is correctly added, however, the import for com.example
isn't added. This makes compilation of the generated classes fail.
It is generated like this:
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.validation.Valid;
import java.util.List;
import lombok.Builder;
@JsonDeserialize(SomeClassDeserializer.class)
@Builder
@Generated(value = "openapi-processor-spring", version = "2024.3")
public record SomeClass(
@JsonProperty("foo")
List<@Valid ArrayOfFoos> foo
) {}
This is almost correct. It just needs to add the import for the class that is in the using
parameter.
As it is it doesn't seem possible to generate models from OpenAPI spec with polymorphic types (i.e. specs that use oneOf
) that will result in successful parsing.
hauner commented
Yes, that is a a bug. 😞
Thanks for reporting!