@dv.net/docs-vitepress-openapi 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/dist/docs-vitepress-openapi.client.cjs.js +1 -0
- package/dist/docs-vitepress-openapi.client.es.js +16 -0
- package/dist/docs-vitepress-openapi.css +1 -0
- package/dist/docs-vitepress-openapi.node.cjs.js +4102 -0
- package/dist/docs-vitepress-openapi.node.es.js +72981 -0
- package/dist/vanilla-picker-BAEwS4Fy.js +536 -0
- package/dist/vanilla-picker-m653iADl.cjs +8 -0
- package/package.json +80 -0
- package/src/client.ts +73 -0
- package/src/components/Common/Lazy/OALazy.vue +49 -0
- package/src/components/Common/Lazy/lazyBus.ts +8 -0
- package/src/components/Common/OACodeBlock.vue +91 -0
- package/src/components/Common/OACodeValue.vue +22 -0
- package/src/components/Common/OAHeaderBadges.vue +44 -0
- package/src/components/Common/OAHeading.vue +84 -0
- package/src/components/Common/OAInfo.vue +106 -0
- package/src/components/Common/OAIntroduction.vue +25 -0
- package/src/components/Common/OAJSONEditor.vue +41 -0
- package/src/components/Common/OAMarkdown.vue +28 -0
- package/src/components/Common/OAMethodBadge.vue +20 -0
- package/src/components/Common/OAServers.vue +42 -0
- package/src/components/Operation/OAOperation.vue +345 -0
- package/src/components/Operation/OAOperationTags.vue +30 -0
- package/src/components/Parameter/OAParameter.vue +80 -0
- package/src/components/Parameter/OAParameterAttribute.vue +44 -0
- package/src/components/Parameter/OAParameterExamples.vue +52 -0
- package/src/components/Parameter/OAParameters.vue +69 -0
- package/src/components/Path/OAPath.vue +347 -0
- package/src/components/Path/OAPathEndpoint.vue +99 -0
- package/src/components/Path/OAPaths.vue +62 -0
- package/src/components/Path/OAPathsByTag.vue +118 -0
- package/src/components/Path/OAPathsByTags.vue +99 -0
- package/src/components/Path/OAPathsSummary.vue +52 -0
- package/src/components/Playground/OAPlaygroundParameterInput.vue +97 -0
- package/src/components/Playground/OAPlaygroundParameters.vue +262 -0
- package/src/components/Playground/OAPlaygroundResponse.vue +74 -0
- package/src/components/Playground/OAPlaygroundSecurityInput.vue +44 -0
- package/src/components/Remote/OARemoteContext.vue +42 -0
- package/src/components/Remote/OARemoteOperation.vue +30 -0
- package/src/components/Remote/OARemoteRoot.vue +29 -0
- package/src/components/Remote/OARemoteSpec.vue +23 -0
- package/src/components/Request/OARequestBody.vue +24 -0
- package/src/components/Response/OAResponse.vue +81 -0
- package/src/components/Response/OAResponses.vue +119 -0
- package/src/components/Sample/OACodeSamples.vue +71 -0
- package/src/components/Schema/OASchemaPropertyAttributes.vue +44 -0
- package/src/components/Schema/OASchemaTabs.vue +90 -0
- package/src/components/Schema/OASchemaUI.vue +151 -0
- package/src/components/Security/OASecurity.vue +79 -0
- package/src/components/Security/OASecurityContent.vue +100 -0
- package/src/components/Spec/OASpec.vue +127 -0
- package/src/components/Spec/OASpecSkeleton.vue +26 -0
- package/src/components/Try/OATryItButton.vue +171 -0
- package/src/components/Try/OATryWithVariables.vue +105 -0
- package/src/components/index.ts +55 -0
- package/src/components/ui/badge/Badge.vue +18 -0
- package/src/components/ui/badge/index.ts +32 -0
- package/src/components/ui/button/Button.vue +28 -0
- package/src/components/ui/button/index.ts +37 -0
- package/src/components/ui/checkbox/Checkbox.vue +33 -0
- package/src/components/ui/checkbox/index.ts +1 -0
- package/src/components/ui/collapsible/Collapsible.vue +18 -0
- package/src/components/ui/collapsible/CollapsibleContent.vue +15 -0
- package/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
- package/src/components/ui/collapsible/index.ts +3 -0
- package/src/components/ui/input/Input.vue +29 -0
- package/src/components/ui/input/index.ts +1 -0
- package/src/components/ui/label/Label.vue +29 -0
- package/src/components/ui/label/index.ts +1 -0
- package/src/components/ui/multiselect/Multiselect.vue +104 -0
- package/src/components/ui/select/Select.vue +15 -0
- package/src/components/ui/select/SelectContent.vue +56 -0
- package/src/components/ui/select/SelectGroup.vue +24 -0
- package/src/components/ui/select/SelectItem.vue +40 -0
- package/src/components/ui/select/SelectItemText.vue +12 -0
- package/src/components/ui/select/SelectLabel.vue +14 -0
- package/src/components/ui/select/SelectScrollDownButton.vue +29 -0
- package/src/components/ui/select/SelectScrollUpButton.vue +29 -0
- package/src/components/ui/select/SelectSeparator.vue +22 -0
- package/src/components/ui/select/SelectTrigger.vue +33 -0
- package/src/components/ui/select/SelectValue.vue +12 -0
- package/src/components/ui/select/index.ts +11 -0
- package/src/components/ui/tabs/Tabs.vue +15 -0
- package/src/components/ui/tabs/TabsContent.vue +24 -0
- package/src/components/ui/tabs/TabsList.vue +27 -0
- package/src/components/ui/tabs/TabsTrigger.vue +33 -0
- package/src/components/ui/tabs/index.ts +21 -0
- package/src/composables/useOpenapi.ts +70 -0
- package/src/composables/usePaths.ts +31 -0
- package/src/composables/usePlayground.ts +49 -0
- package/src/composables/useShiki.ts +46 -0
- package/src/composables/useSidebar.ts +301 -0
- package/src/composables/useTheme.ts +799 -0
- package/src/index.ts +8 -0
- package/src/json.css +251 -0
- package/src/lib/OpenApi.ts +254 -0
- package/src/lib/codeSamples/buildRequest.ts +149 -0
- package/src/lib/codeSamples/generateCodeSample.ts +20 -0
- package/src/lib/codeSamples/generateCodeSampleCurl.ts +150 -0
- package/src/lib/codeSamples/generateCodeSampleJavaScript.ts +29 -0
- package/src/lib/codeSamples/generateCodeSamplePhp.ts +50 -0
- package/src/lib/codeSamples/generateCodeSamplePython.ts +32 -0
- package/src/lib/codeSamples/request.ts +25 -0
- package/src/lib/constraintsParser.ts +30 -0
- package/src/lib/createOpenApiInstance.ts +18 -0
- package/src/lib/deepUnref.ts +76 -0
- package/src/lib/examples/getPropertyExample.ts +31 -0
- package/src/lib/examples/getPropertyExamples.ts +27 -0
- package/src/lib/examples/getSchemaExample.ts +38 -0
- package/src/lib/examples/getSchemaUiJson.ts +150 -0
- package/src/lib/examples/getSchemaUiXml.ts +9 -0
- package/src/lib/examples/hasExample.ts +26 -0
- package/src/lib/getOpenApiInstance.ts +39 -0
- package/src/lib/getSchemaUi.ts +280 -0
- package/src/lib/getSecurityUi.ts +33 -0
- package/src/lib/operationData.ts +24 -0
- package/src/lib/prepareOpenAPI/generateMissingOperationIds.ts +19 -0
- package/src/lib/prepareOpenAPI/generateMissingSummary.ts +20 -0
- package/src/lib/prepareOpenAPI/generateMissingTags.ts +36 -0
- package/src/lib/prepareOpenAPI/prepareOpenAPI.ts +35 -0
- package/src/lib/processOpenAPI.ts +131 -0
- package/src/lib/resolveCircularRef.ts +66 -0
- package/src/lib/sidebar/cleanSidebarItems.ts +19 -0
- package/src/lib/sidebar/ensureGroupTextSlashPrefix.ts +18 -0
- package/src/lib/sidebar/flatSidebarItems.ts +58 -0
- package/src/lib/sidebar/generateSidebarItemsByPaths.ts +132 -0
- package/src/lib/sidebar/mergeAdjacentGroups.ts +56 -0
- package/src/lib/sidebar/setItemCollapsedState.ts +15 -0
- package/src/lib/utils.ts +7 -0
- package/src/locales/en.json +50 -0
- package/src/locales/index.ts +4 -0
- package/src/style.css +180 -0
- package/src/types.ts +73 -0
- package/src/vite-env.d.ts +8 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import OASpecSkeleton from '../Spec/OASpecSkeleton.vue'
|
|
3
|
+
import OARemoteContext from './OARemoteContext.vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
specUrl: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const emits = defineEmits([
|
|
13
|
+
'update:spec',
|
|
14
|
+
])
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<Suspense>
|
|
19
|
+
<OARemoteContext :spec-url="props.specUrl" @update:spec="emits('update:spec', $event)">
|
|
20
|
+
<template #default="{ spec }">
|
|
21
|
+
<slot :spec="spec" />
|
|
22
|
+
</template>
|
|
23
|
+
</OARemoteContext>
|
|
24
|
+
|
|
25
|
+
<template #fallback>
|
|
26
|
+
<OASpecSkeleton />
|
|
27
|
+
</template>
|
|
28
|
+
</Suspense>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import OASpec from '../Spec/OASpec.vue'
|
|
3
|
+
import OARemoteRoot from './OARemoteRoot.vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
specUrl: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const emits = defineEmits([
|
|
13
|
+
'update:spec',
|
|
14
|
+
])
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<OARemoteRoot :spec-url="props.specUrl" @update:spec="emits('update:spec', $event)">
|
|
19
|
+
<template #default="{ spec }">
|
|
20
|
+
<OASpec :spec="spec" v-bind="$attrs" />
|
|
21
|
+
</template>
|
|
22
|
+
</OARemoteRoot>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
operationId: {
|
|
4
|
+
type: String,
|
|
5
|
+
required: true,
|
|
6
|
+
},
|
|
7
|
+
requestBody: {
|
|
8
|
+
type: Object,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
contentType: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<OASchemaTabs
|
|
20
|
+
:schema="props.requestBody?.content?.[props.contentType]?.ui"
|
|
21
|
+
:examples="props.requestBody?.content?.[props.contentType]?.examples"
|
|
22
|
+
:content-type="props.contentType"
|
|
23
|
+
/>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, defineProps, ref } from 'vue'
|
|
3
|
+
import { Label } from '../ui/label'
|
|
4
|
+
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
operationId: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
response: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
responseCode: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const contentTypes = Object.keys(props.response.content ?? {})
|
|
22
|
+
|
|
23
|
+
const contentType = ref(contentTypes[0] ?? undefined)
|
|
24
|
+
|
|
25
|
+
const schema = computed(() => props.response.content?.[contentType.value]?.ui)
|
|
26
|
+
|
|
27
|
+
const examples = computed(() => props.response.content?.[contentType.value]?.examples)
|
|
28
|
+
|
|
29
|
+
const contentTypeId = `content-type-${Math.random().toString(36).substring(7)}`
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<div class="flex flex-col space-y-4">
|
|
34
|
+
<span class="text-gray-800 dark:text-gray-200 text-lg">{{ props.response.description }}</span>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
v-if="props.response?.content && contentTypes.length"
|
|
38
|
+
class="flex flex-row items-center gap-2 text-xs"
|
|
39
|
+
>
|
|
40
|
+
<Label
|
|
41
|
+
:for="contentTypeId"
|
|
42
|
+
class="flex-shrink-0 text-gray-600 dark:text-gray-400"
|
|
43
|
+
>
|
|
44
|
+
{{ $t('Content-Type') }}
|
|
45
|
+
</Label>
|
|
46
|
+
<div class="flex-shrink-0">
|
|
47
|
+
<Select
|
|
48
|
+
v-if="contentTypes.length > 1"
|
|
49
|
+
:id="contentTypeId"
|
|
50
|
+
v-model="contentType"
|
|
51
|
+
>
|
|
52
|
+
<SelectTrigger
|
|
53
|
+
aria-label="Content-Type"
|
|
54
|
+
class="h-6 text-xs"
|
|
55
|
+
>
|
|
56
|
+
<SelectValue>{{ contentType }}</SelectValue>
|
|
57
|
+
</SelectTrigger>
|
|
58
|
+
<SelectContent>
|
|
59
|
+
<SelectGroup>
|
|
60
|
+
<SelectItem
|
|
61
|
+
v-for="(type, idx) in contentTypes"
|
|
62
|
+
:key="idx"
|
|
63
|
+
:value="type"
|
|
64
|
+
>
|
|
65
|
+
{{ type }}
|
|
66
|
+
</SelectItem>
|
|
67
|
+
</SelectGroup>
|
|
68
|
+
</SelectContent>
|
|
69
|
+
</Select>
|
|
70
|
+
<span v-else class="h-6 text-xs rounded-md bg-muted px-3 py-1">{{ contentType }}</span>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<OASchemaTabs
|
|
75
|
+
v-if="schema"
|
|
76
|
+
:schema="schema"
|
|
77
|
+
:examples="examples"
|
|
78
|
+
:content-type="contentType"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { TabsIndicator } from 'radix-vue'
|
|
3
|
+
import { computed, defineProps, ref } from 'vue'
|
|
4
|
+
import { useTheme } from '../../composables/useTheme'
|
|
5
|
+
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
|
|
6
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
operationId: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
responses: {
|
|
14
|
+
type: Object,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
headingPrefix: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: null,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const themeConfig = useTheme()
|
|
24
|
+
|
|
25
|
+
const responsesCodes = Object.keys(props.responses)
|
|
26
|
+
|
|
27
|
+
const vModel = ref(responsesCodes && responsesCodes.length > 0 ? responsesCodes[0] : null)
|
|
28
|
+
|
|
29
|
+
const tabsSelector = computed(() => {
|
|
30
|
+
const selector = themeConfig.getResponseCodeSelector()
|
|
31
|
+
|
|
32
|
+
if (selector === 'tabs') {
|
|
33
|
+
const maxTabs = themeConfig.getResponseCodeMaxTabs()
|
|
34
|
+
|
|
35
|
+
return maxTabs && responsesCodes.length > maxTabs ? 'select' : 'tabs'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return selector
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<div class="flex flex-col">
|
|
44
|
+
<Tabs
|
|
45
|
+
:default-value="vModel"
|
|
46
|
+
>
|
|
47
|
+
<div class="mt-[48px] mb-[16px] pt-[24px] border-t-[1px] border-[var(--vp-c-divider)]">
|
|
48
|
+
<TabsList class="w-full bg-transparent text-muted-foreground p-0">
|
|
49
|
+
<OAHeading
|
|
50
|
+
level="h2"
|
|
51
|
+
:prefix="headingPrefix"
|
|
52
|
+
class="text-[var(--vp-c-text-1)] !my-0 !py-0 !border-t-0"
|
|
53
|
+
header-anchor-class="!top-0"
|
|
54
|
+
>
|
|
55
|
+
{{ $t('Responses') }}
|
|
56
|
+
</OAHeading>
|
|
57
|
+
|
|
58
|
+
<span class="flex-grow min-w-2" />
|
|
59
|
+
|
|
60
|
+
<div class="relative flex flex-row">
|
|
61
|
+
<template v-if="tabsSelector === 'tabs'">
|
|
62
|
+
<TabsIndicator class="absolute left-0 h-full bottom-0 w-[--radix-tabs-indicator-size] translate-x-[--radix-tabs-indicator-position] rounded transition-[width,transform] duration-300 bg-muted" />
|
|
63
|
+
|
|
64
|
+
<TabsTrigger
|
|
65
|
+
v-for="responseCode in responsesCodes"
|
|
66
|
+
:key="responseCode"
|
|
67
|
+
:value="responseCode"
|
|
68
|
+
class="h-full z-10"
|
|
69
|
+
>
|
|
70
|
+
{{ responseCode }}
|
|
71
|
+
</TabsTrigger>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<Select
|
|
75
|
+
v-if="tabsSelector === 'select'"
|
|
76
|
+
v-model="vModel"
|
|
77
|
+
>
|
|
78
|
+
<SelectTrigger
|
|
79
|
+
aria-label="Response Code"
|
|
80
|
+
class="px-3 py-1.5 text-foreground"
|
|
81
|
+
>
|
|
82
|
+
<SelectValue>{{ vModel }}</SelectValue>
|
|
83
|
+
</SelectTrigger>
|
|
84
|
+
<SelectContent>
|
|
85
|
+
<SelectGroup>
|
|
86
|
+
<TabsTrigger
|
|
87
|
+
v-for="(code, idx) in responsesCodes"
|
|
88
|
+
:key="idx"
|
|
89
|
+
:value="code"
|
|
90
|
+
variant="select"
|
|
91
|
+
>
|
|
92
|
+
<SelectItem
|
|
93
|
+
:value="code"
|
|
94
|
+
>
|
|
95
|
+
{{ code }}
|
|
96
|
+
</SelectItem>
|
|
97
|
+
</TabsTrigger>
|
|
98
|
+
</SelectGroup>
|
|
99
|
+
</SelectContent>
|
|
100
|
+
</Select>
|
|
101
|
+
</div>
|
|
102
|
+
</TabsList>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<TabsContent
|
|
106
|
+
v-for="responseCode in responsesCodes"
|
|
107
|
+
:key="responseCode"
|
|
108
|
+
:value="responseCode"
|
|
109
|
+
>
|
|
110
|
+
<OAResponse
|
|
111
|
+
v-if="props.responses[responseCode]"
|
|
112
|
+
:operation-id="props.operationId"
|
|
113
|
+
:response="props.responses[responseCode]"
|
|
114
|
+
:response-code="responseCode"
|
|
115
|
+
/>
|
|
116
|
+
</TabsContent>
|
|
117
|
+
</Tabs>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useTheme } from '../../composables/useTheme'
|
|
4
|
+
import { OARequest } from '../../lib/codeSamples/request'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
operationId: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
request: {
|
|
12
|
+
type: Object,
|
|
13
|
+
default: () => (new OARequest()),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const themeConfig = useTheme()
|
|
18
|
+
|
|
19
|
+
const availableLanguages = themeConfig.getCodeSamplesAvailableLanguages()
|
|
20
|
+
|
|
21
|
+
const configuredLanguages = themeConfig.getCodeSamplesLangs()
|
|
22
|
+
|
|
23
|
+
const generator = themeConfig.getCodeSamplesGenerator()
|
|
24
|
+
|
|
25
|
+
const samples = computed(() => availableLanguages
|
|
26
|
+
.filter((availableLanguage) => {
|
|
27
|
+
return configuredLanguages.includes(availableLanguage.lang)
|
|
28
|
+
})
|
|
29
|
+
.map((availableLanguage) => {
|
|
30
|
+
return {
|
|
31
|
+
...availableLanguage,
|
|
32
|
+
source: generator(availableLanguage.lang, {
|
|
33
|
+
...props.request,
|
|
34
|
+
headers: {
|
|
35
|
+
...(themeConfig.getCodeSamplesDefaultHeaders() || {}),
|
|
36
|
+
...props.request.headers,
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
)
|
|
42
|
+
const defaultLang = themeConfig.getCodeSamplesDefaultLang()
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div class="vp-code-group vp-adaptive-theme">
|
|
47
|
+
<div class="tabs">
|
|
48
|
+
<template v-for="sample in samples" :key="sample.lang">
|
|
49
|
+
<input
|
|
50
|
+
:id="`tab-${props.operationId}-${sample.lang}`"
|
|
51
|
+
type="radio"
|
|
52
|
+
:name="`group-${props.operationId}`"
|
|
53
|
+
:checked="sample.lang === defaultLang"
|
|
54
|
+
>
|
|
55
|
+
<label :for="`tab-${props.operationId}-${sample.lang}`">{{ sample.label || sample.lang }}</label>
|
|
56
|
+
</template>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div class="blocks">
|
|
60
|
+
<OACodeBlock
|
|
61
|
+
v-for="sample in samples"
|
|
62
|
+
:key="sample.lang"
|
|
63
|
+
:code="sample.source"
|
|
64
|
+
:lang="sample.highlighter"
|
|
65
|
+
:label="sample.label"
|
|
66
|
+
:class="{ active: sample.lang === defaultLang }"
|
|
67
|
+
class="!mb-0"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { titleCase } from 'scule'
|
|
3
|
+
import OACodeValue from '../Common/OACodeValue.vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
property: {
|
|
7
|
+
type: Object,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const keysToIgnore = ['name', 'types', 'description', 'properties', 'required', 'items', 'xml', 'allOf', 'anyOf', 'oneOf', 'not']
|
|
13
|
+
|
|
14
|
+
const isNonEmptyValue = (value) => {
|
|
15
|
+
if (value === null || value === undefined) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
return value.length > 0
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === 'object') {
|
|
22
|
+
return Object.keys(value).length > 0
|
|
23
|
+
}
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const properties = Object.keys(props.property)
|
|
28
|
+
.filter(key => !keysToIgnore.includes(key)) // Exclude specified keys
|
|
29
|
+
.filter(key => isNonEmptyValue(props.property[key])) // Keep only non-empty values
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<div
|
|
34
|
+
v-for="(key, propertyIdx) in properties"
|
|
35
|
+
:key="propertyIdx"
|
|
36
|
+
class="flex flex-row flex-wrap items-center gap-2"
|
|
37
|
+
>
|
|
38
|
+
<span class="text-xs text-gray-600 dark:text-gray-300">
|
|
39
|
+
{{ titleCase(key) }}
|
|
40
|
+
</span>
|
|
41
|
+
|
|
42
|
+
<OACodeValue :value="props.property[key]" />
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useTheme } from '../../composables/useTheme'
|
|
4
|
+
import OAMarkdown from '../Common/OAMarkdown.vue'
|
|
5
|
+
import OASchemaUI from '../Schema/OASchemaUI.vue'
|
|
6
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
schema: {
|
|
10
|
+
type: Object,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
examples: {
|
|
14
|
+
type: null,
|
|
15
|
+
required: false,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const themeConfig = useTheme()
|
|
20
|
+
|
|
21
|
+
const defaultValue = computed(() => {
|
|
22
|
+
const defaultView = themeConfig.schemaConfig.defaultView.value
|
|
23
|
+
const examplesKeys = Object.keys(props.examples ?? {})
|
|
24
|
+
|
|
25
|
+
const viewMap = {
|
|
26
|
+
schema: 'schema',
|
|
27
|
+
contentType: examplesKeys?.length ? `examples.${examplesKeys[0]}` : 'schema',
|
|
28
|
+
autogenerated: (() => {
|
|
29
|
+
const autogeneratedExample = examplesKeys.find(key => props.examples[key]?.isAutogenerated)
|
|
30
|
+
return autogeneratedExample ? `examples.${autogeneratedExample}` : 'schema'
|
|
31
|
+
})(),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return viewMap[defaultView] ?? defaultView
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<Tabs
|
|
40
|
+
:default-value="defaultValue"
|
|
41
|
+
>
|
|
42
|
+
<TabsList class="relative flex flex-row justify-start">
|
|
43
|
+
<TabsTrigger
|
|
44
|
+
value="schema"
|
|
45
|
+
variant="schemaTabs"
|
|
46
|
+
class="h-full"
|
|
47
|
+
>
|
|
48
|
+
{{ $t('Schema') }}
|
|
49
|
+
</TabsTrigger>
|
|
50
|
+
<TabsTrigger
|
|
51
|
+
v-for="(_, exampleKey) in props.examples ?? {}"
|
|
52
|
+
:key="exampleKey"
|
|
53
|
+
:value="`examples.${exampleKey}`"
|
|
54
|
+
variant="schemaTabs"
|
|
55
|
+
class="h-full"
|
|
56
|
+
>
|
|
57
|
+
{{ exampleKey }}
|
|
58
|
+
</TabsTrigger>
|
|
59
|
+
</TabsList>
|
|
60
|
+
<TabsContent value="schema">
|
|
61
|
+
<div class="flex flex-col gap-2">
|
|
62
|
+
<OASchemaUI
|
|
63
|
+
:property="props.schema"
|
|
64
|
+
:schema="props.schema"
|
|
65
|
+
:deep="themeConfig.getSchemaViewerDeep()"
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</TabsContent>
|
|
69
|
+
<TabsContent
|
|
70
|
+
v-for="(example, exampleKey) in props.examples ?? {}"
|
|
71
|
+
:key="exampleKey"
|
|
72
|
+
:value="`examples.${exampleKey}`"
|
|
73
|
+
>
|
|
74
|
+
<div class="flex flex-col gap-2">
|
|
75
|
+
<OAMarkdown
|
|
76
|
+
v-if="example?.description"
|
|
77
|
+
:content="example?.description"
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<OACodeBlock
|
|
81
|
+
v-if="example?.value"
|
|
82
|
+
:code="example?.value"
|
|
83
|
+
:lang="example?.lang ?? 'json'"
|
|
84
|
+
:label="(example?.lang ?? 'json').toUpperCase()"
|
|
85
|
+
class="!my-0"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
</TabsContent>
|
|
89
|
+
</Tabs>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { Badge } from '../ui/badge'
|
|
4
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../ui/collapsible'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
property: {
|
|
8
|
+
type: Object,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
schema: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
deep: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: Infinity,
|
|
18
|
+
},
|
|
19
|
+
level: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 0,
|
|
22
|
+
},
|
|
23
|
+
open: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: undefined,
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const isOpen = ref(props.open !== undefined ? props.open : props.deep > 0 && props.level <= 10)
|
|
30
|
+
|
|
31
|
+
const isObject = props.property.types?.includes('object')
|
|
32
|
+
const isArray = props.property.types?.includes('array')
|
|
33
|
+
const isObjectOrArray = isObject || isArray || props.property.type === 'object' || props.property.type === 'array'
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<div>
|
|
38
|
+
<Collapsible
|
|
39
|
+
v-model:open="isOpen"
|
|
40
|
+
:disabled="!isObjectOrArray"
|
|
41
|
+
>
|
|
42
|
+
<CollapsibleTrigger class="w-full">
|
|
43
|
+
<div class="flex flex-col text-start space-y-1 group select-text cursor-auto">
|
|
44
|
+
<div class="flex flex-row items-center gap-2 text-sm">
|
|
45
|
+
<span
|
|
46
|
+
v-if="props.property.name && props.property.name.trim() !== ''"
|
|
47
|
+
class="font-bold"
|
|
48
|
+
>
|
|
49
|
+
{{ props.property.name }}
|
|
50
|
+
</span>
|
|
51
|
+
|
|
52
|
+
<div
|
|
53
|
+
v-if="isObjectOrArray && props.property.properties"
|
|
54
|
+
class="flex-shrink-0 w-4 h-4 cursor-pointer"
|
|
55
|
+
>
|
|
56
|
+
<svg
|
|
57
|
+
v-if="!isOpen"
|
|
58
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
59
|
+
width="100%"
|
|
60
|
+
height="100%"
|
|
61
|
+
viewBox="0 0 24 24"
|
|
62
|
+
><path
|
|
63
|
+
fill="currentColor"
|
|
64
|
+
d="M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z"
|
|
65
|
+
/></svg>
|
|
66
|
+
<svg
|
|
67
|
+
v-if="isOpen"
|
|
68
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
69
|
+
width="100%"
|
|
70
|
+
height="100%"
|
|
71
|
+
viewBox="0 0 24 24"
|
|
72
|
+
><path
|
|
73
|
+
fill="currentColor"
|
|
74
|
+
d="M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z"
|
|
75
|
+
/></svg>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="flex flex-row items-center gap-1 text-gray-600 dark:text-gray-400">
|
|
79
|
+
<Badge
|
|
80
|
+
v-if="props.property.meta?.isCircularReference === true"
|
|
81
|
+
variant="outline"
|
|
82
|
+
>
|
|
83
|
+
{{ $t('Circular Reference') }}
|
|
84
|
+
</Badge>
|
|
85
|
+
<template v-else-if="props.property.types.length === 1 && ['array'].includes(props.property.types[0]) && props.property.subtype">
|
|
86
|
+
<span>{{ props.property.subtype }}[]</span>
|
|
87
|
+
</template>
|
|
88
|
+
<template v-else-if="props.property.types.length === 1 && ['object'].includes(props.property.types[0]) && props.property.subtype">
|
|
89
|
+
<span>{{ props.property.subtype }}</span>
|
|
90
|
+
</template>
|
|
91
|
+
<template v-else-if="props.property.meta?.isConstant === true">
|
|
92
|
+
<span>{{ $t('const:') }}</span>
|
|
93
|
+
<span v-if="props.property.examples?.length > 0" class="select-all">{{ props.property.examples[0] }}</span>
|
|
94
|
+
</template>
|
|
95
|
+
<template v-else>
|
|
96
|
+
<span v-for="(type, index) in props.property.types" :key="type">
|
|
97
|
+
{{ type }}
|
|
98
|
+
<span v-if="index !== props.property.types.length - 1">|</span>
|
|
99
|
+
</span>
|
|
100
|
+
</template>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div class="flex-grow mx-2">
|
|
104
|
+
<div
|
|
105
|
+
v-if="props.property.required === true"
|
|
106
|
+
class="h-px bg-transparent group-hover:bg-gray-200 dark:group-hover:bg-gray-800"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<span class="text-red-800 dark:text-red-200 text-xs">{{
|
|
111
|
+
props.property.required === true ? $t('Required') : ''
|
|
112
|
+
}}</span>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<OAMarkdown
|
|
116
|
+
v-if="props.property?.description"
|
|
117
|
+
:content="props.property.description"
|
|
118
|
+
class="text-sm text-gray-800 dark:text-gray-300"
|
|
119
|
+
:class="{
|
|
120
|
+
'pl-2': isObjectOrArray,
|
|
121
|
+
}"
|
|
122
|
+
/>
|
|
123
|
+
|
|
124
|
+
<OASchemaPropertyAttributes v-if="props.property.enum" :property="{ [$t('valid values')]: props.property.enum }" />
|
|
125
|
+
|
|
126
|
+
<OASchemaPropertyAttributes v-if="props.property.constraints" :property="props.property.constraints" />
|
|
127
|
+
</div>
|
|
128
|
+
</CollapsibleTrigger>
|
|
129
|
+
<CollapsibleContent v-if="isObjectOrArray" class="ml-2 pl-2 border-l border-l-solid">
|
|
130
|
+
<Badge
|
|
131
|
+
v-if="props.property.meta?.isOneOf === true"
|
|
132
|
+
variant="outline"
|
|
133
|
+
>
|
|
134
|
+
{{ $t('One of') }}
|
|
135
|
+
</Badge>
|
|
136
|
+
|
|
137
|
+
<div class="flex flex-col space-y-2">
|
|
138
|
+
<OASchemaUI
|
|
139
|
+
v-for="(subProperty, idx) in props.property.properties"
|
|
140
|
+
:key="idx"
|
|
141
|
+
:property="subProperty"
|
|
142
|
+
:schema="props.schema"
|
|
143
|
+
:deep="props.deep - 1"
|
|
144
|
+
:level="props.level + 1"
|
|
145
|
+
:open="subProperty?.meta?.isOneOf === true"
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</CollapsibleContent>
|
|
149
|
+
</Collapsible>
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|