diff --git a/openapi-parser/src/main/java/io/openapiparser/model/v31/Schema.java b/openapi-parser/src/main/java/io/openapiparser/model/v31/Schema.java index 35124535..a1f0b5f6 100644 --- a/openapi-parser/src/main/java/io/openapiparser/model/v31/Schema.java +++ b/openapi-parser/src/main/java/io/openapiparser/model/v31/Schema.java @@ -234,10 +234,10 @@ public Collection getType () { /** * JSON Schema Validation: validation Keywords for numeric instances (number and integer) * - * @return exclusive maximum or false if missing + * @return exclusive maximum or null if missing */ - public Boolean getExclusiveMaximum () { - return getBooleanOrDefault (EXCLUSIVE_MAXIMUM, false); + public @Nullable Number getExclusiveMaximum () { + return getNumberOrNull (EXCLUSIVE_MAXIMUM); } /** @@ -252,10 +252,10 @@ public Boolean getExclusiveMaximum () { /** * JSON Schema Validation: validation Keywords for numeric instances (number and integer) * - * @return exclusive minimum or false if missing + * @return exclusive minimum or null if missing */ - public Boolean getExclusiveMinimum () { - return getBooleanOrDefault (EXCLUSIVE_MINIMUM, false); + public Number getExclusiveMinimum () { + return getNumberOrNull (EXCLUSIVE_MINIMUM); } /** diff --git a/openapi-parser/src/test/kotlin/io/openapiparser/model/v30/SchemaSpec.kt b/openapi-parser/src/test/kotlin/io/openapiparser/model/v30/SchemaSpec.kt index 5dbccb6e..97763146 100644 --- a/openapi-parser/src/test/kotlin/io/openapiparser/model/v30/SchemaSpec.kt +++ b/openapi-parser/src/test/kotlin/io/openapiparser/model/v30/SchemaSpec.kt @@ -37,6 +37,14 @@ class SchemaSpec: StringSpec({ schema().nullable.shouldBeFalse() } + "gets schema exclusiveMaximum is false if missing" { + schema().exclusiveMaximum.shouldBeFalse() + } + + "gets schema exclusiveMinimum is false if missing" { + schema().exclusiveMinimum.shouldBeFalse() + } + "gets schema additionalProperties" { schema("additionalProperties: false").additionalProperties.shouldBeInstanceOf() schema("additionalProperties: {}").additionalProperties.shouldBeInstanceOf() diff --git a/openapi-parser/src/test/kotlin/io/openapiparser/model/v31/SchemaSpec.kt b/openapi-parser/src/test/kotlin/io/openapiparser/model/v31/SchemaSpec.kt index b86313d3..df74a4e3 100644 --- a/openapi-parser/src/test/kotlin/io/openapiparser/model/v31/SchemaSpec.kt +++ b/openapi-parser/src/test/kotlin/io/openapiparser/model/v31/SchemaSpec.kt @@ -70,6 +70,14 @@ class SchemaSpec: StringSpec({ schema().minContains shouldBe 1 } + "gets schema exclusiveMaximum is null if missing" { + schema().exclusiveMaximum.shouldBeNull() + } + + "gets schema exclusiveMinimum is null if missing" { + schema().exclusiveMinimum.shouldBeNull() + } + "gets schema dependentRequired" { val required = schema("dependentRequired: {bar: [foo]}").dependentRequired required shouldContainKey "bar" diff --git a/openapi-parser/src/test/kotlin/io/openapiparser/model/v3x/SchemaSpec.kt b/openapi-parser/src/test/kotlin/io/openapiparser/model/v3x/SchemaSpec.kt index c99507d7..2620537d 100644 --- a/openapi-parser/src/test/kotlin/io/openapiparser/model/v3x/SchemaSpec.kt +++ b/openapi-parser/src/test/kotlin/io/openapiparser/model/v3x/SchemaSpec.kt @@ -42,12 +42,7 @@ class SchemaSpec: StringSpec({ "gets schema exclusiveMaximum" { schema30("exclusiveMaximum: true").exclusiveMaximum.shouldBeTrue() - schema31("exclusiveMaximum: true").exclusiveMaximum.shouldBeTrue() - } - - "gets schema exclusiveMaximum is false if missing" { - schema30().exclusiveMaximum.shouldBeFalse() - schema31().exclusiveMaximum.shouldBeFalse() + schema31("exclusiveMaximum: 9.9").exclusiveMaximum shouldBe 9.9 } "gets schema minimum" { @@ -62,12 +57,7 @@ class SchemaSpec: StringSpec({ "gets schema exclusiveMinimum" { schema30("exclusiveMinimum: true").exclusiveMinimum.shouldBeTrue() - schema31("exclusiveMinimum: true").exclusiveMinimum.shouldBeTrue() - } - - "gets schema exclusiveMinimum is false if missing" { - schema30().exclusiveMinimum.shouldBeFalse() - schema31().exclusiveMinimum.shouldBeFalse() + schema31("exclusiveMinimum: 9.9").exclusiveMinimum shouldBe 9.9 } "gets schema maxLength" {