Skip to content

Commit

Permalink
API Explorer v.1.1.0
Browse files Browse the repository at this point in the history
  * 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.
  • Loading branch information
Leonix committed Jan 31, 2025
1 parent 0155693 commit e2e1553
Show file tree
Hide file tree
Showing 36 changed files with 1,814 additions and 512 deletions.
5 changes: 0 additions & 5 deletions wa-apps/apiexplorer/client/.env.development.local.example

This file was deleted.

23 changes: 0 additions & 23 deletions wa-apps/apiexplorer/client/.gitignore

This file was deleted.

34 changes: 34 additions & 0 deletions wa-apps/apiexplorer/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="x-ua-compatible" content="ie=edge">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">

<link href="/wa-content/css/wa/wa-2.0.css" rel="stylesheet">
<link href="/wa-apps/apiexplorer/css/backend.css" rel="stylesheet">
<script defer="" src="/wa-content/js/fontawesome/fontawesome-all.min.js?v=513"></script>
<script src="/wa-content/js/jquery/jquery-3.6.0.min.js"></script>
<script src="/wa-content/js/jquery-wa/wa.js"></script>
<script>
window.appState = {
"baseUrl": document.location.protocol + '//' + document.location.host + "<{ VITE_APP_BASE_URL }>",
"rootUrl": "<{ VITE_APP_ROOT_URL }>",
"user_id": "1",
"development_mode": "1",
"locale": "<{ VITE_APP_I18N_LOCALE }>",
"centralUrl": "<{ VITE_APP_WA_CENTRAL }>"
};
</script>
</head>
<body>
<div id="wa">
<div id="wa-nav">
<div id="wa-header"></div>
</div>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</div>
</body>
</html>
40 changes: 20 additions & 20 deletions wa-apps/apiexplorer/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
"version": "1.0.3",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build && npm run copycss && npm run copyjs && npm run copymanifest",
"lint": "vue-cli-service lint",
"copycss": "copyfiles dist/css/*.css ../css --flat",
"copyjs": "copyfiles dist/js/*.js ../js --flat",
"copymanifest": "copyfiles dist/manifest.json ../js --flat"
"dev": "vite",
"build": "vite build && npm run copycss && npm run copyjs",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"copycss": "copyfiles dist/assets/*.css ../css --flat",
"copyjs": "copyfiles dist/assets/*.js ../js --flat"
},
"dependencies": {
"@popperjs/core": "^2.11.2",
"@intlify/unplugin-vue-i18n": "^0.10.0",
"@popperjs/core": "^2.11.6",
"axios": "^0.21.4",
"copyfiles": "^2.4.1",
"core-js": "^3.20.3",
"marked": "^4.0.10",
"core-js": "^3.27.1",
"jquery": "^3.6.0",
"marked": "^4.2.5",
"mitt": "^3.0.0",
"pretty-print-json": "^1.1.2",
"swagger-client": "^3.18.1",
"pretty-print-json": "^1.3.1",
"swagger-client": "^v3.19.8",
"v-calendar": "^3.0.0-alpha.6",
"vue": "^3.2.27",
"vue": "^3.2.45",
"vue-i18n": "^9.2.2",
"vue-router": "^4.1.5",
"vuex": "^4.0.2"
"vuex": "^4.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.15",
"@vue/cli-plugin-eslint": "^4.5.15",
"@vue/cli-plugin-router": "^4.5.15",
"@vue/cli-plugin-vuex": "^4.5.15",
"@vue/cli-service": "^4.5.15",
"@vue/compiler-sfc": "^3.2.27",
"@rollup/plugin-inject": "^5.0.3",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/compiler-sfc": "^3.2.45",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-plugin-vue": "^7.20.0"
"eslint-plugin-vue": "^7.20.0",
"vite": "^4.3.8",
"vite-plugin-html-env": "^1.2.8"
},
"eslintConfig": {
"root": true,
Expand Down
36 changes: 0 additions & 36 deletions wa-apps/apiexplorer/client/public/index.html

This file was deleted.

8 changes: 4 additions & 4 deletions wa-apps/apiexplorer/client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>
</aside>

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

<script>
import AppList from '@/components/AppList';
import UserList from '@/components/UserList';
import MethodList from '@/components/MethodList';
import AppList from '@/components/AppList.vue';
import UserList from '@/components/UserList.vue';
import MethodList from '@/components/MethodList.vue';
export default {
components: {
AppList,
Expand Down
2 changes: 1 addition & 1 deletion wa-apps/apiexplorer/client/src/components/AppList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<script>
import SwaggerClient from 'swagger-client';
import { swaggerUrl } from '@/funcs'
import { swaggerUrl } from '@/funcs.js';
export default {
name: "AppList",
emits: ["apps-loaded", "app-selected"],
Expand Down
35 changes: 27 additions & 8 deletions wa-apps/apiexplorer/client/src/components/CodeBlock.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div :class="[ error && 'orange', 'highlighted', 'dark-mode-inverted', 'flexbox', 'full-width']">
<pre class="small custom-p-8 custom-m-0 wide" v-html="value_to_show"></pre>
<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>
<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>
<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>
<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>
</div>
</template>

Expand Down Expand Up @@ -38,12 +38,31 @@ export default {
},
methods: {
copy() {
navigator.clipboard.writeText(this.value_to_copy).then(() => {
this.just_copied = true;
setTimeout(() => {
this.just_copied = false;
}, 3000);
});
if (navigator.clipboard) {
navigator.clipboard.writeText(this.value_to_copy).then(() => {
this.just_copied = true;
setTimeout(() => {
this.just_copied = false;
}, 3000);
});
} else {
// fallback to deprecated copy method
const textArea = document.createElement("textarea");
textArea.value = this.value_to_copy;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
this.just_copied = true;
setTimeout(() => {
this.just_copied = false;
}, 3000);
} catch (err) {
console.error('Unable to copy to clipboard', err);
}
document.body.removeChild(textArea);
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion wa-apps/apiexplorer/client/src/components/MethodList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
<div v-else-if="!!app_id && !method_groups[app_id]" class="custom-p-32 align-center">
<i class="fas fa-times-circle" style="font-size: 8rem; opacity: 0.15;"></i>
<h4>{{ $t('no-api-message', [$store.state.apps[app_id].name]) }}</h4>
<p class="hint" v-html="$t('no-api-hint')"></p>
<p class="hint" v-if="locale == 'ru'">
Если вы являетесь разработчиком данного приложения, ознакомьтесь с инструкцией по созданию <a href='https://developers.webasyst.ru/docs/features/apis/' target='_blank'>публичного API в приложениях Webasyst</a>.
</p>
<p class="hint" v-else>
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>.
</p>
</div>
</template>

Expand Down Expand Up @@ -56,6 +61,9 @@ export default {
} else {
return "";
}
},
locale() {
return window.appState.locale;
}
},
methods: {
Expand Down
34 changes: 34 additions & 0 deletions wa-apps/apiexplorer/client/src/components/ParameterDescription.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<strong>{{ parameter.name }}</strong>
<em v-if="parameter.is_optional == 1" class="small">
({{ $t('optional') }})
</em>
<span v-else class="state-caution"> *</span>

<span v-if="parameter.description.length <= DESC_LIMIT"> : {{ parameter.description }}</span>

<span v-if="parameter.description.length > DESC_LIMIT">
<button v-if="show_description" class="nobutton small" @click="show_description=false">{{ $t('hide') }}</button>
<button v-else class="nobutton small" @click="show_description=true">{{ $t('show') }}</button>
</span>

<div v-if="parameter.description.length > DESC_LIMIT && show_description" style="white-space: pre-line;">{{ parameter.description }}</div>
</template>

<script>
export default {
name: "ParameterDescription",
props: {
parameter: Object
},
data() {
return {
show_description: false,
DESC_LIMIT: 150
}
},
mounted() {
this.show_description = this.parameter.description.length <= this.DESC_LIMIT;
}
}
</script>
Loading

0 comments on commit e2e1553

Please sign in to comment.