Skip to content

Commit 2877e38

Browse files
committed
fix exclusive minimum/maximum for OpenAPI 3.1 (#188)
1 parent cd5141d commit 2877e38

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/parser/openapi/v31/Schema.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ class Schema(val schema: Schema31) : ParserSchema {
137137

138138
override fun getMaxItems(): Int? = schema.maxItems
139139

140-
override fun getMaximum (): Number? = schema.maximum
140+
override fun getMaximum (): Number? = schema.maximum ?: schema.exclusiveMaximum
141141

142-
override fun isExclusiveMaximum(): Boolean = schema.exclusiveMaximum
142+
override fun isExclusiveMaximum(): Boolean = schema.exclusiveMaximum != null
143143

144-
override fun getMinimum(): Number? = schema.minimum
144+
override fun getMinimum(): Number? = schema.minimum ?: schema.exclusiveMinimum
145145

146-
override fun isExclusiveMinimum(): Boolean = schema.exclusiveMinimum
146+
override fun isExclusiveMinimum(): Boolean = schema.exclusiveMinimum != null
147147

148148
override val pattern: String?
149149
get() = schema.pattern

openapi-processor-core/src/testInt/resources/tests/bean-validation/inputs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ items:
33
- inputs/openapi31.yaml
44
- inputs/required.yaml
55
- inputs/length.yaml
6-
- inputs/minmax.yaml
6+
- inputs/minmax30.yaml
7+
- inputs/minmax31.yaml
78
- inputs/items.yaml
89
- inputs/obj.yaml
910
- inputs/obj-components.yaml
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
get:
2+
tags:
3+
- endpoint
4+
parameters:
5+
- in: query
6+
name: min
7+
schema:
8+
type: integer
9+
format: int32
10+
minimum: 10
11+
- in: query
12+
name: min-ex
13+
schema:
14+
type: integer
15+
format: int32
16+
exclusiveMinimum: 10
17+
- in: query
18+
name: max
19+
schema:
20+
type: integer
21+
format: int32
22+
maximum: 20
23+
- in: query
24+
name: max-ex
25+
schema:
26+
type: integer
27+
format: int32
28+
exclusiveMaximum: 20
29+
- in: query
30+
name: min-max
31+
schema:
32+
type: integer
33+
format: int32
34+
minimum: 10
35+
maximum: 20
36+
- in: query
37+
name: min-max-ex
38+
schema:
39+
type: integer
40+
format: int32
41+
exclusiveMinimum: 10
42+
exclusiveMaximum: 20
43+
responses:
44+
'204':
45+
description: empty

openapi-processor-core/src/testInt/resources/tests/bean-validation/inputs/openapi30.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ paths:
1111
$ref: 'length.yaml'
1212

1313
/endpoint/minmax:
14-
$ref: 'minmax.yaml'
14+
$ref: 'minmax30.yaml'
1515

1616
/endpoint/items:
1717
$ref: 'items.yaml'

openapi-processor-core/src/testInt/resources/tests/bean-validation/inputs/openapi31.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ paths:
1111
$ref: 'length.yaml'
1212

1313
/endpoint/minmax:
14-
$ref: 'minmax.yaml'
14+
$ref: 'minmax31.yaml'
1515

1616
/endpoint/items:
1717
$ref: 'items.yaml'

0 commit comments

Comments
 (0)