This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
main/kotlin/io/openapiprocessor/core/model/datatypes
test/kotlin/io/openapiprocessor/core/model/datatypes Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,8 @@ class AllOfObjectDataType(
3434
3535 override val referencedImports: Set <String >
3636 get() {
37- return items
38- .filterIsInstance<ObjectDataType >()
39- .map { it.getImports() }
40- .flatten()
37+ return properties.values
38+ .flatMap { it.getImports() }
4139 .toSet()
4240 }
4341
Original file line number Diff line number Diff line change @@ -39,4 +39,33 @@ class ComposedObjectDataTypeSpec : StringSpec({
3939 composed.getImports() shouldBe setOf("pkg.FooX ")
4040 }
4141
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+
4271})
You can’t perform that action at this time.
0 commit comments