diff --git a/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java b/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java index c9816994eda7f004c1439d9b3e4e1110dac2a377..e049eb4bfb615677a454626e6caa1c5a2f2b2bec 100644 --- a/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java +++ b/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java @@ -436,9 +436,25 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator { } } } + + private void getAllProperties(Schema<?> schema, Map<String, Schema> properties) { + List<Schema> xOf = schema.getAllOf(); + if (xOf == null) + xOf = schema.getAnyOf(); + if (xOf == null) + xOf = schema.getOneOf(); + if (xOf != null) { + for (Schema ofSchema : xOf) + this.getAllProperties(ofSchema, properties); + } + if (schema.getProperties() != null) + properties.putAll(schema.getProperties()); + } private DataType translate(Schema<?> schema, String prefix, DataType superType) { - if (getSchemaType(schema) == null && (schema.getProperties() == null || schema.getProperties().isEmpty())) { + Map<String, Schema> properties = new Hashtable<>(); + this.getAllProperties(schema, properties); + if (getSchemaType(schema) == null && properties.isEmpty()) { if (schema.getName() == null) { System.out.println("Why?"); } @@ -448,8 +464,7 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator { if (schema.getName() == null) { name = prefix + "___item"; } - if (schema.getProperties() != null && !schema.getProperties().isEmpty() - || getSchemaType(schema).equals("object")) { + if (!properties.isEmpty() || getSchemaType(schema).equals("object")) { DataType t = translateObject(schema, name); addSuperType(t, superType); return t; @@ -505,12 +520,14 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator { } private DataType translateObject(Schema<?> schema, String name) { + Map<String, Schema> properties = new Hashtable<>(); + this.getAllProperties(schema, properties); StructuredDataType dataType = getStructuredDataTypeFor(name); - if (schema.getProperties() == null || !dataType.getMember().isEmpty()) { + if (properties.isEmpty() || !dataType.getMember().isEmpty()) { return dataType; } - for (Object propertyName : schema.getProperties().keySet()) { - Schema<?> propertySchema = (Schema<?>) schema.getProperties().get(propertyName); + for (Object propertyName : properties.keySet()) { + Schema<?> propertySchema = (Schema<?>) properties.get(propertyName); String reference = propertySchema.get$ref(); DataType memberType = null; if (reference != null) {