Open trentjeff opened 1 year ago
The OpenAPITools generators in general--and the ones our team provided to support Helidon in particular--generate POJO classes for each of the schemas declared in the OpenAPI document. These POJOs include getters and setters for the attributes as illustrated in this generated POJO from our example generated project https://github.com/helidon-io/helidon/blob/helidon-3.x/examples/openapi-tools/quickstart-mp/mp-server/src/main/java/org/openapitools/server/model/Message.java.
One possibility could be to enhance the Helidon OpenAPITools generators with an optional flag to detect a new, optional flag (supported only if the Helidon version is 4.x?) and then:
@Builder
annotation to the generated POJO classes. pom.xml
(if selected) to include the builder annotation processor.We should consider how valuable we think users would find such a feature vs. simply using the already-generated setters and getters on the POJO classes. We also need to weigh our own priorities for various possible enhancements to our generators.
Interestingly our generated pojo does not follow Helidon's record-style coding style guidelines.
/**
* An message for the user
**/
public class Message {
private String message;
private String greeting;
/**
* Get message
*
* @return message
**/
public String getMessage() {
return message;
}
Was that intentional?
Also, what about the no-arg constructor - is that required for serialization purposes?
Everything else here seems like it would be low-hanging fruit to convert to use Builder, and it would make the development experience standard across the product for our users.
Several factors:
Any or all of what you describe could be done, technically, but, again, we have to prioritize carefully among the possible enhancements to the generators (and our other work).
See the OCI's Example as background.
What is happening here behind the scenes is that there is an OpenAPI spec yaml where
GetBucketResponse
andGetBucketRequest
schemas trigger generation of pojo's in a builder style. And then the generated pojo instances are built (builder().namespaceName("myNamespace").bucketName("myBucket").build()
) and then passed to the service interface.This functionality would be a nice enhancement to integrate into our Helidon Builder, where we would delegate directly to BuilderCreator to generate the backing pojo types for this use case.
Details to be worked out through a POC if we think this is worthwhile to pursue.