Skip to content

Commit ba49118

Browse files
authored
Merge pull request #2467 from apinf/develop
Merging for release 0.43.0
2 parents cbf5963 + 9be5d60 commit ba49118

File tree

106 files changed

+2316
-3509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2316
-3509
lines changed

.meteor/packages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ kadira:blaze-layout
3939
kadira:dochead
4040
kadira:flow-router
4141
kurounin:pagination-blaze
42-
kurounin:pagination@=1.0.15
42+
kurounin:pagination@=1.0.21
4343
4444
4545
matb33:collection-hooks

.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ juliancwirko:[email protected]
7676
7777
7878
79-
kurounin:[email protected].15
79+
kurounin:[email protected].21
8080
8181
8282

about/client/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>
3333
Apinf
3434
</dt>
3535
<dd>
36-
0.42.0
36+
0.43.0
3737
</dd>
3838
<dt>
3939
API Umbrella

api_catalog/client/api_catalog.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Template.apiCatalog.onCreated(function () {
2525
// Get user id
2626
const userId = Meteor.userId();
2727

28+
// Default sort
29+
const defaultSort = { name: 1 };
30+
2831
// Set filters
2932
// On default: Show all public apis for anonymous users
3033
let filters = { isPublic: true };
@@ -50,16 +53,10 @@ Template.apiCatalog.onCreated(function () {
5053
// Count of cards in catalog
5154
perPage: 24,
5255
// Set sort by name on default
53-
sort: { name: 1 },
56+
sort: defaultSort,
5457
filters,
5558
});
5659

57-
// Subscribe to API logo collection
58-
instance.subscribe('allApiLogo');
59-
60-
// Subscribe to all users, returns only usernames
61-
instance.subscribe('allUsersUsernamesOnly');
62-
6360
// Subscribe to bookmarks of current user
6461
instance.subscribe('userApiBookmarks');
6562

@@ -73,14 +70,14 @@ Template.apiCatalog.onCreated(function () {
7370
FlowRouter.getQueryParam('sortDirection') === 'ascending' ? 1 : -1;
7471

7572
// Create a object for storage sorting parameters
76-
const sort = {};
77-
// GCheck of existing parameters
73+
let sort = {};
74+
// Check of existing parameters
7875
if (sortByParameter && sortDirectionParameter) {
7976
// Get field and direction of sorting
8077
sort[sortByParameter] = sortDirectionParameter;
8178
} else {
8279
// Otherwise get it like default value
83-
sort.name = 1;
80+
sort = defaultSort;
8481
}
8582

8683
// Change sorting

api_catalog/client/grid/grid.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright 2017 Apinf Oy
2+
This file is covered by the EUPL license.
3+
You may obtain a copy of the licence at
4+
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */
5+
6+
// Meteor packages imports
7+
import { Template } from 'meteor/templating';
8+
9+
Template.apiCatalogGrid.onCreated(function () {
10+
this.autorun(() => {
11+
// Get APIs document
12+
const apis = Template.currentData().apis;
13+
14+
const apiLogoIds = [];
15+
16+
// Get list of logo IDs
17+
apis.forEach((api) => {
18+
if (api.apiLogoFileId) {
19+
apiLogoIds.push(api.apiLogoFileId);
20+
}
21+
});
22+
23+
// Subscribe to API logo collection by logo IDs
24+
this.subscribe('apiLogoByIds', apiLogoIds);
25+
26+
// Subscribe to usernames of API managers
27+
this.subscribe('managersUsernames', apis);
28+
});
29+
});

api_catalog/client/table/table.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright 2017 Apinf Oy
2+
This file is covered by the EUPL license.
3+
You may obtain a copy of the licence at
4+
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11
5+
*/
6+
7+
// Meteor packages imports
8+
import { Template } from 'meteor/templating';
9+
10+
Template.apiCatalogTable.onCreated(function () {
11+
this.autorun(() => {
12+
// Get APIs document
13+
const apis = Template.currentData().apis;
14+
15+
const apiLogoIds = [];
16+
17+
// Get list of logo IDs
18+
apis.forEach((api) => {
19+
if (api.apiLogoFileId) {
20+
apiLogoIds.push(api.apiLogoFileId);
21+
}
22+
});
23+
24+
// Subscribe to API logo collection by logo IDs
25+
this.subscribe('apiLogoByIds', apiLogoIds);
26+
27+
// Subscribe to usernames of API managers
28+
this.subscribe('managersUsernames', apis);
29+
});
30+
});

api_docs/client/manage/manage.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ <h1 class="modal-title">
2626
{{> showHelp 'addApiDocumentation' }}
2727
{{_ "manageApiDocumentationModal_addDocumentation_title" }}
2828
</legend>
29+
<p class="help-text">
30+
{{_ 'manageApiDocumentationModal_helpText_useHttpsProtocol' }}
31+
</p>
2932
{{> afQuickField
3033
name="type"
3134
firstOption=false

api_docs/client/swaggerUI/swaggerUi.html

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,44 @@
44
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 -->
55

66
<template name="swaggerUi">
7-
<div class="swagger-section">
8-
<div id="header">
9-
<div class="swagger-ui-wrap">
10-
<a id="logo" href="http://swagger.io" target="_blank" rel="nofollow">
11-
<img src="/img/logo_small.png" class="logo__img" alt="swagger" height="30" width="30">
12-
<span class="logo__title">swagger</span>
13-
</a>
14-
<form id="api_selector">
15-
<div class="input"><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
16-
<div id="auth_container"></div>
17-
<div class="input"><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
18-
</form>
7+
{{# if dataFetched }}
8+
{{# if useHttpProtocol }}
9+
<div class="alert alert-danger alert-dismissible" role="alert">
10+
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
11+
<span aria-hidden="true">&times;</span>
12+
</button>
13+
<span>
14+
<strong>
15+
{{_ 'swaggerUi_alertText_Warning' }}
16+
</strong>
17+
{{_ 'swaggerUi_alertText_mainText' }}
18+
</span>
1919
</div>
20-
</div>
21-
<div id="message-bar" class="swagger-ui-wrap message-success" data-sw-translate=""></div>
22-
{{# if dataFetched }}
20+
{{/ if }}
21+
<div class="swagger-section">
22+
<div id="header">
23+
<div class="swagger-ui-wrap">
24+
<a id="logo" href="http://swagger.io" target="_blank" rel="nofollow">
25+
<img src="/img/logo_small.png" class="logo__img" alt="swagger" height="30" width="30">
26+
<span class="logo__title">swagger</span>
27+
</a>
28+
<form id="api_selector">
29+
<div class="input"><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
30+
<div id="auth_container"></div>
31+
<div class="input"><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
32+
</form>
33+
</div>
34+
</div>
35+
<div id="message-bar" class="swagger-ui-wrap message-success" data-sw-translate=""></div>
2336
{{# if documentationValid }}
2437
{{> swaggerUiContent api=api }}
2538
{{ else }}
2639
<i>
2740
{{_ 'swaggerUi_swaggerDocumentInvalidText' }}
2841
</i>
2942
{{/ if }}
30-
{{ else }}
31-
{{> spinner }}
32-
{{/ if }}
33-
</div>
43+
</div>
44+
{{ else }}
45+
{{> spinner }}
46+
{{/ if }}
3447
</template>

api_docs/client/swaggerUI/swaggerUi.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,26 @@ Template.swaggerUi.onCreated(() => {
1919
// Get url of api documentation
2020
const documentationURL = instance.data.api.documentation();
2121

22-
// Check validation of Swagger file
23-
Meteor.call('isValidSwagger', documentationURL, (error, result) => {
24-
// result can be 'true' or '{}'
25-
if (result === true) {
26-
// Save result in template instance
27-
instance.documentationValid = result;
22+
// Parsed swagger file
23+
Meteor.call('parsedDocument', documentationURL, (error, result) => {
24+
// Document is valid on default
25+
instance.documentationValid = true;
26+
// Document doesn't contain http protocol on default
27+
instance.useHttpProtocol = false;
28+
29+
// Document is not valid if result is {}
30+
if (result === {}) {
31+
// Set that document is not valid
32+
instance.documentationValid = false;
33+
}
34+
35+
// Checking of scheme contains only http protocol
36+
if (result.schemes && result.schemes[0] === 'http') {
37+
// Set the document contains only http protocol
38+
instance.useHttpProtocol = true;
2839
}
29-
// Set flag on Data is Ready
40+
41+
// Set flag Data is Ready
3042
instance.dataFetched.set(true);
3143
});
3244
});
@@ -42,4 +54,9 @@ Template.swaggerUi.helpers({
4254
// Get status of api documentation is valid
4355
return instance.documentationValid;
4456
},
57+
useHttpProtocol () {
58+
const instance = Template.instance();
59+
// Get status of documentation has only http in schemes
60+
return instance.useHttpProtocol;
61+
},
4562
});

api_docs/client/swaggerUI/swaggerUiContent/swaggerUiContent.js

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,53 @@ Template.swaggerUiContent.onCreated(function () {
2828
// Get URL of api documentation
2929
const documentationURL = api.documentation();
3030

31-
// Get proxy
32-
const proxy = Proxies.findOne();
33-
3431
// Get proxy backend
3532
const proxyBackend = ProxyBackends.findOne({ apiId: api._id });
3633

37-
// Get proxy host if it exists
38-
let proxyHost = proxy ? proxy.apiUmbrella.url : '';
34+
// Placeholders;
35+
let proxyBasePath;
36+
let proxyHost;
37+
let apiKeyValue;
3938

40-
// Get values of proxy apiUmbrella
41-
const apiUmbrellaSettings = proxyBackend ? proxyBackend.apiUmbrella.url_matches : false;
39+
if (proxyBackend) {
40+
// Get ID of current proxy
41+
const proxyId = proxyBackend.proxyId;
4242

43-
// Get proxy base path if it exists
44-
let proxyBasePath = apiUmbrellaSettings ? apiUmbrellaSettings[0].frontend_prefix : '';
43+
const proxy = Proxies.findOne(proxyId);
4544

46-
if (_.startsWith(proxyHost, 'http://')) {
47-
// Delete 'http://' prefix
48-
proxyHost = proxyHost.slice(7, proxyHost.length);
49-
} else {
50-
// Delete 'https://' prefix
51-
proxyHost = proxyHost.slice(8, proxyHost.length);
52-
}
45+
// Get proxy host if it exists
46+
proxyHost = proxy ? proxy.apiUmbrella.url : '';
5347

54-
// Delete last forward slash if it exists
55-
if (_.endsWith(proxyHost, '/')) {
56-
proxyHost = proxyHost.slice(0, -1);
57-
}
48+
// Get values of proxy apiUmbrella
49+
const apiUmbrellaSettings = proxyBackend ? proxyBackend.apiUmbrella.url_matches : false;
5850

59-
// Delete last forward slash if it exists
60-
if (_.endsWith(proxyBasePath, '/')) {
61-
proxyBasePath = proxyBasePath.slice(0, -1);
62-
}
51+
// Get proxy base path if it exists
52+
proxyBasePath = apiUmbrellaSettings ? apiUmbrellaSettings[0].frontend_prefix : '';
6353

64-
// Get api key collection
65-
const apiKey = proxy ? ApiKeys.findOne({ proxyId: proxy._id, userId: Meteor.userId() }) : '';
54+
if (_.startsWith(proxyHost, 'http://')) {
55+
// Delete 'http://' prefix
56+
proxyHost = proxyHost.slice(7, proxyHost.length);
57+
} else {
58+
// Delete 'https://' prefix
59+
proxyHost = proxyHost.slice(8, proxyHost.length);
60+
}
6661

67-
// Check if api-key exists
68-
const apiKeyValue = apiKey ? apiKey.apiUmbrella.apiKey : '';
62+
// Delete last forward slash if it exists
63+
if (_.endsWith(proxyHost, '/')) {
64+
proxyHost = proxyHost.slice(0, -1);
65+
}
66+
67+
// Delete last forward slash if it exists
68+
if (_.endsWith(proxyBasePath, '/')) {
69+
proxyBasePath = proxyBasePath.slice(0, -1);
70+
}
71+
72+
// Get api key collection
73+
const apiKey = proxy ? ApiKeys.findOne({ proxyId: proxy._id, userId: Meteor.userId() }) : '';
74+
75+
// Check if api-key exists
76+
apiKeyValue = apiKey ? apiKey.apiUmbrella.apiKey : '';
77+
}
6978

7079
// Create object to save information about property of api-key authorization
7180
const infoAuth = {};

0 commit comments

Comments
 (0)