Skip to content

Commit

Permalink
fix OpenAPI 3.1 exclusiveMinimum/exclusiveMaximum result type (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauner committed Oct 4, 2024
1 parent 4df4079 commit 4606502
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ public Collection<String> 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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>()
schema("additionalProperties: {}").additionalProperties.shouldBeInstanceOf<Schema>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down

0 comments on commit 4606502

Please sign in to comment.