-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathswaggerUi.js
More file actions
35 lines (31 loc) · 1 KB
/
swaggerUi.js
File metadata and controls
35 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Template } from 'meteor/templating';
import 'swagger-ui/dist/css/screen.css';
Template.swaggerUi.onCreated(function () {
const instance = Template.instance();
// Set flag on Data is not Ready
instance.dataFetched = new ReactiveVar(false);
// Get url of api documentation
const documentationURL = instance.data.apiDoc;
// Check validation of Swagger file
Meteor.call('isValidSwagger', documentationURL, function (error, result) {
// result can be 'true' or '{}'
if (result === true) {
// Save result in template instance
instance.documentationValid = result;
}
// Set flag on Data is Ready
instance.dataFetched.set(true);
});
});
Template.swaggerUi.helpers({
dataFetched () {
const instance = Template.instance();
// Get status of data is ready
return instance.dataFetched.get();
},
documentationValid () {
const instance = Template.instance();
// Get status of api documentation is valid
return instance.documentationValid;
},
});