Skip to content

Commit e2e1553

Browse files
author
Leonix
committed
API Explorer v.1.1.0
* Added a button to view an API method’s OpenAPI description. * Added a link to a web page with a method’s documentation, whose address is specified in the OpenAPI description url property. * Added display of default parameter values specified in the OpenAPI description default property. * Added support of the OpenAPI description additionalProperties property. * Improved sending of empty parameter values. * Made the app interface more convenient and fixed found errors. API Explorer v.1.0.5 * Added support for parameters accepting several data types, which can be described in YAML files using oneOf, alllOf, anyOf syntax options. * Improved support for request-sending HTTP methods PUT, PATCH, DELETE. * Restored and improved previously hidden Result schema tab in the request results info area. * Added support for “date/time” type fields. * Added support for sending files as a base64-encoded string. * Improved method descriptions formatting. * Improved display of method call results for methods returning empty contents. * Increased app stability. * Fixed app functioning error in cases when Webasyst framework is installed in a domain subdirectory.
1 parent 0155693 commit e2e1553

36 files changed

+1814
-512
lines changed

wa-apps/apiexplorer/client/.env.development.local.example

Lines changed: 0 additions & 5 deletions
This file was deleted.

wa-apps/apiexplorer/client/.gitignore

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta charset="x-ua-compatible" content="ie=edge">
6+
<link rel="icon" href="/favicon.ico" />
7+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
8+
9+
<link href="/wa-content/css/wa/wa-2.0.css" rel="stylesheet">
10+
<link href="/wa-apps/apiexplorer/css/backend.css" rel="stylesheet">
11+
<script defer="" src="/wa-content/js/fontawesome/fontawesome-all.min.js?v=513"></script>
12+
<script src="/wa-content/js/jquery/jquery-3.6.0.min.js"></script>
13+
<script src="/wa-content/js/jquery-wa/wa.js"></script>
14+
<script>
15+
window.appState = {
16+
"baseUrl": document.location.protocol + '//' + document.location.host + "<{ VITE_APP_BASE_URL }>",
17+
"rootUrl": "<{ VITE_APP_ROOT_URL }>",
18+
"user_id": "1",
19+
"development_mode": "1",
20+
"locale": "<{ VITE_APP_I18N_LOCALE }>",
21+
"centralUrl": "<{ VITE_APP_WA_CENTRAL }>"
22+
};
23+
</script>
24+
</head>
25+
<body>
26+
<div id="wa">
27+
<div id="wa-nav">
28+
<div id="wa-header"></div>
29+
</div>
30+
<div id="app"></div>
31+
<script type="module" src="/src/main.js"></script>
32+
</div>
33+
</body>
34+
</html>

