Skip to content

Commit b284095

Browse files
committed
use schema related to a ref schema property
1 parent 747c0e4 commit b284095

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.swagger.v3.oas.models.OpenAPI;
2222
import io.swagger.v3.oas.models.Operation;
2323
import io.swagger.v3.oas.models.PathItem;
24+
import io.swagger.v3.oas.models.media.Schema;
2425
import org.apache.commons.lang3.StringUtils;
2526
import org.slf4j.Logger;
2627
import org.slf4j.LoggerFactory;
@@ -468,6 +469,19 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
468469
}
469470
}
470471

472+
@Override
473+
public CodegenProperty fromProperty(String name, Schema propertySchema) {
474+
CodegenProperty codegenProperty = super.fromProperty(name, propertySchema);
475+
if (propertySchema != null && propertySchema.get$ref() != null) {
476+
Schema refSchema = OpenAPIUtil.getSchemaFromRefSchema(propertySchema, this.openAPI);
477+
if (refSchema != null && !isObjectSchema(refSchema) && refSchema.getEnum() == null) {
478+
setSchemaProperties(name, codegenProperty, refSchema);
479+
processPropertySchemaTypes(name, codegenProperty, refSchema);
480+
}
481+
}
482+
return codegenProperty;
483+
}
484+
471485
@Override
472486
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
473487
if((isDefaultLibrary() || isSpringMvcLibrary()) && !useTags) {

0 commit comments

Comments
 (0)