diff --git a/packages/core/src/getters/scalar.ts b/packages/core/src/getters/scalar.ts index c6a2ffdb1..2325b7dbe 100644 --- a/packages/core/src/getters/scalar.ts +++ b/packages/core/src/getters/scalar.ts @@ -52,7 +52,7 @@ export const getScalar = ({ } const itemWithConst = item as SchemaWithConst; - if (itemWithConst.const) { + if (itemWithConst.const !== undefined) { value = itemWithConst.const; } @@ -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; } diff --git a/tests/specifications/const.yaml b/tests/specifications/const.yaml index eef4de41c..ab7a3b105 100644 --- a/tests/specifications/const.yaml +++ b/tests/specifications/const.yaml @@ -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 @@ -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