-
-
- {{#if dataFetched}}
- {{#if documentationValid}}
- {{>swaggerUiContent apiDocumentation=apiDocumentation}}
- {{else}}
-
- {{_ 'swaggerUi_swaggerDocumentInvalidText'}}
-
- {{/if}}
- {{else}}
- {{>spinner}}
- {{/if}}
+
+
+
+ {{#if dataFetched}}
+ {{#if documentationValid}}
+ {{>swaggerUiContent apiDoc=apiDoc api=api}}
+ {{else}}
+
+ {{_ 'swaggerUi_swaggerDocumentInvalidText'}}
+
+ {{/if}}
+ {{else}}
+ {{>spinner}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/documentation/client/swaggerUI/swaggerUi.js b/documentation/client/swaggerUI/swaggerUi.js
index 2d2f6c639f..fae6ed8022 100644
--- a/documentation/client/swaggerUI/swaggerUi.js
+++ b/documentation/client/swaggerUI/swaggerUi.js
@@ -5,10 +5,10 @@ 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.apiDocumentation;
-
+ const documentationURL = instance.data.apiDoc;
+
// Check validation of Swagger file
Meteor.call('isValidSwagger', documentationURL, function (error, result) {
// result can be 'true' or '{}'
diff --git a/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.html b/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.html
index b0a885cf57..16075e9933 100644
--- a/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.html
+++ b/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.html
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.js b/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.js
index 1b70d82493..b6f86f0f87 100644
--- a/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.js
+++ b/documentation/client/swaggerUI/swaggerUiContent/swaggerUiContent.js
@@ -1,29 +1,35 @@
import SwaggerUi from 'swagger-ui-browserify';
+import { Apis } from '/apis/collection';
Template.swaggerUiContent.onCreated(function () {
+ const instance = this;
+
// Get URL of api documentation
- const documentationURL = this.data.apiDocumentation;
-
- // Create Swagger UI
- const swagger = window.swaggerUi = new SwaggerUi({
+ const documentationURL = this.data.apiDoc;
+
+ // Create Swagger UI object
+ const swagger = new SwaggerUi({
url: documentationURL,
dom_id: 'swagger-ui-container',
useJQuery: true,
supportHeaderParams: true,
- supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
apisSorter: 'alpha',
operationsSorter: 'alpha',
- docExpansion: 'none'
+ docExpansion: 'none',
+ });
+
+ // Subscribe to api collection
+ instance.autorun(() => {
+ // Get relevant api collection
+ instance.subscribe('apiBackend', instance.data.api._id);
+
+ // Get api
+ const api = Apis.findOne(instance.data.api._id);
+
+ // Set selected methods in Swagger
+ swagger.setOption('supportedSubmitMethods', api.submit_methods);
+
+ // Load Swagger UI
+ swagger.load();
});
-
- // Load Swagger UI
- swagger.load();
-});
-
-Template.swaggerUiContent.onRendered(function () {
- // Get URL of api documentation
- const documentationURL = this.data.apiDocumentation;
-
- // Display URL on Swagger UI input
- $('#input_baseUrl').val(documentationURL);
});
diff --git a/documentation/client/view/documentation.html b/documentation/client/view/documentation.html
index 2344becf5f..b8bccbc15d 100644
--- a/documentation/client/view/documentation.html
+++ b/documentation/client/view/documentation.html
@@ -41,7 +41,7 @@
{{_ "documentation_Link_Title" }}
{{else}}
{{_ "documentation_No_Link_Message" }}
- {{#if apiBackend.currentUserCanEdit }}
+ {{#if api.currentUserCanEdit }}
{{_ "documentation_No_Link_Manager_Message" }}
{{/if}}
@@ -66,11 +66,11 @@
{{_ "documentation_Viewer_Title" }}
{{#if Template.subscriptionsReady }}
{{#if documentationExists }}
- {{> swaggerUi apiDocumentation=uploadedDocumentationLink}}
+ {{> swaggerUi apiDoc=uploadedDocumentationLink api=api}}
{{ else }}
{{_ "documentation_No_Swagger_Message" }}
- {{#if apiBackend.currentUserCanEdit }}
+ {{#if api.currentUserCanEdit }}
{{_ "documentation_No_Swagger_Manager_Message" }}
{{/if}}
diff --git a/lib/i18n/en.i18n.json b/lib/i18n/en.i18n.json
index f0c6b238bf..c72759b15d 100644
--- a/lib/i18n/en.i18n.json
+++ b/lib/i18n/en.i18n.json
@@ -295,6 +295,11 @@
"responseTimeDistributionChart_title": "API Response Time",
"responseTimeDistributionChart_help_text": "Click on any bar to filter API Request Timeline and HTTP Status Code chart by requests that have the selected response time range.",
"schemas": {
+ "apis": {
+ "submit_methods": {
+ "label": "Allow try-out for following methods:"
+ }
+ },
"apiMetadata": {
"organization": {
"label": "Organization",
diff --git a/package.json b/package.json
index b80793cfac..35f8e7c444 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
"swagger-client": "^2.1.0",
"swagger-parser": "^3.4.1",
"swagger-ui": "^2.2.3",
- "swagger-ui-browserify": "^2.2.3",
+ "swagger-ui-browserify": "^2.2.3-a",
"urijs": "^1.18.1"
},
"devDependencies": {