-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(open-api): improve rendering of (response) schemas
INT-407
- Loading branch information
Showing
3 changed files
with
195 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/.vuepress/theme/client/components/global/OpenApiSchemaInfo.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<header> | ||
<strong v-if="title">{{ title }}</strong> | ||
<strong v-else-if="schema && schema.title">{{ schema.title }}</strong> | ||
<pre | ||
v-if="schema && schema.type" | ||
class="m-0 p-0 text-sm whitespace-nowrap"> | ||
{{ schema.type }} | ||
<template v-if="schema.format">({{ schema.format }})</template> | ||
</pre> | ||
|
||
<p | ||
v-if="schema && schema.description" | ||
class="m-0 p-0 text-gray-500 text-sm"> | ||
{{ schema.description }} | ||
</p> | ||
|
||
<div | ||
v-if="schema && schema.enum" | ||
class="items-center schema-row"> | ||
<div class="font-bold mr-2 schema-row-label">Enum:</div> | ||
<div class="p-2 schema-row-value"> | ||
<ul class="list-disc"> | ||
<li | ||
v-for="(value, index) in schema.enum" | ||
:key="index"> | ||
{{ value }} | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<div | ||
v-if="schema && schema.default" | ||
class="items-center schema-row"> | ||
<span class="font-bold mr-2 schema-row-label">Default:</span> | ||
<span class="schema-row-value">{{ schema.default }}</span> | ||
</div> | ||
|
||
<div | ||
v-if="schema && schema.pattern" | ||
class="items-center schema-row"> | ||
<span class="font-bold mr-2 schema-row-label">Pattern:</span> | ||
<span class="schema-row-value">{{ schema.pattern }}</span> | ||
</div> | ||
</header> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {type OpenAPIV3_1 as OpenApiType} from 'openapi-types'; | ||
defineProps<{ | ||
title?: string; | ||
schema: OpenApiType.SchemaObject; | ||
}>(); | ||
</script> |