diff --git a/src/main/kotlin/com/cjbooms/fabrikt/model/SourceApi.kt b/src/main/kotlin/com/cjbooms/fabrikt/model/SourceApi.kt index 21603c5d..a949e473 100644 --- a/src/main/kotlin/com/cjbooms/fabrikt/model/SourceApi.kt +++ b/src/main/kotlin/com/cjbooms/fabrikt/model/SourceApi.kt @@ -49,7 +49,7 @@ data class SourceApi( val schemaErrors = api.schemas.entries.fold(emptyList()) { errors, entry -> val name = entry.key val schema = entry.value - if (schema.type == OasType.Object.type && ( + if (schema.type == OasType.Object.type && schema.properties?.isNotEmpty() == true && ( schema.oneOfSchemas?.isNotEmpty() == true || schema.allOfSchemas?.isNotEmpty() == true || schema.anyOfSchemas?.isNotEmpty() == true diff --git a/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt b/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt index a15248b6..798ad2e6 100644 --- a/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt +++ b/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt @@ -61,7 +61,11 @@ object KaizenParserExtensions { fun Schema.toMapValueClassName() = safeName().toMapValueClassName() - fun Schema.isSchemaLess() = isObjectType() && properties?.isEmpty() == true + fun Schema.isSchemaLess() = isObjectType() && properties?.isEmpty() == true && ( + oneOfSchemas?.isNotEmpty() != true && + allOfSchemas?.isNotEmpty() != true && + anyOfSchemas?.isNotEmpty() != true + ) fun Schema.isSimpleMapDefinition() = hasAdditionalProperties() && properties?.isEmpty() == true diff --git a/src/test/resources/examples/anyOfOneOfAllOf/api.yaml b/src/test/resources/examples/anyOfOneOfAllOf/api.yaml index 01941ead..fb73a759 100644 --- a/src/test/resources/examples/anyOfOneOfAllOf/api.yaml +++ b/src/test/resources/examples/anyOfOneOfAllOf/api.yaml @@ -21,6 +21,9 @@ components: type: integer ComplexParent: + required: + - top_level_prop + type: object allOf: - $ref: '#/components/schemas/ContainsNestedOneOf' - $ref: '#/components/schemas/ContainsNestedAnyOf'