@@ -13,8 +13,11 @@ import io.kotest.matchers.maps.shouldContainKey
1313import io.kotest.matchers.nulls.shouldBeNull
1414import io.kotest.matchers.nulls.shouldNotBeNull
1515import io.kotest.matchers.shouldBe
16+ import io.kotest.matchers.types.shouldBeInstanceOf
1617import io.openapiparser.model.v31.schema as schema31
17- import io.openapiparser.model.v31.schema as schema32
18+ import io.openapiparser.model.v31.Schema as Schema31
19+ import io.openapiparser.model.v32.schema as schema32
20+ import io.openapiparser.model.v32.Schema as Schema32
1821
1922/* *
2023 * @see [io.openapiparser.model.v3x.SchemaSpec]
@@ -42,6 +45,9 @@ class SchemaSpec: StringSpec({
4245 " gets schema type" {
4346 schema31("type: string").type shouldBe listOf("string")
4447 schema31("type: [string, object]").type shouldBe listOf("string", "object")
48+
49+ schema32("type: string").type shouldBe listOf("string")
50+ schema32("type: [string, object]").type shouldBe listOf("string", "object")
4551 }
4652
4753// "gets schema type throws if missing" {
@@ -50,44 +56,57 @@ class SchemaSpec: StringSpec({
5056
5157 " gets schema const" {
5258 schema31("const: foo").const shouldBe " foo"
59+ schema32("const: foo").const shouldBe " foo"
5360 }
5461
5562 " gets schema const is null if missing" {
5663 schema31().const.shouldBeNull()
64+ schema32().const.shouldBeNull()
5765 }
5866
5967 " gets schema maxContains" {
6068 schema31("maxContains: 9").maxContains shouldBe 9
69+ schema32("maxContains: 9").maxContains shouldBe 9
6170 }
6271
6372 " gets schema maxContains is null if missing" {
6473 schema31().maxContains.shouldBeNull()
74+ schema32().maxContains.shouldBeNull()
6575 }
6676
6777 " gets schema minContains" {
6878 schema31("minContains: 9").minContains shouldBe 9
79+ schema32("minContains: 9").minContains shouldBe 9
6980 }
7081
7182 " gets schema minContains is 1 if missing" {
7283 schema31().minContains shouldBe 1
84+ schema32().minContains shouldBe 1
7385 }
7486
7587 " gets schema exclusiveMaximum is null if missing" {
7688 schema31().exclusiveMaximum.shouldBeNull()
89+ schema32().exclusiveMaximum.shouldBeNull()
7790 }
7891
7992 " gets schema exclusiveMinimum is null if missing" {
8093 schema31().exclusiveMinimum.shouldBeNull()
94+ schema32().exclusiveMinimum.shouldBeNull()
8195 }
8296
8397 " gets schema dependentRequired" {
8498 val required = schema31("dependentRequired: {bar: [foo]}").dependentRequired
8599 required shouldContainKey " bar"
86100 required[" bar" ].shouldContainExactly("foo")
101+
102+ val required32 = schema32("dependentRequired: {bar: [foo]}").dependentRequired
103+ required32 shouldContainKey " bar"
104+ required32[" bar" ].shouldContainExactly("foo")
87105 }
88106
89107 " gets schema dependentRequired is empty if missing" {
90108 schema31().dependentRequired.shouldNotBeNull()
109+ schema32().dependentRequired.shouldNotBeNull()
91110 }
92111
93112 " gets schema patternProperties" {
@@ -101,41 +120,63 @@ class SchemaSpec: StringSpec({
101120 properties.size shouldBe 2
102121 properties[" foo" ].shouldNotBeNull()
103122 properties[" bar" ].shouldNotBeNull()
123+
124+ val properties32 = schema32(source).patternProperties
125+ properties32.size shouldBe 2
126+ properties32[" foo" ].shouldNotBeNull()
127+ properties32[" bar" ].shouldNotBeNull()
104128 }
105129
106130 " gets schema patternProperties is empty if missing" {
107131 schema31().patternProperties.shouldBeEmpty()
132+ schema32().patternProperties.shouldBeEmpty()
108133 }
109134
110135 " gets schema additionalProperties" {
111- schema31("additionalProperties: {}").additionalProperties.shouldNotBeNull()
136+ schema31("additionalProperties: {}").additionalProperties.shouldBeInstanceOf<Schema31 >()
137+ schema32("additionalProperties: {}").additionalProperties.shouldBeInstanceOf<Schema32 >()
138+ }
139+
140+ " gets schema additionalProperties boolean" {
141+ schema31("additionalProperties: true").additionalProperties shouldBe true
142+ schema31("additionalProperties: false").additionalProperties shouldBe false
143+
144+ schema32("additionalProperties: true").additionalProperties shouldBe true
145+ schema32("additionalProperties: false").additionalProperties shouldBe false
112146 }
113147
114148 " gets schema additionalProperties is null if missing" {
115149 schema31().additionalProperties.shouldBeNull()
150+ schema32().additionalProperties.shouldBeNull()
116151 }
117152
118153 " gets schema propertyNames" {
119154 schema31("propertyNames: {}").propertyNames.shouldNotBeNull()
155+ schema32("propertyNames: {}").propertyNames.shouldNotBeNull()
120156 }
121157
122158 " gets schema propertyNames is null if missing" {
123159 schema31().propertyNames.shouldBeNull()
160+ schema32().propertyNames.shouldBeNull()
124161 }
125162
126163 " gets schema prefixItems" {
127164 schema31("prefixItems: [{}]").prefixItems.size shouldBe 1
165+ schema32("prefixItems: [{}]").prefixItems.size shouldBe 1
128166 }
129167
130168 " gets schema prefixItems is empty if missing" {
131169 schema31().prefixItems.shouldBeEmpty()
170+ schema32().prefixItems.shouldBeEmpty()
132171 }
133172
134173 " gets schema contains" {
135174 schema31("contains: {}").contains.shouldNotBeNull()
175+ schema32("contains: {}").contains.shouldNotBeNull()
136176 }
137177
138178 " gets schema contains is null if missing" {
139179 schema31().contains.shouldBeNull()
180+ schema32().contains.shouldBeNull()
140181 }
141182})
0 commit comments