Skip to content

Commit

Permalink
fix: correct invalid use of cases in switch (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalelane authored Mar 8, 2024
1 parent 8ba6992 commit 9e456ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions test/mocks/kafka-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 10 additions & 4 deletions utils/Types.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,18 @@ 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':
case 'number':
return Math.random();

case ('string' || 'binary' || 'password'):
case 'string':
case 'binary':
case 'password':
if (format === 'uuid') {
return 'UUID.randomUUID()';
}
Expand All @@ -151,7 +156,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:
Expand Down

0 comments on commit 9e456ee

Please sign in to comment.