@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.
Files changed (135) hide show
  1. package/README.md +52 -0
  2. package/dist/docs-vitepress-openapi.client.cjs.js +1 -0
  3. package/dist/docs-vitepress-openapi.client.es.js +16 -0
  4. package/dist/docs-vitepress-openapi.css +1 -0
  5. package/dist/docs-vitepress-openapi.node.cjs.js +4102 -0
  6. package/dist/docs-vitepress-openapi.node.es.js +72981 -0
  7. package/dist/vanilla-picker-BAEwS4Fy.js +536 -0
  8. package/dist/vanilla-picker-m653iADl.cjs +8 -0
  9. package/package.json +80 -0
  10. package/src/client.ts +73 -0
  11. package/src/components/Common/Lazy/OALazy.vue +49 -0
  12. package/src/components/Common/Lazy/lazyBus.ts +8 -0
  13. package/src/components/Common/OACodeBlock.vue +91 -0
  14. package/src/components/Common/OACodeValue.vue +22 -0
  15. package/src/components/Common/OAHeaderBadges.vue +44 -0
  16. package/src/components/Common/OAHeading.vue +84 -0
  17. package/src/components/Common/OAInfo.vue +106 -0
  18. package/src/components/Common/OAIntroduction.vue +25 -0
  19. package/src/components/Common/OAJSONEditor.vue +41 -0
  20. package/src/components/Common/OAMarkdown.vue +28 -0
  21. package/src/components/Common/OAMethodBadge.vue +20 -0
  22. package/src/components/Common/OAServers.vue +42 -0
  23. package/src/components/Operation/OAOperation.vue +345 -0
  24. package/src/components/Operation/OAOperationTags.vue +30 -0
  25. package/src/components/Parameter/OAParameter.vue +80 -0
  26. package/src/components/Parameter/OAParameterAttribute.vue +44 -0
  27. package/src/components/Parameter/OAParameterExamples.vue +52 -0
  28. package/src/components/Parameter/OAParameters.vue +69 -0
  29. package/src/components/Path/OAPath.vue +347 -0
  30. package/src/components/Path/OAPathEndpoint.vue +99 -0
  31. package/src/components/Path/OAPaths.vue +62 -0
  32. package/src/components/Path/OAPathsByTag.vue +118 -0
  33. package/src/components/Path/OAPathsByTags.vue +99 -0
  34. package/src/components/Path/OAPathsSummary.vue +52 -0
  35. package/src/components/Playground/OAPlaygroundParameterInput.vue +97 -0
  36. package/src/components/Playground/OAPlaygroundParameters.vue +262 -0
  37. package/src/components/Playground/OAPlaygroundResponse.vue +74 -0
  38. package/src/components/Playground/OAPlaygroundSecurityInput.vue +44 -0
  39. package/src/components/Remote/OARemoteContext.vue +42 -0
  40. package/src/components/Remote/OARemoteOperation.vue +30 -0
  41. package/src/components/Remote/OARemoteRoot.vue +29 -0
  42. package/src/components/Remote/OARemoteSpec.vue +23 -0
  43. package/src/components/Request/OARequestBody.vue +24 -0
  44. package/src/components/Response/OAResponse.vue +81 -0
  45. package/src/components/Response/OAResponses.vue +119 -0
  46. package/src/components/Sample/OACodeSamples.vue +71 -0
  47. package/src/components/Schema/OASchemaPropertyAttributes.vue +44 -0
  48. package/src/components/Schema/OASchemaTabs.vue +90 -0
  49. package/src/components/Schema/OASchemaUI.vue +151 -0
  50. package/src/components/Security/OASecurity.vue +79 -0
  51. package/src/components/Security/OASecurityContent.vue +100 -0
  52. package/src/components/Spec/OASpec.vue +127 -0
  53. package/src/components/Spec/OASpecSkeleton.vue +26 -0
  54. package/src/components/Try/OATryItButton.vue +171 -0
  55. package/src/components/Try/OATryWithVariables.vue +105 -0
  56. package/src/components/index.ts +55 -0
  57. package/src/components/ui/badge/Badge.vue +18 -0
  58. package/src/components/ui/badge/index.ts +32 -0
  59. package/src/components/ui/button/Button.vue +28 -0
  60. package/src/components/ui/button/index.ts +37 -0
  61. package/src/components/ui/checkbox/Checkbox.vue +33 -0
  62. package/src/components/ui/checkbox/index.ts +1 -0
  63. package/src/components/ui/collapsible/Collapsible.vue +18 -0
  64. package/src/components/ui/collapsible/CollapsibleContent.vue +15 -0
  65. package/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
  66. package/src/components/ui/collapsible/index.ts +3 -0
  67. package/src/components/ui/input/Input.vue +29 -0
  68. package/src/components/ui/input/index.ts +1 -0
  69. package/src/components/ui/label/Label.vue +29 -0
  70. package/src/components/ui/label/index.ts +1 -0
  71. package/src/components/ui/multiselect/Multiselect.vue +104 -0
  72. package/src/components/ui/select/Select.vue +15 -0
  73. package/src/components/ui/select/SelectContent.vue +56 -0
  74. package/src/components/ui/select/SelectGroup.vue +24 -0
  75. package/src/components/ui/select/SelectItem.vue +40 -0
  76. package/src/components/ui/select/SelectItemText.vue +12 -0
  77. package/src/components/ui/select/SelectLabel.vue +14 -0
  78. package/src/components/ui/select/SelectScrollDownButton.vue +29 -0
  79. package/src/components/ui/select/SelectScrollUpButton.vue +29 -0
  80. package/src/components/ui/select/SelectSeparator.vue +22 -0
  81. package/src/components/ui/select/SelectTrigger.vue +33 -0
  82. package/src/components/ui/select/SelectValue.vue +12 -0
  83. package/src/components/ui/select/index.ts +11 -0
  84. package/src/components/ui/tabs/Tabs.vue +15 -0
  85. package/src/components/ui/tabs/TabsContent.vue +24 -0
  86. package/src/components/ui/tabs/TabsList.vue +27 -0
  87. package/src/components/ui/tabs/TabsTrigger.vue +33 -0
  88. package/src/components/ui/tabs/index.ts +21 -0
  89. package/src/composables/useOpenapi.ts +70 -0
  90. package/src/composables/usePaths.ts +31 -0
  91. package/src/composables/usePlayground.ts +49 -0
  92. package/src/composables/useShiki.ts +46 -0
  93. package/src/composables/useSidebar.ts +301 -0
  94. package/src/composables/useTheme.ts +799 -0
  95. package/src/index.ts +8 -0
  96. package/src/json.css +251 -0
  97. package/src/lib/OpenApi.ts +254 -0
  98. package/src/lib/codeSamples/buildRequest.ts +149 -0
  99. package/src/lib/codeSamples/generateCodeSample.ts +20 -0
  100. package/src/lib/codeSamples/generateCodeSampleCurl.ts +150 -0
  101. package/src/lib/codeSamples/generateCodeSampleJavaScript.ts +29 -0
  102. package/src/lib/codeSamples/generateCodeSamplePhp.ts +50 -0
  103. package/src/lib/codeSamples/generateCodeSamplePython.ts +32 -0
  104. package/src/lib/codeSamples/request.ts +25 -0
  105. package/src/lib/constraintsParser.ts +30 -0
  106. package/src/lib/createOpenApiInstance.ts +18 -0
  107. package/src/lib/deepUnref.ts +76 -0
  108. package/src/lib/examples/getPropertyExample.ts +31 -0
  109. package/src/lib/examples/getPropertyExamples.ts +27 -0
  110. package/src/lib/examples/getSchemaExample.ts +38 -0
  111. package/src/lib/examples/getSchemaUiJson.ts +150 -0
  112. package/src/lib/examples/getSchemaUiXml.ts +9 -0
  113. package/src/lib/examples/hasExample.ts +26 -0
  114. package/src/lib/getOpenApiInstance.ts +39 -0
  115. package/src/lib/getSchemaUi.ts +280 -0
  116. package/src/lib/getSecurityUi.ts +33 -0
  117. package/src/lib/operationData.ts +24 -0
  118. package/src/lib/prepareOpenAPI/generateMissingOperationIds.ts +19 -0
  119. package/src/lib/prepareOpenAPI/generateMissingSummary.ts +20 -0
  120. package/src/lib/prepareOpenAPI/generateMissingTags.ts +36 -0
  121. package/src/lib/prepareOpenAPI/prepareOpenAPI.ts +35 -0
  122. package/src/lib/processOpenAPI.ts +131 -0
  123. package/src/lib/resolveCircularRef.ts +66 -0
  124. package/src/lib/sidebar/cleanSidebarItems.ts +19 -0
  125. package/src/lib/sidebar/ensureGroupTextSlashPrefix.ts +18 -0
  126. package/src/lib/sidebar/flatSidebarItems.ts +58 -0
  127. package/src/lib/sidebar/generateSidebarItemsByPaths.ts +132 -0
  128. package/src/lib/sidebar/mergeAdjacentGroups.ts +56 -0
  129. package/src/lib/sidebar/setItemCollapsedState.ts +15 -0
  130. package/src/lib/utils.ts +7 -0
  131. package/src/locales/en.json +50 -0
  132. package/src/locales/index.ts +4 -0
  133. package/src/style.css +180 -0
  134. package/src/types.ts +73 -0
  135. package/src/vite-env.d.ts +8 -0
