From 4d14e4a46a0e68fb4bc7f3e3f7cfae4b0f3d16d5 Mon Sep 17 00:00:00 2001 From: Brenda Rearden Date: Thu, 23 Mar 2023 08:06:53 -0700 Subject: [PATCH] fix(oas): change how exclusiveMin & Max are handled (#222) --- src/oas/transformers/schema/__tests__/schema.spec.ts | 10 ++++++++++ src/oas/transformers/schema/keywords/number.ts | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/oas/transformers/schema/__tests__/schema.spec.ts b/src/oas/transformers/schema/__tests__/schema.spec.ts index a1c2db2..79df535 100644 --- a/src/oas/transformers/schema/__tests__/schema.spec.ts +++ b/src/oas/transformers/schema/__tests__/schema.spec.ts @@ -61,6 +61,11 @@ describe('translateSchemaObject', () => { exclusiveMinimum: false, exclusiveMaximum: false, }, + { + type: 'integer', + exclusiveMinimum: 2, + exclusiveMaximum: 10, + }, ], }), ).toStrictEqual({ @@ -89,6 +94,11 @@ describe('translateSchemaObject', () => { minimum: 2, maximum: 10, }, + { + type: 'integer', + exclusiveMinimum: 2, + exclusiveMaximum: 10, + }, ], }); }); diff --git a/src/oas/transformers/schema/keywords/number.ts b/src/oas/transformers/schema/keywords/number.ts index a234ef0..128fc84 100644 --- a/src/oas/transformers/schema/keywords/number.ts +++ b/src/oas/transformers/schema/keywords/number.ts @@ -9,7 +9,9 @@ function createRangeConverter( return schema => { if (!(keyword in schema)) return; const { [keyword]: value } = schema; - if (value !== true || typeof schema[valueKeyword] !== 'number') { + if (typeof value === 'number') { + return; + } else if (value !== true || typeof schema[valueKeyword] !== 'number') { delete schema[keyword]; } else { schema[keyword] = schema[valueKeyword];