update schema responses
This commit is contained in:
1 parent
e3a82d562f
commit
a3f49d4b0b
5 files changed
+103
-23
No files matched your search
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div v-if="schema" class="body">
|
||||
<div v-if="schema.items && schema.type === 'array'" class="items">
|
||||
<h2 class="title">{{ $t('api.entity.arrayOf') }}</h2>
|
||||
<div v-for="(item, itemKey) in schema.items" :key="itemKey" class="item">
|
||||
<response-body :schema="item" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="properties">
|
||||
<div v-for="(item, itemKey) in schema.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>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ISchema } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ResponseBody',
|
||||
props: {
|
||||
schema: {
|
||||
type: Object as () => ISchema,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.items {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
.title {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
.properties {
|
||||
margin-bottom: 10px;
|
||||
.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>
|
||||
@@ -28,19 +28,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="response?.body?.properties" class="body">
|
||||
<div v-if="response?.body" class="body">
|
||||
<h2 class="title">{{ $t('api.entity.responseBody') }}</h2>
|
||||
<div class="properties">
|
||||
<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>
|
||||
<response-body :schema="response?.body" />
|
||||
</div>
|
||||
<div v-if="response?.example" class="example">
|
||||
<h2 class="title">{{ $t('api.entity.responseExample') }}</h2>
|
||||
@@ -56,6 +46,7 @@ import { defineComponent } from 'vue';
|
||||
import { IResponse } from '@/operators/api/models';
|
||||
import CodeSnippet from '../common/CodeSnippet.vue';
|
||||
import { ElCollapse, ElCollapseItem, ElTag } from 'element-plus';
|
||||
import ResponseBody from './ResponseBody.vue';
|
||||
|
||||
interface IData {
|
||||
value: {
|
||||
@@ -69,7 +60,8 @@ export default defineComponent({
|
||||
CodeSnippet,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElTag
|
||||
ElTag,
|
||||
ResponseBody
|
||||
},
|
||||
props: {
|
||||
responses: {
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<div class="queries">
|
||||
<div v-if="api?.request?.queries" class="queries">
|
||||
<h2 class="title">{{ $t('api.entity.requestQueries') }}</h2>
|
||||
<api-form
|
||||
v-model:form="formValue.queries"
|
||||
@@ -11,7 +11,7 @@
|
||||
@refresh-applications="getApplications"
|
||||
/>
|
||||
</div>
|
||||
<div class="headers">
|
||||
<div v-if="api?.request?.headers" class="headers">
|
||||
<h2 class="title">{{ $t('api.entity.requestHeaders') }}</h2>
|
||||
<api-form
|
||||
v-model:form="formValue.headers"
|
||||
@@ -20,13 +20,13 @@
|
||||
:applications="applications"
|
||||
/>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div v-if="api?.request?.body" class="body">
|
||||
<h2 class="title">{{ $t('api.entity.requestBody') }}</h2>
|
||||
<api-form v-model:form="formValue.body" :schema="api?.request?.body" :api="api" :applications="applications" />
|
||||
</div>
|
||||
<div v-if="api?.responses" class="responses">
|
||||
<h2 class="title">{{ $t('api.entity.response') }}</h2>
|
||||
<api-result :responses="api?.responses" />
|
||||
<api-responses :responses="api?.responses" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -35,7 +35,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApi, IForm } from '@/operators/api/models';
|
||||
import ApiForm from './Form.vue';
|
||||
import ApiResult from './Result.vue';
|
||||
import ApiResponses from './Responses.vue';
|
||||
import { applicationOperator } from '@/operators/application/operator';
|
||||
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
||||
|
||||
@@ -49,7 +49,7 @@ export default defineComponent({
|
||||
name: 'ApiUsage',
|
||||
components: {
|
||||
ApiForm,
|
||||
ApiResult
|
||||
ApiResponses
|
||||
},
|
||||
props: {
|
||||
api: {
|
||||
|
||||
@@ -10,5 +10,6 @@ export default {
|
||||
failure: '失败',
|
||||
responseExample: '样例',
|
||||
authentication: '认证',
|
||||
arrayOf: '列表',
|
||||
apiKey: 'API Key'
|
||||
};
|
||||
@@ -14,14 +14,15 @@ export interface IForm {
|
||||
}
|
||||
|
||||
export interface ISchema {
|
||||
properties: {
|
||||
properties?: {
|
||||
[key: string]: ISchema;
|
||||
};
|
||||
enum: (string | number)[];
|
||||
items?: ISchema[];
|
||||
enum?: (string | number)[];
|
||||
type: 'object' | 'array' | 'string' | 'number' | 'boolean';
|
||||
title: string;
|
||||
optional: boolean;
|
||||
example: string | number;
|
||||
optional?: boolean;
|
||||
example?: string | number;
|
||||
}
|
||||
|
||||
export interface IRequest {
|
||||
|
||||
Reference in new issue
Block a user