@@ -0,0 +1,347 @@
1
+ <script setup lang="ts">
2
+ import { useStorage } from '@vueuse/core'
3
+ import { computed, defineProps, provide, ref } from 'vue'
4
+ import { useTheme } from '../../composables/useTheme'
5
+ import { buildRequest } from '../../lib/codeSamples/buildRequest'
6
+ import { getOpenApiInstance } from '../../lib/getOpenApiInstance'
7
+ import { initOperationData } from '../../lib/operationData'
8
+
9
+ const props = defineProps({
10
+ id: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ openapi: {
15
+ type: Object,
16
+ required: false,
17
+ },
18
+ })
19
+
20
+ const themeConfig = useTheme()
21
+
22
+ const openapi = props.openapi ?? getOpenApiInstance()
23
+
24
+ const operation = openapi.getOperation(props.id)
25
+
26
+ const operationData = initOperationData({
27
+ operation,
28
+ })
29
+
30
+ provide('operationData', operationData)
31
+
32
+ const operationPath = openapi.getOperationPath(props.id)
33
+
34
+ const operationMethod = openapi.getOperationMethod(props.id)?.toUpperCase()
35
+
36
+ const operationParsed = openapi.getParsedOperation(props.id)
37
+
38
+ const securityUi = operation.securityUi
39
+
40
+ const operationParameters = operationParsed?.parameters
41
+
42
+ const operationRequestBody = operationParsed?.requestBody
43
+
44
+ const operationResponses = operationParsed?.responses
45
+
46
+ const operationSlots = computed(() => themeConfig.getOperationSlots().filter(slot => !themeConfig.getOperationHiddenSlots().includes(slot)))
47
+
48
+ const operationCols = computed(() => themeConfig.getOperationCols())
49
+
50
+ const bodyRequestContentTypes = computed(() => operationRequestBody ? Object.keys(operationRequestBody.content) : [])
51
+
52
+ const bodyRequestContentType = computed(() => bodyRequestContentTypes.value.length ? bodyRequestContentTypes.value[0] : undefined)
53
+
54
+ const customGetServers = themeConfig.getOperationServers()
55
+
56
+ const customUrl = ref('')
57
+
58
+ const prepareUrls = (serversForPrepare: typeof servers) => {
59
+ for (let i = 0; i < serversForPrepare.length; i++) {
60
+ if ((serversForPrepare[i].url.includes('host') || serversForPrepare[i].url.includes('protocol')) && serversForPrepare[i].variables.host.default && serversForPrepare[i].variables.protocol?.enum) {
61
+ if (serversForPrepare[i].variables.protocol?.default && serversForPrepare[i].variables.protocol?.enum.includes(serversForPrepare[i].variables.protocol?.default)) {
62
+ serversForPrepare[i].variables.protocol.enum = [serversForPrepare[i].variables.protocol?.default, serversForPrepare[i].variables.protocol?.enum.filter(el => el !== serversForPrepare[i].variables.protocol?.default)]
63
+ }
64
+ const newServers = serversForPrepare[i].variables.protocol.enum.map(el => (serversForPrepare[i].url.replace('{protocol}', el).replace('{host}', serversForPrepare[i].variables.host.default)))
65
+ if (newServers.length >= 1) {
66
+ serversForPrepare.splice(i, 1, ...newServers.map(el => ({ url: el })))
67
+ i += newServers.length - 1
68
+ }
69
+ }
70
+ }
71
+
72
+ return serversForPrepare
73
+ }
74
+
75
+ const servers: { url: string, variables: { host: { default: string }, protocol: { enum: string[], default: string } } }[] = prepareUrls(customGetServers
76
+ ? customGetServers({
77
+ method: operationMethod,
78
+ path: operationPath,
79
+ operation,
80
+ })
81
+ : openapi.getOperationServers(props.id),
82
+ )
83
+
84
+ const serversWithCustom = computed(() => customUrl.value ? [...servers, { url: customUrl.value }] : servers)
85
+
86
+ const defaultServer = servers.length ? servers[0]?.url : themeConfig.getOperationDefaultBaseUrl()
87
+
88
+ const selectedServer = servers?.length > 1 && typeof localStorage !== 'undefined'
89
+ ? useStorage(`--oa-operation-${props.id}-selectedServer`, defaultServer, localStorage, {
90
+ mergeDefaults: true,
91
+ })
92
+ : ref(defaultServer)
93
+
94
+ const baseUrl = computed(() => {
95
+ const value = selectedServer.value
96
+
97
+ if (serversWithCustom.value.length > 1 && !serversWithCustom.value.some(server => server.url === value)) {
98
+ updateSelectedServer(servers[0]?.url)
99
+
100
+ return servers[0]?.url
101
+ }
102
+
103
+ return value
104
+ })
105
+
106
+ const shouldBuildRequest = computed(() => ['try-it', 'code-samples'].some(slot => operationSlots.value.includes(slot)))
107
+
108
+ const request = ref(
109
+ shouldBuildRequest.value
110
+ ? buildRequest({
111
+ path: operationPath,
112
+ method: operationMethod,
113
+ baseUrl: baseUrl.value,
114
+ parameters: operationParameters ?? [],
115
+ authorizations: securityUi.length ? Object.entries(securityUi)[0]?.schemes : {},
116
+ body: (operationRequestBody?.content?.[bodyRequestContentType]?.examples ?? { value: '' })[0]?.value,
117
+ variables: {},
118
+ })
119
+ : {},
120
+ )
121
+
122
+ function updateRequest(newRequest) {
123
+ request.value = newRequest
124
+ }
125
+
126
+ function updateSelectedServer(server) {
127
+ selectedServer.value = server
128
+ }
129
+
130
+ const onCustomInputChange = (event: Event) => {
131
+ customUrl.value = (event.target as HTMLInputElement)?.value
132
+ selectedServer.value = (event.target as HTMLInputElement)?.value
133
+ }
134
+ </script>
135
+
136
+ <template>
137
+ <div>
138
+ <div
139
+ v-if="operation"
140
+ class="OAPath flex flex-col space-y-4"
141
+ >
142
+ <template v-if="operationSlots.includes('header')">
143
+ <slot
144
+ name="header"
145
+ :operation="operation"
146
+ :method="operationMethod"
147
+ :base-url="baseUrl"
148
+ :path="operationPath"
149
+ :deprecated="operation.deprecated"
150
+ />
151
+ </template>
152
+
153
+ <template v-if="operationSlots.includes('tags')">
154
+ <slot
155
+ name="tags"
156
+ :operation="operation"
157
+ :method="operationMethod"
158
+ :base-url="baseUrl"
159
+ :path="operationPath"
160
+ :tags="operation.tags"
161
+ />
162
+ </template>
163
+
164
+ <div
165
+ :class="{
166
+ 'sm:grid-cols-1': operationCols === 1,
167
+ 'sm:grid-cols-2': operationCols === 2,
168
+ }"
169
+ class="relative grid grid-cols-1"
170
+ >
171
+ <div class="OAPathContentStart flex flex-col">
172
+ <div class="flex flex-col gap-4">
173
+ <div
174
+ v-if="operationSlots.includes('path')"
175
+ :class="{
176
+ 'sm:hidden': operationCols === 2,
177
+ }"
178
+ >
179
+ <slot
180
+ name="path"
181
+ :operation-id="props.id"
182
+ :operation="operation"
183
+ :method="operationMethod"
184
+ :base-url="baseUrl"
185
+ :path="operationPath"
186
+ :hide-base-url="!themeConfig.getShowBaseURL()"
187
+ :deprecated="operation.deprecated"
188
+ :servers="servers"
189
+ :update-selected-server="updateSelectedServer"
190
+ />
191
+ </div>
192
+
193
+ <template v-if="operationSlots.includes('description')">
194
+ <slot
195
+ name="description"
196
+ :operation="operation"
197
+ :method="operationMethod"
198
+ :base-url="baseUrl"
199
+ :path="operationPath"
200
+ />
201
+ </template>
202
+ </div>
203
+
204
+ <template v-if="operationSlots.includes('security')">
205
+ <slot
206
+ v-if="Object.keys(securityUi).length"
207
+ name="security"
208
+ :operation="operation"
209
+ :method="operationMethod"
210
+ :base-url="baseUrl"
211
+ :path="operationPath"
212
+ :security-ui="securityUi"
213
+ />
214
+ </template>
215
+
216
+ <template v-if="operationSlots.includes('parameters')">
217
+ <slot
218
+ v-if="operationParameters?.length"
219
+ name="parameters"
220
+ :operation-id="props.id"
221
+ :parameters="operationParameters"
222
+ />
223
+ </template>
224
+
225
+ <template v-if="operationSlots.includes('request-body')">
226
+ <slot
227
+ v-if="operationRequestBody"
228
+ name="request-body"
229
+ :operation-id="props.id"
230
+ :request-body="operationRequestBody"
231
+ :content-type="bodyRequestContentType"
232
+ />
233
+ </template>
234
+
235
+ <template v-if="operationSlots.includes('responses')">
236
+ <slot
237
+ v-if="operationResponses"
238
+ name="responses"
239
+ :operation-id="props.id"
240
+ :responses="operationResponses"
241
+ />
242
+ </template>
243
+ </div>
244
+
245
+ <div class="flex flex-col">
246
+ <div
247
+ class="OAPathContentEnd sticky top-[100px] inset-x-0 flex flex-col space-y-4"
248
+ :class="{
249
+ '!px-0': operationCols === 1,
250
+ }"
251
+ >
252
+ <div
253
+ v-if="operationSlots.includes('path') && operationCols === 2"
254
+ :class="{
255
+ 'hidden sm:block': operationCols === 2,
256
+ }"
257
+ >
258
+ <slot
259
+ name="path"
260
+ :operation-id="props.id"
261
+ :operation="operation"
262
+ :method="operationMethod"
263
+ :base-url="baseUrl"
264
+ :path="operationPath"
265
+ :hide-base-url="!themeConfig.getShowBaseURL()"
266
+ :deprecated="operation.deprecated"
267
+ :servers="serversWithCustom"
268
+ :update-selected-server="updateSelectedServer"
269
+ />
270
+
271
+ <div class="mt-2 flex flex-col gap-2">
272
+ <div class="flex flex-row items-center space-x-2">
273
+ <span class="text-sm font-bold">Server</span>
274
+ </div>
275
+
276
+ <div class="flex flex-row items-center space-x-2">
277
+ <div class="flex flex-col space-y-2 w-full">
278
+ <input
279
+ type="text"
280
+ class="flex h-10 w-full rounded-md border border-input px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 bg-muted"
281
+ placeholder="Server (don't forget add http:// or https://)"
282
+ :value="customUrl"
283
+ @input="onCustomInputChange"
284
+ >
285
+ </div>
286
+ </div>
287
+ </div>
288
+ </div>
289
+
290
+ <template v-if="operationSlots.includes('try-it')">
291
+ <slot
292
+ name="try-it"
293
+ :operation-id="props.id"
294
+ :path="operationPath"
295
+ :method="operationMethod"
296
+ :base-url="baseUrl"
297
+ :parameters="operationParameters"
298
+ :request-body="operationRequestBody"
299
+ :security-ui="securityUi"
300
+ :content-type="bodyRequestContentType"
301
+ :request="request"
302
+ :update-request="updateRequest"
303
+ :servers="serversWithCustom"
304
+ :update-selected-server="updateSelectedServer"
305
+ />
306
+ </template>
307
+
308
+ <template v-if="operationSlots.includes('code-samples')">
309
+ <slot
310
+ name="code-samples"
311
+ :operation-id="props.id"
312
+ :operation="operation"
313
+ :method="operationMethod"
314
+ :base-url="baseUrl"
315
+ :path="operationPath"
316
+ :request="request"
317
+ :update-request="updateRequest"
318
+ />
319
+ </template>
320
+ </div>
321
+ </div>
322
+ </div>
323
+
324
+ <template v-if="operationSlots.includes('branding')">
325
+ <slot
326
+ name="branding"
327
+ :operation-id="props.id"
328
+ :operation="operation"
329
+ :method="operationMethod"
330
+ :base-url="baseUrl"
331
+ :path="operationPath"
332
+ />
333
+ </template>
334
+
335
+ <template v-if="operationSlots.includes('footer')">
336
+ <slot
337
+ name="footer"
338
+ :operation-id="props.id"
339
+ :operation="operation"
340
+ :method="operationMethod"
341
+ :base-url="baseUrl"
342
+ :path="operationPath"
343
+ />
344
+ </template>
345
+ </div>
346
+ </div>
347
+ </template>
@@ -0,0 +1,99 @@
1
+ <script setup>
2
+ import { defineEmits } from 'vue'
3
+ import OAMethodBadge from '../Common/OAMethodBadge.vue'
4
+
5
+ const props = defineProps({
6
+ path: {
7
+ type: String,
8
+ required: true,
9
+ },
10
+ method: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ baseUrl: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ hideBaseUrl: {
19
+ type: Boolean,
20
+ default: false,
21
+ },
22
+ deprecated: {
23
+ type: Boolean,
24
+ default: false,
25
+ },
26
+ servers: {
27
+ type: Array,
28
+ required: false,
29
+ },
30
+ })
31
+
32
+ const emits = defineEmits([
33
+ 'update:selectedServer',
34
+ ])
35
+ </script>
36
+
37
+ <template>
38
+ <div class="flex flex-col gap-2 text-sm bg-muted rounded p-2">
39
+ <div class="language-bash !overflow-hidden !my-0 h-8 flex flex-row items-center gap-4">
40
+ <button
41
+ :title="$t('Copy endpoint')"
42
+ class="copy absolute !top-1 z-50 OAPathEndpoint__copy"
43
+ />
44
+
45
+ <OAMethodBadge :method="props.method" />
46
+
47
+ <div class="overflow-x-auto whitespace-nowrap">
48
+ <span class="flex flex-row flex-shrink-0 text-gray-600 dark:text-gray-400">
49
+ <span
50
+ v-if="!props.hideBaseUrl"
51
+ class="hidden md:inline-block"
52
+ >
53
+ {{ props.baseUrl }}
54
+ </span>
55
+ <span
56
+ :class="{
57
+ 'line-through': props.deprecated,
58
+ }"
59
+ class="text-gray-800 dark:text-gray-200 font-bold select-all"
60
+ >{{ props.path }}</span>
61
+ </span>
62
+ </div>
63
+ </div>
64
+
65
+ <div
66
+ v-if="props.servers && props.servers.length > 1"
67
+ class="flex flex-row items-center gap-2"
68
+ >
69
+ <span class="text-gray-600 dark:text-gray-400">
70
+ {{ $t('Server') }}
71
+ </span>
72
+ <select
73
+ :value="props.baseUrl"
74
+ class="w-full rounded p-1 text-sm bg-white dark:bg-gray-800 dark:text-gray-200"
75
+ @change="($event) => emits('update:selectedServer', $event.target.value)"
76
+ >
77
+ <option
78
+ v-for="(server, idx) in props.servers"
79
+ :key="`${server.url}-${idx}`"
80
+ :value="server.url"
81
+ :selected="server.url === props.baseUrl"
82
+ >
83
+ {{ server.url }}
84
+ </option>
85
+ </select>
86
+ </div>
87
+ </div>
88
+ </template>
89
+
90
+ <style scoped>
91
+ .OAPathEndpoint__copy {
92
+ width: 1.5rem !important;
93
+ height: 1.5rem !important;
94
+ }
95
+
96
+ .OAPathEndpoint__copy.copied::before {
97
+ height: 1.5rem !important;
98
+ }
99
+ </style>
@@ -0,0 +1,62 @@
1
+ <script setup lang="ts">
2
+ import type { OperationSlot } from '../../types'
3
+ import { defineProps } from 'vue'
4
+ import { useTheme } from '../../composables/useTheme'
5
+ import OALazy from '../Common/Lazy/OALazy.vue'
6
+
7
+ const { openapi, paths } = defineProps({
8
+ openapi: {
9
+ type: Object,
10
+ required: true,
11
+ },
12
+ paths: {
13
+ type: Object,
14
+ required: true,
15
+ },
16
+ })
17
+
18
+ const slots = defineSlots<Record<string, OperationSlot>>()
19
+
20
+ const themeConfig = useTheme()
21
+
22
+ const operations = Object.entries(paths).reduce((acc: { operationId: string }[], [_, path]) => {
23
+ return [
24
+ ...acc,
25
+ ...Object.keys(path).filter(m => path[m].operationId).map((method) => {
26
+ return {
27
+ operationId: path[method].operationId,
28
+ }
29
+ }),
30
+ ]
31
+ }, [])
32
+
33
+ const lazyRendering = themeConfig.getSpecConfig()?.lazyRendering?.value
34
+ </script>
35
+
36
+ <template>
37
+ <OALazy
38
+ v-for="(operation, operationIdx) in operations"
39
+ :key="operation.operationId"
40
+ :is-lazy="lazyRendering && operationIdx > 0"
41
+ >
42
+ <OAOperation
43
+ :operation-id="operation.operationId"
44
+ :openapi="openapi"
45
+ prefix-headings
46
+ hide-branding
47
+ >
48
+ <!-- Expose all slots upwards -->
49
+ <template
50
+ v-for="(_, name) in slots"
51
+ #[name]="slotProps"
52
+ >
53
+ <slot
54
+ :name="name"
55
+ v-bind="slotProps || {}"
56
+ />
57
+ </template>
58
+ </OAOperation>
59
+
60
+ <hr>
61
+ </OALazy>
62
+ </template>
@@ -0,0 +1,118 @@
1
+ <script setup lang="ts">
2
+ import type { OperationSlot } from '../../types'
3
+ import { computed, defineProps, ref } from 'vue'
4
+ import { useTheme } from '../../composables/useTheme'
5
+ import { getOpenApiInstance } from '../../lib/getOpenApiInstance'
6
+ import OAPathsSummary from '../Path/OAPathsSummary.vue'
7
+ import { Button } from '../ui/button'
8
+ import { Collapsible, CollapsibleTrigger } from '../ui/collapsible'
9
+
10
+ export interface Tag {
11
+ tag: string
12
+ paths: Record<string, any>
13
+ isOpen: boolean
14
+ description?: string
15
+ }
16
+
17
+ const props = defineProps({
18
+ openapi: {
19
+ type: Object,
20
+ required: true,
21
+ },
22
+ tag: {
23
+ type: Object as () => Tag,
24
+ required: true,
25
+ },
26
+ hidePathsSummary: {
27
+ type: Boolean,
28
+ default: undefined,
29
+ },
30
+ })
31
+
32
+ const slots = defineSlots<Record<string, OperationSlot>>()
33
+
34
+ const themeConfig = useTheme()
35
+
36
+ const openapi = props.openapi ?? getOpenApiInstance()
37
+
38
+ const lazyRendering = themeConfig.getSpecConfig()?.lazyRendering?.value
39
+
40
+ const showPathsSummary = computed(() => props.hidePathsSummary === undefined
41
+ ? themeConfig.getSpecConfig()?.showPathsSummary?.value
42
+ : !props.hidePathsSummary,
43
+ )
44
+
45
+ const hasDescription = computed(() => props.tag?.description && props.tag?.description.trim() !== '')
46
+
47
+ const isOpen = ref(!themeConfig.getSpecConfig()?.collapsePaths?.value)
48
+
49
+ function onPathClick() {
50
+ isOpen.value = true
51
+ }
52
+ </script>
53
+
54
+ <template>
55
+ <Collapsible
56
+ v-model:open="isOpen"
57
+ >
58
+ <OAHeading level="h1">
59
+ {{ props.tag.tag }}
60
+ </OAHeading>
61
+
62
+ <div
63
+ :class="{ 'md:grid-cols-2': showPathsSummary && hasDescription }"
64
+ class="grid grid-cols-1 gap-10"
65
+ >
66
+ <div v-if="hasDescription">
67
+ <p>
68
+ {{ props.tag.description }}
69
+ </p>
70
+ </div>
71
+
72
+ <div
73
+ v-if="showPathsSummary"
74
+ class="flex-1 my-[16px]"
75
+ >
76
+ <OAPathsSummary
77
+ :paths="props.tag.paths"
78
+ @path-click="onPathClick()"
79
+ />
80
+ </div>
81
+ </div>
82
+
83
+ <div
84
+ v-if="showPathsSummary || themeConfig.getSpecConfig()?.collapsePaths?.value === true"
85
+ class="flex justify-center"
86
+ >
87
+ <CollapsibleTrigger>
88
+ <Button>
89
+ {{ isOpen ? $t('Hide operations') : $t('Show operations') }}
90
+ </Button>
91
+ </CollapsibleTrigger>
92
+ </div>
93
+
94
+ <hr>
95
+
96
+ <div
97
+ v-if="!lazyRendering || isOpen"
98
+ class="flex flex-col space-y-10"
99
+ :class="[{ hidden: !isOpen }]"
100
+ >
101
+ <OAPaths
102
+ :openapi="openapi"
103
+ :paths="props.tag.paths"
104
+ >
105
+ <!-- Expose all slots upwards -->
106
+ <template
107
+ v-for="(_, name) in slots"
108
+ #[name]="slotProps"
109
+ >
110
+ <slot
111
+ :name="name"
112
+ v-bind="slotProps || {}"
113
+ />
114
+ </template>
115
+ </OAPaths>
116
+ </div>
117
+ </Collapsible>
118
+ </template>