This commit is contained in:
syuilo 2021-01-10 11:16:20 +09:00
parent e5107f47cf
commit 10c1e8161f
5 changed files with 48 additions and 38 deletions

View File

@ -13,7 +13,7 @@
<h2>Response</h2>
<section v-for="status in Object.keys(ep.spec.responses)" :key="status">
<h3>{{ status }}</h3>
<XValue :value="ep.spec.responses[status].content['application/json'].schema" :schemas="ep.schemas"/>
<XValue v-if="ep.spec.responses[status].content" :value="ep.spec.responses[status].content['application/json'].schema" :schemas="ep.schemas"/>
</section>
</section>
<section class="raw">

View File

@ -2,7 +2,7 @@
<div class="">
Array of
<div class="">
<XValue class="kv _vMargin _shadow" :value="array" :schemas="schemas"/>
<XValue class="" :value="array" :schemas="schemas"/>
</div>
</div>
</template>

View File

@ -1,7 +1,8 @@
<template>
<div class="jhpkzgfz">
<div class="kvs">
<XValue v-for="kv in kvs" :key="kv[0]" class="kv _vMargin _shadow" :name="kv[0]" :value="kv[1]" :schemas="schemas"/>
<div class="kv" v-for="kv in kvs" :key="kv[0]">
<div class="k _monospace">{{ kv[0] }}</div>
<XValue class="v" :value="kv[1]" :schemas="schemas"/>
</div>
</div>
</template>
@ -43,16 +44,27 @@ export default defineComponent({
<style lang="scss" scoped>
.jhpkzgfz {
> .kvs {
border: solid 1px var(--divider);
border-radius: 4px;
padding: 16px;
> .kv {
::v-deep(.k) {
font-weight: bold;
}
> .kv {
display: flex;
::v-deep(.v) {
padding: 16px;
}
&:not(:first-child) {
margin-top: 16px;
padding-top: 16px;
border-top: solid 1px var(--divider);
}
> .k {
font-weight: bold;
margin-right: 1em;
min-width: 8em;
}
> .v {
flex: 1;
}
}
}

View File

@ -1,18 +1,17 @@
<template>
<MkContainer :body-togglable="true" class="ezkosiua">
<template #header>
<div class="header _monospace">
<span class="name">{{ name }}</span>
<span class="type">{{ type }}</span>
</div>
</template>
<div class="ezkosiua">
<div class="header _monospace">
<span v-if="value.$ref" class="ref">
<button class="_textButton" @click="resolveRef = true">
{{ value.$ref.replace('#/components/schemas/', '') }}
</button>
</span>
<span class="type">{{ type }}</span>
</div>
<div class="body">
<div class="description">{{ value.description }}</div>
<div v-if="value.$ref" class="ref">
<button class="_textButton" @click="resolveRef = true">
{{ value.$ref.replace('#/components/schemas/', '') }}
</button>
<div v-if="resolveRef">
<XValue :value="schemas[value.$ref.replace('#/components/schemas/', '')]" :schemas="schemas"/>
</div>
@ -29,7 +28,7 @@
unknown
</div>
</div>
</MkContainer>
</div>
</template>
<script lang="ts">
@ -62,10 +61,6 @@ export default defineComponent({
type: Object,
required: true
},
name: {
type: String,
required: false
},
},
data() {
@ -82,14 +77,9 @@ export default defineComponent({
<style lang="scss" scoped>
.ezkosiua {
::v-deep(.header) {
> .name {
font-weight: bold;
margin-right: 1em;
&:empty {
display: none;
}
> .header {
> .ref {
margin-right: 8px;
}
> .type {
@ -99,8 +89,8 @@ export default defineComponent({
}
}
::v-deep(.body) {
padding: 16px;
> .body {
margin-top: 8px;
}
}
</style>

View File

@ -8,7 +8,15 @@ import { schemas, convertSchemaToOpenApiSchema } from './schemas';
import { getDescription } from './description';
export function genOpenapiSpecForEndpoint(endpoint: IEndpoint, lang = 'ja-JP') {
const locale = yaml.safeLoad(fs.readFileSync(__dirname + `/../../../api-docs/${lang}/` + endpoint.name + '.yml', 'utf-8'));
let locale;
try {
locale = yaml.safeLoad(fs.readFileSync(__dirname + `/../../../api-docs/${lang}/` + endpoint.name + '.yml', 'utf-8'));
} catch (e) {
locale = {
params: {}
};
}
function genProps(props: { [key: string]: Context; }) {
const properties = {} as any;