Skip to content

Commit

Permalink
fix(type): Only allow specified boolean when given
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jan 8, 2024
1 parent a6dc75d commit defa2d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/OpenApiType.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ private static function resolveIdentifier(string $context, array $definitions, s
"positive-int" => new OpenApiType(type: "integer", format: "int64", minimum: 1),
"negative-int" => new OpenApiType(type: "integer", format: "int64", maximum: -1),
"non-positive-int" => new OpenApiType(type: "integer", format: "int64", maximum: 0),
"bool", "boolean", "true", "false" => new OpenApiType(type: "boolean"),
"bool", "boolean" => new OpenApiType(type: "boolean"),
"true" => new OpenApiType(type: "boolean", enum: [true]),
"false" => new OpenApiType(type: "boolean", enum: [false]),
"double" => new OpenApiType(type: "number", format: "double"),
"float" => new OpenApiType(type: "number", format: "float"),
"mixed", "empty", "array" => new OpenApiType(type: "object"),
Expand Down
9 changes: 6 additions & 3 deletions tests/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,6 @@
"required": true,
"schema": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer",
"enum": [
Expand All @@ -1313,6 +1310,12 @@
"yes",
"no"
]
},
{
"type": "boolean",
"enum": [
true
]
}
]
}
Expand Down

0 comments on commit defa2d1

Please sign in to comment.