update api docs page
This commit is contained in:
1 parent
f8f34b0084
commit
4b493ac330
14 files changed
+505
-92
No files matched your search
@@ -1,16 +1,55 @@
|
||||
<template>
|
||||
<div v-if="responses" class="wrapper">
|
||||
<div v-for="(response, responseKey) in responses" :key="responseKey" class="item">
|
||||
<div>
|
||||
{{ response }}
|
||||
<el-collapse v-if="responses" id="document-response-item" class="wrapper" accordion>
|
||||
<el-collapse-item v-for="(response, responseKey) in responses" :key="responseKey" class="item" :name="responseKey">
|
||||
<template #title>
|
||||
<span class="badge">
|
||||
<el-tag v-if="response.isSuccess" class="ml-2" type="success">{{ $t('api.entity.success') }}</el-tag>
|
||||
<el-tag v-else class="ml-2" type="danger">{{ $t('api.entity.failure') }}</el-tag>
|
||||
</span>
|
||||
<span class="code">
|
||||
{{ response.statusCode }}
|
||||
</span>
|
||||
</template>
|
||||
<div class="item-body">
|
||||
<div v-if="response?.headers?.properties" class="headers">
|
||||
<h2 class="title">{{ $t('api.entity.responseHeaders') }}</h2>
|
||||
<div v-for="(item, itemKey) in response?.headers?.properties" :key="itemKey">
|
||||
<div class="property">
|
||||
<div class="info">
|
||||
<span class="key">{{ itemKey }}</span>
|
||||
<span class="type">{{ item.type }}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ item.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="response?.body?.properties" class="body">
|
||||
<h2 class="title">{{ $t('api.entity.responseBody') }}</h2>
|
||||
<div v-for="(item, itemKey) in response?.body?.properties" :key="itemKey" class="property">
|
||||
<div class="info">
|
||||
<span class="key">{{ itemKey }}</span>
|
||||
<span class="type">{{ item.type }}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ item.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="response?.example" class="example">
|
||||
<h2 class="title">{{ $t('api.entity.responseExample') }}</h2>
|
||||
<code-snippet :code="response?.example" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IResponse, ISchema } from '@/operators/api/models';
|
||||
import { IResponse } from '@/operators/api/models';
|
||||
import CodeSnippet from '../common/CodeSnippet.vue';
|
||||
|
||||
interface IData {
|
||||
value: {
|
||||
@@ -20,6 +59,9 @@ interface IData {
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiResult',
|
||||
components: {
|
||||
CodeSnippet
|
||||
},
|
||||
props: {
|
||||
responses: {
|
||||
type: Object as () => IResponse[] | [],
|
||||
@@ -39,47 +81,88 @@ export default defineComponent({
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
border: none;
|
||||
|
||||
.item {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
background-color: rgb(248, 248, 248);
|
||||
padding: 10px;
|
||||
background-color: #f8f8f8;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
|
||||
.left {
|
||||
width: 70%;
|
||||
float: left;
|
||||
.info {
|
||||
.key {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
padding: 6px;
|
||||
}
|
||||
.type {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 6px;
|
||||
}
|
||||
.required {
|
||||
font-size: 12px;
|
||||
color: #dd1e2e;
|
||||
display: inline-block;
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
.description {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
&.el-collapse-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.right {
|
||||
width: 30%;
|
||||
float: left;
|
||||
|
||||
&:first-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-child):not(:last-child) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
.item-body {
|
||||
padding: 15px;
|
||||
.body,
|
||||
.headers {
|
||||
.property {
|
||||
padding: 10px;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:first-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-of-type):not(:last-of-type) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
.info {
|
||||
.key {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.type {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
#document-response-item {
|
||||
.el-collapse-item__header {
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user