@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
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dv.net/docs-vitepress-openapi",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.7",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/types/src/index.d.ts",
|
|
9
|
+
"import": "./dist/docs-vitepress-openapi.node.es.js"
|
|
10
|
+
},
|
|
11
|
+
"./client": {
|
|
12
|
+
"types": "./dist/types/src/client.d.ts",
|
|
13
|
+
"import": "./dist/docs-vitepress-openapi.client.es.js"
|
|
14
|
+
},
|
|
15
|
+
"./dist/style.css": "./dist/docs-vitepress-openapi.css"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/docs-vitepress-openapi.node.es.js",
|
|
18
|
+
"module": "./dist/docs-vitepress-openapi.node.es.js",
|
|
19
|
+
"types": "./dist/types/src/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "vite build",
|
|
29
|
+
"build-watch": "vite build --watch",
|
|
30
|
+
"lint": "eslint src",
|
|
31
|
+
"lint:fix": "eslint src --fix",
|
|
32
|
+
"typecheck": "vue-tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"vitepress": "1.6.3",
|
|
36
|
+
"vue": "3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@antfu/eslint-config": "4.2.0",
|
|
40
|
+
"@scalar/openapi-types": "0.1.7",
|
|
41
|
+
"@sindresorhus/slugify": "2.2.1",
|
|
42
|
+
"@trojs/openapi-dereference": "1.0.1",
|
|
43
|
+
"@vueuse/core": "12.5.0",
|
|
44
|
+
"@types/node": "22.13.1",
|
|
45
|
+
"@vitejs/plugin-vue": "5.2.1",
|
|
46
|
+
"allof-merge": "0.6.6",
|
|
47
|
+
"autoprefixer": "10.4.20",
|
|
48
|
+
"class-variance-authority": "0.7.1",
|
|
49
|
+
"clsx": "2.1.1",
|
|
50
|
+
"confbox": "0.1.8",
|
|
51
|
+
"destr": "2.0.3",
|
|
52
|
+
"eslint": "9.20.1",
|
|
53
|
+
"eslint-plugin-cypress": "4.1.0",
|
|
54
|
+
"eslint-plugin-format": "1.0.1",
|
|
55
|
+
"globals": "15.14.0",
|
|
56
|
+
"json-editor-vue": "0.17.3",
|
|
57
|
+
"json-xml-parse": "1.3.0",
|
|
58
|
+
"lucide-vue-next": "0.474.0",
|
|
59
|
+
"markdown-it": "14.1.0",
|
|
60
|
+
"postcss": "8.5.1",
|
|
61
|
+
"prettier": "3.5.0",
|
|
62
|
+
"scule": "1.3.0",
|
|
63
|
+
"shiki": "2.3.2",
|
|
64
|
+
"tailwindcss": "3.4.17",
|
|
65
|
+
"typescript": "5.7.3",
|
|
66
|
+
"vite": "6.1.0",
|
|
67
|
+
"vitepress": "1.6.3",
|
|
68
|
+
"radix-vue": "1.9.13",
|
|
69
|
+
"tailwind-merge": "2.6.0",
|
|
70
|
+
"tailwindcss-animate": "1.0.7",
|
|
71
|
+
"vue": "3.5.13",
|
|
72
|
+
"vue-i18n": "11.1.1",
|
|
73
|
+
"vue-json-pretty": "2.4.0",
|
|
74
|
+
"vue-tsc": "2.2.0",
|
|
75
|
+
"xml-formatter": "3.6.4"
|
|
76
|
+
},
|
|
77
|
+
"resolutions": {
|
|
78
|
+
"@typescript-eslint/utils": "8.21.0"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Awaitable } from 'vitepress'
|
|
2
|
+
import type { EnhanceAppContext, Theme } from 'vitepress/client'
|
|
3
|
+
import type { Component } from 'vue'
|
|
4
|
+
import type { createOpenApiInstance } from './lib/createOpenApiInstance'
|
|
5
|
+
import { watch } from 'vue'
|
|
6
|
+
import * as VueI18n from 'vue-i18n'
|
|
7
|
+
import * as components from './components'
|
|
8
|
+
import { useShiki } from './composables/useShiki'
|
|
9
|
+
import { DEFAULT_OPERATION_SLOTS, useTheme } from './composables/useTheme'
|
|
10
|
+
|
|
11
|
+
import 'tailwindcss/tailwind.css'
|
|
12
|
+
import './style.css'
|
|
13
|
+
import './json.css'
|
|
14
|
+
|
|
15
|
+
interface OAEnhanceAppContext extends EnhanceAppContext {
|
|
16
|
+
openapi?: ReturnType<typeof createOpenApiInstance> | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface VPTheme {
|
|
20
|
+
Layout: Component
|
|
21
|
+
enhanceApp: (ctx: OAEnhanceAppContext) => Awaitable<void>
|
|
22
|
+
extends?: Theme
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const theme = {
|
|
26
|
+
enhanceApp({ app, openapi = null }) {
|
|
27
|
+
if (openapi) {
|
|
28
|
+
app.provide('openapi', openapi)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const themeConfig = useTheme()
|
|
32
|
+
|
|
33
|
+
const i18nConfig = themeConfig.getI18nConfig()
|
|
34
|
+
const i18n: any = VueI18n.createI18n({
|
|
35
|
+
legacy: false,
|
|
36
|
+
locale: i18nConfig.locale.value,
|
|
37
|
+
fallbackLocale: i18nConfig.fallbackLocale.value,
|
|
38
|
+
messages: i18nConfig.messages,
|
|
39
|
+
})
|
|
40
|
+
app.use(i18n)
|
|
41
|
+
|
|
42
|
+
watch(
|
|
43
|
+
() => themeConfig.getLocale(),
|
|
44
|
+
() => {
|
|
45
|
+
if (i18n.global.locale.value !== themeConfig.getLocale()) {
|
|
46
|
+
i18n.global.locale.value = themeConfig.getLocale()
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
immediate: true,
|
|
51
|
+
},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
Object.entries(components).forEach(([key, component]) => {
|
|
55
|
+
app.component(key, component)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
useShiki().initShiki()
|
|
59
|
+
},
|
|
60
|
+
} as VPTheme
|
|
61
|
+
|
|
62
|
+
export { useOpenapi } from './composables/useOpenapi'
|
|
63
|
+
export { usePlayground } from './composables/usePlayground'
|
|
64
|
+
export { DEFAULT_OPERATION_SLOTS }
|
|
65
|
+
export { useShiki } from './composables/useShiki'
|
|
66
|
+
export { useTheme } from './composables/useTheme'
|
|
67
|
+
export { generateCodeSample } from './lib/codeSamples/generateCodeSample'
|
|
68
|
+
export { OARequest } from './lib/codeSamples/request'
|
|
69
|
+
export type { IOARequest } from './lib/codeSamples/request'
|
|
70
|
+
export { createOpenApiInstance } from './lib/createOpenApiInstance'
|
|
71
|
+
export { getOpenApiInstance } from './lib/getOpenApiInstance'
|
|
72
|
+
export { OpenApi } from './lib/OpenApi'
|
|
73
|
+
export { locales } from './locales'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { nextTick, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import { lazyBus } from './lazyBus'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Component which loads lazily when the browser is "idle"
|
|
8
|
+
* Disabled if being rendered from the server
|
|
9
|
+
*
|
|
10
|
+
* @link https://medium.com/js-dojo/lazy-rendering-in-vue-to-improve-performance-dcccd445d5f
|
|
11
|
+
* @author [Scalar](https://github.com/scalar/scalar/tree/main/packages/api-reference)
|
|
12
|
+
*/
|
|
13
|
+
const props = withDefaults(
|
|
14
|
+
defineProps<{
|
|
15
|
+
// Identifier for loaded event, if no ID is passed then no event is dispatched
|
|
16
|
+
id?: string
|
|
17
|
+
// To lazyload or not to lazyload, that is the question
|
|
18
|
+
isLazy?: boolean
|
|
19
|
+
// Amount of time in ms to wait before triggering requestIdleCallback
|
|
20
|
+
lazyTimeout?: number
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
isLazy: true,
|
|
24
|
+
lazyTimeout: 0,
|
|
25
|
+
},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const onIdle = (cb = () => {}) => {
|
|
29
|
+
setTimeout(() => nextTick(cb), props.lazyTimeout ?? 300)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const shouldRender = ref(!props.isLazy)
|
|
33
|
+
|
|
34
|
+
// Fire the event for non-lazy components as well to keep track of loading
|
|
35
|
+
if (props.isLazy) {
|
|
36
|
+
onIdle(() => {
|
|
37
|
+
shouldRender.value = true
|
|
38
|
+
if (props.id) {
|
|
39
|
+
nextTick(() => lazyBus.emit({ id: props.id! }))
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
} else if (props.id) {
|
|
43
|
+
nextTick(() => lazyBus.emit({ id: props.id! }))
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<slot v-if="shouldRender" />
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EventBusKey } from '@vueuse/core'
|
|
2
|
+
import { useEventBus } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Setup an event bus so we can listen for loaded events.
|
|
6
|
+
*/
|
|
7
|
+
const lazyEventBusKey: EventBusKey<{ id: string }> = Symbol('lazyEventBus')
|
|
8
|
+
export const lazyBus = useEventBus(lazyEventBusKey)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { destr } from 'destr'
|
|
3
|
+
import { computed, ref, watch } from 'vue'
|
|
4
|
+
import VueJsonPretty from 'vue-json-pretty'
|
|
5
|
+
import { useShiki } from '../../composables/useShiki'
|
|
6
|
+
import { useTheme } from '../../composables/useTheme'
|
|
7
|
+
import 'vue-json-pretty/lib/styles.css'
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
code: {
|
|
11
|
+
type: [String, Object, Array, Number, Boolean],
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
lang: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
label: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: '',
|
|
21
|
+
},
|
|
22
|
+
disableHtmlTransform: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const themeConfig = useTheme()
|
|
29
|
+
|
|
30
|
+
const isDark = themeConfig.isDark
|
|
31
|
+
|
|
32
|
+
const html = ref(null)
|
|
33
|
+
|
|
34
|
+
const shiki = useShiki()
|
|
35
|
+
|
|
36
|
+
const jsonData = computed(() => {
|
|
37
|
+
return typeof props.code === 'string' ? destr(props.code) : props.code
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
watch(
|
|
41
|
+
[() => props.code, () => props.lang, isDark],
|
|
42
|
+
async () => {
|
|
43
|
+
if (props.lang === 'json') {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (props.disableHtmlTransform) {
|
|
48
|
+
html.value = `<pre><code>${props.code}</code></pre>`
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
html.value = shiki.renderShiki(props.code, {
|
|
53
|
+
lang: props.lang,
|
|
54
|
+
theme: isDark.value ? 'vitesse-dark' : 'vitesse-light',
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
immediate: true,
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<div
|
|
65
|
+
class="vp-adaptive-theme min-h-16"
|
|
66
|
+
:class="[`language-${props.lang}`]"
|
|
67
|
+
>
|
|
68
|
+
<button
|
|
69
|
+
title="Copy Code"
|
|
70
|
+
class="copy"
|
|
71
|
+
/>
|
|
72
|
+
<span class="lang">{{ props.label }}</span>
|
|
73
|
+
|
|
74
|
+
<VueJsonPretty
|
|
75
|
+
v-if="props.lang === 'json' && !props.disableHtmlTransform"
|
|
76
|
+
:data="jsonData"
|
|
77
|
+
:theme="isDark ? 'dark' : 'light'"
|
|
78
|
+
:deep="themeConfig.getJsonViewerDeep()"
|
|
79
|
+
show-icon
|
|
80
|
+
class="p-2"
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<div
|
|
84
|
+
v-else-if="html && !props.disableHtmlTransform"
|
|
85
|
+
class="vp-adaptive-theme"
|
|
86
|
+
v-html="html"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<pre v-else>{{ props.code }}</pre>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const { value } = defineProps({
|
|
3
|
+
value: [String, Number, Boolean, Array, Object],
|
|
4
|
+
})
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<template v-if="Array.isArray(value)">
|
|
9
|
+
<code
|
|
10
|
+
v-for="(item, attributeIdx) in value"
|
|
11
|
+
:key="attributeIdx"
|
|
12
|
+
class="!text-xs text-wrap break-all"
|
|
13
|
+
>
|
|
14
|
+
{{ item }}
|
|
15
|
+
</code>
|
|
16
|
+
</template>
|
|
17
|
+
<code
|
|
18
|
+
v-else class="!text-xs"
|
|
19
|
+
>
|
|
20
|
+
{{ value }}
|
|
21
|
+
</code>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, defineProps } from 'vue'
|
|
3
|
+
import { useTheme } from '../../composables/useTheme'
|
|
4
|
+
import { Badge } from '../ui/badge'
|
|
5
|
+
|
|
6
|
+
const { deprecated } = defineProps({
|
|
7
|
+
operation: {
|
|
8
|
+
type: Object,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
deprecated: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
required: false,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const themeConfig = useTheme()
|
|
18
|
+
|
|
19
|
+
const operationBadges = computed(() => themeConfig.getOperationBadges().filter((badge) => {
|
|
20
|
+
if (badge === 'deprecated' && !deprecated) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return true
|
|
25
|
+
}))
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="flex flex-row gap-2">
|
|
30
|
+
<Badge
|
|
31
|
+
v-for="badge in operationBadges"
|
|
32
|
+
:key="badge"
|
|
33
|
+
variant="outline"
|
|
34
|
+
>
|
|
35
|
+
<template v-if="badge === 'deprecated'">
|
|
36
|
+
{{ $t('Deprecated') }}
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template v-else-if="badge === 'operationId'">
|
|
40
|
+
{{ $t('operation.badgePrefix.operationId') }}{{ operation.operationId }}
|
|
41
|
+
</template>
|
|
42
|
+
</Badge>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import slugify from '@sindresorhus/slugify'
|
|
3
|
+
import { computed, useSlots } from 'vue'
|
|
4
|
+
import { useTheme } from '../../composables/useTheme'
|
|
5
|
+
import { cn } from '../../lib/utils'
|
|
6
|
+
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
id: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: false,
|
|
11
|
+
},
|
|
12
|
+
level: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
prefix: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: null,
|
|
19
|
+
},
|
|
20
|
+
class: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: false,
|
|
23
|
+
},
|
|
24
|
+
headerAnchorClass: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'header-anchor',
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
function getSlotChildrenText(children) {
|
|
31
|
+
return children.map((node) => {
|
|
32
|
+
if (!node.children || typeof node.children === 'string') {
|
|
33
|
+
return node.children || ''
|
|
34
|
+
} else if (Array.isArray(node.children)) {
|
|
35
|
+
return getSlotChildrenText(node.children)
|
|
36
|
+
} else if (node.children.default) {
|
|
37
|
+
return getSlotChildrenText(node.children.default())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return ''
|
|
41
|
+
}).join('')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const slots = useSlots()
|
|
45
|
+
|
|
46
|
+
const defaultSlot = slots.default
|
|
47
|
+
|
|
48
|
+
const slotText = computed(() => {
|
|
49
|
+
return getSlotChildrenText(defaultSlot())
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const id = computed(() => {
|
|
53
|
+
if (props.id) {
|
|
54
|
+
return props.id
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const value = props.prefix ? `${props.prefix}-${slotText.value}` : slotText.value
|
|
58
|
+
|
|
59
|
+
return slugify(value, { decamelize: false })
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const themeConfig = useTheme()
|
|
63
|
+
|
|
64
|
+
const hLevel = computed(() => {
|
|
65
|
+
return themeConfig.getHeadingLevel(props.level) ?? props.level
|
|
66
|
+
})
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<component
|
|
71
|
+
:is="hLevel"
|
|
72
|
+
:id="id"
|
|
73
|
+
tabindex="-1"
|
|
74
|
+
:class="cn(props.class)"
|
|
75
|
+
>
|
|
76
|
+
<slot />
|
|
77
|
+
|
|
78
|
+
<a
|
|
79
|
+
:class="cn('header-anchor', props.headerAnchorClass)"
|
|
80
|
+
:href="`#${id}`"
|
|
81
|
+
:aria-label="`Permalink to ${slotText}`"
|
|
82
|
+
>​</a>
|
|
83
|
+
</component>
|
|
84
|
+
</template>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
import { getOpenApiInstance } from '../../lib/getOpenApiInstance'
|
|
4
|
+
import { Badge } from '../ui/badge'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
spec: {
|
|
8
|
+
type: Object,
|
|
9
|
+
required: false,
|
|
10
|
+
},
|
|
11
|
+
openapi: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: false,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const openapi = props.openapi ?? getOpenApiInstance({
|
|
18
|
+
custom: { spec: props.spec },
|
|
19
|
+
injected: inject('openapi', undefined),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const info = openapi.getInfo()
|
|
23
|
+
|
|
24
|
+
const externalDocs = openapi.getExternalDocs()
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div class="flex flex-col">
|
|
29
|
+
<div class="flex flex-col items-start">
|
|
30
|
+
<div class="flex flex-row items-center gap-2">
|
|
31
|
+
<Badge
|
|
32
|
+
v-if="info.version"
|
|
33
|
+
variant="outline"
|
|
34
|
+
>
|
|
35
|
+
v{{ info.version }}
|
|
36
|
+
</Badge>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<OAHeading level="h1">
|
|
40
|
+
{{ info.title ?? $t('API Documentation') }}
|
|
41
|
+
</OAHeading>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<span v-if="info.summary" class="text-gray-600 dark:text-gray-300">
|
|
45
|
+
{{ info.summary }}
|
|
46
|
+
</span>
|
|
47
|
+
|
|
48
|
+
<OAMarkdown
|
|
49
|
+
v-if="info.description"
|
|
50
|
+
:content="info.description"
|
|
51
|
+
class="mt-4"
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<template v-if="info.contact">
|
|
55
|
+
<OAHeading level="h2">
|
|
56
|
+
{{ $t('Contact') }}
|
|
57
|
+
</OAHeading>
|
|
58
|
+
|
|
59
|
+
<div class="flex flex-row items-center gap-2">
|
|
60
|
+
<template v-if="info.contact.url">
|
|
61
|
+
<a :href="info.contact.url" :aria-label="info.contact.name ?? $t('Contact')">
|
|
62
|
+
{{ info.contact.name ?? $t('Contact') }}
|
|
63
|
+
</a>
|
|
64
|
+
|
|
65
|
+
<span v-if="info.contact.email" class="text-gray-400 dark:text-gray-500">/</span>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<a v-if="info.contact.email" :href="`mailto:${info.contact.email}`" :aria-label="info.contact.email">
|
|
69
|
+
{{ info.contact.email }}
|
|
70
|
+
</a>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
|
75
|
+
<div v-if="info.termsOfService">
|
|
76
|
+
<OAHeading level="h2">
|
|
77
|
+
{{ $t('Terms of Service') }}
|
|
78
|
+
</OAHeading>
|
|
79
|
+
|
|
80
|
+
<a :href="info.termsOfService" :aria-label="info.termsOfService">
|
|
81
|
+
{{ info.termsOfService }}
|
|
82
|
+
</a>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div v-if="info.license">
|
|
86
|
+
<OAHeading level="h2">
|
|
87
|
+
{{ $t('License') }}
|
|
88
|
+
</OAHeading>
|
|
89
|
+
|
|
90
|
+
<a :href="info.license.url" :aria-label="info.license.name">
|
|
91
|
+
{{ info.license.name ?? $t('License') }}
|
|
92
|
+
</a>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<template v-if="Object.keys(externalDocs).length">
|
|
97
|
+
<OAHeading level="h2">
|
|
98
|
+
{{ $t('External Documentation') }}
|
|
99
|
+
</OAHeading>
|
|
100
|
+
|
|
101
|
+
<a :href="externalDocs.url" :aria-label="externalDocs.description ?? $t('External Documentation')">
|
|
102
|
+
{{ externalDocs.description ?? $t('External Documentation') }}
|
|
103
|
+
</a>
|
|
104
|
+
</template>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { inject } from 'vue'
|
|
3
|
+
import { getOpenApiInstance } from '../../lib/getOpenApiInstance'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
spec: {
|
|
7
|
+
type: Object,
|
|
8
|
+
required: false,
|
|
9
|
+
},
|
|
10
|
+
openapi: {
|
|
11
|
+
type: Object,
|
|
12
|
+
required: false,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const openapi = props.openapi ?? getOpenApiInstance({
|
|
17
|
+
custom: { spec: props.spec },
|
|
18
|
+
injected: inject('openapi', undefined),
|
|
19
|
+
})
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<OAInfo :spec="spec" :openapi="openapi" />
|
|
24
|
+
<OAServers :spec="spec" :openapi="openapi" />
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import JsonEditorVue from 'json-editor-vue'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { useTheme } from '../../composables/useTheme'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: Object,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
options: {
|
|
12
|
+
type: Object,
|
|
13
|
+
default: () => ({}),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits(['update:modelValue'])
|
|
18
|
+
|
|
19
|
+
const value = computed({
|
|
20
|
+
get: () => props.modelValue,
|
|
21
|
+
set: val => emit('update:modelValue', val),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const themeConfig = useTheme()
|
|
25
|
+
|
|
26
|
+
const isDark = themeConfig.isDark
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<JsonEditorVue
|
|
31
|
+
v-model="value"
|
|
32
|
+
:main-menu-bar="themeConfig.getPlaygroundJsonEditorMainMenuBar()"
|
|
33
|
+
:navigation-bar="themeConfig.getPlaygroundJsonEditorNavigationBar()"
|
|
34
|
+
:mode="themeConfig.getPlaygroundJsonEditorMode()"
|
|
35
|
+
class="oa-jse"
|
|
36
|
+
:class="{
|
|
37
|
+
'oa-jse-theme-dark': isDark,
|
|
38
|
+
'oa-jse-theme-light': !isDark,
|
|
39
|
+
}"
|
|
40
|
+
/>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import markdownit from 'markdown-it'
|
|
3
|
+
import { cn } from '../../lib/utils'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
content: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: false,
|
|
9
|
+
default: '',
|
|
10
|
+
},
|
|
11
|
+
class: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: false,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const md = markdownit({
|
|
18
|
+
html: true,
|
|
19
|
+
breaks: true,
|
|
20
|
+
})
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div
|
|
25
|
+
:class="cn('oa-doc', props.class)"
|
|
26
|
+
v-html="md.render(props.content)"
|
|
27
|
+
/>
|
|
28
|
+
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { Badge } from '../ui/badge'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
method: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
})
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<Badge
|
|
14
|
+
variant="plain"
|
|
15
|
+
:class="[`OAMethodBadge--${props.method.toLowerCase()}`]"
|
|
16
|
+
class="px-2 py-1 rounded"
|
|
17
|
+
>
|
|
18
|
+
{{ props.method.toUpperCase() }}
|
|
19
|
+
</Badge>
|
|
20
|
+
</template>
|