diff --git a/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v3/OpenAPIV3Generator.java b/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v3/OpenAPIV3Generator.java index f423be82d6e8d..f26ad6821c583 100644 --- a/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v3/OpenAPIV3Generator.java +++ b/metadata-service/openapi-servlet/src/main/java/io/datahubproject/openapi/v3/OpenAPIV3Generator.java @@ -547,12 +547,12 @@ private static void addAspectSchemas(final Components components, final AspectSp String $ref = schema.get$ref(); boolean isNameRequired = requiredNames.contains(name); if ($ref != null && !isNameRequired) { - // A non-required $ref property must be wrapped in a { allOf: [ $ref ] } + // A non-required $ref property must be wrapped in a { anyOf: [ $ref ] } // object to allow the // property to be marked as nullable schema.setType(TYPE_OBJECT); schema.set$ref(null); - schema.setAllOf(List.of(new Schema().$ref($ref))); + schema.setAnyOf(List.of(new Schema().$ref($ref))); } schema.setNullable(!isNameRequired); }); @@ -578,7 +578,7 @@ private static Schema buildAspectRefResponseSchema(final String aspectName) { "systemMetadata", new Schema<>() .type(TYPE_OBJECT) - .allOf(List.of(new Schema().$ref(PATH_DEFINITIONS + "SystemMetadata"))) + .anyOf(List.of(new Schema().$ref(PATH_DEFINITIONS + "SystemMetadata"))) .description("System metadata for the aspect.") .nullable(true)); return result; @@ -595,7 +595,7 @@ private static Schema buildAspectRefRequestSchema(final String aspectName) { "systemMetadata", new Schema<>() .type(TYPE_OBJECT) - .allOf(List.of(new Schema().$ref(PATH_DEFINITIONS + "SystemMetadata"))) + .anyOf(List.of(new Schema().$ref(PATH_DEFINITIONS + "SystemMetadata"))) .description("System metadata for the aspect.") .nullable(true)); @@ -681,7 +681,7 @@ private static Schema buildEntityBatchGetRequestSchema( } private static Schema buildAspectRef(final String aspect, final boolean withSystemMetadata) { - // A non-required $ref property must be wrapped in a { allOf: [ $ref ] } + // A non-required $ref property must be wrapped in a { anyOf: [ $ref ] } // object to allow the // property to be marked as nullable final Schema result = new Schema<>(); @@ -697,7 +697,7 @@ private static Schema buildAspectRef(final String aspect, final boolean withSyst internalRef = String.format(FORMAT_PATH_DEFINITIONS, toUpperFirst(aspect), ASPECT_REQUEST_SUFFIX); } - result.setAllOf(List.of(new Schema().$ref(internalRef))); + result.setAnyOf(List.of(new Schema().$ref(internalRef))); return result; } diff --git a/metadata-service/openapi-servlet/src/test/java/io/datahubproject/openapi/v3/OpenAPIV3GeneratorTest.java b/metadata-service/openapi-servlet/src/test/java/io/datahubproject/openapi/v3/OpenAPIV3GeneratorTest.java index b0fbbce05a0f8..e1568017156d9 100644 --- a/metadata-service/openapi-servlet/src/test/java/io/datahubproject/openapi/v3/OpenAPIV3GeneratorTest.java +++ b/metadata-service/openapi-servlet/src/test/java/io/datahubproject/openapi/v3/OpenAPIV3GeneratorTest.java @@ -61,12 +61,12 @@ public void testOpenApiSpecBuilder() throws Exception { assertFalse(requiredNames.contains("name")); assertTrue(name.getNullable()); - // Assert non-required $ref properties are replaced by nullable { allOf: [ $ref ] } objects + // Assert non-required $ref properties are replaced by nullable { anyOf: [ $ref ] } objects Schema created = properties.get("created"); assertFalse(requiredNames.contains("created")); assertEquals("object", created.getType()); assertNull(created.get$ref()); - assertEquals(List.of(new Schema().$ref("#/components/schemas/TimeStamp")), created.getAllOf()); + assertEquals(List.of(new Schema().$ref("#/components/schemas/TimeStamp")), created.getAnyOf()); assertTrue(created.getNullable()); // Assert systemMetadata property on response schema is optional. @@ -81,7 +81,7 @@ public void testOpenApiSpecBuilder() throws Exception { assertNull(systemMetadata.get$ref()); assertEquals( List.of(new Schema().$ref("#/components/schemas/SystemMetadata")), - systemMetadata.getAllOf()); + systemMetadata.getAnyOf()); assertTrue(systemMetadata.getNullable()); // Assert enum property is string.