-
Notifications
You must be signed in to change notification settings - Fork 33
Validate swagger #972
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
Validate swagger #972
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import SwaggerParser from 'swagger-parser'; | ||
|
|
||
| Meteor.methods({ | ||
| // Validate Swagger JSON/YAML | ||
| // Params: URL or file path to Swagger file | ||
| // Returns: true if valid else false | ||
| validateSwagger: function(url) { | ||
| SwaggerParser.validate(url) | ||
| .then(function(api){ | ||
| console.log("Your API is valid!"); | ||
| console.log("API name: %s, Version: %s", api.info.title, api.info.version); | ||
| return true; | ||
| }) | ||
| .catch(function(err){ | ||
| console.log(err); | ||
| return false; | ||
|
||
| }); | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably do not need to show any console logs, since this code runs on the server. We will use the return value of this function to show an alert to the user.