wa-apps/apiexplorer/client/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,38 @@
33
"version": "1.0.3",
44
"private": true,
55
"scripts": {
6-
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build && npm run copycss && npm run copyjs && npm run copymanifest",
8-
"lint": "vue-cli-service lint",
9-
"copycss": "copyfiles dist/css/*.css ../css --flat",
10-
"copyjs": "copyfiles dist/js/*.js ../js --flat",
11-
"copymanifest": "copyfiles dist/manifest.json ../js --flat"
6+
"dev": "vite",
7+
"build": "vite build && npm run copycss && npm run copyjs",
8+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
9+
"copycss": "copyfiles dist/assets/*.css ../css --flat",
10+
"copyjs": "copyfiles dist/assets/*.js ../js --flat"
1211
},
1312
"dependencies": {
14-
"@popperjs/core": "^2.11.2",
13+
"@intlify/unplugin-vue-i18n": "^0.10.0",
14+
"@popperjs/core": "^2.11.6",
1515
"axios": "^0.21.4",
1616
"copyfiles": "^2.4.1",
17-
"core-js": "^3.20.3",
18-
"marked": "^4.0.10",
17+
"core-js": "^3.27.1",
18+
"jquery": "^3.6.0",
19+
"marked": "^4.2.5",
1920
"mitt": "^3.0.0",
20-
"pretty-print-json": "^1.1.2",
21-
"swagger-client": "^3.18.1",
21+
"pretty-print-json": "^1.3.1",
22+
"swagger-client": "^v3.19.8",
2223
"v-calendar": "^3.0.0-alpha.6",
23-
"vue": "^3.2.27",
24+
"vue": "^3.2.45",
2425
"vue-i18n": "^9.2.2",
2526
"vue-router": "^4.1.5",
26-
"vuex": "^4.0.2"
27+
"vuex": "^4.1.0"
2728
},
2829
"devDependencies": {
29-
"@vue/cli-plugin-babel": "^4.5.15",
30-
"@vue/cli-plugin-eslint": "^4.5.15",
31-
"@vue/cli-plugin-router": "^4.5.15",
32-
"@vue/cli-plugin-vuex": "^4.5.15",
33-
"@vue/cli-service": "^4.5.15",
34-
"@vue/compiler-sfc": "^3.2.27",
30+
"@rollup/plugin-inject": "^5.0.3",
31+
"@vitejs/plugin-vue": "^4.2.3",
32+
"@vue/compiler-sfc": "^3.2.45",
3533
"babel-eslint": "^10.1.0",
3634
"eslint": "^6.8.0",
37-
"eslint-plugin-vue": "^7.20.0"
35+
"eslint-plugin-vue": "^7.20.0",
36+
"vite": "^4.3.8",
37+
"vite-plugin-html-env": "^1.2.8"
3838
},
3939
"eslintConfig": {
4040
"root": true,

wa-apps/apiexplorer/client/public/index.html

Lines changed: 0 additions & 36 deletions
This file was deleted.

wa-apps/apiexplorer/client/src/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</div>
3737
</aside>
3838

39-
<div class="article content">
39+
<div class="article content wide">
4040
<div class="article-body" id="wa-app-content">
4141
<router-view v-if="loaded" :key="$route.fullPath"/>
4242
<div v-else class="box skeleton" style="width: 70%;">
@@ -64,9 +64,9 @@
6464
</template>
6565

6666
<script>
67-
import AppList from '@/components/AppList';
68-
import UserList from '@/components/UserList';
69-
import MethodList from '@/components/MethodList';
67+
import AppList from '@/components/AppList.vue';
68+
import UserList from '@/components/UserList.vue';
69+
import MethodList from '@/components/MethodList.vue';
7070
export default {
7171
components: {
7272
AppList,

wa-apps/apiexplorer/client/src/components/AppList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<script>
3838
import SwaggerClient from 'swagger-client';
39-
import { swaggerUrl } from '@/funcs'
39+
import { swaggerUrl } from '@/funcs.js';
4040
export default {
4141
name: "AppList",
4242
emits: ["apps-loaded", "app-selected"],

wa-apps/apiexplorer/client/src/components/CodeBlock.vue

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div :class="[ error && 'orange', 'highlighted', 'dark-mode-inverted', 'flexbox', 'full-width']">
33
<pre class="small custom-p-8 custom-m-0 wide" v-html="value_to_show"></pre>
4-
<div v-if="just_copied" class="custom-my-4 custom-mx-8 large" style="color: var(--green);"><i class="fas fa-check" title="copied"></i></div>
5-
<a v-else style="color: var(--gray);" title="Copy to clipboard" class="custom-my-4 custom-mx-8 large" href="javascript:void(0);" @click="copy()"><i class="far fa-copy"></i></a>
4+
<div v-if="just_copied" class="custom-my-4 custom-mx-8 large" style="color: var(--green);"><i class="fas fa-check" :title="$t('copied')"></i></div>
5+
<a v-else style="color: var(--gray);" :title="$t('Copy to clipboard')" class="custom-my-4 custom-mx-8 large" href="javascript:void(0);" @click="copy()"><i class="far fa-copy"></i></a>
66
</div>
77
</template>
88

@@ -38,12 +38,31 @@ export default {
3838
},
3939
methods: {
4040
copy() {
41-
navigator.clipboard.writeText(this.value_to_copy).then(() => {
42-
this.just_copied = true;
43-
setTimeout(() => {
44-
this.just_copied = false;
45-
}, 3000);
46-
});
41+
if (navigator.clipboard) {
42+
navigator.clipboard.writeText(this.value_to_copy).then(() => {
43+
this.just_copied = true;
44+
setTimeout(() => {
45+
this.just_copied = false;
46+
}, 3000);
47+
});
48+
} else {
49+
// fallback to deprecated copy method
50+
const textArea = document.createElement("textarea");
51+
textArea.value = this.value_to_copy;
52+
document.body.appendChild(textArea);
53+
textArea.focus();
54+
textArea.select();
55+
try {
56+
document.execCommand('copy');
57+
this.just_copied = true;
58+
setTimeout(() => {
59+
this.just_copied = false;
60+
}, 3000);
61+
} catch (err) {
62+
console.error('Unable to copy to clipboard', err);
63+
}
64+
document.body.removeChild(textArea);
65+
}
4766
}
4867
}
4968
}

wa-apps/apiexplorer/client/src/components/MethodList.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
<div v-else-if="!!app_id && !method_groups[app_id]" class="custom-p-32 align-center">
2727
<i class="fas fa-times-circle" style="font-size: 8rem; opacity: 0.15;"></i>
2828
<h4>{{ $t('no-api-message', [$store.state.apps[app_id].name]) }}</h4>
29-
<p class="hint" v-html="$t('no-api-hint')"></p>
29+
<p class="hint" v-if="locale == 'ru'">
30+
Если вы являетесь разработчиком данного приложения, ознакомьтесь с инструкцией по созданию <a href='https://developers.webasyst.ru/docs/features/apis/' target='_blank'>публичного API в приложениях Webasyst</a>.
31+
</p>
32+
<p class="hint" v-else>
33+
If you are a developer of this app, please refer to this guide on how to create <a href='https://developers.webasyst.com/features/apis/' target='_blank'>an API-enabled Webasyst app</a>.
34+
</p>
3035
</div>
3136
</template>
3237

@@ -56,6 +61,9 @@ export default {
5661
} else {
5762
return "";
5863
}
64+
},
65+
locale() {
66+
return window.appState.locale;
5967
}
6068
},
6169
methods: {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<strong>{{ parameter.name }}</strong>
3+
<em v-if="parameter.is_optional == 1" class="small">
4+
({{ $t('optional') }})
5+
</em>
6+
<span v-else class="state-caution"> *</span>
7+
8+
<span v-if="parameter.description.length <= DESC_LIMIT"> : {{ parameter.description }}</span>
9+
10+
<span v-if="parameter.description.length > DESC_LIMIT">
11+
<button v-if="show_description" class="nobutton small" @click="show_description=false">{{ $t('hide') }}</button>
12+
<button v-else class="nobutton small" @click="show_description=true">{{ $t('show') }}</button>
13+
</span>
14+
15+
<div v-if="parameter.description.length > DESC_LIMIT && show_description" style="white-space: pre-line;">{{ parameter.description }}</div>
16+
</template>
17+
18+
<script>
19+
export default {
20+
name: "ParameterDescription",
21+
props: {
22+
parameter: Object
23+
},
24+
data() {
25+
return {
26+
show_description: false,
27+
DESC_LIMIT: 150
28+
}
29+
},
30+
mounted() {
31+
this.show_description = this.parameter.description.length <= this.DESC_LIMIT;
32+
}
33+
}
34+
</script>

0 commit comments

Comments
 (0)