From e2aa7ad3bf4fb5749c50587e7b486ff02069719f Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Fri, 5 Jan 2018 15:30:39 -0600 Subject: [PATCH 1/5] int64 becomes a string --- lib/generators/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generators/index.js b/lib/generators/index.js index 9a300dd..c73f808 100644 --- a/lib/generators/index.js +++ b/lib/generators/index.js @@ -109,6 +109,9 @@ const integerMock = schema => { } else { intmock = Chance.integer(opts); } + if (schema.format === 'int64') { + intmock = String(intmock); + } return intmock; }; From 5568c9d80d36dae97dae1e7b52d2dbdd6872bcb3 Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Fri, 5 Jan 2018 15:41:47 -0600 Subject: [PATCH 2/5] for number too --- lib/generators/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generators/index.js b/lib/generators/index.js index c73f808..e249eec 100644 --- a/lib/generators/index.js +++ b/lib/generators/index.js @@ -151,6 +151,9 @@ const numberMock = schema => { } else { nummock = Chance.floating(opts); } + if (schema.format === 'int64') { + nummock = String(nummock); + } return nummock; }; From 9f811b9a730a17107d678fe07de8bbe3603e65c9 Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Fri, 5 Jan 2018 15:49:15 -0600 Subject: [PATCH 3/5] Updated tests. --- tests/request_mockgen.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/request_mockgen.js b/tests/request_mockgen.js index cd805df..12cb172 100644 --- a/tests/request_mockgen.js +++ b/tests/request_mockgen.js @@ -88,8 +88,8 @@ describe('Request Mock generator', () => { Assert.ok(request.body, 'Generated body request'); let order = request.body; Assert.ok(typeof order === 'object', 'OK value for body'); - Assert.ok(Number.isInteger(order.id), 'order.id is integer'); - Assert.ok(Number.isInteger(order.petId), 'order.petId is integer'); + Assert.ok(typeof order.id === 'string', 'order.id is string (int64)'); + Assert.ok(typeof order.petId === 'string', 'order.petId is string (int64)'); Assert.ok(Number.isInteger(order.quantity), 'order.quantity is integer'); Assert.ok(typeof order.shipDate === 'string', 'order.shipDate is string'); Assert.ok(['placed','approved','delivered'].indexOf(order.status) !== -1, 'order.status is enum'); @@ -112,7 +112,7 @@ describe('Request Mock generator', () => { Assert.ok(users.length === 1, 'Created a request array of users'); let user = users[0]; Assert.ok(typeof user === 'object', 'OK value for user request'); - Assert.ok(Number.isInteger(user.id), 'user.id is integer'); + Assert.ok(typeof user.id === 'string', 'user.id is string (int64)'); Assert.ok(Number.isInteger(user.userStatus), 'user.userStatus is integer'); Assert.ok(typeof user.username === 'string', 'user.username is string'); From c17d148008af4eff85fc51577ecbfa41b6b0dc4b Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Fri, 5 Jan 2018 15:51:02 -0600 Subject: [PATCH 4/5] updated tests for string int64 --- tests/response_mockgen.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/response_mockgen.js b/tests/response_mockgen.js index 5af1d85..d1c7078 100644 --- a/tests/response_mockgen.js +++ b/tests/response_mockgen.js @@ -16,8 +16,8 @@ describe('Response Mock generator', () => { Assert.ok(mock, 'Generated mock'); let resp = mock.responses; Assert.ok(resp, 'Generated response'); - Assert.ok(Number.isInteger(resp.id), 'id is integer'); - Assert.ok(Number.isInteger(resp.petId), 'petId is integer'); + Assert.ok(typeof resp.id === 'string', 'id is string (int64)'); + Assert.ok(typeof resp.petId === 'string'), 'petId is string (int64)'); Assert.ok([ 1, 3, 5 ].indexOf(resp.quantity) != -1, 'quantity is integer enum'); Assert.ok(typeof resp.shipDate === 'string', 'shipDate is string'); Assert.ok(['placed','approved','delivered'].indexOf(resp.status) !== -1, 'status is enum'); @@ -40,7 +40,7 @@ describe('Response Mock generator', () => { Assert.ok(Array.isArray(resp), 'response is Pet array'); let pet = resp[0]; Assert.ok(pet, 'Ok Pet response'); - Assert.ok(Number.isInteger(pet.id), 'id is integer'); + Assert.ok(typeof pet.petId === 'string', 'id is string (int64)'); //TODO add asserts for pending props done(); }); From 68c5e1701608383cac3466d172fbbb3d99317263 Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Fri, 5 Jan 2018 15:57:52 -0600 Subject: [PATCH 5/5] typo --- tests/response_mockgen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/response_mockgen.js b/tests/response_mockgen.js index d1c7078..831e50f 100644 --- a/tests/response_mockgen.js +++ b/tests/response_mockgen.js @@ -17,7 +17,7 @@ describe('Response Mock generator', () => { let resp = mock.responses; Assert.ok(resp, 'Generated response'); Assert.ok(typeof resp.id === 'string', 'id is string (int64)'); - Assert.ok(typeof resp.petId === 'string'), 'petId is string (int64)'); + Assert.ok(typeof resp.petId === 'string', 'petId is string (int64)'); Assert.ok([ 1, 3, 5 ].indexOf(resp.quantity) != -1, 'quantity is integer enum'); Assert.ok(typeof resp.shipDate === 'string', 'shipDate is string'); Assert.ok(['placed','approved','delivered'].indexOf(resp.status) !== -1, 'status is enum');