Skip to content

Commit b4c315e

Browse files
committed
use model utils check instead of instanceof
1 parent 03af25c commit b4c315e

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
770770
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
771771
String key = propertiesEntry.getKey();
772772
Schema property = propertiesEntry.getValue();
773-
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
774-
&& ((ObjectSchema) property).getProperties().size() > 0) {
775-
ObjectSchema op = (ObjectSchema) property;
773+
if (ModelUtils.isObjectSchema(property)) {
774+
Schema op = property;
776775
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
777776
Schema model = modelFromProperty(openAPI, op, modelName);
778777
String existing = matchGenerated(model);
@@ -789,8 +788,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
789788
}
790789
} else if (ModelUtils.isArraySchema(property)) {
791790
Schema inner = ModelUtils.getSchemaItems(property);
792-
if (inner instanceof ObjectSchema) {
793-
ObjectSchema op = (ObjectSchema) inner;
791+
if (ModelUtils.isObjectSchema(inner)) {
792+
Schema op = inner;
794793
if (op.getProperties() != null && op.getProperties().size() > 0) {
795794
flattenProperties(openAPI, op.getProperties(), path);
796795
String modelName = resolveModelName(op.getTitle(), path + "_" + key);
@@ -819,8 +818,8 @@ private void flattenProperties(OpenAPI openAPI, Map<String, Schema> properties,
819818
}
820819
} else if (ModelUtils.isMapSchema(property)) {
821820
Schema inner = ModelUtils.getAdditionalProperties(property);
822-
if (inner instanceof ObjectSchema) {
823-
ObjectSchema op = (ObjectSchema) inner;
821+
if (ModelUtils.isObjectSchema(inner)) {
822+
Schema op = inner;
824823
if (op.getProperties() != null && op.getProperties().size() > 0) {
825824
flattenProperties(openAPI, op.getProperties(), path);
826825
String modelName = resolveModelName(op.getTitle(), path + "_" + key);

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private boolean isEnumSchema(Schema schema) {
281281
private void collectEnumSchemas(String parentName, String sName, Schema schema) {
282282
if (ModelUtils.isArraySchema(schema)) {
283283
collectEnumSchemas(parentName, sName, ModelUtils.getSchemaItems(schema));
284-
} else if (schema instanceof MapSchema && schema.getAdditionalProperties() instanceof Schema) {
284+
} else if (ModelUtils.isMapSchema(schema) && schema.getAdditionalProperties() instanceof Schema) {
285285
collectEnumSchemas(parentName, sName, (Schema) schema.getAdditionalProperties());
286286
} else if (isEnumSchema(schema)) {
287287
String h = hashEnum(schema);

0 commit comments

Comments
 (0)