vitepress-openapi 0.2.10 → 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.
- package/dist/OAJSONEditor-BTGtvci-.js +36528 -0
- package/dist/OAJSONEditor-DMDZUFqm.cjs +3859 -0
- package/dist/{angular-html-CW1rj3uY.js → angular-html-BQID9WhU.js} +2 -2
- package/dist/{angular-html-9C0z-SLY.cjs → angular-html-DNIOHlGh.cjs} +1 -1
- package/dist/{angular-ts-mPv4HwYZ.js → angular-ts-CDXMy72c.js} +2 -2
- package/dist/{angular-ts-DbwmQ_7d.cjs → angular-ts-TtL5PHiu.cjs} +1 -1
- package/dist/{apl-eQdB3PpW.cjs → apl-CHXP_PuI.cjs} +1 -1
- package/dist/{apl-B5ZmCr35.js → apl-aiTHik1p.js} +5 -5
- package/dist/{astro-CM9Z6ANX.js → astro-Bk0EGHbZ.js} +5 -5
- package/dist/{astro-HhXWiqIA.cjs → astro-Bs6LKdLd.cjs} +1 -1
- package/dist/{blade-JajcDFoh.cjs → blade-Cv7NuX7S.cjs} +1 -1
- package/dist/{blade-BbaEXel2.js → blade-dcNVF1Xb.js} +7 -7
- package/dist/{c-C1-DO9YE.js → c-COk7hDJA.js} +1 -1
- package/dist/{c-Bj7dnvXD.cjs → c-CZCz03tk.cjs} +1 -1
- package/dist/{chapel-BNOH_ZrL.js → chapel-BHO5Jgs1.js} +1 -1
- package/dist/{chapel-BN6g3eE8.cjs → chapel-Bj11wkLP.cjs} +1 -1
- package/dist/classPrivateFieldGet2-B5R_onup.js +22 -0
- package/dist/classPrivateFieldGet2-Bglvjmhn.cjs +1 -0
- package/dist/{cobol-BgxKhyCv.cjs → cobol-B2PKMb5_.cjs} +1 -1
- package/dist/{cobol-CKBH7GfD.js → cobol-D29hA4_9.js} +2 -2
- package/dist/{coffee-SILQVDCE.js → coffee-DBMuDZbT.js} +1 -1
- package/dist/{coffee-C7l0xOrD.cjs → coffee-TE_xgObZ.cjs} +1 -1
- package/dist/core-BPyqqKDB.cjs +12 -0
- package/dist/core-CEXh5eq0.js +4924 -0
- package/dist/{cpp-BlEoy55C.js → cpp-BSp0ExOJ.js} +3 -3
- package/dist/{cpp-BRnhGWPj.cjs → cpp-Drml9yi6.cjs} +1 -1
- package/dist/{crystal-TOC2d_1v.js → crystal-BxHtn_X1.js} +6 -6
- package/dist/{crystal-Ba2X2QUX.cjs → crystal-T6SYXb8o.cjs} +1 -1
- package/dist/{css-BzCmrrfz.js → css-B4-pOoLE.js} +1 -1
- package/dist/{css-DwAz9Pjn.cjs → css-oMq01QVM.cjs} +1 -1
- package/dist/dist-8gEJqHbm.cjs +145 -0
- package/dist/dist-BdFVNebX.js +3184 -0
- package/dist/{edge-DyJcz27i.cjs → edge-BPRyfS4T.cjs} +1 -1
- package/dist/{edge-BDg5VzpV.js → edge-CH9qUYIG.js} +3 -3
- package/dist/{elixir-BHz2KhQu.cjs → elixir-CYNNAueU.cjs} +1 -1
- package/dist/{elixir-BzDCz4UH.js → elixir-IMwLX-5a.js} +1 -1
- package/dist/{elm-DoAGeaf_.js → elm-8i0ndpf8.js} +1 -1
- package/dist/{elm-CY9z_JCT.cjs → elm-CsSGOCo2.cjs} +1 -1
- package/dist/engine-javascript-B8eiD8I_.js +2446 -0
- package/dist/engine-javascript-BA-lwMk1.cjs +141 -0
- package/dist/{erb-DaIUVjt9.js → erb-B3JdRKLz.js} +2 -2
- package/dist/{erb-DN2MJHn3.cjs → erb-CCijh5g_.cjs} +1 -1
- package/dist/{git-rebase-BVojUTC8.cjs → git-rebase-CqTcx364.cjs} +1 -1
- package/dist/{git-rebase-8pjy4fqK.js → git-rebase-s4xgRin3.js} +1 -1
- package/dist/{glimmer-js-ByU2UZIA.js → glimmer-js-BRlqJZKJ.js} +4 -4
- package/dist/{glimmer-js-Dt8MM2fQ.cjs → glimmer-js-BmyOid01.cjs} +1 -1
- package/dist/{glimmer-ts-CEC_6Qd3.cjs → glimmer-ts-Cr-avsOb.cjs} +1 -1
- package/dist/{glimmer-ts-DaRJKOPS.js → glimmer-ts-_bCiLZ83.js} +4 -4
- package/dist/{glsl-B_0Mq6To.cjs → glsl-CjCNYdIn.cjs} +1 -1
- package/dist/{glsl-DO2w2Ik-.js → glsl-DEotYDrM.js} +2 -2
- package/dist/{graphql-D1WJND44.cjs → graphql-DAvjEaGE.cjs} +1 -1
- package/dist/{graphql-DXbz5Omg.js → graphql-Eb9BjU5l.js} +5 -5
- package/dist/{hack-BlSDwC0z.cjs → hack-BzUM5t5Z.cjs} +1 -1
- package/dist/{hack-D34BZTSC.js → hack-qsr2p76N.js} +2 -2
- package/dist/{haml-Dt5MpFE9.cjs → haml-BRTyh0NA.cjs} +1 -1
- package/dist/{haml-BRknWCT7.js → haml-C9NgGuR7.js} +3 -3
- package/dist/{handlebars-9ppD0m7C.cjs → handlebars-B3AlHew8.cjs} +1 -1
- package/dist/{handlebars-BRspYj6G.js → handlebars-DKLGUOgk.js} +4 -4
- package/dist/{html-BU1zY3Jp.cjs → html-CXX4v0hN.cjs} +1 -1
- package/dist/{html-CMRq88ww.js → html-b1x-0Sjo.js} +3 -3
- package/dist/{html-derivative-D7LwmusG.cjs → html-derivative-D4EoT0cZ.cjs} +1 -1
- package/dist/{html-derivative-BrFXBPOJ.js → html-derivative-D5RWFbq-.js} +1 -1
- package/dist/{http-CwR8DNhu.cjs → http-CL9xVX7f.cjs} +1 -1
- package/dist/{http-B5LG-yWC.js → http-Cu3ENe5f.js} +4 -4
- package/dist/{hurl-B1GvAf8k.cjs → hurl-CWH_45Jf.cjs} +1 -1
- package/dist/{hurl-wtqYtxyo.js → hurl-n9N1IzC8.js} +2 -2
- package/dist/{java-B8fWOsDG.cjs → java-DopTp571.cjs} +1 -1
- package/dist/{java-B4SaXsau.js → java-DsOZx36s.js} +1 -1
- package/dist/{javascript-BBx3tGbJ.js → javascript-BeZuSKue.js} +1 -1
- package/dist/{javascript-VrrJ04H7.cjs → javascript-BoVqPY81.cjs} +1 -1
- package/dist/{jinja-BkYZGd40.js → jinja-BZOrYxA1.js} +1 -1
- package/dist/{jinja-CkJfL3dp.cjs → jinja-C3xeiIjm.cjs} +1 -1
- package/dist/{jison-CiLUBliq.cjs → jison-BswhHWc-.cjs} +1 -1
- package/dist/{jison-C4L8qAyA.js → jison-CJd90rxW.js} +1 -1
- package/dist/js-yaml-BP7bOeG0.cjs +28 -0
- package/dist/js-yaml-Bd7r_XRf.js +1311 -0
- package/dist/{json-Bp2tbsW1.js → json-BYngJnVq.js} +1 -1
- package/dist/{json-D3DciEq1.cjs → json-eIjfv80J.cjs} +1 -1
- package/dist/{jsx-B_Y6H1Mp.js → jsx-DD3WDGak.js} +1 -1
- package/dist/{jsx-DQaEsgGs.cjs → jsx-rnl1r2fp.cjs} +1 -1
- package/dist/{julia-Dc5JrGFN.js → julia-BbEQUnh9.js} +4 -4
- package/dist/{julia-DH-aextI.cjs → julia-CQHqjN9U.cjs} +1 -1
- package/dist/{just-L67PN1Uc.cjs → just-BtQy4COc.cjs} +1 -1
- package/dist/{just--rdnVJkn.js → just-CC-2RAnt.js} +5 -5
- package/dist/{latex-BYkatXlR.js → latex-DI79tfSU.js} +1 -1
- package/dist/{latex-DKzGMDlD.cjs → latex-Dc8GmMF-.cjs} +1 -1
- package/dist/lib-Bm75kWfF.js +27 -0
- package/dist/lib-jITBAUlk.cjs +1 -0
- package/dist/{liquid-BIvrZoOi.cjs → liquid-BaVa8jbp.cjs} +1 -1
- package/dist/{liquid-BQZ084XB.js → liquid-CQgClb2e.js} +4 -4
- package/dist/{lua-3QPa8W-M.js → lua-Aa6xlS3m.js} +2 -2
- package/dist/{lua-jbPUNPQN.cjs → lua-CMQuF1NW.cjs} +1 -1
- package/dist/{marko-DTymm-Xt.js → marko-CnoSbnyW.js} +3 -3
- package/dist/{marko-DH2FDJVi.cjs → marko-a44Rx8oD.cjs} +1 -1
- package/dist/{mdc-BgDnCF09.cjs → mdc-DDEndBZK.cjs} +1 -1
- package/dist/{mdc-BJascUlE.js → mdc-yfhLFlW0.js} +2 -2
- package/dist/{nginx-D_gIjk1c.cjs → nginx-D1dqVYm1.cjs} +1 -1
- package/dist/{nginx-3tiv8u2V.js → nginx-DlNKblVY.js} +1 -1
- package/dist/{nim-LQ8-6E6B.cjs → nim-BD5WfdQE.cjs} +1 -1
- package/dist/{nim-BVrlAKS0.js → nim-DF1HAFuL.js} +6 -6
- package/dist/{org-BFJf-e_S.js → org-BxOhd5H8.js} +26 -26
- package/dist/{org-DQ-Vd8YY.cjs → org-D39t4cfx.cjs} +1 -1
- package/dist/{perl-KJFFDyul.cjs → perl-BvvR-UBE.cjs} +1 -1
- package/dist/{perl-D4z5Iu0X.js → perl-ChFS9GSw.js} +5 -5
- package/dist/{php-D7CN11Vh.cjs → php-99Ucsqtp.cjs} +1 -1
- package/dist/{php-DXJK24g0.js → php-BlFx1-Cw.js} +6 -6
- package/dist/{pug-ChxFEl92.js → pug-DoeArbRk.js} +3 -3
- package/dist/{pug-DMpsCZkW.cjs → pug-DsD7dGZV.cjs} +1 -1
- package/dist/{qml-B8gGaJm0.cjs → qml-BmSeqgID.cjs} +1 -1
- package/dist/{qml-BRxjovis.js → qml-Cud5ERAo.js} +1 -1
- package/dist/{r-BgoFf1ZB.js → r-BUvWMIiI.js} +1 -1
- package/dist/{r-uXN9C_n5.cjs → r-kc1tv3cq.cjs} +1 -1
- package/dist/{razor-CGDVSdG5.js → razor-B9XjYQDL.js} +1 -1
- package/dist/{razor-tBRWbTeh.cjs → razor-csAIEUlG.cjs} +1 -1
- package/dist/{regexp-CNMHS6k4.js → regexp-BgOYBevC.js} +1 -1
- package/dist/{regexp-8S_97zWV.cjs → regexp-btboojP2.cjs} +1 -1
- package/dist/{rst-1xt-aBNB.cjs → rst-Cp5naB83.cjs} +1 -1
- package/dist/{rst-DPz6kXU9.js → rst-DlKl41_0.js} +6 -6
- package/dist/{ruby-C7ICjErH.js → ruby-BF0WTTH3.js} +12 -12
- package/dist/{ruby-wisDyjQe.cjs → ruby-CkdMUJEH.cjs} +1 -1
- package/dist/{sas-CwNeBf6W.cjs → sas-14QiNRYQ.cjs} +1 -1
- package/dist/{sas-BbrqtORA.js → sas-C6FSUZ8u.js} +1 -1
- package/dist/{scss-D_ULJoO6.cjs → scss-BtbTbZQd.cjs} +1 -1
- package/dist/{scss-BbIN9GY7.js → scss-CCWZPu2R.js} +2 -2
- package/dist/{shellscript-BKOBitlL.cjs → shellscript-DPLlmD_A.cjs} +1 -1
- package/dist/{shellscript-CCUj_44n.js → shellscript-DZCVULM8.js} +1 -1
- package/dist/{shellsession-Du8yRV76.js → shellsession-BN3RSO1C.js} +1 -1
- package/dist/{shellsession-DNR4eLoG.cjs → shellsession-BqWcPKhV.cjs} +1 -1
- package/dist/{soy-GdzY-Mv1.cjs → soy-CABMyeew.cjs} +1 -1
- package/dist/{soy-ZEl6DKSa.js → soy-Du5nNttL.js} +1 -1
- package/dist/{sql-C7EzXxFy.js → sql-CYkpqzkZ.js} +1 -1
- package/dist/{sql-CHjHiyDi.cjs → sql-HyLtRgmm.cjs} +1 -1
- package/dist/{stata-FwAAoJQl.cjs → stata-C2nzzUtY.cjs} +1 -1
- package/dist/{stata-DE-nQXRr.js → stata-CTsPxspI.js} +1 -1
- package/dist/{surrealql-D6TEktB8.cjs → surrealql-Czd_jpdF.cjs} +1 -1
- package/dist/{surrealql-C9gPXNXx.js → surrealql-Do7t2lbF.js} +1 -1
- package/dist/{svelte-By2RvWwP.js → svelte-BsAqSY0W.js} +3 -3
- package/dist/{svelte-Bmv6_lIz.cjs → svelte-DCXhqWK2.cjs} +1 -1
- package/dist/{templ-Ds996O4o.js → templ-CiuTNFNN.js} +2 -2
- package/dist/{templ-C7RiHTfw.cjs → templ-CizIGDIX.cjs} +1 -1
- package/dist/{tex-Dw7Ay8Ut.js → tex-BQ--pZc4.js} +2 -2
- package/dist/{tex-DXDFN6Ui.cjs → tex-CZcUsj1k.cjs} +1 -1
- package/dist/{ts-tags-D5UgzHMk.cjs → ts-tags-Cj-sekFe.cjs} +1 -1
- package/dist/{ts-tags-DHX1jw76.js → ts-tags-_na8tAcU.js} +7 -7
- package/dist/{tsx-lbxmz0z3.js → tsx-Be52Rwki.js} +1 -1
- package/dist/{tsx-DZUHQ6F0.cjs → tsx-CrwGvZn1.cjs} +1 -1
- package/dist/{twig-DIOHbBlx.cjs → twig-CBOETUN2.cjs} +1 -1
- package/dist/{twig-B6ULrIm_.js → twig-CqrXvA-X.js} +5 -5
- package/dist/types/src/components/Common/OAJSONEditorAsync.d.ts +4 -0
- package/dist/types/src/components/Common/OALoadError.vue.d.ts +13 -0
- package/dist/types/src/components/Feature/OAOperation.vue.d.ts +3 -1
- package/dist/types/src/components/Feature/OAOperationContent.vue.d.ts +2 -2
- package/dist/types/src/components/Feature/OASpec.vue.d.ts +3 -1
- package/dist/types/src/components/Feature/OASpecContent.vue.d.ts +2 -2
- package/dist/types/src/components/Path/OAPaths.vue.d.ts +2 -2
- package/dist/types/src/components/Path/OAPathsGroup.vue.d.ts +2 -2
- package/dist/types/src/components/Path/OAPathsGroups.vue.d.ts +2 -2
- package/dist/types/src/components/Playground/OAPlaygroundParameterInput.vue.d.ts +2 -2
- package/dist/types/src/components/Playground/OAPlaygroundSecurityInput.vue.d.ts +2 -2
- package/dist/types/src/components/Response/OAResponse.vue.d.ts +13 -3
- package/dist/types/src/components/Response/OAResponses.vue.d.ts +13 -3
- package/dist/types/src/components/ui/select-with-custom-option/SelectWithCustomOption.vue.d.ts +2 -2
- package/dist/types/src/lib/utils/vHydratableHtml.d.ts +13 -0
- package/dist/types/src/types.d.ts +11 -0
- package/dist/{typescript-TPcOw_OF.cjs → typescript-DdVmgSX4.cjs} +1 -1
- package/dist/{typescript-z9xA3p3l.js → typescript-ED10Lubp.js} +1 -1
- package/dist/{typst-Gn-Njx36.js → typst-Bx5HBJWo.js} +29 -29
- package/dist/{typst-BS7hKepS.cjs → typst-D7Y713mB.cjs} +1 -1
- package/dist/useOpenapi-BEqmTxjl.cjs +50 -0
- package/dist/{useOpenapi-DaLjivRh.js → useOpenapi-DbIj-ke3.js} +1947 -5112
- package/dist/vitepress-openapi.client.cjs.js +5 -4041
- package/dist/vitepress-openapi.client.es.js +5408 -50199
- 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/dist/{vue-DsBCt_qn.js → vue-Cjtnfpir.js} +6 -6
- package/dist/{vue-html-AXTx9UKx.js → vue-html-BzsnfhsM.js} +1 -1
- package/dist/{vue-html-CzxTAYWX.cjs → vue-html-_YQvkRyf.cjs} +1 -1
- package/dist/{vue-Bu0iwAjS.cjs → vue-kHo8rCXT.cjs} +1 -1
- package/dist/{vue-vine-B7dphuhu.js → vue-vine-COYWN94q.js} +3 -3
- package/dist/{vue-vine-CxFGofPC.cjs → vue-vine-DTEBBIT8.cjs} +1 -1
- package/dist/{xml-B11l1AZx.js → xml-B8H1TJZQ.js} +2 -2
- package/dist/{xml-Ck4C7_Cv.cjs → xml-CTTlGNVY.cjs} +1 -1
- package/dist/{xsl-YCtJy4fp.cjs → xsl-C_9xxcnq.cjs} +1 -1
- package/dist/{xsl-1UpUfcja.js → xsl-cP3lHVuQ.js} +1 -1
- package/dist/{yaml-BcaXAU4E.cjs → yaml-2duz-WDn.cjs} +1 -1
- package/dist/{yaml-BkLRBEYn.js → yaml-DEgccW2V.js} +1 -1
- package/package.json +1 -1
- package/src/components/Common/Highlight/OAShiki.vue +7 -4
- package/src/components/Common/OAJSONEditorAsync.ts +30 -0
- package/src/components/Common/OALoadError.vue +26 -0
- package/src/components/Common/OAMarkdown.vue +2 -1
- package/src/components/Feature/OADownloadSpec.vue +38 -23
- package/src/components/Feature/OAOperation.vue +4 -2
- package/src/components/Feature/OAOperationContent.vue +13 -3
- package/src/components/Feature/OASpec.vue +4 -2
- package/src/components/Feature/OASpecContent.vue +2 -2
- package/src/components/Path/OAPaths.vue +2 -2
- package/src/components/Path/OAPathsGroup.vue +2 -2
- package/src/components/Path/OAPathsGroups.vue +2 -2
- package/src/components/Playground/OAPlaygroundBodyInput.vue +1 -1
- package/src/components/Playground/OAPlaygroundParameterInput.vue +1 -1
- package/src/components/Response/OAResponse.vue +21 -7
- package/src/components/Response/OAResponses.vue +20 -5
- package/src/components/Sample/OACodeSamples.vue +24 -9
- package/src/composables/useShiki.ts +9 -3
- package/src/lib/codeSamples/generateCodeSample.ts +3 -2
- package/src/lib/utils/vHydratableHtml.ts +32 -0
- package/src/locales/en.json +4 -1
- package/src/locales/es.json +4 -1
- package/src/locales/ja.json +4 -1
- package/src/locales/pt-BR.json +4 -1
- package/src/locales/zh.json +4 -1
- package/src/types.ts +13 -0
- package/dist/useOpenapi-D_IvjhM7.cjs +0 -194
|
@@ -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,
|
|
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
|
-
<
|
|
42
|
-
|
|
43
|
-
:
|
|
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,
|
|
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
|
|
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>
|
|
@@ -35,6 +35,15 @@ const samples = ref<Sample[]>([])
|
|
|
35
35
|
|
|
36
36
|
const activeSampleKey = ref('')
|
|
37
37
|
|
|
38
|
+
// Highlighting is costly (e.g. PHP), so a tab is highlighted only once it has been shown.
|
|
39
|
+
const shownSampleKeys = ref(new Set<string>())
|
|
40
|
+
|
|
41
|
+
watch(activeSampleKey, (key) => {
|
|
42
|
+
if (key) {
|
|
43
|
+
shownSampleKeys.value.add(key)
|
|
44
|
+
}
|
|
45
|
+
}, { immediate: true })
|
|
46
|
+
|
|
38
47
|
const radioGroupName = `group-${props.operationId}`
|
|
39
48
|
|
|
40
49
|
watch(operationData.playground.request, async (playgroundRequest, _, onInvalidate) => {
|
|
@@ -87,8 +96,17 @@ watch(operationData.playground.request, async (playgroundRequest, _, onInvalidat
|
|
|
87
96
|
return
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
let nextActiveKey = activeSampleKey.value
|
|
100
|
+
if (!nextActiveKey || !nextSamples.some(s => s.key === nextActiveKey)) {
|
|
101
|
+
const defaultLang = themeConfig.getCodeSamplesDefaultLang()
|
|
102
|
+
nextActiveKey = (nextSamples.find(s => s.lang === defaultLang) || nextSamples[0])?.key ?? ''
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Preload only the languages of tabs that are highlighted.
|
|
106
|
+
const uniqueHighlighters = [...new Set(nextSamples
|
|
107
|
+
.filter(s => s.key === nextActiveKey || shownSampleKeys.value.has(s.key))
|
|
108
|
+
.map(s => s.highlighter)
|
|
109
|
+
.filter(Boolean))]
|
|
92
110
|
await Promise.all(uniqueHighlighters.map(lang => shiki.ensureLanguage(lang)))
|
|
93
111
|
|
|
94
112
|
if (cancelled) {
|
|
@@ -96,13 +114,9 @@ watch(operationData.playground.request, async (playgroundRequest, _, onInvalidat
|
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
samples.value = nextSamples
|
|
99
|
-
|
|
100
|
-
if (!
|
|
101
|
-
|
|
102
|
-
const defaultSample = samples.value.find(s => s.lang === defaultLang) || samples.value[0]
|
|
103
|
-
if (defaultSample) {
|
|
104
|
-
activeSampleKey.value = defaultSample.key
|
|
105
|
-
}
|
|
117
|
+
// Keep a tab the user selected while the languages were loading.
|
|
118
|
+
if (!nextSamples.some(s => s.key === activeSampleKey.value)) {
|
|
119
|
+
activeSampleKey.value = nextActiveKey
|
|
106
120
|
}
|
|
107
121
|
}, {
|
|
108
122
|
deep: true,
|
|
@@ -140,6 +154,7 @@ watch(operationData.playground.request, async (playgroundRequest, _, onInvalidat
|
|
|
140
154
|
:lang="sample.highlighter"
|
|
141
155
|
:label="sample.label"
|
|
142
156
|
:active="activeSampleKey === sample.key"
|
|
157
|
+
:disable-html-transform="!shownSampleKeys.has(sample.key)"
|
|
143
158
|
:class="{ active: activeSampleKey === sample.key }"
|
|
144
159
|
class="m-0!"
|
|
145
160
|
/>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { HighlighterCore, LanguageRegistration } from 'shiki/core'
|
|
2
2
|
import type { BundledLanguage } from 'shiki/langs'
|
|
3
|
-
import { createHighlighterCore } from 'shiki/core'
|
|
4
|
-
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'
|
|
5
3
|
import { bundledLanguages as highlighterImports } from 'shiki/langs'
|
|
6
4
|
import { ref } from 'vue'
|
|
7
5
|
import {
|
|
@@ -14,7 +12,11 @@ import { useTheme } from './useTheme'
|
|
|
14
12
|
/** Always loaded for response / schema bodies (not the code-samples UI). */
|
|
15
13
|
const CORE_HIGHLIGHTERS: BundledLanguage[] = ['json', 'xml', 'markdown']
|
|
16
14
|
|
|
17
|
-
const
|
|
15
|
+
const RE_HTML_ESCAPE = /[&<>]/g
|
|
16
|
+
const HTML_ESCAPES: Record<string, string> = { '&': '&', '<': '<', '>': '>' }
|
|
17
|
+
|
|
18
|
+
// The result is inserted with v-html, so the code must be escaped (e.g. a playground response body).
|
|
19
|
+
const FALLBACK_HTML = (content: string) => `<pre><code>${content.replace(RE_HTML_ESCAPE, char => HTML_ESCAPES[char])}</code></pre>`
|
|
18
20
|
|
|
19
21
|
let shiki: HighlighterCore | null = null
|
|
20
22
|
let initPromise: Promise<void> | null = null
|
|
@@ -70,6 +72,10 @@ async function loadCoreLanguages(): Promise<LanguageRegistration[]> {
|
|
|
70
72
|
|
|
71
73
|
async function createHighlighter(): Promise<HighlighterCore> {
|
|
72
74
|
const themeConfig = useTheme()
|
|
75
|
+
const [{ createHighlighterCore }, { createJavaScriptRegexEngine }] = await Promise.all([
|
|
76
|
+
import('shiki/core'),
|
|
77
|
+
import('shiki/engine/javascript'),
|
|
78
|
+
])
|
|
73
79
|
const highlighter = await createHighlighterCore({
|
|
74
80
|
themes: [
|
|
75
81
|
themeConfig.getHighlighterTheme()?.light,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LanguageConfig } from '../../composables/useTheme'
|
|
2
|
-
import { snippetz } from '@scalar/snippetz'
|
|
3
2
|
import { buildHarRequest } from './buildHarRequest'
|
|
4
3
|
import { buildRequest } from './buildRequest'
|
|
5
4
|
import { OARequest } from './request'
|
|
@@ -27,9 +26,11 @@ export async function generateCodeSample(
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
try {
|
|
29
|
+
// Lazy: keep @scalar/snippetz out of the initial client bundle.
|
|
30
|
+
const { snippetz } = await import('@scalar/snippetz')
|
|
30
31
|
return snippetz().print(target as any, client as any, harRequest) ?? ''
|
|
31
32
|
} catch (e) {
|
|
32
|
-
console.error(e
|
|
33
|
+
console.error(e)
|
|
33
34
|
return ''
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Directive } from 'vue'
|
|
2
|
+
|
|
3
|
+
type HtmlElement = Pick<HTMLElement, 'innerHTML' | 'hasChildNodes'> & { _oaHtml?: string }
|
|
4
|
+
|
|
5
|
+
function writeHtml(el: HtmlElement, html: string) {
|
|
6
|
+
if (el._oaHtml !== html) {
|
|
7
|
+
el.innerHTML = html
|
|
8
|
+
el._oaHtml = html
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Like `v-html`, but keeps server-rendered markup while hydrating.
|
|
14
|
+
*
|
|
15
|
+
* Vue re-assigns `innerHTML` for `v-html` during hydration, even when it is unchanged.
|
|
16
|
+
* That recreates every child node, so the browser reports a new Largest Contentful Paint
|
|
17
|
+
* at hydration time. This directive adopts the server markup and only writes on change.
|
|
18
|
+
*/
|
|
19
|
+
export const vHydratableHtml: Directive<HtmlElement, string> = {
|
|
20
|
+
getSSRProps: ({ value }) => ({ innerHTML: value }),
|
|
21
|
+
beforeMount(el, { value }) {
|
|
22
|
+
// Hydration: the element already holds the server-rendered markup for this value.
|
|
23
|
+
if (el.hasChildNodes()) {
|
|
24
|
+
el._oaHtml = value
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
writeHtml(el, value)
|
|
28
|
+
},
|
|
29
|
+
updated(el, { value }) {
|
|
30
|
+
writeHtml(el, value)
|
|
31
|
+
},
|
|
32
|
+
}
|
package/src/locales/en.json
CHANGED
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"Pattern": "Pattern",
|
|
80
80
|
"Unique Items": "Unique Items",
|
|
81
81
|
"Add Field": "Add Field",
|
|
82
|
-
"Click to set in playground": "Click to set in playground"
|
|
82
|
+
"Click to set in playground": "Click to set in playground",
|
|
83
|
+
"Failed to load the JSON editor.": "Failed to load the JSON editor.",
|
|
84
|
+
"Failed to download the OpenAPI Document.": "Failed to download the OpenAPI Document.",
|
|
85
|
+
"Reload page": "Reload page"
|
|
83
86
|
}
|
package/src/locales/es.json
CHANGED
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"Pattern": "Patrón",
|
|
80
80
|
"Unique Items": "Elementos únicos",
|
|
81
81
|
"Add Field": "Agregar campo",
|
|
82
|
-
"Click to set in playground": "Clic para usar en el playground"
|
|
82
|
+
"Click to set in playground": "Clic para usar en el playground",
|
|
83
|
+
"Failed to load the JSON editor.": "No se pudo cargar el editor JSON.",
|
|
84
|
+
"Failed to download the OpenAPI Document.": "No se pudo descargar el Documento OpenAPI.",
|
|
85
|
+
"Reload page": "Recargar página"
|
|
83
86
|
}
|
package/src/locales/ja.json
CHANGED
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"Pattern": "パターン",
|
|
80
80
|
"Unique Items": "ユニーク項目",
|
|
81
81
|
"Add Field": "フィールドを追加",
|
|
82
|
-
"Click to set in playground": "クリックしてプレイグラウンドに設定"
|
|
82
|
+
"Click to set in playground": "クリックしてプレイグラウンドに設定",
|
|
83
|
+
"Failed to load the JSON editor.": "JSON エディターを読み込めませんでした。",
|
|
84
|
+
"Failed to download the OpenAPI Document.": "OpenAPI ドキュメントをダウンロードできませんでした。",
|
|
85
|
+
"Reload page": "ページを再読み込み"
|
|
83
86
|
}
|
package/src/locales/pt-BR.json
CHANGED
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"Pattern": "Padrão",
|
|
80
80
|
"Unique Items": "Itens únicos",
|
|
81
81
|
"Add Field": "Adicionar campo",
|
|
82
|
-
"Click to set in playground": "Clique para definir no playground"
|
|
82
|
+
"Click to set in playground": "Clique para definir no playground",
|
|
83
|
+
"Failed to load the JSON editor.": "Não foi possível carregar o editor JSON.",
|
|
84
|
+
"Failed to download the OpenAPI Document.": "Não foi possível baixar o Documento OpenAPI.",
|
|
85
|
+
"Reload page": "Recarregar página"
|
|
83
86
|
}
|
package/src/locales/zh.json
CHANGED
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"Pattern": "模式",
|
|
80
80
|
"Unique Items": "唯一项",
|
|
81
81
|
"Add Field": "添加字段",
|
|
82
|
-
"Click to set in playground": "点击在 Playground 中设置"
|
|
82
|
+
"Click to set in playground": "点击在 Playground 中设置",
|
|
83
|
+
"Failed to load the JSON editor.": "无法加载 JSON 编辑器。",
|
|
84
|
+
"Failed to download the OpenAPI Document.": "无法下载 OpenAPI 文档。",
|
|
85
|
+
"Reload page": "重新加载页面"
|
|
83
86
|
}
|
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 & {
|