I am using Value.Immutable classes as the rest api request/response. The generated OpenAPI doc does not show the properties of the immutable class. It looks like the OpenAPI generator does not understand these beans as there are no getters and setters in the immutable abstract definition.
How could I properly generate the OpenAPI doc when I use Value.Immutable classes?
Here's a simple example --
The Value.Immutable class:
@Value.Immutable
@JsonSerialize(as = ImmutableCity.class)
@JsonDeserialize(as = ImmutableCity.class)
@Introspected
@Schema(implementation = ImmutableCity.class, name = "City", description = "City model")
@Value.Style(
passAnnotations = {Schema.class},
visibility = ImplementationVisibility.PUBLIC)
public abstract class City {
@JsonProperty("name")
@NotBlank
public abstract String name();
@JsonProperty("description")
public abstract String description();
}
The controller:
@Controller("/city")
public class CityController {
/**
* Persist a city
* @param city
* @return the persisted city
*/
@Post("save")
@Tag(name = "city")
public HttpResponse<City> save(
@Body City city) {
// persist it...
return HttpResponse.created(city);
}
}
The generated OpenAPI schema for City has no properties:
components:
schemas:
City:
type: object
description: City model
If I change City.java to not use immutables but to have getters/setters, the properties are generated:
components:
schemas:
City:
type: object
description: City model
properties:
name:
minLength: 1
type: string
description:
type: string