diff --git a/lib/swagger.js b/lib/swagger.js index 174f8f7f3..2ec4b1947 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -29,9 +29,16 @@ exports.run = function({ args, opts }) { function success(data) { const msg = data.headers.location - ? `You've successfully uploaded a new swagger file to your Readme.io project! You can view it here directly: ${data.headers.location}` + ? `You've successfully uploaded a new swagger file to your Readme project! See what was imported here: ${data.headers.location}` : 'Success!'; + console.log(msg.green); + console.log( + `Run 'rdme swagger FILE --key=API_KEY --id=${ + // eslint-disable-next-line + JSON.parse(data.body)._id + }' to update this spec in the future.`, + ); } function error(err) { diff --git a/test/swagger.test.js b/test/swagger.test.js index 2eb6ebfa7..f60033494 100644 --- a/test/swagger.test.js +++ b/test/swagger.test.js @@ -35,7 +35,7 @@ describe('swagger command', () => { const mock = nock(config.host) .post('/api/v1/api-specification', body => body.match('form-data; name="spec"')) .basicAuth({ user: key }) - .reply(201); + .reply(201, { body: '{ id: 1 }' }); return swagger(['./test/fixtures/swagger.json'], { key }).then(() => mock.done()); }); @@ -45,7 +45,7 @@ describe('swagger command', () => { const mock = nock(config.host) .put(`/api/v1/api-specification/${id}`, body => body.match('form-data; name="spec"')) .basicAuth({ user: key }) - .reply(201); + .reply(201, { body: '{ id: 1 }' }); return swagger(['./test/fixtures/swagger.json'], { key, id }).then(() => mock.done()); }); @@ -55,7 +55,7 @@ describe('swagger command', () => { const mock = nock(config.host) .put(`/api/v1/api-specification/${id}`, body => body.match('form-data; name="spec"')) .basicAuth({ user: key }) - .reply(201); + .reply(201, { body: '{ id: 1 }' }); return swagger(['./test/fixtures/swagger.json'], { token: `${key}-${id}` }).then(() => mock.done(),