vitepress-openapi 0.0.3-alpha.75 → 0.0.3-alpha.76
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/dist/OpenApi-CDzPw3Gb.js +5669 -0
- package/dist/OpenApi-JZDy_oqC.cjs +111 -0
- package/dist/types/src/components/Context/OAContextAsync.vue.d.ts +4 -4
- package/dist/types/src/components/Context/OAContextProvider.vue.d.ts +2 -2
- package/dist/types/src/components/Feature/OAInfo.vue.d.ts +2 -2
- package/dist/types/src/components/Feature/OAIntroduction.vue.d.ts +2 -2
- package/dist/types/src/components/Feature/OAOperation.vue.d.ts +19 -4
- package/dist/types/src/components/Feature/OAServers.vue.d.ts +2 -2
- package/dist/types/src/components/Feature/OASpec.vue.d.ts +20 -5
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/ui/button/Button.vue.d.ts +4 -4
- package/dist/types/src/components/ui/checkbox/Checkbox.vue.d.ts +12 -12
- package/dist/types/src/components/ui/collapsible/Collapsible.vue.d.ts +2 -2
- package/dist/types/src/components/ui/collapsible/CollapsibleContent.vue.d.ts +2 -2
- package/dist/types/src/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +2 -2
- package/dist/types/src/components/ui/label/Label.vue.d.ts +3 -3
- package/dist/types/src/components/ui/select/Select.vue.d.ts +11 -10
- package/dist/types/src/components/ui/select/SelectContent.vue.d.ts +21 -10
- package/dist/types/src/components/ui/select/SelectGroup.vue.d.ts +3 -3
- package/dist/types/src/components/ui/select/SelectItem.vue.d.ts +4 -4
- package/dist/types/src/components/ui/select/SelectItemText.vue.d.ts +2 -2
- package/dist/types/src/components/ui/select/SelectLabel.vue.d.ts +2 -2
- package/dist/types/src/components/ui/select/SelectScrollDownButton.vue.d.ts +3 -3
- package/dist/types/src/components/ui/select/SelectScrollUpButton.vue.d.ts +3 -3
- package/dist/types/src/components/ui/select/SelectSeparator.vue.d.ts +1 -1
- package/dist/types/src/components/ui/select/SelectTrigger.vue.d.ts +4 -3
- package/dist/types/src/components/ui/select/SelectValue.vue.d.ts +2 -2
- package/dist/types/src/components/ui/tabs/Tabs.vue.d.ts +6 -6
- package/dist/types/src/components/ui/tabs/TabsContent.vue.d.ts +4 -4
- package/dist/types/src/components/ui/tabs/TabsList.vue.d.ts +3 -3
- package/dist/types/src/components/ui/tabs/TabsTrigger.vue.d.ts +4 -4
- package/dist/types/src/composables/useOpenapi.d.ts +2 -2
- package/dist/types/src/composables/useShiki.d.ts +1 -0
- package/dist/types/src/lib/parser/parseOpenapi.d.ts +4 -4
- package/dist/vitepress-openapi.client.cjs.js +135 -151
- package/dist/vitepress-openapi.client.es.js +17589 -18289
- package/dist/vitepress-openapi.css +1 -1
- package/dist/vitepress-openapi.node.cjs.js +1 -1
- package/dist/vitepress-openapi.node.es.js +1 -1
- package/package.json +5 -4
- package/src/components/Common/Highlight/OAShiki.vue +1 -1
- package/src/components/Context/OAContextAsync.vue +2 -3
- package/src/components/Context/OAContextProvider.vue +1 -1
- package/src/components/Feature/OAInfo.vue +1 -1
- package/src/components/Feature/OAIntroduction.vue +1 -1
- package/src/components/Feature/OAOperation.vue +13 -3
- package/src/components/Feature/OAServers.vue +1 -1
- package/src/components/Feature/OASpec.vue +12 -3
- package/src/components/Playground/OAPlaygroundParameterInput.vue +2 -2
- package/src/components/Playground/OAPlaygroundParameters.vue +4 -4
- package/src/components/Response/OAResponses.vue +2 -2
- package/src/components/index.ts +0 -4
- package/src/components/ui/button/Button.vue +2 -2
- package/src/components/ui/checkbox/Checkbox.vue +2 -2
- package/src/components/ui/collapsible/Collapsible.vue +2 -2
- package/src/components/ui/collapsible/CollapsibleContent.vue +2 -2
- package/src/components/ui/collapsible/CollapsibleTrigger.vue +2 -2
- package/src/components/ui/label/Label.vue +2 -2
- package/src/components/ui/select/Select.vue +2 -2
- package/src/components/ui/select/SelectContent.vue +3 -3
- package/src/components/ui/select/SelectGroup.vue +2 -2
- package/src/components/ui/select/SelectItem.vue +2 -2
- package/src/components/ui/select/SelectItemText.vue +2 -2
- package/src/components/ui/select/SelectLabel.vue +2 -2
- package/src/components/ui/select/SelectScrollDownButton.vue +2 -2
- package/src/components/ui/select/SelectScrollUpButton.vue +2 -2
- package/src/components/ui/select/SelectSeparator.vue +2 -2
- package/src/components/ui/select/SelectTrigger.vue +2 -2
- package/src/components/ui/select/SelectValue.vue +2 -2
- package/src/components/ui/select-with-custom-option/SelectWithCustomOption.vue +1 -1
- package/src/components/ui/tabs/Tabs.vue +2 -2
- package/src/components/ui/tabs/TabsContent.vue +2 -2
- package/src/components/ui/tabs/TabsList.vue +2 -2
- package/src/components/ui/tabs/TabsTrigger.vue +2 -2
- package/src/composables/useOpenapi.ts +3 -3
- package/src/composables/useShiki.ts +6 -2
- package/src/lib/parser/parseOpenapi.ts +43 -19
- package/dist/OpenApi-BpIBs3Rx.cjs +0 -95
- package/dist/OpenApi-CJg3ai1M.js +0 -4851
- package/dist/types/src/components/Feature/OARemoteOperation.vue.d.ts +0 -32
- package/dist/types/src/components/Feature/OARemoteSpec.vue.d.ts +0 -24
- package/src/components/Feature/OARemoteOperation.vue +0 -41
- package/src/components/Feature/OARemoteSpec.vue +0 -36
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectLabelProps } from '
|
|
2
|
+
import type { SelectLabelProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
|
-
import { SelectLabel } from '
|
|
4
|
+
import { SelectLabel } from 'reka-ui'
|
|
5
5
|
import { cn } from '../../../lib/utils'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<SelectLabelProps & { class?: HTMLAttributes['class'] }>()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectScrollDownButtonProps } from '
|
|
2
|
+
import type { SelectScrollDownButtonProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
4
|
import { ChevronDown } from 'lucide-vue-next'
|
|
5
|
-
import { SelectScrollDownButton, useForwardProps } from '
|
|
5
|
+
import { SelectScrollDownButton, useForwardProps } from 'reka-ui'
|
|
6
6
|
import { computed } from 'vue'
|
|
7
7
|
import { cn } from '../../../lib/utils'
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectScrollUpButtonProps } from '
|
|
2
|
+
import type { SelectScrollUpButtonProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
4
|
import { ChevronUp } from 'lucide-vue-next'
|
|
5
|
-
import { SelectScrollUpButton, useForwardProps } from '
|
|
5
|
+
import { SelectScrollUpButton, useForwardProps } from 'reka-ui'
|
|
6
6
|
import { computed } from 'vue'
|
|
7
7
|
import { cn } from '../../../lib/utils'
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectSeparatorProps } from '
|
|
2
|
+
import type { SelectSeparatorProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
|
-
import { SelectSeparator } from '
|
|
4
|
+
import { SelectSeparator } from 'reka-ui'
|
|
5
5
|
import { computed } from 'vue'
|
|
6
6
|
import { cn } from '../../../lib/utils'
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectTriggerProps } from '
|
|
2
|
+
import type { SelectTriggerProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
4
|
import { ChevronDown } from 'lucide-vue-next'
|
|
5
|
-
import { SelectIcon, SelectTrigger, useForwardProps } from '
|
|
5
|
+
import { SelectIcon, SelectTrigger, useForwardProps } from 'reka-ui'
|
|
6
6
|
import { computed } from 'vue'
|
|
7
7
|
import { cn } from '../../../lib/utils'
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { SelectValueProps } from '
|
|
3
|
-
import { SelectValue } from '
|
|
2
|
+
import type { SelectValueProps } from 'reka-ui'
|
|
3
|
+
import { SelectValue } from 'reka-ui'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<SelectValueProps>()
|
|
6
6
|
</script>
|
|
@@ -73,7 +73,7 @@ const handleSelectChange = (selectedValue: string) => {
|
|
|
73
73
|
<Select
|
|
74
74
|
:model-value="value"
|
|
75
75
|
class="absolute inset-0"
|
|
76
|
-
@update:model-value="handleSelectChange"
|
|
76
|
+
@update:model-value="handleSelectChange(String($event))"
|
|
77
77
|
>
|
|
78
78
|
<SelectTrigger :aria-label="$t('Select')">
|
|
79
79
|
<SelectValue :placeholder="placeholder" class="text-start" />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { TabsRootEmits, TabsRootProps } from '
|
|
2
|
+
import type { TabsRootEmits, TabsRootProps } from 'reka-ui'
|
|
3
3
|
import type { ComputedRef } from 'vue'
|
|
4
|
-
import { TabsRoot, useForwardPropsEmits } from '
|
|
4
|
+
import { TabsRoot, useForwardPropsEmits } from 'reka-ui'
|
|
5
5
|
|
|
6
6
|
const props = defineProps<TabsRootProps>()
|
|
7
7
|
const emits = defineEmits<TabsRootEmits>()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { TabsContentProps } from '
|
|
2
|
+
import type { TabsContentProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
|
-
import { TabsContent } from '
|
|
4
|
+
import { TabsContent } from 'reka-ui'
|
|
5
5
|
import { computed } from 'vue'
|
|
6
6
|
import { cn } from '../../../lib/utils'
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { TabsListProps } from '
|
|
2
|
+
import type { TabsListProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
|
-
import { TabsList } from '
|
|
4
|
+
import { TabsList } from 'reka-ui'
|
|
5
5
|
import { computed } from 'vue'
|
|
6
6
|
import { cn } from '../../../lib/utils'
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { TabsTriggerProps } from '
|
|
2
|
+
import type { TabsTriggerProps } from 'reka-ui'
|
|
3
3
|
import type { HTMLAttributes } from 'vue'
|
|
4
4
|
import type { TabsTriggerVariants } from './index'
|
|
5
|
-
import { TabsTrigger, useForwardProps } from '
|
|
5
|
+
import { TabsTrigger, useForwardProps } from 'reka-ui'
|
|
6
6
|
import { computed } from 'vue'
|
|
7
7
|
import { cn } from '../../../lib/utils'
|
|
8
8
|
import { tabsTriggerVariants } from './index'
|
|
@@ -12,7 +12,7 @@ export function useOpenapi({
|
|
|
12
12
|
spec,
|
|
13
13
|
config,
|
|
14
14
|
}: {
|
|
15
|
-
spec?: OpenAPIDocument
|
|
15
|
+
spec?: OpenAPIDocument | string
|
|
16
16
|
config?: PartialUseThemeConfig
|
|
17
17
|
} = {}) {
|
|
18
18
|
if (config) {
|
|
@@ -36,7 +36,7 @@ export function useOpenapi({
|
|
|
36
36
|
function sync({
|
|
37
37
|
spec,
|
|
38
38
|
}: {
|
|
39
|
-
spec?: OpenAPIDocument
|
|
39
|
+
spec?: OpenAPIDocument | string
|
|
40
40
|
} = {}) {
|
|
41
41
|
if (spec) {
|
|
42
42
|
setInstance(
|
|
@@ -58,7 +58,7 @@ export function useOpenapi({
|
|
|
58
58
|
async function async({
|
|
59
59
|
spec,
|
|
60
60
|
}: {
|
|
61
|
-
spec?: OpenAPIDocument
|
|
61
|
+
spec?: OpenAPIDocument | string
|
|
62
62
|
} = {}) {
|
|
63
63
|
if (spec) {
|
|
64
64
|
setInstance(
|
|
@@ -20,7 +20,7 @@ const loading = ref(true)
|
|
|
20
20
|
const themeConfig = useTheme()
|
|
21
21
|
|
|
22
22
|
export function useShiki() {
|
|
23
|
-
async function
|
|
23
|
+
async function init() {
|
|
24
24
|
if (shiki) {
|
|
25
25
|
return
|
|
26
26
|
}
|
|
@@ -48,6 +48,10 @@ export function useShiki() {
|
|
|
48
48
|
return {
|
|
49
49
|
loading,
|
|
50
50
|
renderShiki,
|
|
51
|
-
|
|
51
|
+
init,
|
|
52
|
+
initShiki: async () => {
|
|
53
|
+
console.warn('initShiki is deprecated, use init instead')
|
|
54
|
+
await init()
|
|
55
|
+
},
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -3,6 +3,7 @@ import type { OpenAPIDocument, ParsedOpenAPI } from '../../types'
|
|
|
3
3
|
import { dereferenceSync } from '@trojs/openapi-dereference'
|
|
4
4
|
import { $trycatch } from '@tszen/trycatch'
|
|
5
5
|
import { merge } from 'allof-merge'
|
|
6
|
+
import { parseYAML } from 'confbox'
|
|
6
7
|
import { generateCodeSamples } from './generateCodeSamples'
|
|
7
8
|
import { generateMissingOperationIds } from './generateMissingOperationIds'
|
|
8
9
|
import { generateMissingSummary } from './generateMissingSummary'
|
|
@@ -12,12 +13,29 @@ import { generateResponseUi } from './generateResponseUi'
|
|
|
12
13
|
import { generateSecurityUi } from './generateSecurityUi'
|
|
13
14
|
|
|
14
15
|
export function parseOpenapi() {
|
|
16
|
+
function parseSpecContent(spec: OpenAPIDocument | string): OpenAPIDocument | null {
|
|
17
|
+
if (typeof spec === 'string') {
|
|
18
|
+
try {
|
|
19
|
+
const parsed = parseYAML(spec)
|
|
20
|
+
return parsed as OpenAPIDocument
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error('Error parsing spec', e)
|
|
23
|
+
}
|
|
24
|
+
} else if (typeof spec === 'object') {
|
|
25
|
+
return spec as OpenAPIDocument
|
|
26
|
+
} else {
|
|
27
|
+
console.error('Invalid spec format')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {} as OpenAPIDocument
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
function transformSync({
|
|
16
34
|
spec,
|
|
17
35
|
defaultTag = undefined,
|
|
18
36
|
defaultTagDescription = undefined,
|
|
19
37
|
}: {
|
|
20
|
-
spec: OpenAPIDocument
|
|
38
|
+
spec: OpenAPIDocument | string
|
|
21
39
|
defaultTag?: string
|
|
22
40
|
defaultTagDescription?: string
|
|
23
41
|
}) {
|
|
@@ -25,38 +43,42 @@ export function parseOpenapi() {
|
|
|
25
43
|
console.warn('Transforming OpenAPI spec:', spec)
|
|
26
44
|
}
|
|
27
45
|
|
|
28
|
-
|
|
46
|
+
let specContent = parseSpecContent(spec)
|
|
47
|
+
|
|
48
|
+
if (!specContent) {
|
|
29
49
|
return {}
|
|
30
50
|
}
|
|
31
51
|
|
|
32
|
-
if (!
|
|
52
|
+
if (!specContent.openapi || !String(specContent.openapi).startsWith('3.')) {
|
|
33
53
|
console.warn('Only OpenAPI 3.x is supported')
|
|
34
54
|
return {}
|
|
35
55
|
}
|
|
36
56
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
if (specContent?.paths) {
|
|
58
|
+
specContent = generateMissingOperationIds(specContent)
|
|
59
|
+
specContent = generateMissingSummary(specContent)
|
|
60
|
+
specContent = generateMissingTags({ spec: specContent, defaultTag, defaultTagDescription })
|
|
41
61
|
}
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
specContent.externalDocs = specContent.externalDocs || {}
|
|
64
|
+
specContent.info = specContent.info || {}
|
|
65
|
+
specContent.servers = specContent.servers || []
|
|
66
|
+
specContent.tags = specContent.tags || []
|
|
47
67
|
|
|
48
|
-
return Object.assign({},
|
|
68
|
+
return Object.assign({}, specContent)
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
async function transformAsync({
|
|
52
72
|
spec,
|
|
53
73
|
}: {
|
|
54
|
-
spec: ParsedOpenAPI
|
|
74
|
+
spec: ParsedOpenAPI | string
|
|
55
75
|
}): Promise<ParsedOpenAPI> {
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
let specContent = parseSpecContent(spec) as ParsedOpenAPI
|
|
77
|
+
|
|
78
|
+
const [result, err] = await $trycatch(() => generateCodeSamples(specContent))
|
|
79
|
+
specContent = err ? specContent : result
|
|
58
80
|
|
|
59
|
-
return
|
|
81
|
+
return specContent
|
|
60
82
|
}
|
|
61
83
|
|
|
62
84
|
function parseSync({
|
|
@@ -64,11 +86,13 @@ export function parseOpenapi() {
|
|
|
64
86
|
defaultTag = undefined,
|
|
65
87
|
defaultTagDescription = undefined,
|
|
66
88
|
}: {
|
|
67
|
-
spec: OpenAPIDocument
|
|
89
|
+
spec: OpenAPIDocument | string
|
|
68
90
|
defaultTag?: string
|
|
69
91
|
defaultTagDescription?: string
|
|
70
92
|
}): ParsedOpenAPI {
|
|
71
|
-
|
|
93
|
+
const specContent = parseSpecContent(spec)
|
|
94
|
+
|
|
95
|
+
let parsedSpec = Object.assign({}, specContent) as ParsedOpenAPI
|
|
72
96
|
|
|
73
97
|
const [mergedSpec, errMerge] = $trycatch(() => merge(
|
|
74
98
|
transformSync({
|
|
@@ -104,7 +128,7 @@ export function parseOpenapi() {
|
|
|
104
128
|
defaultTag = undefined,
|
|
105
129
|
defaultTagDescription = undefined,
|
|
106
130
|
}: {
|
|
107
|
-
spec: OpenAPIDocument
|
|
131
|
+
spec: OpenAPIDocument | string
|
|
108
132
|
defaultTag?: string
|
|
109
133
|
defaultTagDescription?: string
|
|
110
134
|
}): Promise<ParsedOpenAPI> {
|