vitepress-openapi 0.0.3-alpha.74 → 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 (91) 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/OAOperationContent.vue.d.ts +0 -8
  9. package/dist/types/src/components/Feature/OAServers.vue.d.ts +2 -2
  10. package/dist/types/src/components/Feature/OASpec.vue.d.ts +20 -5
  11. package/dist/types/src/components/Feature/OASpecContent.vue.d.ts +0 -11
  12. package/dist/types/src/components/index.d.ts +1 -3
  13. package/dist/types/src/components/ui/button/Button.vue.d.ts +4 -4
  14. package/dist/types/src/components/ui/button/index.d.ts +1 -1
  15. package/dist/types/src/components/ui/checkbox/Checkbox.vue.d.ts +12 -12
  16. package/dist/types/src/components/ui/collapsible/Collapsible.vue.d.ts +2 -2
  17. package/dist/types/src/components/ui/collapsible/CollapsibleContent.vue.d.ts +2 -2
  18. package/dist/types/src/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +2 -2
  19. package/dist/types/src/components/ui/label/Label.vue.d.ts +3 -3
  20. package/dist/types/src/components/ui/select/Select.vue.d.ts +11 -10
  21. package/dist/types/src/components/ui/select/SelectContent.vue.d.ts +21 -10
  22. package/dist/types/src/components/ui/select/SelectGroup.vue.d.ts +3 -3
  23. package/dist/types/src/components/ui/select/SelectItem.vue.d.ts +4 -4
  24. package/dist/types/src/components/ui/select/SelectItemText.vue.d.ts +2 -2
  25. package/dist/types/src/components/ui/select/SelectLabel.vue.d.ts +2 -2
  26. package/dist/types/src/components/ui/select/SelectScrollDownButton.vue.d.ts +3 -3
  27. package/dist/types/src/components/ui/select/SelectScrollUpButton.vue.d.ts +3 -3
  28. package/dist/types/src/components/ui/select/SelectSeparator.vue.d.ts +1 -1
  29. package/dist/types/src/components/ui/select/SelectTrigger.vue.d.ts +4 -3
  30. package/dist/types/src/components/ui/select/SelectValue.vue.d.ts +2 -2
  31. package/dist/types/src/components/ui/tabs/Tabs.vue.d.ts +6 -6
  32. package/dist/types/src/components/ui/tabs/TabsContent.vue.d.ts +4 -4
  33. package/dist/types/src/components/ui/tabs/TabsList.vue.d.ts +3 -3
  34. package/dist/types/src/components/ui/tabs/TabsTrigger.vue.d.ts +4 -4
  35. package/dist/types/src/composables/useOpenapi.d.ts +2 -2
  36. package/dist/types/src/composables/useShiki.d.ts +1 -0
  37. package/dist/types/src/composables/useTheme.d.ts +2 -0
  38. package/dist/types/src/lib/parser/parseOpenapi.d.ts +4 -4
  39. package/dist/vitepress-openapi.client.cjs.js +135 -151
  40. package/dist/vitepress-openapi.client.es.js +17591 -18299
  41. package/dist/vitepress-openapi.css +1 -1
  42. package/dist/vitepress-openapi.node.cjs.js +1 -1
  43. package/dist/vitepress-openapi.node.es.js +1 -1
  44. package/package.json +7 -5
  45. package/src/components/Common/Highlight/OAShiki.vue +1 -1
  46. package/src/components/Context/OAContextAsync.vue +2 -3
  47. package/src/components/Context/OAContextProvider.vue +1 -1
  48. package/src/components/Feature/OAInfo.vue +1 -1
  49. package/src/components/Feature/OAIntroduction.vue +1 -1
  50. package/src/components/Feature/OAOperation.vue +13 -3
  51. package/src/components/Feature/OAOperationContent.vue +0 -4
  52. package/src/components/Feature/OAServers.vue +1 -1
  53. package/src/components/Feature/OASpec.vue +12 -3
  54. package/src/components/Feature/OASpecContent.vue +0 -5
  55. package/src/components/Playground/OAPlaygroundParameterInput.vue +2 -2
  56. package/src/components/Playground/OAPlaygroundParameters.vue +4 -4
  57. package/src/components/Response/OAResponses.vue +2 -2
  58. package/src/components/Sample/OACodeSamples.vue +4 -1
  59. package/src/components/index.ts +0 -4
  60. package/src/components/ui/button/Button.vue +2 -2
  61. package/src/components/ui/checkbox/Checkbox.vue +2 -2
  62. package/src/components/ui/collapsible/Collapsible.vue +2 -2
  63. package/src/components/ui/collapsible/CollapsibleContent.vue +2 -2
  64. package/src/components/ui/collapsible/CollapsibleTrigger.vue +2 -2
  65. package/src/components/ui/label/Label.vue +2 -2
  66. package/src/components/ui/select/Select.vue +2 -2
  67. package/src/components/ui/select/SelectContent.vue +3 -3
  68. package/src/components/ui/select/SelectGroup.vue +2 -2
  69. package/src/components/ui/select/SelectItem.vue +2 -2
  70. package/src/components/ui/select/SelectItemText.vue +2 -2
  71. package/src/components/ui/select/SelectLabel.vue +2 -2
  72. package/src/components/ui/select/SelectScrollDownButton.vue +2 -2
  73. package/src/components/ui/select/SelectScrollUpButton.vue +2 -2
  74. package/src/components/ui/select/SelectSeparator.vue +2 -2
  75. package/src/components/ui/select/SelectTrigger.vue +2 -2
  76. package/src/components/ui/select/SelectValue.vue +2 -2
  77. package/src/components/ui/select-with-custom-option/SelectWithCustomOption.vue +1 -1
  78. package/src/components/ui/tabs/Tabs.vue +2 -2
  79. package/src/components/ui/tabs/TabsContent.vue +2 -2
  80. package/src/components/ui/tabs/TabsList.vue +2 -2
  81. package/src/components/ui/tabs/TabsTrigger.vue +2 -2
  82. package/src/composables/useOpenapi.ts +3 -3
  83. package/src/composables/useShiki.ts +6 -2
  84. package/src/composables/useTheme.ts +9 -1
  85. package/src/lib/parser/parseOpenapi.ts +43 -19
  86. package/dist/OpenApi-B8nR467A.cjs +0 -95
  87. package/dist/OpenApi-snG2qo-c.js +0 -4847
  88. package/dist/types/src/components/Feature/OARemoteOperation.vue.d.ts +0 -32
  89. package/dist/types/src/components/Feature/OARemoteSpec.vue.d.ts +0 -24
  90. package/src/components/Feature/OARemoteOperation.vue +0 -41
  91. package/src/components/Feature/OARemoteSpec.vue +0 -36
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import type { SelectContentEmits, SelectContentProps } from 'radix-vue'
2
+ import type { SelectContentEmits, SelectContentProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { SelectContent, SelectPortal, SelectViewport, useForwardPropsEmits } from 'radix-vue'
4
+ import { SelectContent, SelectPortal, SelectViewport, useForwardPropsEmits } from 'reka-ui'
5
5
  import { computed } from 'vue'
6
6
  import { SelectScrollDownButton, SelectScrollUpButton } from '.'
7
7
  import { cn } from '../../../lib/utils'
@@ -41,7 +41,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
41
41
  "
42
42
  >
43
43
  <SelectScrollUpButton />
44
- <SelectViewport :class="cn('p-1', position === 'popper' && 'h-[--radix-select-trigger-height] w-full min-w-[--radix-select-trigger-width]')">
44
+ <SelectViewport :class="cn('p-1', position === 'popper' && 'h-[--reka-select-trigger-height] w-full min-w-[--reka-select-trigger-width]')">
45
45
  <slot />
46
46
  </SelectViewport>
47
47
  <SelectScrollDownButton />
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import type { SelectGroupProps } from 'radix-vue'
2
+ import type { SelectGroupProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
- import { SelectGroup } from 'radix-vue'
4
+ import { SelectGroup } 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 { SelectItemProps } from 'radix-vue'
2
+ import type { SelectItemProps } from 'reka-ui'
3
3
  import type { HTMLAttributes } from 'vue'
4
4
  import { Check } from 'lucide-vue-next'
5
- import { SelectItem, SelectItemIndicator, SelectItemText, useForwardProps } from 'radix-vue'
5
+ import { SelectItem, SelectItemIndicator, SelectItemText, 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 { SelectItemTextProps } from 'radix-vue'
3
- import { SelectItemText } from 'radix-vue'
2
+ import type { SelectItemTextProps } from 'reka-ui'
3
+ import { SelectItemText } from 'reka-ui'
4
4
 
5
5
  const props = defineProps<SelectItemTextProps>()
6
6
  </script>
@@ -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
  }
@@ -143,6 +143,7 @@ interface LanguageConfig {
143
143
  lang: string
144
144
  label: string
145
145
  highlighter: string
146
+ icon?: string
146
147
  }
147
148
 
148
149
  export type PartialUseThemeConfig = Partial<UnwrapNestedRefs<UseThemeConfig>>
@@ -172,21 +173,25 @@ export const availableLanguages: LanguageConfig[] = [
172
173
  lang: 'curl',
173
174
  label: 'cURL',
174
175
  highlighter: 'bash',
176
+ icon: 'curl',
175
177
  },
176
178
  {
177
179
  lang: 'javascript',
178
180
  label: 'JavaScript',
179
181
  highlighter: 'javascript',
182
+ icon: '.js',
180
183
  },
181
184
  {
182
185
  lang: 'php',
183
186
  label: 'PHP',
184
187
  highlighter: 'php',
188
+ icon: '.php',
185
189
  },
186
190
  {
187
191
  lang: 'python',
188
192
  label: 'Python',
189
193
  highlighter: 'python',
194
+ icon: '.py',
190
195
  },
191
196
  ]
192
197
 
@@ -786,7 +791,10 @@ export function useTheme(initialConfig: PartialUseThemeConfig = {}) {
786
791
  const uniqueLanguages = [...new Set(languages.map(({ lang }) => lang))]
787
792
 
788
793
  themeConfig.codeSamples.availableLanguages = uniqueLanguages.map((lang) => {
789
- const language = availableLanguages.find(l => l.lang === lang)
794
+ const language
795
+ = languages.find(l => l.lang === lang)
796
+ ?? availableLanguages.find(l => l.lang === lang)
797
+
790
798
  return language || { lang, label: lang, highlighter: 'plaintext' }
791
799
  })
792
800
  }
@@ -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> {