Skip to content

Commit 318e272

Browse files
committed
Do not enumerate [true, false] for boolean type
1 parent f292798 commit 318e272

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.4.50] - 2022-04-28
8+
9+
### Fixed
10+
11+
- Exhaustive boolean values elision in const block
12+
713
## [0.4.49] - 2022-04-28
814

915
### Fixed
@@ -288,6 +294,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
288294
### Fixed
289295
- Removed unnecessary regexp dependency, #7.
290296

297+
[0.4.50]: https://github.com/swaggest/go-code-builder/compare/v0.4.49...v0.4.50
291298
[0.4.49]: https://github.com/swaggest/go-code-builder/compare/v0.4.48...v0.4.49
292299
[0.4.48]: https://github.com/swaggest/go-code-builder/compare/v0.4.47...v0.4.48
293300
[0.4.47]: https://github.com/swaggest/go-code-builder/compare/v0.4.46...v0.4.47

src/JsonSchema/TypeBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@ private function processEnum(NamedType $baseType)
658658
$enumSchemas = null;
659659
}
660660

661+
if ($enum !== null && count($enum) === 2
662+
&& $this->schema->type === Schema::BOOLEAN) {
663+
return $baseType;
664+
}
665+
661666
if ($enum !== null) {
662667
if ($this->goBuilder->options->hideConstProperties && count($enum) === 1) {
663668
return $baseType;

0 commit comments

Comments
 (0)