Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int64 becomes a string #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/generators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const integerMock = schema => {
} else {
intmock = Chance.integer(opts);
}
if (schema.format === 'int64') {
intmock = String(intmock);
}
return intmock;
};

Expand Down Expand Up @@ -148,6 +151,9 @@ const numberMock = schema => {
} else {
nummock = Chance.floating(opts);
}
if (schema.format === 'int64') {
nummock = String(nummock);
}
return nummock;
};

Expand Down
6 changes: 3 additions & 3 deletions tests/request_mockgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');

Expand Down
6 changes: 3 additions & 3 deletions tests/response_mockgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
});
Expand Down