From 8dff3a583676f8fc8f24aa2797837b423355595e Mon Sep 17 00:00:00 2001 From: Dale Lane Date: Fri, 8 Mar 2024 16:37:50 +0000 Subject: [PATCH 1/2] fix: correct invalid use of cases in switch Signed-off-by: Dale Lane --- utils/Types.utils.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/utils/Types.utils.js b/utils/Types.utils.js index a4e7830..7f3a6ca 100644 --- a/utils/Types.utils.js +++ b/utils/Types.utils.js @@ -133,13 +133,17 @@ export function asyncApiToDemoValue(type, format) { const boolWords = ['true', 'false']; switch (type) { - case ('integer' || 'long'): + case 'integer': + case 'long': return parseInt(Math.random() * 1000, 10); - case ('float' || 'double'): + case 'float': + case 'double': return Math.random(); - case ('string' || 'binary' || 'password'): + case 'string': + case 'binary': + case 'password': if (format === 'uuid') { return 'UUID.randomUUID()'; } @@ -151,7 +155,8 @@ export function asyncApiToDemoValue(type, format) { case 'boolean': return boolWords[Math.floor(Math.random()*boolWords.length)]; - case ('date' || 'dateTime'): + case 'date': + case 'dateTime': return (new Date()).toISOString().split('T')[0]; default: From 49f9039a90683f9fc210f5421ec385eca5f16097 Mon Sep 17 00:00:00 2001 From: Dale Lane Date: Fri, 8 Mar 2024 17:44:18 +0000 Subject: [PATCH 2/2] fix: add missing data type Signed-off-by: Dale Lane --- test/mocks/kafka-example.yml | 3 +++ utils/Types.utils.js | 1 + 2 files changed, 4 insertions(+) diff --git a/test/mocks/kafka-example.yml b/test/mocks/kafka-example.yml index d4f7b39..006441c 100644 --- a/test/mocks/kafka-example.yml +++ b/test/mocks/kafka-example.yml @@ -42,6 +42,9 @@ components: genre: type: string description: Primary song genre + something: + type: number + description: some non-integer number length: type: integer description: Track length in seconds diff --git a/utils/Types.utils.js b/utils/Types.utils.js index 7f3a6ca..79f7044 100644 --- a/utils/Types.utils.js +++ b/utils/Types.utils.js @@ -139,6 +139,7 @@ export function asyncApiToDemoValue(type, format) { case 'float': case 'double': + case 'number': return Math.random(); case 'string':