This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree 2 files changed +31
-4
lines changed
main/kotlin/io/openapiprocessor/core/model/datatypes
test/kotlin/io/openapiprocessor/core/model/datatypes 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,8 @@ class AllOfObjectDataType(
34
34
35
35
override val referencedImports: Set <String >
36
36
get() {
37
- return items
38
- .filterIsInstance<ObjectDataType >()
39
- .map { it.getImports() }
40
- .flatten()
37
+ return properties.values
38
+ .flatMap { it.getImports() }
41
39
.toSet()
42
40
}
43
41
Original file line number Diff line number Diff line change @@ -39,4 +39,33 @@ class ComposedObjectDataTypeSpec : StringSpec({
39
39
composed.getImports() shouldBe setOf("pkg.FooX ")
40
40
}
41
41
42
+ // https://github.com/openapi-processor/openapi-processor-spring/issues/128
43
+ " allOf creates imports for all items" {
44
+ val composed = AllOfObjectDataType (DataTypeName ("Foo "), "pkg", listOf(
45
+ ObjectDataType ("Foo ", "pkg", linkedMapOf(
46
+ "foo" to OffsetDateTimeDataType ()
47
+ )),
48
+ ObjectDataType ("Bar ", "pkg", linkedMapOf(
49
+ "bar" to ObjectDataType ("BarBar ", "pkg", linkedMapOf(
50
+ "barbar" to OffsetDateTimeDataType ()
51
+ ))
52
+ ))
53
+ ))
54
+
55
+ composed.getImports() shouldBe setOf("pkg.Foo ")
56
+ composed.referencedImports shouldBe setOf("java.time.OffsetDateTime ", "pkg.BarBar ")
57
+ }
58
+
59
+ " allOf creates does not leak import for type-less item" {
60
+ val composed = AllOfObjectDataType (DataTypeName ("Foo "), "pkg", listOf(
61
+ ObjectDataType ("Bar ", "pkg", linkedMapOf(
62
+ "bar" to StringDataType ())
63
+ ),
64
+ NoDataType ("Leak ")
65
+ ))
66
+
67
+ composed.getImports() shouldBe setOf("pkg.Foo ")
68
+ composed.referencedImports shouldBe setOf("java.lang.String ")
69
+ }
70
+
42
71
})
You can’t perform that action at this time.
0 commit comments