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

Ignore deprecation check #45

Merged
merged 2 commits into from
Dec 29, 2016
Merged
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
2 changes: 2 additions & 0 deletions example/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module.exports.setup = function(app) {
* type: string
* password:
* type: string
* path:
* type: string
*/

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/swagger-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ function addDataToSwaggerObject(swaggerObject, data) {
function seekWrong(list, wrongSet, problems) {
var iterator = new RecursiveIterator(list, 0, false);
for (var item = iterator.next(); !item.done; item = iterator.next()) {
if (wrongSet.indexOf(item.value.key) > 0) {
var isDirectChildOfProperties =
item.value.path[item.value.path.length - 2] === 'properties';

if (wrongSet.indexOf(item.value.key) > 0 && !isDirectChildOfProperties) {
problems.push(item.value.key);
}
}
Expand Down
22 changes: 17 additions & 5 deletions test/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,18 @@ describe('command line interface', function () {
done();
});
});


it('should warn when deprecated properties are used', function (done) {
var deprecatedProperties = process.env.PWD + '/bin/swagger-jsdoc.js -d example/swaggerDef.js test/fixtures/deprecated_routes.js';
exec(deprecatedProperties, function (error, stdout, stderr) {
if (error) {
throw new Error(error, stderr);
}
expect(stderr).to.contain('You are using properties to be deprecated');
done();
});
});

it('should require arguments with jsDoc data about an API', function (done) {
var missingApis = process.env.PWD + '/bin/swagger-jsdoc.js -d example/swaggerDef.js';
exec(missingApis, function (error, stdout, stderr) {
Expand All @@ -73,21 +84,22 @@ describe('command line interface', function () {
done();
});
});

it('should create swaggerSpec.json by default when the API input is good', function (done) {
var goodInput = process.env.PWD + '/bin/swagger-jsdoc.js -d example/swaggerDef.js example/routes.js';
exec(goodInput, function (error, stdout, stderr) {
if (error) {
throw new Error(error, stderr);
}
expect(stdout).to.contain('Swagger specification created successfully.');
expect(stderr).to.not.contain('You are using properties to be deprecated');
var specification = fs.statSync('swaggerSpec.json');
// Check that the physical file was created.
expect(specification.nlink).to.be.above(0);
done();
});
});

it('should accept custom configuration for output specification', function (done) {
var goodInput = process.env.PWD + '/bin/swagger-jsdoc.js -d example/swaggerDef.js -o customSpec.json example/routes.js';
exec(goodInput, function (error, stdout, stderr) {
Expand All @@ -100,8 +112,8 @@ describe('command line interface', function () {
expect(specification.nlink).to.be.above(0);
done();
});
});
});

// Cleanup test files if any.
after(function() {
var defaultSpecification = process.env.PWD + '/swaggerSpec.json';
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/deprecated_routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

module.exports.setup = function(app) {
/**
* @swagger
* /deprecated:
* get:
* description: Returns a string
* path: '/deprecated'
* responses:
* 200:
* description: deprecated path
*/
app.get('/deprecated', function(req, res) {
res.send('Deprecated "path" property!');
});
};
3 changes: 3 additions & 0 deletions test/swagger-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
},
"password": {
"type": "string"
},
"path": {
"type": "string"
}
}
}
Expand Down