Skip to content

Commit

Permalink
use model utils check instead of instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Apr 11, 2024
1 parent 03af25c commit b4c315e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
String key = propertiesEntry.getKey();
Schema property = propertiesEntry.getValue();
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
&& ((ObjectSchema) property).getProperties().size() > 0) {
ObjectSchema op = (ObjectSchema) property;
if (ModelUtils.isObjectSchema(property)) {
Schema op = property;
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
Schema model = modelFromProperty(openAPI, op, modelName);
String existing = matchGenerated(model);
Expand All @@ -789,8 +788,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
}
} else if (ModelUtils.isArraySchema(property)) {
Schema inner = ModelUtils.getSchemaItems(property);
if (inner instanceof ObjectSchema) {
ObjectSchema op = (ObjectSchema) inner;
if (ModelUtils.isObjectSchema(inner)) {
Schema op = inner;
if (op.getProperties() != null && op.getProperties().size() > 0) {
flattenProperties(openAPI, op.getProperties(), path);
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
Expand Down Expand Up @@ -819,8 +818,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
}
} else if (ModelUtils.isMapSchema(property)) {
Schema inner = ModelUtils.getAdditionalProperties(property);
if (inner instanceof ObjectSchema) {
ObjectSchema op = (ObjectSchema) inner;
if (ModelUtils.isObjectSchema(inner)) {
Schema op = inner;
if (op.getProperties() != null && op.getProperties().size() > 0) {
flattenProperties(openAPI, op.getProperties(), path);
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private boolean isEnumSchema(Schema schema) {
private void collectEnumSchemas(String parentName, String sName, Schema schema) {
if (ModelUtils.isArraySchema(schema)) {
collectEnumSchemas(parentName, sName, ModelUtils.getSchemaItems(schema));
} else if (schema instanceof MapSchema && schema.getAdditionalProperties() instanceof Schema) {
} else if (ModelUtils.isMapSchema(schema) && schema.getAdditionalProperties() instanceof Schema) {
collectEnumSchemas(parentName, sName, (Schema) schema.getAdditionalProperties());
} else if (isEnumSchema(schema)) {
String h = hashEnum(schema);
Expand Down

0 comments on commit b4c315e

Please sign in to comment.