forked from loafle/openapi-generator-original
[Bug][Go] consider allOf schemas for rendering string default vaules (#14684)
This commit is contained in:
parent
7968349991
commit
e9f55c0dd9
@ -387,10 +387,29 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if at least one of the allOf pieces of a schema are of type string
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
private boolean isAllOfStringSchema(Schema schema) {
|
||||
if (schema.getAllOf() != null) {
|
||||
Iterator<Schema> it = schema.getAllOf().iterator();
|
||||
while (it.hasNext()) {
|
||||
Schema childSchema = ModelUtils.getReferencedSchema(this.openAPI, it.next());
|
||||
if (ModelUtils.isStringSchema(childSchema)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
p = ModelUtils.getReferencedSchema(this.openAPI, p);
|
||||
if (ModelUtils.isStringSchema(p)) {
|
||||
if (ModelUtils.isStringSchema(p) || isAllOfStringSchema(p)) {
|
||||
Object defaultObj = p.getDefault();
|
||||
if (defaultObj != null) {
|
||||
if (defaultObj instanceof java.lang.String) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user