-
-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestscope: compile-timespecification
Description
I use lombok with the openApi plugin and all works well, unless I use a field with @Data. @Data generates setters that return the object after use. If this happens, the openApi spec generated becomes a self reference:
DataClass": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"value1": {
"type": "integer",
"format": "int32"
},
"nonFinalIntegerValue": {
"$ref": "#/components/schemas/DataClass"
},
},
For example:
@Data @OpenApiByFields(Visibility.PRIVATE)
public class DataClass
private final String name;
private final int finalIntegerValue; // Shows up correctly in the spec as it's final so no setter is generated
private int nonFinalIntegerValue; // Shows up as a self reference
// Generated
public DataClass nonFinalIntegerValue(int nonFinalIntegerValue) {
this.nonFinalIntegerValue = nonFinalIntegerValue;
return this;
}
Generated setters:
public DataClass
The only way I'm able to undo this is by manually writing out the setters and adding @OpenApiIgnore above them. Is there no way to ensure that @OpenApiByFields ONLY looks at fields and ignores any methods?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestscope: compile-timespecification
Type
Projects
Status
✅ Done