smallrye-open-api icon indicating copy to clipboard operation
smallrye-open-api copied to clipboard

Support Fluent Setters for Annotations

Open funkrusher opened this issue 1 year ago • 0 comments

it seems, that currently only regular setters are scanned/resolved for Annotations (Schema, SchemaProperty). For example:

The following setter method is recognized in my quarkus service, that uses smallrye-open-api, and it will show in the swagger-ui (in the examples area of swagger), like defined here:

Normal Setter:

@Schema(name = "createdAt", example = "1618312800000", type = SchemaType.NUMBER, format = "date-time", description = "Timestamp in milliseconds since 1970-01-01T00:00:00Z")
    public void setCreatedAt(LocalDateTime value);

It is often very convenient to use "fluent setters", which return the Class instance to make fluent setter calls possible. If not know, i want to show this convenience in following example:

Product product = new Product()
    .setCreatedAt(123433434L)
    .setTitle("test")
    .setType(3);

The JSON Library Jackson does correctly recognize those fluent setters, so it seems that some libraries already support them. The jOOQ Library (Object Oriented Queries) also is able to create fluent setters into the code.

Following example does not seem to be recognized by smallrye-open-api, as it does not show up in the swagger-ui:

Fluent Setter:

@Schema(name = "createdAt", example = "1618312800000", type = SchemaType.NUMBER, format = "date-time", description = "Timestamp in milliseconds since 1970-01-01T00:00:00Z")
    public IProduct setCreatedAt(LocalDateTime value);

It would be cool if you could consider making this possible :) thanks in advance.

funkrusher avatar Apr 27 '24 14:04 funkrusher