Open tomgeek27 opened 3 days ago
In general I'd like to use a more user friendly way to build model. At the moment the only way is using a constructor with every attributes (become crazy with 10+ params)
🗞️ UPDATE: for the moment I found this workaround that could be useful for whoever is struggling with the same problem:
micronaut {
// ...
openapi {
client(file) {
// other config
additionalProperties = [
requiredPropertiesInConstructor: 'false',
]
}
}
}
With this configuration you can create any model with default empty constructor and then define every named attributes in this way:
Model model = new Model().attrA(..).attrB(..);
Actually, I deliberately didn't add the @Builder
annotation because, in my opinion, it's pointless. Instead, I added the @Accessors(chain = true)
annotation just so that you could use the builder principle, but not create extra objects (builders)
And if you enable lombok option like this:
micronaut {
// ...
openapi {
client(file) {
lombok = true
}
}
}
You can create objects like this:
var model = new Model()
.setAttrA(..)
.setAttrB(..);
Expected Behavior
I'd like to use this configuration:
to generate models with just the
@lombok.Builder(toBuilder = true)
annotationActual Behaviour
The problem relies on the fact that it add automatically other lombok annotation (even if I define
lombok = false
) as:@AllArgsConstructor
@NoArgsConstructor
@Data
and this implies that will create a conflict between the constructor generated by
@AllArgsConstructor
and the one generated by the plugin itselfSteps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version
id("io.micronaut.openapi") version '4.4.4