-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from holidayextras/swagger-fixes
Swagger Improvements
- Loading branch information
Showing
9 changed files
with
95 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ env: | |
- TEST_STEP=lint | ||
- TEST_STEP=flow | ||
- TEST_STEP=test | ||
- TEST_STEP=swagger | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use strict"; | ||
var jsonApiTestServer = require("./example/server.js"); | ||
var request = require("request"); | ||
var assert = require("assert"); | ||
|
||
describe("Use a tool to validate the generated swagger document", function() { | ||
it("should not contain any errors", function(done) { | ||
var validator = require("swagger-tools").specs.v2; | ||
|
||
var uri = "http://localhost:16006/rest/swagger.json"; | ||
request(uri, function(meh, res, swaggerObject) { | ||
swaggerObject = JSON.parse(swaggerObject); | ||
|
||
validator.validate(swaggerObject, function (err, result) { | ||
assert.ifError(err); | ||
|
||
if (!result) { | ||
console.log("Swagger document is valid"); | ||
return done(); | ||
} | ||
|
||
if (result.errors.length > 0) { | ||
console.log("The Swagger document is invalid..."); | ||
console.log(""); | ||
console.log("Errors"); | ||
console.log("------"); | ||
console.log(result.errors); | ||
console.log(""); | ||
} | ||
|
||
if (result.warnings.length > 0) { | ||
console.log("Warnings"); | ||
console.log("--------"); | ||
console.log(result.warnings); | ||
} | ||
|
||
done(new Error("Invalid swagger.json!")); | ||
}); | ||
}); | ||
}); | ||
|
||
before(function() { | ||
jsonApiTestServer.start(); | ||
}); | ||
after(function() { | ||
jsonApiTestServer.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters