vitepress-openapi 0.2.11 → 0.2.12

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.
@@ -16030,10 +16030,10 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16030
16030
  ])]);
16031
16031
  };
16032
16032
  }
16033
- }), lh = { class: "flex flex-col space-y-4" }, uh = {
16034
- key: 1,
16033
+ }), lh = { class: "OAResponse flex flex-col space-y-4" }, uh = {
16034
+ key: 0,
16035
16035
  class: "flex flex-row items-center gap-2 text-xs"
16036
- }, dh = { class: "flex-shrink-0" }, fh = {
16036
+ }, dh = { class: "flex-shrink-0" }, fh = /* @__PURE__ */ F({
16037
16037
  __name: "OAResponse",
16038
16038
  props: {
16039
16039
  operationId: {
@@ -16061,10 +16061,16 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16061
16061
  return (e, t) => {
16062
16062
  var n;
16063
16063
  return B(), j("div", lh, [
16064
- r.response.description ? (B(), k(hi, {
16064
+ U(e.$slots, "response-description", {
16065
+ operationId: r.operationId,
16066
+ responseCode: r.responseCode,
16067
+ response: r.response,
16068
+ description: r.response.description
16069
+ }, () => [r.response.description ? (B(), k(hi, {
16065
16070
  key: 0,
16066
- content: r.response.description
16067
- }, null, 8, ["content"])) : A("", !0),
16071
+ content: r.response.description,
16072
+ class: "OAResponseDescription"
16073
+ }, null, 8, ["content"])) : A("", !0)]),
16068
16074
  (n = r.response) != null && n.content && G(i).length ? (B(), j("div", uh, [P(G(Uf), {
16069
16075
  for: c,
16070
16076
  class: "flex-shrink-0 text-muted-foreground"
@@ -16083,7 +16089,7 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16083
16089
  "content-types"
16084
16090
  ])])])) : A("", !0),
16085
16091
  o.value ? (B(), k(ih, {
16086
- key: 2,
16092
+ key: 1,
16087
16093
  schema: o.value,
16088
16094
  examples: s.value,
16089
16095
  "content-type": a.value,
@@ -16097,7 +16103,7 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16097
16103
  ]);
16098
16104
  };
16099
16105
  }
16100
- }, ph = { class: "flex flex-col" }, mh = { class: "mt-[48px] mb-[16px] pt-[24px] border-t-[1px] border-(--vp-c-divider) flex flex-wrap flex-row items-center justify-between gap-y-[16px]" }, hh = { class: "w-full flex" }, gh = { class: "relative flex flex-row" }, _h = {
16106
+ }), ph = { class: "OAResponses flex flex-col" }, mh = { class: "mt-[48px] mb-[16px] pt-[24px] border-t-[1px] border-(--vp-c-divider) flex flex-wrap flex-row items-center justify-between gap-y-[16px]" }, hh = { class: "w-full flex" }, gh = { class: "relative flex flex-row" }, _h = /* @__PURE__ */ F({
16101
16107
  __name: "OAResponses",
16102
16108
  props: {
16103
16109
  operationId: {
@@ -16114,48 +16120,48 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16114
16120
  }
16115
16121
  },
16116
16122
  setup(e) {
16117
- let t = e, n = w(), { t: r } = J(), i = Object.keys(t.responses), a = V(i && i.length > 0 ? i[0] : null), o = O(() => {
16118
- let e = n.getResponseCodeSelector();
16123
+ let t = e, n = nt(), r = w(), { t: i } = J(), a = Object.keys(t.responses), o = V(a[0]), s = O(() => {
16124
+ let e = r.getResponseCodeSelector();
16119
16125
  if (e === "tabs") {
16120
- let e = n.getResponseCodeMaxTabs();
16121
- return e && i.length > e ? "select" : "tabs";
16126
+ let e = r.getResponseCodeMaxTabs();
16127
+ return e && a.length > e ? "select" : "tabs";
16122
16128
  }
16123
16129
  return e;
16124
16130
  });
16125
- return (n, s) => (B(), j("div", ph, [P(G(Zm), { "default-value": a.value }, {
16131
+ return (r, c) => (B(), j("div", ph, [P(G(Zm), { "default-value": o.value }, {
16126
16132
  default: q(() => [M("div", mh, [P(ri, {
16127
16133
  level: "h2",
16128
16134
  prefix: e.headingPrefix,
16129
16135
  class: "text-[color:var(--vp-c-text-1)] my-0! py-0! border-t-0! inline-block",
16130
16136
  "header-anchor-class": "top-0!"
16131
16137
  }, {
16132
- default: q(() => [N(W(G(r)("Responses")), 1)]),
16138
+ default: q(() => [N(W(G(i)("Responses")), 1)]),
16133
16139
  _: 1
16134
- }, 8, ["prefix"]), M("div", { class: R({ "overflow-x-auto": G(i).length > 1 }) }, [M("div", hh, [P(G($m), { class: "bg-transparent text-muted-foreground p-0" }, {
16135
- default: q(() => [M("div", gh, [o.value === "tabs" ? (B(), j(D, { key: 0 }, [P(G(Hl), { class: "absolute left-0 h-full bottom-0 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position) rounded transition-[width,transform] duration-300 bg-muted" }), (B(!0), j(D, null, H(G(i), (e) => (B(), k(G(eh), {
16140
+ }, 8, ["prefix"]), M("div", { class: R({ "overflow-x-auto": G(a).length > 1 }) }, [M("div", hh, [P(G($m), { class: "bg-transparent text-muted-foreground p-0" }, {
16141
+ default: q(() => [M("div", gh, [s.value === "tabs" ? (B(), j(D, { key: 0 }, [P(G(Hl), { class: "absolute left-0 h-full bottom-0 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position) rounded transition-[width,transform] duration-300 bg-muted" }), (B(!0), j(D, null, H(G(a), (e) => (B(), k(G(eh), {
16136
16142
  key: e,
16137
16143
  value: e,
16138
16144
  class: "h-full z-10"
16139
16145
  }, {
16140
16146
  default: q(() => [N(W(e), 1)]),
16141
16147
  _: 2
16142
- }, 1032, ["value"]))), 128))], 64)) : A("", !0), o.value === "select" ? (B(), k(G(Mu), {
16148
+ }, 1032, ["value"]))), 128))], 64)) : A("", !0), s.value === "select" ? (B(), k(G(Mu), {
16143
16149
  key: 1,
16144
- modelValue: a.value,
16145
- "onUpdate:modelValue": s[0] || (s[0] = (e) => a.value = e)
16150
+ modelValue: o.value,
16151
+ "onUpdate:modelValue": c[0] || (c[0] = (e) => o.value = e)
16146
16152
  }, {
16147
16153
  default: q(() => [P(G(nd), {
16148
16154
  "aria-label": "Response Code",
16149
16155
  class: "px-3 py-1.5 text-foreground"
16150
16156
  }, {
16151
16157
  default: q(() => [P(G(rd), null, {
16152
- default: q(() => [N(W(a.value), 1)]),
16158
+ default: q(() => [N(W(o.value), 1)]),
16153
16159
  _: 1
16154
16160
  })]),
16155
16161
  _: 1
16156
16162
  }), P(G(Nu), null, {
16157
16163
  default: q(() => [P(G(Pu), null, {
16158
- default: q(() => [(B(!0), j(D, null, H(G(i), (e, t) => (B(), k(G(eh), {
16164
+ default: q(() => [(B(!0), j(D, null, H(G(a), (e, t) => (B(), k(G(eh), {
16159
16165
  key: t,
16160
16166
  value: e,
16161
16167
  variant: "select"
@@ -16173,7 +16179,7 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16173
16179
  _: 1
16174
16180
  }, 8, ["modelValue"])) : A("", !0)])]),
16175
16181
  _: 1
16176
- })])], 2)]), (B(!0), j(D, null, H(G(i), (e) => (B(), k(G(Qm), {
16182
+ })])], 2)]), (B(!0), j(D, null, H(G(a), (e) => (B(), k(G(Qm), {
16177
16183
  key: e,
16178
16184
  value: e
16179
16185
  }, {
@@ -16182,17 +16188,21 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16182
16188
  "operation-id": t.operationId,
16183
16189
  response: t.responses[e],
16184
16190
  "response-code": e
16185
- }, null, 8, [
16191
+ }, Oe({ _: 2 }, [n["response-description"] ? {
16192
+ name: "response-description",
16193
+ fn: q((e) => [U(r.$slots, "response-description", L({ ref_for: !0 }, e))]),
16194
+ key: "0"
16195
+ } : void 0]), 1032, [
16186
16196
  "operation-id",
16187
16197
  "response",
16188
16198
  "response-code"
16189
16199
  ])) : A("", !0)]),
16190
16200
  _: 2
16191
16201
  }, 1032, ["value"]))), 128))]),
16192
- _: 1
16202
+ _: 3
16193
16203
  }, 8, ["default-value"])]));
16194
16204
  }
16195
- }, vh = {
16205
+ }), vh = {
16196
16206
  key: 0,
16197
16207
  class: "vp-code-group vp-adaptive-theme mt-0"
16198
16208
  }, yh = { class: "tabs m-0!" }, bh = [
@@ -16411,7 +16421,7 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16411
16421
  function o(e) {
16412
16422
  return e === "try-it" && n[e] !== void 0 && console.warn("`try-it` slot is deprecated. Use `playground` slot instead."), n[e] !== void 0;
16413
16423
  }
16414
- return (e, n) => t.operationId && G(i) ? (B(), k(yf, {
16424
+ return (e, s) => t.operationId && G(i) ? (B(), k(yf, {
16415
16425
  key: 0,
16416
16426
  id: t.operationId,
16417
16427
  operation: G(i),
@@ -16516,12 +16526,16 @@ var tm = ["innerHTML"], nm = { key: 1 }, rm = {
16516
16526
  key: "12"
16517
16527
  } : {
16518
16528
  name: "responses",
16519
- fn: q((e) => [P(_h, {
16520
- "operation-id": e.operationId,
16521
- responses: e.responses,
16522
- "response-type": e.responseType,
16529
+ fn: q((t) => [P(_h, {
16530
+ "operation-id": t.operationId,
16531
+ responses: t.responses,
16532
+ "response-type": t.responseType,
16523
16533
  "heading-prefix": a.value
16524
- }, null, 8, [
16534
+ }, Oe({ _: 2 }, [n["response-description"] ? {
16535
+ name: "response-description",
16536
+ fn: q((t) => [U(e.$slots, "response-description", z(I(t)))]),
16537
+ key: "0"
16538
+ } : void 0]), 1032, [
16525
16539
  "operation-id",
16526
16540
  "responses",
16527
16541
  "response-type",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-openapi",
3
3
  "type": "module",
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "engines": {
6
6
  "node": "^20.19.0 || ^22.13.0 || >=24.0.0"
7
7
  },
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot } from '../../types'
2
+ import type { OperationSlot, ResponseDescriptionSlotProps } from '../../types'
3
3
  import OAProvider from '../Context/OAProvider.vue'
4
4
  import OAOperationContent from './OAOperationContent.vue'
5
5
 
@@ -49,7 +49,9 @@ const emits = defineEmits([
49
49
  'update:spec',
50
50
  ])
51
51
 
52
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
52
+ const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any } & {
53
+ 'response-description'?: (props: ResponseDescriptionSlotProps) => any
54
+ }>()
53
55
  </script>
54
56
 
55
57
  <template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot } from '../../types'
2
+ import type { OperationNestedSlot, OperationSlot } from '../../types'
3
3
  import { useI18n } from '@byjohann/vue-i18n'
4
4
  import { computed } from 'vue'
5
5
  import OAFooter from '../Common/OAFooter.vue'
@@ -53,7 +53,7 @@ const props = defineProps({
53
53
  },
54
54
  })
55
55
 
56
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
56
+ const slots = defineSlots<{ [K in OperationSlot | OperationNestedSlot]?: (props: any) => any }>()
57
57
 
58
58
  const { t } = useI18n()
59
59
 
@@ -239,7 +239,17 @@ function hasSlot(name: OperationSlot): boolean {
239
239
  :responses="responses.responses"
240
240
  :response-type="responses.responseType"
241
241
  :heading-prefix="headingPrefix"
242
- />
242
+ >
243
+ <template
244
+ v-if="slots['response-description']"
245
+ #response-description="responseDescription"
246
+ >
247
+ <slot
248
+ name="response-description"
249
+ v-bind="responseDescription"
250
+ />
251
+ </template>
252
+ </OAResponses>
243
253
  </template>
244
254
 
245
255
  <template
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot } from '../../types'
2
+ import type { OperationSlot, ResponseDescriptionSlotProps } from '../../types'
3
3
  import OAProvider from '../Context/OAProvider.vue'
4
4
  import OASpecContent from './OASpecContent.vue'
5
5
 
@@ -61,7 +61,9 @@ const emits = defineEmits([
61
61
  'update:spec',
62
62
  ])
63
63
 
64
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
64
+ const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any } & {
65
+ 'response-description'?: (props: ResponseDescriptionSlotProps) => any
66
+ }>()
65
67
  </script>
66
68
 
67
69
  <template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { OpenAPIV3 } from '@scalar/openapi-types'
3
- import type { OperationSlot, PathsGroupView } from '../../types'
3
+ import type { OperationNestedSlot, OperationSlot, PathsGroupView } from '../../types'
4
4
  import { useI18n } from '@byjohann/vue-i18n'
5
5
  import { computed } from 'vue'
6
6
  import { useTheme } from '../../composables/useTheme'
@@ -57,7 +57,7 @@ const props = defineProps({
57
57
  },
58
58
  })
59
59
 
60
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
60
+ const slots = defineSlots<{ [K in OperationSlot | OperationNestedSlot]?: (props: any) => any }>()
61
61
 
62
62
  const { t } = useI18n()
63
63
 
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot } from '../../types'
2
+ import type { OperationNestedSlot, OperationSlot } from '../../types'
3
3
  import { getGlobalOpenapi, injectOpenapi } from '../../composables/useOpenapi'
4
4
  import { useTheme } from '../../composables/useTheme'
5
5
  import OALazy from '../Common/Lazy/OALazy.vue'
@@ -12,7 +12,7 @@ const { paths } = defineProps({
12
12
  },
13
13
  })
14
14
 
15
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
15
+ const slots = defineSlots<{ [K in OperationSlot | OperationNestedSlot]?: (props: any) => any }>()
16
16
 
17
17
  const themeConfig = useTheme()
18
18
 
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot, PathsGroupView } from '../../types'
2
+ import type { OperationNestedSlot, OperationSlot, PathsGroupView } from '../../types'
3
3
  import { useI18n } from '@byjohann/vue-i18n'
4
4
  import { computed, nextTick, ref } from 'vue'
5
5
  import { scrollToHash } from '@/lib/utils/utils'
@@ -19,7 +19,7 @@ interface Props {
19
19
 
20
20
  const props = defineProps<Props>()
21
21
 
22
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
22
+ const slots = defineSlots<{ [K in OperationSlot | OperationNestedSlot]?: (props: any) => any }>()
23
23
 
24
24
  const themeConfig = useTheme()
25
25
  const { t } = useI18n()
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { OperationSlot, PathsGroupView } from '../../types'
2
+ import type { OperationNestedSlot, OperationSlot, PathsGroupView } from '../../types'
3
3
  import { useTheme } from '../../composables/useTheme'
4
4
  import OAPathsGroup from './OAPathsGroup.vue'
5
5
 
@@ -14,7 +14,7 @@ const props = defineProps({
14
14
  },
15
15
  })
16
16
 
17
- const slots = defineSlots<{ [K in OperationSlot]?: (props: any) => any }>()
17
+ const slots = defineSlots<{ [K in OperationSlot | OperationNestedSlot]?: (props: any) => any }>()
18
18
 
19
19
  const themeConfig = useTheme()
20
20
  const lazyRendering = themeConfig.getSpecConfig()?.lazyRendering?.value
@@ -1,6 +1,7 @@
1
- <script setup>
1
+ <script setup lang="ts">
2
+ import type { ResponseDescriptionSlotProps } from '../../types'
2
3
  import { useI18n } from '@byjohann/vue-i18n'
3
- import { computed, defineProps, ref } from 'vue'
4
+ import { computed, ref } from 'vue'
4
5
  import { useTheme } from '../../composables/useTheme'
5
6
  import OAContentTypeSelect from '../Common/OAContentTypeSelect.vue'
6
7
  import OAMarkdown from '../Common/OAMarkdown.vue'
@@ -22,6 +23,10 @@ const props = defineProps({
22
23
  },
23
24
  })
24
25
 
26
+ defineSlots<{
27
+ 'response-description'?: (props: ResponseDescriptionSlotProps) => any
28
+ }>()
29
+
25
30
  const contentTypes = Object.keys(props.response.content ?? {})
26
31
 
27
32
  const contentType = ref(contentTypes[0] ?? undefined)
@@ -37,11 +42,20 @@ const { t } = useI18n()
37
42
  </script>
38
43
 
39
44
  <template>
40
- <div class="flex flex-col space-y-4">
41
- <OAMarkdown
42
- v-if="props.response.description"
43
- :content="props.response.description"
44
- />
45
+ <div class="OAResponse flex flex-col space-y-4">
46
+ <slot
47
+ name="response-description"
48
+ :operation-id="props.operationId"
49
+ :response-code="props.responseCode"
50
+ :response="props.response"
51
+ :description="props.response.description"
52
+ >
53
+ <OAMarkdown
54
+ v-if="props.response.description"
55
+ :content="props.response.description"
56
+ class="OAResponseDescription"
57
+ />
58
+ </slot>
45
59
 
46
60
  <div
47
61
  v-if="props.response?.content && contentTypes.length"
@@ -1,7 +1,8 @@
1
- <script setup>
1
+ <script setup lang="ts">
2
+ import type { ResponseDescriptionSlotProps } from '../../types'
2
3
  import { useI18n } from '@byjohann/vue-i18n'
3
4
  import { TabsIndicator } from 'reka-ui'
4
- import { computed, defineProps, ref } from 'vue'
5
+ import { computed, ref } from 'vue'
5
6
  import { useTheme } from '../../composables/useTheme'
6
7
  import OAHeading from '../Common/OAHeading.vue'
7
8
  import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
@@ -23,12 +24,16 @@ const props = defineProps({
23
24
  },
24
25
  })
25
26
 
27
+ const slots = defineSlots<{
28
+ 'response-description'?: (props: ResponseDescriptionSlotProps) => any
29
+ }>()
30
+
26
31
  const themeConfig = useTheme()
27
32
  const { t } = useI18n()
28
33
 
29
34
  const responsesCodes = Object.keys(props.responses)
30
35
 
31
- const vModel = ref(responsesCodes && responsesCodes.length > 0 ? responsesCodes[0] : null)
36
+ const vModel = ref<string | undefined>(responsesCodes[0])
32
37
 
33
38
  const tabsSelector = computed(() => {
34
39
  const selector = themeConfig.getResponseCodeSelector()
@@ -44,7 +49,7 @@ const tabsSelector = computed(() => {
44
49
  </script>
45
50
 
46
51
  <template>
47
- <div class="flex flex-col">
52
+ <div class="OAResponses flex flex-col">
48
53
  <Tabs
49
54
  :default-value="vModel"
50
55
  >
@@ -121,7 +126,17 @@ const tabsSelector = computed(() => {
121
126
  :operation-id="props.operationId"
122
127
  :response="props.responses[responseCode]"
123
128
  :response-code="responseCode"
124
- />
129
+ >
130
+ <template
131
+ v-if="slots['response-description']"
132
+ #response-description="responseDescription"
133
+ >
134
+ <slot
135
+ name="response-description"
136
+ v-bind="responseDescription"
137
+ />
138
+ </template>
139
+ </OAResponse>
125
140
  </TabsContent>
126
141
  </Tabs>
127
142
  </div>
package/src/types.ts CHANGED
@@ -22,6 +22,19 @@ export type OperationSlot
22
22
  // | 'summary'
23
23
  // | 'servers'
24
24
 
25
+ /**
26
+ * Slots for parts inside an operation section, forwarded like `OperationSlot`.
27
+ * They are not sections, so `operation.slots` and `operation.hiddenSlots` do not apply to them.
28
+ */
29
+ export type OperationNestedSlot = 'response-description'
30
+
31
+ export interface ResponseDescriptionSlotProps {
32
+ operationId: string
33
+ responseCode: string
34
+ response: Record<string, any>
35
+ description?: string
36
+ }
37
+
25
38
  export type OpenAPIDocument = OpenAPIV3.Document & OpenAPIV3_1.Document
26
39
 
27
40
  export type ParsedPaths = OpenAPIV3.PathsObject & OpenAPIV3_1.PathsObject & {