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.
Files changed (83) hide show
  1. package/dist/OpenApi-CDzPw3Gb.js +5669 -0
  2. package/dist/OpenApi-JZDy_oqC.cjs +111 -0
  3. package/dist/types/src/components/Context/OAContextAsync.vue.d.ts +4 -4
  4. package/dist/types/src/components/Context/OAContextProvider.vue.d.ts +2 -2
  5. package/dist/types/src/components/Feature/OAInfo.vue.d.ts +2 -2
  6. package/dist/types/src/components/Feature/OAIntroduction.vue.d.ts +2 -2
  7. package/dist/types/src/components/Feature/OAOperation.vue.d.ts +19 -4
  8. package/dist/types/src/components/Feature/OAServers.vue.d.ts +2 -2
  9. package/dist/types/src/components/Feature/OASpec.vue.d.ts +20 -5
  10. package/dist/types/src/components/index.d.ts +1 -3
  11. package/dist/types/src/components/ui/button/Button.vue.d.ts +4 -4
  12. package/dist/types/src/components/ui/checkbox/Checkbox.vue.d.ts +12 -12
  13. package/dist/types/src/components/ui/collapsible/Collapsible.vue.d.ts +2 -2
  14. package/dist/types/src/components/ui/collapsible/CollapsibleContent.vue.d.ts +2 -2
  15. package/dist/types/src/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +2 -2
  16. package/dist/types/src/components/ui/label/Label.vue.d.ts +3 -3
  17. package/dist/types/src/components/ui/select/Select.vue.d.ts +11 -10
  18. package/dist/types/src/components/ui/select/SelectContent.vue.d.ts +21 -10
  19. package/dist/types/src/components/ui/select/SelectGroup.vue.d.ts +3 -3
  20. package/dist/types/src/components/ui/select/SelectItem.vue.d.ts +4 -4
  21. package/dist/types/src/components/ui/select/SelectItemText.vue.d.ts +2 -2
  22. package/dist/types/src/components/ui/select/SelectLabel.vue.d.ts +2 -2
  23. package/dist/types/src/components/ui/select/SelectScrollDownButton.vue.d.ts +3 -3
  24. package/dist/types/src/components/ui/select/SelectScrollUpButton.vue.d.ts +3 -3
  25. package/dist/types/src/components/ui/select/SelectSeparator.vue.d.ts +1 -1
  26. package/dist/types/src/components/ui/select/SelectTrigger.vue.d.ts +4 -3
  27. package/dist/types/src/components/ui/select/SelectValue.vue.d.ts +2 -2
  28. package/dist/types/src/components/ui/tabs/Tabs.vue.d.ts +6 -6
  29. package/dist/types/src/components/ui/tabs/TabsContent.vue.d.ts +4 -4
  30. package/dist/types/src/components/ui/tabs/TabsList.vue.d.ts +3 -3
  31. package/dist/types/src/components/ui/tabs/TabsTrigger.vue.d.ts +4 -4
  32. package/dist/types/src/composables/useOpenapi.d.ts +2 -2
  33. package/dist/types/src/composables/useShiki.d.ts +1 -0
  34. package/dist/types/src/lib/parser/parseOpenapi.d.ts +4 -4
  35. package/dist/vitepress-openapi.client.cjs.js +135 -151
  36. package/dist/vitepress-openapi.client.es.js +17589 -18289
  37. package/dist/vitepress-openapi.css +1 -1
  38. package/dist/vitepress-openapi.node.cjs.js +1 -1
  39. package/dist/vitepress-openapi.node.es.js +1 -1
  40. package/package.json +5 -4
  41. package/src/components/Common/Highlight/OAShiki.vue +1 -1
  42. package/src/components/Context/OAContextAsync.vue +2 -3
  43. package/src/components/Context/OAContextProvider.vue +1 -1
  44. package/src/components/Feature/OAInfo.vue +1 -1
  45. package/src/components/Feature/OAIntroduction.vue +1 -1
  46. package/src/components/Feature/OAOperation.vue +13 -3
  47. package/src/components/Feature/OAServers.vue +1 -1
  48. package/src/components/Feature/OASpec.vue +12 -3
  49. package/src/components/Playground/OAPlaygroundParameterInput.vue +2 -2
  50. package/src/components/Playground/OAPlaygroundParameters.vue +4 -4
  51. package/src/components/Response/OAResponses.vue +2 -2
  52. package/src/components/index.ts +0 -4
  53. package/src/components/ui/button/Button.vue +2 -2
  54. package/src/components/ui/checkbox/Checkbox.vue +2 -2
  55. package/src/components/ui/collapsible/Collapsible.vue +2 -2
  56. package/src/components/ui/collapsible/CollapsibleContent.vue +2 -2
  57. package/src/components/ui/collapsible/CollapsibleTrigger.vue +2 -2
  58. package/src/components/ui/label/Label.vue +2 -2
  59. package/src/components/ui/select/Select.vue +2 -2
  60. package/src/components/ui/select/SelectContent.vue +3 -3
  61. package/src/components/ui/select/SelectGroup.vue +2 -2
  62. package/src/components/ui/select/SelectItem.vue +2 -2
  63. package/src/components/ui/select/SelectItemText.vue +2 -2
  64. package/src/components/ui/select/SelectLabel.vue +2 -2
  65. package/src/components/ui/select/SelectScrollDownButton.vue +2 -2
  66. package/src/components/ui/select/SelectScrollUpButton.vue +2 -2
  67. package/src/components/ui/select/SelectSeparator.vue +2 -2
  68. package/src/components/ui/select/SelectTrigger.vue +2 -2
  69. package/src/components/ui/select/SelectValue.vue +2 -2
  70. package/src/components/ui/select-with-custom-option/SelectWithCustomOption.vue +1 -1
  71. package/src/components/ui/tabs/Tabs.vue +2 -2
  72. package/src/components/ui/tabs/TabsContent.vue +2 -2
  73. package/src/components/ui/tabs/TabsList.vue +2 -2
  74. package/src/components/ui/tabs/TabsTrigger.vue +2 -2
  75. package/src/composables/useOpenapi.ts +3 -3
  76. package/src/composables/useShiki.ts +6 -2
  77. package/src/lib/parser/parseOpenapi.ts +43 -19
  78. package/dist/OpenApi-BpIBs3Rx.cjs +0 -95
  79. package/dist/OpenApi-CJg3ai1M.js +0 -4851
  80. package/dist/types/src/components/Feature/OARemoteOperation.vue.d.ts +0 -32
  81. package/dist/types/src/components/Feature/OARemoteSpec.vue.d.ts +0 -24
  82. package/src/components/Feature/OARemoteOperation.vue +0 -41
  83. package/src/components/Feature/OARemoteSpec.vue +0 -36
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import type { SelectLabelProps } from 'radix-vue'
2
+ import type { SelectLabelProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { SelectLabel } from 'radix-vue'
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 'radix-vue'
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 'radix-vue'
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 'radix-vue'
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 'radix-vue'
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 'radix-vue'
2
+ import type { SelectSeparatorProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { SelectSeparator } from 'radix-vue'
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 'radix-vue'
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 'radix-vue'
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 'radix-vue'
3
- import { SelectValue } from 'radix-vue'
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 'radix-vue'
2
+ import type { TabsRootEmits, TabsRootProps } from 'reka-ui'
3
3
  import type { ComputedRef } from 'vue'
4
- import { TabsRoot, useForwardPropsEmits } from 'radix-vue'
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 'radix-vue'
2
+ import type { TabsContentProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { TabsContent } from 'radix-vue'
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 'radix-vue'
2
+ import type { TabsListProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { TabsList } from 'radix-vue'
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 'radix-vue'
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 'radix-vue'
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 initShiki() {
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
- initShiki,
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
- if (!spec) {
46
+ let specContent = parseSpecContent(spec)
47
+
48
+ if (!specContent) {
29
49
  return {}
30
50
  }
31
51
 
32
- if (!spec.openapi || !String(spec.openapi).startsWith('3.')) {
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 (spec?.paths) {
38
- spec = generateMissingOperationIds(spec)
39
- spec = generateMissingSummary(spec)
40
- spec = generateMissingTags({ spec, defaultTag, defaultTagDescription })
57
+ if (specContent?.paths) {
58
+ specContent = generateMissingOperationIds(specContent)
59
+ specContent = generateMissingSummary(specContent)
60
+ specContent = generateMissingTags({ spec: specContent, defaultTag, defaultTagDescription })
41
61
  }
42
62
 
43
- spec.externalDocs = spec.externalDocs || spec.externalDocs || {}
44
- spec.info = spec.info || spec.info || {}
45
- spec.servers = spec.servers || spec.servers || []
46
- spec.tags = spec.tags || spec.tags || []
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({}, spec)
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
- const [result, err] = await $trycatch(() => generateCodeSamples(spec))
57
- spec = err ? spec : result
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 spec
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
- let parsedSpec = Object.assign({}, spec) as ParsedOpenAPI
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> {