Skip to content

Commit c60c12a

Browse files
committed
add missing tests
1 parent acd54ee commit c60c12a

File tree

1 file changed

+25
-0
lines changed
  • openapi-parser/src/test/kotlin/io/openapiparser

1 file changed

+25
-0
lines changed

openapi-parser/src/test/kotlin/io/openapiparser/RefSpec.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package io.openapiparser
77

88
import io.kotest.core.spec.style.StringSpec
99
import io.kotest.matchers.booleans.shouldBeTrue
10+
import io.kotest.matchers.collections.shouldContainExactly
1011
import io.kotest.matchers.shouldBe
1112
import io.openapiparser.support.ApiBuilder
1213
import io.openapiparser.support.getParameters
@@ -29,6 +30,30 @@ class RefSpec: StringSpec({
2930
ref.properties["bar"]!!.type shouldBe "string"
3031
}
3132

33+
"parses ref into another file, v31" {
34+
val api = ApiBuilder().buildOpenApi31("/ref/v3x/ref-into-another-file/openapi.yaml")
35+
36+
val schema = api.getResponseSchema("/foo", "200", "application/json")
37+
schema.ref shouldBe "foo.yaml#/Foo"
38+
39+
val ref = schema.refObject
40+
ref.type shouldContainExactly listOf("object")
41+
ref.properties.size shouldBe 1
42+
ref.properties["bar"]!!.type shouldContainExactly listOf("string")
43+
}
44+
45+
"parses ref into another file, v32" {
46+
val api = ApiBuilder().buildOpenApi32("/ref/v3x/ref-into-another-file/openapi.yaml")
47+
48+
val schema = api.getResponseSchema("/foo", "200", "application/json")
49+
schema.ref shouldBe "foo.yaml#/Foo"
50+
51+
val ref = schema.refObject
52+
ref.type shouldContainExactly listOf("object")
53+
ref.properties.size shouldBe 1
54+
ref.properties["bar"]!!.type shouldContainExactly listOf("string")
55+
}
56+
3257
"parses ref array items with nested ref" {
3358
val api = ApiBuilder()
3459
.buildOpenApi30("/v30/ref-array-items-nested/openapi.yaml")

0 commit comments

Comments
 (0)