Skip to content

Commit

Permalink
fix: Correctly set type for false or 0 constants (#1653)
Browse files Browse the repository at this point in the history
* chore: Expand const specification with false and 0 constants

* fix: Correctly set type for false or 0 constants
  • Loading branch information
RinseV authored Oct 1, 2024
1 parent b3b0306 commit 4692501
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/getters/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getScalar = ({
}

const itemWithConst = item as SchemaWithConst;
if (itemWithConst.const) {
if (itemWithConst.const !== undefined) {
value = itemWithConst.const;
}

Expand All @@ -73,7 +73,7 @@ export const getScalar = ({
let value = 'boolean';

const itemWithConst = item as SchemaWithConst;
if (itemWithConst.const) {
if (itemWithConst.const !== undefined) {
value = itemWithConst.const;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/specifications/const.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ components:
type: object
required:
- value
- valueFalse
- valueNullable
properties:
value:
type: boolean
const: true
valueFalse:
type: boolean
const: false
valueNullable:
type:
- boolean
Expand All @@ -40,11 +44,15 @@ components:
type: object
required:
- value
- valueZero
- valueNullable
properties:
value:
type: number
const: 1
valueZero:
type: number
const: 0
valueNullable:
type:
- number
Expand Down

0 comments on commit 4692501

Please sign in to comment.