@scalar/api-client 2.15.0 → 2.17.0
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/CHANGELOG.md +150 -0
- package/dist/hooks/useResponseBody.js +6 -6
- package/dist/libs/errors.d.ts +1 -0
- package/dist/libs/errors.d.ts.map +1 -1
- package/dist/libs/errors.js +1 -0
- package/dist/libs/send-request/create-request-operation.d.ts.map +1 -1
- package/dist/libs/send-request/create-request-operation.js +41 -35
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +28 -38
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +84 -45
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +1 -11
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js +2 -2
- package/dist/v2/blocks/operation-block/components/Header.vue2.js +28 -35
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts +10 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js +22 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +31 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +31 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts +3 -9
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +56 -0
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts +10 -3
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-security.js +46 -0
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts +45 -0
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/build-request.js +66 -0
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +9 -0
- package/dist/v2/blocks/operation-block/helpers/get-cookie-header-keys.d.ts +16 -0
- package/dist/v2/blocks/operation-block/helpers/get-cookie-header-keys.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/get-cookie-header-keys.js +4 -0
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.js +17 -0
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts +9 -3
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.js +21 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +53 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.js +120 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue2.js +89 -110
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts +2 -2
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts +8 -13
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js +22 -28
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +19 -8
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +30 -24
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts +12 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js +20 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts +10 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js +4 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +14 -12
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +191 -169
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +10 -10
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts +2 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +15 -19
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +2 -2
- package/dist/v2/blocks/operation-code-sample/index.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/types.d.ts +16 -0
- package/dist/v2/blocks/operation-code-sample/types.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +15 -10
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue2.js +158 -125
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +2 -2
- package/dist/v2/blocks/request-block/components/RequestBody.vue2.js +59 -50
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts +8 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js +127 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue2.js +4 -0
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.js +24 -23
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +1 -0
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js +148 -149
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.d.ts +1 -0
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue2.js +28 -27
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts +3 -2
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js +13 -3
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts +4 -4
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js +3 -3
- package/dist/v2/blocks/response-block/ResponseBlock.vue2.js +41 -45
- package/dist/v2/blocks/response-block/components/Headers.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/Headers.vue.js +27 -27
- package/dist/v2/blocks/response-block/components/ResponseCookies.vue.js +1 -1
- package/dist/v2/blocks/response-block/helpers/parse-set-cookie.d.ts +18 -0
- package/dist/v2/blocks/response-block/helpers/parse-set-cookie.d.ts.map +1 -0
- package/dist/v2/blocks/response-block/helpers/parse-set-cookie.js +12 -0
- package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +0 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +97 -87
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.d.ts +19 -0
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.js +24 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +3 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js +59 -56
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +3 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js +26 -24
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +2 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js +44 -43
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js +7 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +4 -4
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.d.ts +2 -2
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +7 -6
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +2 -2
- package/dist/v2/components/code-input/CodeInput.vue2.js +61 -59
- package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts +2 -2
- package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInputSelect.vue.js +44 -44
- package/dist/v2/components/resize/index.d.ts +0 -1
- package/dist/v2/components/resize/index.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +5 -5
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.js +49 -47
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +1 -1
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.d.ts +3 -0
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +128 -139
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts +3 -3
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +2 -2
- package/dist/v2/features/app/components/AppSidebar.vue2.js +103 -80
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +1 -1
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts +1 -1
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts +2 -2
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.js +8 -8
- package/dist/v2/features/app/helpers/routes.d.ts +32 -6
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js +25 -16
- package/dist/v2/{hooks/use-sidebar-state.d.ts → features/app/hooks/use-app-sidebar.d.ts} +10 -11
- package/dist/v2/features/app/hooks/use-app-sidebar.d.ts.map +1 -0
- package/dist/v2/{hooks/use-sidebar-state.js → features/app/hooks/use-app-sidebar.js} +19 -19
- package/dist/v2/features/app/hooks/use-document-watcher.d.ts.map +1 -0
- package/dist/v2/{hooks → features/app/hooks}/use-sync-path.d.ts +2 -2
- package/dist/v2/features/app/hooks/use-sync-path.d.ts.map +1 -0
- package/dist/v2/features/app/hooks/use-sync-path.js +52 -0
- package/dist/v2/{hooks → features/app/hooks}/use-tabs.d.ts +2 -2
- package/dist/v2/features/app/hooks/use-tabs.d.ts.map +1 -0
- package/dist/v2/{hooks → features/app/hooks}/use-tabs.js +1 -1
- package/dist/v2/{hooks/use-workspace-client-events.d.ts → features/app/hooks/use-workspace-client-app-events.d.ts} +5 -5
- package/dist/v2/features/app/hooks/use-workspace-client-app-events.d.ts.map +1 -0
- package/dist/v2/{hooks/use-workspace-client-events.js → features/app/hooks/use-workspace-client-app-events.js} +48 -45
- package/dist/v2/features/app/hooks/use-workspace-selector.d.ts.map +1 -0
- package/dist/v2/{hooks → features/app/hooks}/use-workspace-selector.js +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js +92 -2
- package/dist/v2/features/collection/DocumentCollection.vue2.js +2 -91
- package/dist/v2/features/collection/WorkspaceCollection.vue.js +42 -2
- package/dist/v2/features/collection/WorkspaceCollection.vue2.js +2 -41
- package/dist/v2/features/collection/components/Authentication.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js +2 -2
- package/dist/v2/features/collection/components/Authentication.vue2.js +14 -12
- package/dist/v2/features/collection/components/Cookies.vue.js +30 -1
- package/dist/v2/features/collection/components/Cookies.vue2.js +1 -29
- package/dist/v2/features/collection/components/Environment.vue.js +32 -1
- package/dist/v2/features/collection/components/Environment.vue2.js +1 -31
- package/dist/v2/features/collection/components/Overview.vue2.js +5 -4
- package/dist/v2/features/collection/components/Servers.vue.js +142 -2
- package/dist/v2/features/collection/components/Servers.vue2.js +2 -141
- package/dist/v2/features/collection/components/Settings.vue.js +58 -2
- package/dist/v2/features/collection/components/Settings.vue2.js +2 -57
- package/dist/v2/features/modal/Modal.vue.d.ts +23 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js +1 -1
- package/dist/v2/features/modal/Modal.vue2.js +118 -31
- package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts +18 -32
- package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.js +46 -26
- package/dist/v2/features/modal/helpers/resolve-route-parameters.d.ts +55 -0
- package/dist/v2/features/modal/helpers/resolve-route-parameters.d.ts.map +1 -0
- package/dist/v2/features/modal/helpers/resolve-route-parameters.js +29 -0
- package/dist/v2/features/modal/hooks/use-modal-sidebar.d.ts +42 -0
- package/dist/v2/features/modal/hooks/use-modal-sidebar.d.ts.map +1 -0
- package/dist/v2/features/modal/hooks/use-modal-sidebar.js +93 -0
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts +18 -0
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts.map +1 -0
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.js +30 -0
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +59 -28
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts +17 -0
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts.map +1 -0
- package/dist/v2/features/operation/helpers/get-operation-header.js +12 -0
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts +1 -1
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts.map +1 -1
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts +7 -0
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts.map +1 -0
- package/dist/v2/features/operation/helpers/get-selected-security.js +19 -0
- package/dist/v2/features/operation/index.d.ts +0 -1
- package/dist/v2/features/operation/index.d.ts.map +1 -1
- package/dist/v2/features/search/components/SearchModal.vue.d.ts.map +1 -1
- package/dist/v2/features/search/components/SearchModal.vue.js +3 -3
- package/dist/v2/features/search/components/SearchModal.vue2.js +45 -44
- package/dist/v2/helpers/generate-location-id.d.ts +19 -0
- package/dist/v2/helpers/generate-location-id.d.ts.map +1 -0
- package/dist/v2/helpers/generate-location-id.js +10 -0
- package/dist/v2/helpers/get-active-environment.d.ts +5 -0
- package/dist/v2/helpers/get-active-environment.d.ts.map +1 -0
- package/dist/v2/helpers/get-active-environment.js +22 -0
- package/dist/v2/helpers/get-tab-details.d.ts +2 -2
- package/dist/v2/helpers/get-tab-details.d.ts.map +1 -1
- package/dist/v2/helpers/handle-hotkeys.js +1 -1
- package/dist/v2/helpers/plugins.d.ts +59 -0
- package/dist/v2/helpers/plugins.d.ts.map +1 -0
- package/dist/v2/helpers/plugins.js +11 -0
- package/dist/v2/hooks/use-scroll-lock.d.ts +28 -0
- package/dist/v2/hooks/use-scroll-lock.d.ts.map +1 -0
- package/dist/v2/hooks/use-scroll-lock.js +21 -0
- package/dist/views/Components/CodeSnippet/helpers/get-har-request.d.ts +2 -0
- package/dist/views/Components/CodeSnippet/helpers/get-har-request.d.ts.map +1 -1
- package/dist/views/Components/CodeSnippet/helpers/get-har-request.js +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/index.d.ts +0 -1
- package/dist/views/Request/RequestSection/RequestAuth/index.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +18 -18
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.d.ts +0 -7
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.js +0 -28
- package/dist/v2/blocks/request-block/helpers/get-parameter-example.d.ts +0 -6
- package/dist/v2/blocks/request-block/helpers/get-parameter-example.d.ts.map +0 -1
- package/dist/v2/blocks/request-block/helpers/get-parameter-example.js +0 -12
- package/dist/v2/hooks/use-document-watcher.d.ts.map +0 -1
- package/dist/v2/hooks/use-sidebar-state.d.ts.map +0 -1
- package/dist/v2/hooks/use-sync-path.d.ts.map +0 -1
- package/dist/v2/hooks/use-sync-path.js +0 -51
- package/dist/v2/hooks/use-tabs.d.ts.map +0 -1
- package/dist/v2/hooks/use-workspace-client-events.d.ts.map +0 -1
- package/dist/v2/hooks/use-workspace-selector.d.ts.map +0 -1
- package/dist/v2/plugins.d.ts +0 -44
- package/dist/v2/plugins.d.ts.map +0 -1
- /package/dist/v2/{hooks → features/app/hooks}/use-document-watcher.d.ts +0 -0
- /package/dist/v2/{hooks → features/app/hooks}/use-document-watcher.js +0 -0
- /package/dist/v2/{hooks → features/app/hooks}/use-workspace-selector.d.ts +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { defineComponent as D, computed as
|
|
2
|
-
import { ScalarCard as
|
|
3
|
-
import { freezeElement as
|
|
4
|
-
import { ScalarIconCaretDown as
|
|
1
|
+
import { defineComponent as D, computed as a, ref as C, watch as I, useId as N, createBlock as i, createCommentVNode as f, openBlock as s, unref as o, withCtx as n, createVNode as r, createSlots as W, createElementVNode as b, createElementBlock as x, renderSlot as y, createTextVNode as R, toDisplayString as z } from "vue";
|
|
2
|
+
import { ScalarCard as S, ScalarCardHeader as U, ScalarCombobox as A, ScalarButton as F, ScalarCardSection as T, ScalarCodeBlock as M, ScalarVirtualText as K, ScalarCardFooter as Z } from "@scalar/components";
|
|
3
|
+
import { freezeElement as G } from "@scalar/helpers/dom/freeze-element";
|
|
4
|
+
import { ScalarIconCaretDown as J } from "@scalar/icons";
|
|
5
5
|
import { emitCustomEvent as V } from "@scalar/workspace-store/events";
|
|
6
|
-
import { getResolvedRef as
|
|
7
|
-
import { operationToHar as
|
|
8
|
-
import
|
|
9
|
-
import { findClient as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { getSecrets as
|
|
6
|
+
import { getResolvedRef as P } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
7
|
+
import { operationToHar as Q } from "../helpers/operation-to-har/operation-to-har.js";
|
|
8
|
+
import q from "./HttpMethod.vue.js";
|
|
9
|
+
import { findClient as $ } from "../helpers/find-client.js";
|
|
10
|
+
import { getClients as X } from "../helpers/get-clients.js";
|
|
11
|
+
import { getCustomCodeSamples as Y } from "../helpers/get-custom-code-samples.js";
|
|
12
|
+
import { getSecrets as _ } from "../helpers/get-secrets.js";
|
|
13
|
+
import { generateCodeSnippet as ee } from "../helpers/generate-code-snippet.js";
|
|
13
14
|
import te from "./ExamplePicker.vue.js";
|
|
14
15
|
const le = ["innerHTML"], oe = ["id"], ae = {
|
|
15
16
|
key: 0,
|
|
16
17
|
class: "request-card-footer-addon"
|
|
17
|
-
}, ne = { class: "request-header" },
|
|
18
|
-
...
|
|
18
|
+
}, ne = { class: "request-header" }, se = {}, ge = /* @__PURE__ */ D({
|
|
19
|
+
...se,
|
|
19
20
|
__name: "OperationCodeSample",
|
|
20
21
|
props: {
|
|
21
22
|
clientOptions: {},
|
|
@@ -31,99 +32,77 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
31
32
|
generateLabel: { type: Function },
|
|
32
33
|
isWebhook: { type: Boolean }
|
|
33
34
|
},
|
|
34
|
-
setup(
|
|
35
|
-
const d =
|
|
36
|
-
const e =
|
|
37
|
-
return
|
|
35
|
+
setup(t) {
|
|
36
|
+
const d = a(() => {
|
|
37
|
+
const e = P(t.operation.requestBody)?.content ?? {}, l = t.selectedContentType || Object.keys(e)[0];
|
|
38
|
+
return l ? e[l]?.examples ?? {} : {};
|
|
38
39
|
}), p = C(
|
|
39
|
-
|
|
40
|
-
),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
].flatMap((t) => l.operation[t] ?? [])), h = n(() => b.value.length ? [
|
|
45
|
-
{
|
|
46
|
-
label: "Code Examples",
|
|
47
|
-
options: b.value.map((t) => {
|
|
48
|
-
const a = $(t), k = t.label || t.lang || a;
|
|
49
|
-
return {
|
|
50
|
-
id: a,
|
|
51
|
-
lang: t.lang || "plaintext",
|
|
52
|
-
title: k,
|
|
53
|
-
label: k
|
|
54
|
-
};
|
|
55
|
-
})
|
|
56
|
-
},
|
|
57
|
-
...l.clientOptions
|
|
58
|
-
] : l.clientOptions), c = C(
|
|
59
|
-
O(h.value, l.selectedClient)
|
|
40
|
+
t.selectedExample ?? Object.keys(d.value)[0] ?? ""
|
|
41
|
+
), g = a(() => Y(t.operation)), h = a(
|
|
42
|
+
() => X(g.value, t.clientOptions)
|
|
43
|
+
), u = C(
|
|
44
|
+
$(h.value, t.selectedClient)
|
|
60
45
|
);
|
|
61
|
-
|
|
62
|
-
() =>
|
|
46
|
+
I(
|
|
47
|
+
() => t.selectedClient,
|
|
63
48
|
(e) => {
|
|
64
|
-
const
|
|
65
|
-
|
|
49
|
+
const l = $(h.value, e);
|
|
50
|
+
l && (u.value = l);
|
|
66
51
|
}
|
|
67
52
|
);
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
53
|
+
const k = a(() => {
|
|
54
|
+
if (!t.isWebhook) return null;
|
|
70
55
|
try {
|
|
71
|
-
return
|
|
72
|
-
operation:
|
|
73
|
-
method:
|
|
74
|
-
path:
|
|
56
|
+
return Q({
|
|
57
|
+
operation: t.operation,
|
|
58
|
+
method: t.method,
|
|
59
|
+
path: t.path,
|
|
75
60
|
example: p.value
|
|
76
61
|
});
|
|
77
62
|
} catch (e) {
|
|
78
63
|
return console.error("[webhookHar]", e), null;
|
|
79
64
|
}
|
|
80
|
-
}), v =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
example: p.value
|
|
94
|
-
}) : "";
|
|
95
|
-
} catch (e) {
|
|
96
|
-
return console.error("[generateSnippet]", e), "";
|
|
97
|
-
}
|
|
98
|
-
}), B = n(() => l.isWebhook ? j.value : c.value?.lang), j = n(() => {
|
|
99
|
-
if (!x.value?.postData) return "json";
|
|
100
|
-
const e = x.value.postData.mimeType;
|
|
65
|
+
}), v = a(() => t.isWebhook ? k.value?.postData?.text ?? "" : ee({
|
|
66
|
+
clientId: u.value?.id,
|
|
67
|
+
customCodeSamples: g.value,
|
|
68
|
+
operation: t.operation,
|
|
69
|
+
method: t.method,
|
|
70
|
+
path: t.path,
|
|
71
|
+
contentType: t.selectedContentType,
|
|
72
|
+
server: t.selectedServer,
|
|
73
|
+
securitySchemes: t.securitySchemes,
|
|
74
|
+
example: p.value
|
|
75
|
+
})), B = a(() => t.isWebhook ? E.value : u.value?.lang), E = a(() => {
|
|
76
|
+
if (!k.value?.postData) return "json";
|
|
77
|
+
const e = k.value.postData.mimeType;
|
|
101
78
|
return e?.includes("json") ? "json" : e?.includes("xml") ? "xml" : e?.includes("yaml") || e?.includes("yml") ? "yaml" : e?.includes("text/plain") ? "text" : "json";
|
|
102
|
-
}),
|
|
79
|
+
}), O = a(() => _(t.securitySchemes)), m = C(null), j = (e) => {
|
|
103
80
|
if (m.value) {
|
|
104
|
-
const
|
|
81
|
+
const l = G(m.value.$el);
|
|
105
82
|
setTimeout(() => {
|
|
106
|
-
|
|
83
|
+
l();
|
|
107
84
|
}, 300);
|
|
108
85
|
}
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
|
|
86
|
+
u.value = e, e.id.startsWith("custom") || V(m.value?.$el, "scalar-update-selected-client", e.id);
|
|
87
|
+
}, w = 2e4, H = a(
|
|
88
|
+
() => (v.value.length ?? 0) > w
|
|
89
|
+
), L = N();
|
|
90
|
+
return (e, l) => v.value ? (s(), i(o(S), {
|
|
112
91
|
key: 0,
|
|
113
92
|
ref_key: "elem",
|
|
114
93
|
ref: m,
|
|
115
94
|
class: "request-card dark-mode"
|
|
116
95
|
}, {
|
|
117
|
-
default:
|
|
118
|
-
|
|
119
|
-
default:
|
|
120
|
-
|
|
121
|
-
|
|
96
|
+
default: n(() => [
|
|
97
|
+
r(o(U), { class: "pr-2.5" }, W({
|
|
98
|
+
default: n(() => [
|
|
99
|
+
l[3] || (l[3] = b("span", { class: "sr-only" }, "Request Example for", -1)),
|
|
100
|
+
r(q, {
|
|
122
101
|
as: "span",
|
|
123
102
|
class: "request-method",
|
|
124
103
|
method: e.method
|
|
125
104
|
}, null, 8, ["method"]),
|
|
126
|
-
e.generateLabel ? (s(),
|
|
105
|
+
e.generateLabel ? (s(), x("span", {
|
|
127
106
|
key: 0,
|
|
128
107
|
innerHTML: e.generateLabel()
|
|
129
108
|
}, null, 8, le)) : f("", !0),
|
|
@@ -133,24 +112,24 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
133
112
|
}, [
|
|
134
113
|
!e.isWebhook && h.value.length ? {
|
|
135
114
|
name: "actions",
|
|
136
|
-
fn:
|
|
137
|
-
|
|
115
|
+
fn: n(() => [
|
|
116
|
+
r(o(A), {
|
|
138
117
|
class: "max-h-80",
|
|
139
|
-
modelValue:
|
|
118
|
+
modelValue: u.value,
|
|
140
119
|
options: h.value,
|
|
141
120
|
placement: "bottom-end",
|
|
142
121
|
teleport: "",
|
|
143
|
-
"onUpdate:modelValue":
|
|
122
|
+
"onUpdate:modelValue": l[0] || (l[0] = (c) => j(c))
|
|
144
123
|
}, {
|
|
145
|
-
default:
|
|
146
|
-
|
|
124
|
+
default: n(() => [
|
|
125
|
+
r(o(F), {
|
|
147
126
|
class: "text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal",
|
|
148
127
|
"data-testid": "client-picker",
|
|
149
128
|
variant: "ghost"
|
|
150
129
|
}, {
|
|
151
|
-
default:
|
|
152
|
-
|
|
153
|
-
|
|
130
|
+
default: n(() => [
|
|
131
|
+
R(z(u.value?.title) + " ", 1),
|
|
132
|
+
r(o(J), {
|
|
154
133
|
class: "ui-open:rotate-180 mt-0.25 size-3 transition-transform duration-100",
|
|
155
134
|
weight: "bold"
|
|
156
135
|
})
|
|
@@ -164,23 +143,23 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
164
143
|
key: "0"
|
|
165
144
|
} : void 0
|
|
166
145
|
]), 1024),
|
|
167
|
-
|
|
168
|
-
default:
|
|
169
|
-
|
|
170
|
-
id: `${o(
|
|
146
|
+
r(o(T), { class: "request-editor-section custom-scroll p-0" }, {
|
|
147
|
+
default: n(() => [
|
|
148
|
+
b("div", {
|
|
149
|
+
id: `${o(L)}-example`,
|
|
171
150
|
class: "code-snippet"
|
|
172
151
|
}, [
|
|
173
|
-
|
|
152
|
+
H.value ? (s(), i(o(K), {
|
|
174
153
|
key: 1,
|
|
175
154
|
containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
|
|
176
155
|
contentClass: "language-plaintext whitespace-pre font-code text-base",
|
|
177
156
|
lineHeight: 20,
|
|
178
157
|
text: v.value
|
|
179
|
-
}, null, 8, ["text"])) : (s(), i(o(
|
|
158
|
+
}, null, 8, ["text"])) : (s(), i(o(M), {
|
|
180
159
|
key: 0,
|
|
181
160
|
class: "bg-b-2 !min-h-full -outline-offset-2",
|
|
182
161
|
content: v.value,
|
|
183
|
-
hideCredentials:
|
|
162
|
+
hideCredentials: O.value,
|
|
184
163
|
lang: B.value,
|
|
185
164
|
lineNumbers: ""
|
|
186
165
|
}, null, 8, ["content", "hideCredentials", "lang"]))
|
|
@@ -188,21 +167,21 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
188
167
|
]),
|
|
189
168
|
_: 1
|
|
190
169
|
}),
|
|
191
|
-
Object.keys(d.value).length > 1 || e.$slots.footer ? (s(), i(o(
|
|
170
|
+
Object.keys(d.value).length > 1 || e.$slots.footer ? (s(), i(o(Z), {
|
|
192
171
|
key: 0,
|
|
193
172
|
class: "request-card-footer bg-b-3"
|
|
194
173
|
}, {
|
|
195
|
-
default:
|
|
196
|
-
Object.keys(d.value).length > 1 ? (s(),
|
|
174
|
+
default: n(() => [
|
|
175
|
+
Object.keys(d.value).length > 1 ? (s(), x("div", ae, [
|
|
197
176
|
Object.keys(d.value).length ? (s(), i(te, {
|
|
198
177
|
key: 0,
|
|
199
178
|
modelValue: p.value,
|
|
200
179
|
"onUpdate:modelValue": [
|
|
201
|
-
|
|
202
|
-
|
|
180
|
+
l[1] || (l[1] = (c) => p.value = c),
|
|
181
|
+
l[2] || (l[2] = (c) => o(V)(
|
|
203
182
|
m.value?.$el,
|
|
204
183
|
"scalar-update-selected-example",
|
|
205
|
-
|
|
184
|
+
c
|
|
206
185
|
))
|
|
207
186
|
],
|
|
208
187
|
examples: d.value
|
|
@@ -214,15 +193,15 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
214
193
|
})) : f("", !0)
|
|
215
194
|
]),
|
|
216
195
|
_: 3
|
|
217
|
-
}, 512)) : e.fallback ? (s(), i(o(
|
|
196
|
+
}, 512)) : e.fallback ? (s(), i(o(S), {
|
|
218
197
|
key: 1,
|
|
219
198
|
class: "request-card dark-mode"
|
|
220
199
|
}, {
|
|
221
|
-
default:
|
|
222
|
-
|
|
223
|
-
default:
|
|
224
|
-
|
|
225
|
-
|
|
200
|
+
default: n(() => [
|
|
201
|
+
r(o(T), { class: "request-card-simple" }, {
|
|
202
|
+
default: n(() => [
|
|
203
|
+
b("div", ne, [
|
|
204
|
+
r(q, {
|
|
226
205
|
as: "span",
|
|
227
206
|
class: "request-method",
|
|
228
207
|
method: e.method
|
|
@@ -239,5 +218,5 @@ const le = ["innerHTML"], oe = ["id"], ae = {
|
|
|
239
218
|
}
|
|
240
219
|
});
|
|
241
220
|
export {
|
|
242
|
-
|
|
221
|
+
ge as default
|
|
243
222
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AvailableClients } from '@scalar/snippetz';
|
|
2
|
-
import type { ClientOption,
|
|
2
|
+
import type { ClientOption, CustomClientOption, CustomClientOptionGroup } from '../../../../v2/blocks/operation-code-sample/types';
|
|
3
3
|
export declare const DEFAULT_CLIENT = "shell/curl";
|
|
4
4
|
/** Type guard to check if a string is a valid client id */
|
|
5
5
|
export declare const isClient: (id: any) => id is AvailableClients[number];
|
|
@@ -37,5 +37,5 @@ export declare const isClient: (id: any) => id is AvailableClients[number];
|
|
|
37
37
|
* // Returns: { id: 'js/fetch', label: 'Fetch API', lang: 'js' }
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
export declare const findClient: (clientGroups:
|
|
40
|
+
export declare const findClient: (clientGroups: CustomClientOptionGroup[], clientId?: AvailableClients[number] | undefined) => ClientOption | CustomClientOption | undefined;
|
|
41
41
|
//# sourceMappingURL=find-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-client.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/find-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAE3E,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"find-client.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/find-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAE3E,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AAExH,eAAO,MAAM,cAAc,eAAe,CAAA;AAE1C,2DAA2D;AAC3D,eAAO,MAAM,QAAQ,GAAI,IAAI,GAAG,KAAG,EAAE,IAAI,gBAAgB,CAAC,MAAM,CAAmC,CAAA;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,UAAU,GACrB,cAAc,uBAAuB,EAAE,EACvC,WAAW,gBAAgB,CAAC,MAAM,CAAC,GAAG,SAAS,KAC9C,YAAY,GAAG,kBAAkB,GAAG,SAwBtC,CAAA"}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AvailableClients } from '@scalar/snippetz';
|
|
2
2
|
import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
|
|
3
3
|
import type { ClientOptionGroup } from '../../../../v2/blocks/operation-code-sample/types';
|
|
4
|
+
/** Type of custom code sample IDs */
|
|
5
|
+
export type CustomCodeSampleId = `custom/${string}`;
|
|
4
6
|
/** Helper to generate an ID for custom code samples */
|
|
5
|
-
export declare const generateCustomId: (example: XCodeSample) =>
|
|
7
|
+
export declare const generateCustomId: (example: XCodeSample) => CustomCodeSampleId;
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
* built-in snippets based on the hiddenClients configuration. This function creates
|
|
9
|
-
* a structured list of available client options that can be used to generate code
|
|
10
|
-
* examples for different programming languages and frameworks.
|
|
9
|
+
* Generate client options for the request example block by filtering by allowed clients
|
|
11
10
|
*
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
14
|
-
* parameter supports multiple formats:
|
|
15
|
-
* - boolean: true to hide all clients
|
|
16
|
-
* - array: ['fetch', 'axios'] to hide specific clients across all categories
|
|
17
|
-
* - object: { node: true, python: ['requests'] } to hide entire categories or specific clients within categories
|
|
11
|
+
* @param allowedClients - The list of allowed clients to include in the options
|
|
12
|
+
* @returns A list of client option groups
|
|
18
13
|
*/
|
|
19
|
-
export declare const generateClientOptions: (
|
|
14
|
+
export declare const generateClientOptions: (allowedClients?: AvailableClients) => ClientOptionGroup[];
|
|
20
15
|
//# sourceMappingURL=generate-client-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-client-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAY,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAGvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAEhF,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAEnD,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,KAAG,kBAA8C,CAAA;AAEtG;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,iBAAgB,gBAAoC,KAAG,iBAAiB,EAsC7G,CAAA"}
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import { snippetz as
|
|
2
|
-
import { capitalize as
|
|
3
|
-
const y = (
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
label:
|
|
20
|
-
|
|
21
|
-
targetTitle: e.title,
|
|
22
|
-
clientKey: r.client
|
|
1
|
+
import { AVAILABLE_CLIENTS as o, snippetz as a } from "@scalar/snippetz";
|
|
2
|
+
import { capitalize as c } from "vue";
|
|
3
|
+
const y = (n) => `custom/${n.lang}`, $ = (n = o) => {
|
|
4
|
+
const s = new Set(n);
|
|
5
|
+
return a().clients().flatMap((t) => {
|
|
6
|
+
const l = t.clients.flatMap((e) => {
|
|
7
|
+
const i = `${t.key}/${e.client}`;
|
|
8
|
+
return s.has(i) ? {
|
|
9
|
+
id: i,
|
|
10
|
+
lang: e.client === "curl" ? "curl" : t.key,
|
|
11
|
+
title: `${c(t.title)} ${e.title}`,
|
|
12
|
+
label: e.title,
|
|
13
|
+
targetKey: t.key,
|
|
14
|
+
targetTitle: t.title,
|
|
15
|
+
clientKey: e.client
|
|
16
|
+
} : [];
|
|
17
|
+
});
|
|
18
|
+
return l.length === 0 ? [] : {
|
|
19
|
+
label: t.title,
|
|
20
|
+
options: l
|
|
23
21
|
};
|
|
24
22
|
});
|
|
25
|
-
|
|
26
|
-
label: e.title,
|
|
27
|
-
options: n
|
|
28
|
-
};
|
|
29
|
-
});
|
|
23
|
+
};
|
|
30
24
|
export {
|
|
31
|
-
|
|
25
|
+
$ as generateClientOptions,
|
|
32
26
|
y as generateCustomId
|
|
33
27
|
};
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AvailableClient } from '@scalar/snippetz';
|
|
3
|
+
import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
|
|
3
4
|
import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { type CustomCodeSampleId } from './generate-client-options.js';
|
|
6
|
+
export type GenerateCodeSnippetProps = {
|
|
7
|
+
/** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */
|
|
8
|
+
clientId: AvailableClient | CustomCodeSampleId | undefined;
|
|
9
|
+
/** The Content-Type header value for the request body (e.g., 'application/json'). */
|
|
10
|
+
contentType?: string | undefined;
|
|
11
|
+
/** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */
|
|
12
|
+
customCodeSamples: XCodeSample[];
|
|
13
|
+
/** The specific example value to use when generating the code snippet. */
|
|
7
14
|
example?: string | undefined;
|
|
15
|
+
/** The HTTP method for the operation (e.g., GET, POST, PUT). */
|
|
8
16
|
method: HttpMethod;
|
|
17
|
+
/** The OpenAPI operation object containing request/response details. */
|
|
18
|
+
operation: OperationObject;
|
|
19
|
+
/** The API endpoint path (e.g., '/users/{id}'). */
|
|
9
20
|
path: string;
|
|
10
|
-
|
|
11
|
-
server?: ServerObject | undefined;
|
|
21
|
+
/** Array of security schemes to apply to the request (e.g., API keys, OAuth). */
|
|
12
22
|
securitySchemes?: SecuritySchemeObject[] | undefined;
|
|
23
|
+
/** The server object defining the base URL for the API request. */
|
|
24
|
+
server?: ServerObject | undefined;
|
|
13
25
|
};
|
|
14
26
|
/** Generate the code snippet for the selected example OR operation */
|
|
15
|
-
export declare const generateCodeSnippet: ({ clientId, operation, method, path, example, contentType, server, securitySchemes, }:
|
|
16
|
-
export {};
|
|
27
|
+
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, operation, method, path, example, contentType, server, securitySchemes, }: GenerateCodeSnippetProps) => string;
|
|
17
28
|
//# sourceMappingURL=generate-code-snippet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,2BAA2B,CAAA;AAErF,MAAM,MAAM,wBAAwB,GAAG;IACrC,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAA;IAClB,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,CAAC,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAA;IACpD,mEAAmE;IACnE,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAClC,CAAA;AAED,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,0GAUjC,wBAAwB,KAAG,MAqC7B,CAAA"}
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import { operationToHar as
|
|
2
|
-
import { getSnippet as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { operationToHar as C } from "./operation-to-har/operation-to-har.js";
|
|
2
|
+
import { getSnippet as y } from "../../../../views/Components/CodeSnippet/helpers/get-snippet.js";
|
|
3
|
+
import { generateCustomId as S } from "./generate-client-options.js";
|
|
4
|
+
const E = ({
|
|
5
|
+
clientId: e,
|
|
6
|
+
customCodeSamples: o,
|
|
7
|
+
operation: n,
|
|
8
|
+
method: p,
|
|
9
|
+
path: s,
|
|
10
|
+
example: a,
|
|
11
|
+
contentType: i,
|
|
12
|
+
server: g,
|
|
13
|
+
securitySchemes: m
|
|
12
14
|
}) => {
|
|
13
15
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
if (!e)
|
|
17
|
+
return "";
|
|
18
|
+
if (e.startsWith("custom"))
|
|
19
|
+
return o.find((d) => S(d) === e)?.source ?? "Custom example not found";
|
|
20
|
+
const r = C({
|
|
21
|
+
operation: n,
|
|
22
|
+
contentType: i,
|
|
23
|
+
method: p,
|
|
24
|
+
path: s,
|
|
25
|
+
server: g,
|
|
26
|
+
securitySchemes: m,
|
|
27
|
+
example: a
|
|
28
|
+
}), [u, c] = e.split("/"), [t, f] = y(u, c, r);
|
|
29
|
+
return t ? (console.error("[generateCodeSnippet]", t), t.message ?? "Error generating code snippet") : f;
|
|
30
|
+
} catch (r) {
|
|
31
|
+
return console.error("[generateCodeSnippet]", r), "Error generating code snippet";
|
|
26
32
|
}
|
|
27
33
|
};
|
|
28
34
|
export {
|
|
29
|
-
|
|
35
|
+
E as generateCodeSnippet
|
|
30
36
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
|
|
2
|
+
import type { ClientOptionGroup } from '../../../../v2/blocks/operation-code-sample/index.js';
|
|
3
|
+
import type { CustomClientOptionGroup } from '../../../../v2/blocks/operation-code-sample/types';
|
|
4
|
+
/**
|
|
5
|
+
* Merges custom code samples with the client options
|
|
6
|
+
*
|
|
7
|
+
* @param customCodeSamples - The custom code samples from the operation to merge with the client options
|
|
8
|
+
* @param clientOptions - The client options to merge with the custom code samples
|
|
9
|
+
* @returns A list of client option groups
|
|
10
|
+
*/
|
|
11
|
+
export declare const getClients: (customCodeSamples: XCodeSample[], clientOptions: ClientOptionGroup[]) => CustomClientOptionGroup[];
|
|
12
|
+
//# sourceMappingURL=get-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-clients.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAEvF,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,mCAAmC,CAAA;AAE9F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AAEtF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,mBAAmB,WAAW,EAAE,EAChC,eAAe,iBAAiB,EAAE,KACjC,uBAAuB,EA2BzB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { generateCustomId as i } from "./generate-client-options.js";
|
|
2
|
+
const a = (n, e) => n.length ? [
|
|
3
|
+
{
|
|
4
|
+
label: "Code Examples",
|
|
5
|
+
options: n.map((t) => {
|
|
6
|
+
const l = i(t), o = t.label || t.lang || l, r = t.lang || "plaintext";
|
|
7
|
+
return {
|
|
8
|
+
id: l,
|
|
9
|
+
lang: r,
|
|
10
|
+
title: o,
|
|
11
|
+
label: o,
|
|
12
|
+
clientKey: "custom"
|
|
13
|
+
};
|
|
14
|
+
})
|
|
15
|
+
},
|
|
16
|
+
...e
|
|
17
|
+
] : e;
|
|
18
|
+
export {
|
|
19
|
+
a as getClients
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
|
|
2
|
+
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
|
+
/**
|
|
4
|
+
* Grabs any custom code samples from the operation
|
|
5
|
+
*
|
|
6
|
+
* @param operation - The operation to get the custom code samples from
|
|
7
|
+
* @returns An array of custom code samples which exist in the operation
|
|
8
|
+
*/
|
|
9
|
+
export declare const getCustomCodeSamples: (operation: OperationObject) => XCodeSample[];
|
|
10
|
+
//# sourceMappingURL=get-custom-code-samples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-custom-code-samples.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAEnG;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,WAAW,eAAe,KAAG,WAAW,EAG5E,CAAA"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
type GetExampleFromSchemaOptions = {
|
|
3
|
+
/** Fallback string for empty string values. */
|
|
4
|
+
emptyString?: string;
|
|
5
|
+
/** Whether to use XML tag names as keys. */
|
|
6
|
+
xml?: boolean;
|
|
7
|
+
/** Whether to show read-only/write-only properties. */
|
|
8
|
+
mode?: 'read' | 'write';
|
|
9
|
+
/** Dynamic variables which can replace values via x-variable. */
|
|
10
|
+
variables?: Record<string, unknown>;
|
|
11
|
+
/** Whether to omit empty and optional properties. */
|
|
12
|
+
omitEmptyAndOptionalProperties?: boolean;
|
|
13
|
+
};
|
|
2
14
|
/**
|
|
3
15
|
* Generate an example value from a given OpenAPI SchemaObject.
|
|
4
16
|
*
|
|
@@ -14,21 +26,11 @@ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/o
|
|
|
14
26
|
* @param name - The name of the property being processed.
|
|
15
27
|
* @returns An example value for the given schema.
|
|
16
28
|
*/
|
|
17
|
-
export declare const getExampleFromSchema: (schema: SchemaObject, options?: {
|
|
18
|
-
/** Fallback string for empty string values. */
|
|
19
|
-
emptyString?: string;
|
|
20
|
-
/** Whether to use XML tag names as keys. */
|
|
21
|
-
xml?: boolean;
|
|
22
|
-
/** Whether to show read-only/write-only properties. */
|
|
23
|
-
mode?: "read" | "write";
|
|
24
|
-
/** Dynamic variables which can replace values via x-variable. */
|
|
25
|
-
variables?: Record<string, unknown>;
|
|
26
|
-
/** Whether to omit empty and optional properties. */
|
|
27
|
-
omitEmptyAndOptionalProperties?: boolean;
|
|
28
|
-
}, args?: Partial<{
|
|
29
|
+
export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, }?: Partial<{
|
|
29
30
|
level: number;
|
|
30
31
|
parentSchema: SchemaObject;
|
|
31
32
|
name: string;
|
|
32
33
|
seen: WeakSet<object>;
|
|
33
34
|
}>) => unknown;
|
|
35
|
+
export {};
|
|
34
36
|
//# sourceMappingURL=get-example-from-schema.d.ts.map
|