forked from loafle/openapi-generator-original
SortModelPropertiesByRequiredFlag - simplified comparison to order boolean false first (#20602)
This commit is contained in:
parent
e1130c343a
commit
055605b075
@ -3190,14 +3190,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void SortModelPropertiesByRequiredFlag(CodegenModel model) {
|
protected void SortModelPropertiesByRequiredFlag(CodegenModel model) {
|
||||||
Comparator<CodegenProperty> comparator = new Comparator<CodegenProperty>() {
|
Comparator<CodegenProperty> comparator = Comparator.comparing(prop -> !prop.required);
|
||||||
@Override
|
|
||||||
public int compare(CodegenProperty one, CodegenProperty another) {
|
|
||||||
if (one.required == another.required) return 0;
|
|
||||||
else if (one.required) return -1;
|
|
||||||
else return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Collections.sort(model.vars, comparator);
|
Collections.sort(model.vars, comparator);
|
||||||
Collections.sort(model.allVars, comparator);
|
Collections.sort(model.allVars, comparator);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user