@scalar/blocks 0.7.3 → 0.7.4
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 +19 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +1 -2
- package/dist/code-example/components/AsyncApiCodeExample.vue.js +1 -2
- package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-example/components/CodeExample.vue.d.ts +2 -0
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/CodeExample.vue.js +4 -5
- package/dist/code-example/components/CodeExample.vue.js.map +1 -1
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +102 -100
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue.js +1 -2
- package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/code-example/components/HttpMethod.vue.js +1 -2
- package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
- package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/code-example/helpers/filter-clients-by-query.js +1 -2
- package/dist/code-example/helpers/find-client.js +1 -2
- package/dist/code-example/helpers/format-language.js +1 -2
- package/dist/code-example/helpers/generate-client-options.js +1 -2
- package/dist/code-example/helpers/generate-code-snippet.d.ts +2 -1
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.js +11 -11
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
- package/dist/code-example/helpers/get-asyncapi-example-context.js +1 -2
- package/dist/code-example/helpers/get-clients.js +8 -9
- package/dist/code-example/helpers/get-custom-code-samples.js +1 -2
- package/dist/code-example/helpers/get-generated-payload-example.js +1 -2
- package/dist/code-example/helpers/get-message-example-content.js +1 -2
- package/dist/code-example/helpers/get-secrets.js +1 -2
- package/dist/code-example/helpers/get-snippet.js +1 -2
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +2 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js +32 -31
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts +2 -2
- package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-body.js +80 -52
- package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +2 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.js +65 -58
- package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +1 -2
- package/dist/code-example/helpers/operation-to-har/process-server-url.js +1 -2
- package/dist/code-example/index.js +10 -10
- package/dist/code-example/mount-asyncapi.js +7 -8
- package/dist/code-example/mount.js +5 -6
- package/dist/constants.js +2 -3
- package/dist/schema/LinkButton.vue.js +1 -2
- package/dist/schema/RenderString.vue.js +1 -2
- package/dist/schema/RenderString.vue.js.map +1 -1
- package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/Schema.vue.js +4 -5
- package/dist/schema/Schema.vue.js.map +1 -1
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +67 -68
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaCollapsedPreview.vue.js +1 -2
- package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaComposition.vue.js +4 -5
- package/dist/schema/SchemaComposition.vue.js.map +1 -1
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +26 -27
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem.vue.js +1 -2
- package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaEnums.vue.js +4 -5
- package/dist/schema/SchemaEnums.vue.js.map +1 -1
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +12 -13
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaGlyphPuck.vue.js +1 -2
- package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
- package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaGutterToggle.vue.js +1 -2
- package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
- package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaHeading.vue.js +4 -5
- package/dist/schema/SchemaHeading.vue.js.map +1 -1
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +1 -2
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaObjectProperties.vue.js +1 -2
- package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaProperty.vue.js +4 -5
- package/dist/schema/SchemaProperty.vue.js.map +1 -1
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +48 -49
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyDefault.vue.js +4 -5
- package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +9 -10
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyDetail.vue.js +4 -5
- package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples.vue.js +4 -5
- package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +18 -19
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyHeading.vue.js +4 -5
- package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +101 -102
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/SchemaPropertyPattern.vue.js +4 -5
- package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaRailPanel.vue.js +1 -2
- package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/schema/components/CopyLinkButton.vue.js +1 -2
- package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
- package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/components/WithBreadcrumb.vue.js +1 -2
- package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
- package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/schema/discriminator-metadata.js +1 -2
- package/dist/schema/helpers/dynamic-scope.js +1 -2
- package/dist/schema/helpers/format-example.js +1 -2
- package/dist/schema/helpers/format-value.js +1 -2
- package/dist/schema/helpers/get-compositions-to-render.js +19 -20
- package/dist/schema/helpers/get-discriminator-values.js +1 -2
- package/dist/schema/helpers/get-enum-values.js +1 -2
- package/dist/schema/helpers/get-property-description.js +1 -2
- package/dist/schema/helpers/get-ref-name.js +1 -2
- package/dist/schema/helpers/get-rendered-example.js +1 -2
- package/dist/schema/helpers/get-schema-type.js +1 -2
- package/dist/schema/helpers/get-type-signature-tokens.d.ts +2 -2
- package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
- package/dist/schema/helpers/get-type-signature-tokens.js +3 -4
- package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
- package/dist/schema/helpers/has-complex-array-items.js +1 -2
- package/dist/schema/helpers/index.js +13 -13
- package/dist/schema/helpers/is-empty-schema-object.js +1 -2
- package/dist/schema/helpers/is-model-linkable.js +1 -2
- package/dist/schema/helpers/is-on-schema-target-path.js +1 -2
- package/dist/schema/helpers/is-type-object.js +1 -2
- package/dist/schema/helpers/merge-all-of-schemas.js +1 -2
- package/dist/schema/helpers/normalize-object-composition.js +1 -2
- package/dist/schema/helpers/optimize-value-for-display.js +1 -2
- package/dist/schema/helpers/partition-all-of-compositions.js +1 -2
- package/dist/schema/helpers/schema-composition.js +1 -2
- package/dist/schema/helpers/schema-cycle.js +1 -2
- package/dist/schema/helpers/schema-expansion.js +1 -2
- package/dist/schema/helpers/schema-keyboard-nav.js +1 -2
- package/dist/schema/helpers/schema-name.js +2 -3
- package/dist/schema/helpers/schema-name.js.map +1 -1
- package/dist/schema/helpers/should-display-description.js +1 -2
- package/dist/schema/helpers/should-display-heading.js +1 -2
- package/dist/schema/helpers/should-render-array-item-composition.js +1 -2
- package/dist/schema/helpers/sort-property-names.js +1 -2
- package/dist/schema/helpers/unwrap-for-read.js +1 -2
- package/dist/schema/index.js +8 -8
- package/dist/schema/localization/index.js +1 -2
- package/dist/schema/localization/locales/ar.js +1 -2
- package/dist/schema/localization/locales/de.js +1 -2
- package/dist/schema/localization/locales/en.js +1 -2
- package/dist/schema/localization/locales/es.js +1 -2
- package/dist/schema/localization/locales/fr.js +1 -2
- package/dist/schema/localization/locales/pt.js +1 -2
- package/dist/schema/localization/locales/ru.js +1 -2
- package/dist/schema/localization/locales/zh-cn.js +1 -2
- package/dist/schema/localization/locales/zh-tw.js +1 -2
- package/dist/schema/localization/translations.js +1 -2
- package/dist/schema/protobuf-metadata.js +1 -2
- package/dist/schema/recursive-metadata.js +1 -2
- package/dist/schema/request-body-composition-index.js +1 -2
- package/dist/shared/Badge.vue.d.ts.map +1 -1
- package/dist/shared/Badge.vue.js +4 -5
- package/dist/shared/Badge.vue.js.map +1 -1
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +2 -3
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/shared/ExternalDocs.vue.js +1 -2
- package/dist/shared/ExternalDocs.vue.js.map +1 -1
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/shared/ScreenReader.vue.js +1 -2
- package/dist/shared/ScreenReader.vue.js.map +1 -1
- package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/shared/index.js +4 -4
- package/dist/specification-extensions/ExtensionValue.vue.js +1 -2
- package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +5 -6
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/specification-extensions/SpecificationExtensions.vue.js +1 -2
- package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +1 -2
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/style.css +40 -20
- package/dist/vue-styles.css +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeExample.vue_vue_type_script_setup_true_lang.js","names":["$slots","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createSlots","_createElementVNode","HttpMethod","_createElementBlock","_createCommentVNode","_renderSlot","_createTextVNode","_toDisplayString","_normalizeClass","_Fragment","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","watch","watchEffect","selectExample","key","customCodeSamples","getCustomCodeSamples","clients","getClients","clientCount","total","group","localSelectedClient","findClient","newClient","client","clientPickerAriaLabel","codeSampleAriaLabel","elem","visible","useExampleVisibility","externalExamples","useExternalExamples","getOperationExamples","resolvedOperation","resolveOperationExamples","showExamplePicker","webhookHar","operationToHar","error","generatedTemplate","generateCodeSnippet","resolvedCredentials","scheme","resolveCredentialPlaceholders","generatedCode","displayCode","codeBlockLanguage","webhookLanguage","secretCredentials","getSecrets","selectClient","unfreeze","freezeElement","option","shouldVirtualize","id","useId","unref","openBlock","createBlock","ScalarCard","withCtx","createVNode","ScalarCardHeader","createSlots","_cache","createElementVNode","createElementBlock","createCommentVNode","renderSlot","_ctx","ScalarCombobox","filterClientsByQuery","$event","ScalarButton","createTextVNode","toDisplayString","ScalarIconCaretDown","normalizeClass","open","ScalarCardSection","Fragment","ScalarCodeBlockCopy","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /**\n * Localized purpose of the client picker. It opens the button's accessible name and the\n * selected client's title is appended, so the name still contains the visible label.\n */\n clientPickerLabel?: string\n /** Localized accessible name for the search field inside the client picker. */\n clientSearchLabel?: string\n /**\n * Localized accessible name for the focusable code sample. The selected client's title is\n * appended so the announcement also says which language the sample is in.\n */\n codeSampleLabel?: string\n /**\n * Integration type: determines if the code sample is displayed in a client environment\n * or in an API reference environment.\n */\n integration?: 'client' | 'reference'\n /**\n * List of all http clients formatted into option groups for the client selector\n */\n clientOptions: ClientOptionGroup[]\n /**\n * Pre-selected client, this will determine which client is initially selected in the dropdown.\n * Either a built-in client id (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * Typed as a plain string: unioning the (large) client-id union with the `custom/...`\n * ids overflows TypeScript's union-complexity limit inside this component's `defineProps`.\n *\n * @defaults to a custom sample if one is available, otherwise shell/curl\n */\n selectedClient?: string\n /**\n * Which server from the spec to use for the code example\n */\n selectedServer?: ServerObject | null\n /**\n * The selected content type from the requestBody.content, this will determine which examples are available\n * as well as the content type of the code example\n *\n * @defaults to the first content type if not provided\n */\n selectedContentType?: string\n /**\n * Example name to use for resolving example values for parameters AND requestBody.\n *\n * This is the document-wide selection: it is honored only when this operation defines an example\n * with the same key, so picking an example on one operation syncs the rest without blanking out\n * operations that do not share that key.\n *\n * @example \"limited\"\n * ```ts\n * parameters: {\n * name: 'foobar',\n * in: 'query',\n * examples: {\n * limited: {\n * dataValue: 10,\n * }\n * }\n * },\n * body: {\n * content: {\n * 'application/json': {\n * examples: {\n * limited: {\n * dataValue: { foo: 'bar' },\n * }\n * }\n * }\n * }\n * }\n *\n * ```\n */\n selectedExample?: string\n /**\n * Event bus\n */\n eventBus: WorkspaceEventBus\n /**\n * The security schemes which are applicable to this operation\n */\n securitySchemes: SecuritySchemeObjectSecret[]\n /**\n * HTTP method of the operation\n */\n method: string\n /**\n * Path of the operation\n */\n path: string\n /**\n * De-referenced OpenAPI Operation object\n */\n operation: OperationObject\n /**\n * If true and there's no example, we will display a small card with the method and path only\n */\n fallback?: boolean\n /**\n * A method to generate the label of the block, should return an html string\n */\n generateLabel?: () => string\n /**\n * If true, render this as a webhook request example\n */\n isWebhook?: boolean\n /**\n * Workspace + document cookies\n */\n globalCookies?: XScalarCookie[]\n /**\n * When the request body schema uses oneOf/anyOf, use these selected variants\n * for the example snippet (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getOperationExamples,\n resolveOperationExamples,\n} from '@scalar/workspace-store/helpers/operation-examples'\nimport {\n useExampleVisibility,\n useExternalExamples,\n} from '@scalar/workspace-store/helpers/use-external-examples'\nimport {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n ref,\n useId,\n watch,\n watchEffect,\n type ComponentPublicInstance,\n} from 'vue'\n\nimport { filterClientsByQuery } from '../helpers/filter-clients-by-query'\nimport { findClient } from '../helpers/find-client'\nimport { generateCodeSnippet } from '../helpers/generate-code-snippet'\nimport { getClients } from '../helpers/get-clients'\nimport { getCustomCodeSamples } from '../helpers/get-custom-code-samples'\nimport { getSecrets } from '../helpers/get-secrets'\nimport { operationToHar } from '../helpers/operation-to-har/operation-to-har'\nimport type {\n ClientOption,\n ClientOptionGroup,\n CustomClientOption,\n} from '../types'\nimport ExamplePicker from './ExamplePicker.vue'\nimport HttpMethod from './HttpMethod.vue'\n\nconst {\n integration,\n codeSampleUnavailable = 'No code sample available for this example.',\n clientPickerLabel = 'Change code sample language',\n clientSearchLabel = 'Search clients',\n codeSampleLabel = 'Code sample',\n clientOptions,\n selectedClient,\n selectedServer = null,\n selectedContentType,\n selectedExample,\n securitySchemes = [],\n method,\n eventBus,\n path,\n operation,\n isWebhook,\n generateLabel,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n} = defineProps<CodeExampleProps>()\n\nconst emit = defineEmits<{\n /**\n * Emitted whenever the example key actually shown for this operation changes.\n *\n * This is the resolved local key (not the raw document-wide selection), so layouts that render\n * the test-request button outside this component can open the client with the same example the\n * snippet displays.\n */\n (e: 'update:exampleKey', value: string): void\n}>()\n\ndefineSlots<{\n 'header': () => unknown\n /** Rendered at the start of the footer, only while the example picker does not need that space */\n 'footer-start'?: () => unknown\n 'footer': ({ exampleName }: { exampleName: string }) => unknown\n}>()\n\n/** Grab the examples for the given content type */\nconst requestBodyExamples = computed(() => {\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const contentType = selectedContentType || Object.keys(content)[0]\n if (!contentType) return {}\n\n const examples = content[contentType]?.examples ?? {}\n\n return examples\n})\n\n/**\n * The example key actually shown for this operation.\n *\n * `selectedExample` is the document-wide selection that syncs across operations. We honor it only\n * when this operation actually defines that key, otherwise we keep the local example: a selection\n * on one operation should never blank out an operation that does not share the same example.\n */\nconst localExampleKey = ref('')\n\n/** Resolve the key to display, preferring the document-wide selection when this operation has it */\nconst resolveExampleKey = (preferred: string | undefined): string => {\n const keys = Object.keys(requestBodyExamples.value)\n if (preferred && keys.includes(preferred)) {\n return preferred\n }\n // Keep the current local example when it is still valid, otherwise fall back to the first one\n if (localExampleKey.value && keys.includes(localExampleKey.value)) {\n return localExampleKey.value\n }\n return keys[0] ?? ''\n}\n\n// Set the initial example from the document-wide selection, falling back to the first example.\n// This runs during setup so the server renders the same example as the browser.\nlocalExampleKey.value = resolveExampleKey(selectedExample)\n\n// Follow the document-wide selection when it changes and this operation has that example\nwatch(\n () => selectedExample,\n (preferred) => {\n localExampleKey.value = resolveExampleKey(preferred)\n },\n)\n\n/** Reset the selected example key if the content type changes and the new content type doesn't have the previously selected example */\nwatch(\n () => selectedContentType,\n () => {\n if (\n !Object.keys(requestBodyExamples.value).includes(localExampleKey.value)\n ) {\n // Re-resolve so the new content type still follows the document-wide selection when it has\n // that key, instead of always snapping back to the first example\n localExampleKey.value = resolveExampleKey(selectedExample)\n }\n },\n)\n\n// Keep the parent informed of the resolved key so a test-request button rendered outside this\n// component (e.g. the classic layout header) opens the client with the example the snippet shows\nwatchEffect(() => {\n emit('update:exampleKey', localExampleKey.value)\n})\n\n/** Select an example locally and sync the choice across the document */\nconst selectExample = (key: string) => {\n localExampleKey.value = key\n eventBus.emit('workspace:update:selected-example', key)\n}\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/** Total number of available clients across all option groups */\nconst clientCount = computed(() =>\n clients.value.reduce((total, group) => total + group.options.length, 0),\n)\n\n/** The locally selected client which would include code samples from this operation only */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/**\n * Accessible name for the client picker.\n *\n * On its own the button reads as its current value (\"C Libcurl\"), which never\n * says what activating it does. The visible title stays part of the name so it\n * still matches what is on screen.\n */\nconst clientPickerAriaLabel = computed(() =>\n [clientPickerLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\n/**\n * Accessible name for the focusable code sample, e.g. \"Code sample: Shell cURL\".\n *\n * Screen readers announce only the name and role when focus lands on the scroller, so the\n * name tells the user both what the region is and which client it is generated for.\n */\nconst codeSampleAriaLabel = computed(() =>\n [codeSampleLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\nconst elem = ref<ComponentPublicInstance | null>(null)\nconst visible = useExampleVisibility(elem)\nconst externalExamples = useExternalExamples(\n () =>\n getOperationExamples(operation, localExampleKey.value, selectedContentType),\n () => visible.value,\n)\nconst resolvedOperation = computed(() =>\n resolveOperationExamples(\n operation,\n localExampleKey.value,\n selectedContentType,\n externalExamples.resolve,\n ),\n)\n\n/** Keep the picker available because it also selects the example opened by Test Request. */\nconst showExamplePicker = computed(\n () => Object.keys(requestBodyExamples.value).length > 1,\n)\n\n/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation: resolvedOperation.value,\n method,\n path,\n example: localExampleKey.value,\n openapiVersion,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedTemplate = computed<string | null>(() => {\n if (isWebhook) {\n return webhookHar.value?.postData?.text ?? ''\n }\n\n return generateCodeSnippet({\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n includeDefaultHeaders: integration === 'client',\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation: resolvedOperation.value,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n })\n})\n\n/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\n)\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\n\n/** Set custom example, or update the selected HTTP client globally */\nconst selectClient = (option: ClientOption) => {\n // We need to freeze the ui to prevent scrolling as the clients change\n if (elem.value) {\n const unfreeze = freezeElement(elem.value.$el)\n setTimeout(() => {\n unfreeze()\n }, 300)\n }\n // Update to the local example\n localSelectedClient.value = option\n\n // Sync the selection globally so other operations follow along. Custom samples\n // sync too (keyed by language), so picking e.g. the Python SDK example here\n // shows the Python example on every operation that ships one.\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n// Virtualize the code block if it's too large\n// This prevents the entire app from freezing up if there's a massive example\n// We set a lower threshold here as code examples can get quite large\nconst VIRTUALIZATION_THRESHOLD = 20_000\n\nconst shouldVirtualize = computed(\n () => (generatedCode.value?.length ?? 0) > VIRTUALIZATION_THRESHOLD,\n)\n\nconst id = useId()\n</script>\n<template>\n <ScalarCard\n v-if=\"\n generatedCode === null || generatedCode || externalExamples.pending.value\n \"\n ref=\"elem\"\n class=\"request-card dark-mode\">\n <!-- Header -->\n <ScalarCardHeader class=\"pr-2.5\">\n <span class=\"sr-only\">Request Example for</span>\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <span\n v-if=\"generateLabel\"\n v-html=\"generateLabel()\" />\n <slot name=\"header\" />\n <!-- Client picker -->\n <template\n v-if=\"!isWebhook && clientCount\"\n #actions>\n <!-- Multiple clients: render a dropdown to switch between them -->\n <ScalarCombobox\n v-if=\"clientCount > 1\"\n v-slot=\"{ open }\"\n class=\"max-h-80\"\n :filterFn=\"filterClientsByQuery\"\n :inputLabel=\"clientSearchLabel\"\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\n :aria-label=\"clientPickerAriaLabel\"\n 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\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <!--\n Follow this picker's own state. The `ui-open:` variant also matches any open\n Headless UI ancestor, such as an expanded operation in the classic layout.\n -->\n <ScalarIconCaretDown\n class=\"mt-px size-3 transition-transform duration-100\"\n :class=\"{ 'rotate-180': open }\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarCombobox>\n <!-- Single client: just show its label, no need for a dropdown -->\n <span\n v-else\n class=\"text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\">\n {{ localSelectedClient?.title }}\n </span>\n </template>\n </ScalarCardHeader>\n\n <!-- Code snippet -->\n <ScalarCardSection class=\"request-editor-section custom-scroll p-0\">\n <div\n v-if=\"externalExamples.pending.value\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamples.failed.value\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"externalExamples.retry\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n <div\n v-else-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ codeSampleUnavailable }}\n </div>\n <div\n v-else\n :id=\"`${id}-example`\"\n class=\"code-snippet group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"h-full bg-transparent\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"20\"\n role=\"region\"\n :text=\"displayCode ?? ''\" />\n </template>\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer\"\n :class=\"{\n 'request-card-footer--wraps':\n showExamplePicker || $slots['footer-start'],\n }\">\n <!-- Example picker -->\n <div\n v-if=\"showExamplePicker\"\n class=\"request-card-footer-addon\">\n <template v-if=\"Object.keys(requestBodyExamples).length\">\n <ExamplePicker\n :examples=\"requestBodyExamples\"\n :modelValue=\"localExampleKey\"\n @update:modelValue=\"selectExample\" />\n </template>\n </div>\n <!-- Otherwise the start of the footer is free for the caller -->\n <div\n v-else-if=\"$slots['footer-start']\"\n class=\"request-card-footer-start\">\n <slot name=\"footer-start\" />\n </div>\n\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <!-- A single row of method, path and actions reads as a header, so it stays on the card -->\n <ScalarCardSection class=\"request-card-simple bg-transparent shadow-none\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n margin-right: 6px;\n}\n.request-card-footer {\n display: flex;\n justify-content: flex-end;\n padding: 6px;\n flex-shrink: 0;\n position: relative;\n}\n/*\n * The example picker or footer-start content keeps room for itself; when the footer is too narrow\n * for everything, the end controls wrap onto a second line instead of squeezing or covering it.\n */\n.request-card-footer--wraps {\n flex-wrap: wrap;\n row-gap: 4px;\n}\n.request-card-footer-start {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n}\n/*\n * The picker asks for its example name's width, capped at 7em (about eight characters), so on a\n * narrow card the end controls wrap rather than squeeze the name out of view. The cap keeps a long\n * name truncating beside them on wider cards, as before. The picker never grows past its name, and\n * the end margin holds it at the start of the line.\n */\n.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1 1 7em;\n min-width: 0;\n max-width: max-content;\n margin-inline-end: auto;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n/*\n * A long sample is drawn as virtual text with its own copy button rather than a code block, so\n * that button gets the same raised fill a code block gives its button on a card's surface.\n */\n.code-snippet > .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n.request-card-simple {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0NA,IAAM8B,KAAOD,GAmBPE,IAAsBC,QAAe;GACzC,IAAMC,IAAUC,GAAeC,EAAA,UAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7DC,IAAcD,EAAA,uBAAuB,OAAO,KAAKF,CAAO,CAAC,CAAC;GAKhE,OAJKG,IAEYH,EAAQG,EAAY,EAAE,YAAY,CAAC,IAF3B,CAAC;EAK5B,CAAC,GASKC,IAAkBC,EAAI,EAAE,GAGxBC,KAAqB,MAA0C;GACnE,IAAMC,IAAO,OAAO,KAAKT,EAAoB,KAAK;GAQlD,OAPIU,KAAaD,EAAK,SAASC,CAAS,IAC/BA,IAGLJ,EAAgB,SAASG,EAAK,SAASH,EAAgB,KAAK,IACvDA,EAAgB,QAElBG,EAAK,MAAM;EACpB;EA8BA,AA1BA,EAAgB,QAAQD,EAAkBJ,EAAA,eAAe,GAGzDO,QACQP,EAAA,kBACL,MAAc;GACb,EAAgB,QAAQI,EAAkBE,CAAS;EACrD,CACF,GAGAC,QACQP,EAAA,2BACA;GACJ,AACG,OAAO,KAAKJ,EAAoB,KAAK,CAAC,CAAC,SAASM,EAAgB,KAAK,MAItE,EAAgB,QAAQE,EAAkBJ,EAAA,eAAe;EAE7D,CACF,GAIAQ,SAAkB;GAChB,GAAK,qBAAqBN,EAAgB,KAAK;EACjD,CAAC;EAGD,IAAMO,MAAiB,MAAgB;GAErC,AADA,EAAgB,QAAQC,GACxBV,EAAA,SAAS,KAAK,qCAAqCU,CAAG;EACxD,GAGMC,IAAoBd,QAAee,GAAqBZ,EAAA,SAAS,CAAC,GAGlEa,IAAUhB,QACdiB,GACEH,EAAkB,MAAM,SACxBX,EAAA,eACA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C,EAeoBJ,EAAA+G,CAAA,GAAA,EAfD,OAAM,iDAAgD,GAAA;IACvE,SAAA5G,QAMM,CANNG,EAMM,OANNmB,GAMM,CALJrB,EAGqBG,GAAA;KAFnB,IAAG;KACH,OAAM;KACL,QAAQ2B,EAAA;I,yBACXxB,EAAsB2F,EAAA,QAAA,UAAA,CAAA,GAAA,KAAA,GAAA,EAAA,C,IAGhBtG,EAAAA,OAAO,UADfE,EAAA,GAAAO,EAMM,OANNkB,GAMM,CAHJhB,EAEkB2F,EAAA,QAAA,UAAA,EADf,aAAajE,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C"}
|
|
1
|
+
{"version":3,"file":"CodeExample.vue_vue_type_script_setup_true_lang.js","names":["$slots","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createSlots","_createElementVNode","HttpMethod","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_normalizeClass","_Fragment","ExamplePicker","ExamplePicker_default","HttpMethod_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","CodeExample_vue_vue_type_script_setup_true_lang_default","__emit","emit","requestBodyExamples","computed","content","getResolvedRef","__props","contentType","localExampleKey","ref","resolveExampleKey","keys","preferred","watch","watchEffect","selectExample","key","customCodeSamples","getCustomCodeSamples","clients","getClients","clientCount","total","group","localSelectedClient","findClient","newClient","client","clientPickerAriaLabel","codeSampleAriaLabel","elem","visible","useExampleVisibility","externalExamples","useExternalExamples","getOperationExamples","resolvedOperation","resolveOperationExamples","showExamplePicker","webhookHar","operationToHar","error","generatedTemplate","generateCodeSnippet","resolvedCredentials","scheme","resolveCredentialPlaceholders","generatedCode","displayCode","codeBlockLanguage","webhookLanguage","secretCredentials","getSecrets","selectClient","unfreeze","freezeElement","option","shouldVirtualize","id","useId","unref","openBlock","createBlock","ScalarCard","withCtx","createVNode","ScalarCardHeader","createSlots","_cache","createElementVNode","createElementBlock","createCommentVNode","renderSlot","_ctx","ScalarCombobox","filterClientsByQuery","$event","ScalarButton","createTextVNode","toDisplayString","ScalarIconCaretDown","normalizeClass","open","ScalarCardSection","Fragment","ScalarCodeBlockCopy","ScalarVirtualText","ScalarCodeBlock","ScalarCardFooter"],"sources":["../../../src/code-example/components/CodeExample.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type CodeExampleProps = {\n /** Localized status text shown when the selected example has no linked code sample. */\n codeSampleUnavailable?: string\n /**\n * Localized purpose of the client picker. It opens the button's accessible name and the\n * selected client's title is appended, so the name still contains the visible label.\n */\n clientPickerLabel?: string\n /** Localized accessible name for the search field inside the client picker. */\n clientSearchLabel?: string\n /**\n * Localized accessible name for the focusable code sample. The selected client's title is\n * appended so the announcement also says which language the sample is in.\n */\n codeSampleLabel?: string\n /**\n * Integration type: determines if the code sample is displayed in a client environment\n * or in an API reference environment.\n */\n integration?: 'client' | 'reference'\n /**\n * List of all http clients formatted into option groups for the client selector\n */\n clientOptions: ClientOptionGroup[]\n /**\n * Pre-selected client, this will determine which client is initially selected in the dropdown.\n * Either a built-in client id (e.g. `js/fetch`) or a custom sample id (e.g. `custom/python`).\n *\n * Typed as a plain string: unioning the (large) client-id union with the `custom/...`\n * ids overflows TypeScript's union-complexity limit inside this component's `defineProps`.\n *\n * @defaults to a custom sample if one is available, otherwise shell/curl\n */\n selectedClient?: string\n /**\n * Which server from the spec to use for the code example\n */\n selectedServer?: ServerObject | null\n /**\n * The selected content type from the requestBody.content, this will determine which examples are available\n * as well as the content type of the code example\n *\n * @defaults to the first content type if not provided\n */\n selectedContentType?: string\n /**\n * Example name to use for resolving example values for parameters AND requestBody.\n *\n * This is the document-wide selection: it is honored only when this operation defines an example\n * with the same key, so picking an example on one operation syncs the rest without blanking out\n * operations that do not share that key.\n *\n * @example \"limited\"\n * ```ts\n * parameters: {\n * name: 'foobar',\n * in: 'query',\n * examples: {\n * limited: {\n * dataValue: 10,\n * }\n * }\n * },\n * body: {\n * content: {\n * 'application/json': {\n * examples: {\n * limited: {\n * dataValue: { foo: 'bar' },\n * }\n * }\n * }\n * }\n * }\n *\n * ```\n */\n selectedExample?: string\n /**\n * Event bus\n */\n eventBus: WorkspaceEventBus\n /**\n * The security schemes which are applicable to this operation\n */\n securitySchemes: SecuritySchemeObjectSecret[]\n /**\n * HTTP method of the operation\n */\n method: string\n /**\n * Path of the operation\n */\n path: string\n /**\n * De-referenced OpenAPI Operation object\n */\n operation: OperationObject\n /**\n * If true and there's no example, we will display a small card with the method and path only\n */\n fallback?: boolean\n /**\n * A method to generate the label of the block, should return an html string\n */\n generateLabel?: () => string\n /**\n * If true, render this as a webhook request example\n */\n isWebhook?: boolean\n /**\n * Workspace + document cookies\n */\n globalCookies?: XScalarCookie[]\n /**\n * When the request body schema uses oneOf/anyOf, use these selected variants\n * for the example snippet (e.g. from the schema dropdowns in the API reference).\n */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n /** Document-level JSON Schema dialect used when generating array `contains` examples. */\n jsonSchemaDialect?: string\n requestBodyCompositionSelection?: Record<string, number>\n}\n\n/**\n * Request Example\n *\n * The core component for rendering a request example block,\n * this component does not have much of its own state but operates on props and custom events\n *\n * @event workspace:update:selected-client - Emitted when the selected client changes\n * @event workspace:update:selected-example - Emitted when the selected example changes, so other operations can sync\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport {\n ScalarCard,\n ScalarCardFooter,\n ScalarCardHeader,\n ScalarCardSection,\n} from '@scalar/components/card'\nimport {\n ScalarCodeBlock,\n ScalarCodeBlockCopy,\n} from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarVirtualText } from '@scalar/components/virtual-text'\nimport { freezeElement } from '@scalar/helpers/dom/freeze-element'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getOperationExamples,\n resolveOperationExamples,\n} from '@scalar/workspace-store/helpers/operation-examples'\nimport {\n useExampleVisibility,\n useExternalExamples,\n} from '@scalar/workspace-store/helpers/use-external-examples'\nimport {\n resolveCredentialPlaceholders,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OperationObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport {\n computed,\n ref,\n useId,\n watch,\n watchEffect,\n type ComponentPublicInstance,\n} from 'vue'\n\nimport { filterClientsByQuery } from '../helpers/filter-clients-by-query'\nimport { findClient } from '../helpers/find-client'\nimport { generateCodeSnippet } from '../helpers/generate-code-snippet'\nimport { getClients } from '../helpers/get-clients'\nimport { getCustomCodeSamples } from '../helpers/get-custom-code-samples'\nimport { getSecrets } from '../helpers/get-secrets'\nimport { operationToHar } from '../helpers/operation-to-har/operation-to-har'\nimport type {\n ClientOption,\n ClientOptionGroup,\n CustomClientOption,\n} from '../types'\nimport ExamplePicker from './ExamplePicker.vue'\nimport HttpMethod from './HttpMethod.vue'\n\nconst {\n integration,\n codeSampleUnavailable = 'No code sample available for this example.',\n clientPickerLabel = 'Change code sample language',\n clientSearchLabel = 'Search clients',\n codeSampleLabel = 'Code sample',\n clientOptions,\n selectedClient,\n selectedServer = null,\n selectedContentType,\n selectedExample,\n securitySchemes = [],\n method,\n eventBus,\n path,\n operation,\n isWebhook,\n generateLabel,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n} = defineProps<CodeExampleProps>()\n\nconst emit = defineEmits<{\n /**\n * Emitted whenever the example key actually shown for this operation changes.\n *\n * This is the resolved local key (not the raw document-wide selection), so layouts that render\n * the test-request button outside this component can open the client with the same example the\n * snippet displays.\n */\n (e: 'update:exampleKey', value: string): void\n}>()\n\ndefineSlots<{\n 'header': () => unknown\n /** Rendered at the start of the footer, only while the example picker does not need that space */\n 'footer-start'?: () => unknown\n 'footer': ({ exampleName }: { exampleName: string }) => unknown\n}>()\n\n/** Grab the examples for the given content type */\nconst requestBodyExamples = computed(() => {\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const contentType = selectedContentType || Object.keys(content)[0]\n if (!contentType) return {}\n\n const examples = content[contentType]?.examples ?? {}\n\n return examples\n})\n\n/**\n * The example key actually shown for this operation.\n *\n * `selectedExample` is the document-wide selection that syncs across operations. We honor it only\n * when this operation actually defines that key, otherwise we keep the local example: a selection\n * on one operation should never blank out an operation that does not share the same example.\n */\nconst localExampleKey = ref('')\n\n/** Resolve the key to display, preferring the document-wide selection when this operation has it */\nconst resolveExampleKey = (preferred: string | undefined): string => {\n const keys = Object.keys(requestBodyExamples.value)\n if (preferred && keys.includes(preferred)) {\n return preferred\n }\n // Keep the current local example when it is still valid, otherwise fall back to the first one\n if (localExampleKey.value && keys.includes(localExampleKey.value)) {\n return localExampleKey.value\n }\n return keys[0] ?? ''\n}\n\n// Set the initial example from the document-wide selection, falling back to the first example.\n// This runs during setup so the server renders the same example as the browser.\nlocalExampleKey.value = resolveExampleKey(selectedExample)\n\n// Follow the document-wide selection when it changes and this operation has that example\nwatch(\n () => selectedExample,\n (preferred) => {\n localExampleKey.value = resolveExampleKey(preferred)\n },\n)\n\n/** Reset the selected example key if the content type changes and the new content type doesn't have the previously selected example */\nwatch(\n () => selectedContentType,\n () => {\n if (\n !Object.keys(requestBodyExamples.value).includes(localExampleKey.value)\n ) {\n // Re-resolve so the new content type still follows the document-wide selection when it has\n // that key, instead of always snapping back to the first example\n localExampleKey.value = resolveExampleKey(selectedExample)\n }\n },\n)\n\n// Keep the parent informed of the resolved key so a test-request button rendered outside this\n// component (e.g. the classic layout header) opens the client with the example the snippet shows\nwatchEffect(() => {\n emit('update:exampleKey', localExampleKey.value)\n})\n\n/** Select an example locally and sync the choice across the document */\nconst selectExample = (key: string) => {\n localExampleKey.value = key\n eventBus.emit('workspace:update:selected-example', key)\n}\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/** Total number of available clients across all option groups */\nconst clientCount = computed(() =>\n clients.value.reduce((total, group) => total + group.options.length, 0),\n)\n\n/** The locally selected client which would include code samples from this operation only */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/**\n * Accessible name for the client picker.\n *\n * On its own the button reads as its current value (\"C Libcurl\"), which never\n * says what activating it does. The visible title stays part of the name so it\n * still matches what is on screen.\n */\nconst clientPickerAriaLabel = computed(() =>\n [clientPickerLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\n/**\n * Accessible name for the focusable code sample, e.g. \"Code sample: Shell cURL\".\n *\n * Screen readers announce only the name and role when focus lands on the scroller, so the\n * name tells the user both what the region is and which client it is generated for.\n */\nconst codeSampleAriaLabel = computed(() =>\n [codeSampleLabel, localSelectedClient.value?.title]\n .filter(Boolean)\n .join(': '),\n)\n\nconst elem = ref<ComponentPublicInstance | null>(null)\nconst visible = useExampleVisibility(elem)\nconst externalExamples = useExternalExamples(\n () =>\n getOperationExamples(operation, localExampleKey.value, selectedContentType),\n () => visible.value,\n)\nconst resolvedOperation = computed(() =>\n resolveOperationExamples(\n operation,\n localExampleKey.value,\n selectedContentType,\n externalExamples.resolve,\n ),\n)\n\n/** Keep the picker available because it also selects the example opened by Test Request. */\nconst showExamplePicker = computed(\n () => Object.keys(requestBodyExamples.value).length > 1,\n)\n\n/** Generate HAR data for webhook requests */\nconst webhookHar = computed(() => {\n if (!isWebhook) return null\n\n try {\n return operationToHar({\n operation: resolvedOperation.value,\n method,\n path,\n example: localExampleKey.value,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n })\n } catch (error) {\n console.error('[webhookHar]', error)\n return null\n }\n})\n\n/** Generate the code snippet for the selected example */\nconst generatedTemplate = computed<string | null>(() => {\n if (isWebhook) {\n return webhookHar.value?.postData?.text ?? ''\n }\n\n return generateCodeSnippet({\n // Only required parameters are shown in code examples; optional parameters\n // are omitted unless explicitly enabled via `x-disabled: false`.\n defaultDisabledParameters: true,\n includeDefaultHeaders: integration === 'client',\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation: resolvedOperation.value,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: localExampleKey.value,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n })\n})\n\n/** Resolve custom templates at render time so auth changes never mutate the document. */\nconst resolvedCredentials = computed(() =>\n !isWebhook &&\n localSelectedClient.value?.id.startsWith('custom/') &&\n generatedTemplate.value !== null &&\n securitySchemes.some((scheme) => 'x-scalar-credential-placeholders' in scheme)\n ? resolveCredentialPlaceholders(generatedTemplate.value, securitySchemes)\n : undefined,\n)\n\nconst generatedCode = computed(\n () => resolvedCredentials.value?.content ?? generatedTemplate.value,\n)\n\n/** Mask inserted secrets before escaping or syntax tokenization can split their values. */\nconst displayCode = computed(\n () => resolvedCredentials.value?.displayContent ?? generatedCode.value,\n)\n\n/** The language for the code block, used for syntax highlighting */\nconst codeBlockLanguage = computed(() => {\n if (isWebhook) {\n return webhookLanguage.value\n }\n\n return localSelectedClient.value?.lang\n})\n\n/** Determine the language for webhook content based on MIME type */\nconst webhookLanguage = computed<string>(() => {\n if (!webhookHar.value?.postData) return 'json'\n\n const contentType = webhookHar.value.postData.mimeType\n if (contentType?.includes('json')) return 'json'\n if (contentType?.includes('xml')) return 'xml'\n if (contentType?.includes('yaml') || contentType?.includes('yml'))\n return 'yaml'\n if (contentType?.includes('text/plain')) return 'text'\n\n return 'json'\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() =>\n resolvedCredentials.value ? [] : getSecrets(securitySchemes),\n)\n\n/** Set custom example, or update the selected HTTP client globally */\nconst selectClient = (option: ClientOption) => {\n // We need to freeze the ui to prevent scrolling as the clients change\n if (elem.value) {\n const unfreeze = freezeElement(elem.value.$el)\n setTimeout(() => {\n unfreeze()\n }, 300)\n }\n // Update to the local example\n localSelectedClient.value = option\n\n // Sync the selection globally so other operations follow along. Custom samples\n // sync too (keyed by language), so picking e.g. the Python SDK example here\n // shows the Python example on every operation that ships one.\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n// Virtualize the code block if it's too large\n// This prevents the entire app from freezing up if there's a massive example\n// We set a lower threshold here as code examples can get quite large\nconst VIRTUALIZATION_THRESHOLD = 20_000\n\nconst shouldVirtualize = computed(\n () => (generatedCode.value?.length ?? 0) > VIRTUALIZATION_THRESHOLD,\n)\n\nconst id = useId()\n</script>\n<template>\n <ScalarCard\n v-if=\"\n generatedCode === null || generatedCode || externalExamples.pending.value\n \"\n ref=\"elem\"\n class=\"request-card dark-mode\">\n <!-- Header -->\n <ScalarCardHeader class=\"pr-2.5\">\n <span class=\"sr-only\">Request Example for</span>\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <span\n v-if=\"generateLabel\"\n v-html=\"generateLabel()\" />\n <slot name=\"header\" />\n <!-- Client picker -->\n <template\n v-if=\"!isWebhook && clientCount\"\n #actions>\n <!-- Multiple clients: render a dropdown to switch between them -->\n <ScalarCombobox\n v-if=\"clientCount > 1\"\n v-slot=\"{ open }\"\n class=\"max-h-80\"\n :filterFn=\"filterClientsByQuery\"\n :inputLabel=\"clientSearchLabel\"\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n teleport\n @update:modelValue=\"selectClient($event as ClientOption)\">\n <ScalarButton\n :aria-label=\"clientPickerAriaLabel\"\n 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\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <!--\n Follow this picker's own state. The `ui-open:` variant also matches any open\n Headless UI ancestor, such as an expanded operation in the classic layout.\n -->\n <ScalarIconCaretDown\n class=\"mt-px size-3 transition-transform duration-100\"\n :class=\"{ 'rotate-180': open }\"\n weight=\"bold\" />\n </ScalarButton>\n </ScalarCombobox>\n <!-- Single client: just show its label, no need for a dropdown -->\n <span\n v-else\n class=\"text-c-2 flex h-full w-fit items-center px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\">\n {{ localSelectedClient?.title }}\n </span>\n </template>\n </ScalarCardHeader>\n\n <!-- Code snippet -->\n <ScalarCardSection class=\"request-editor-section custom-scroll p-0\">\n <div\n v-if=\"externalExamples.pending.value\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n <template v-if=\"externalExamples.failed.value\">\n Could not load this example.\n <ScalarButton\n size=\"sm\"\n variant=\"ghost\"\n @click=\"externalExamples.retry\">\n Retry\n </ScalarButton>\n </template>\n <template v-else>Loading example…</template>\n </div>\n <div\n v-else-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ codeSampleUnavailable }}\n </div>\n <div\n v-else\n :id=\"`${id}-example`\"\n class=\"code-snippet group/code-block relative\">\n <ScalarCodeBlock\n v-if=\"!shouldVirtualize\"\n class=\"h-full bg-transparent\"\n :content=\"displayCode ?? ''\"\n :copyContent=\"resolvedCredentials ? (generatedCode ?? '') : undefined\"\n :hideCredentials=\"secretCredentials\"\n :label=\"codeSampleAriaLabel\"\n :lang=\"codeBlockLanguage\"\n lineNumbers />\n <template v-else>\n <ScalarCodeBlockCopy\n :aria-controls=\"`${id}-virtual-code`\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5 z-1\"\n :content=\"generatedCode\"\n :lang=\"codeBlockLanguage\" />\n <ScalarVirtualText\n :id=\"`${id}-virtual-code`\"\n aria-label=\"Request code sample\"\n containerClass=\"custom-scroll scalar-code-block flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"20\"\n role=\"region\"\n :text=\"displayCode ?? ''\" />\n </template>\n </div>\n </ScalarCardSection>\n\n <!-- Footer -->\n <ScalarCardFooter\n v-if=\"showExamplePicker || $slots.footer || $slots['footer-start']\"\n class=\"request-card-footer\"\n :class=\"{\n 'request-card-footer--wraps':\n showExamplePicker || $slots['footer-start'],\n }\">\n <!-- Example picker -->\n <div\n v-if=\"showExamplePicker\"\n class=\"request-card-footer-addon\">\n <template v-if=\"Object.keys(requestBodyExamples).length\">\n <ExamplePicker\n :examples=\"requestBodyExamples\"\n :modelValue=\"localExampleKey\"\n @update:modelValue=\"selectExample\" />\n </template>\n </div>\n <!-- Otherwise the start of the footer is free for the caller -->\n <div\n v-else-if=\"$slots['footer-start']\"\n class=\"request-card-footer-start\">\n <slot name=\"footer-start\" />\n </div>\n\n <!-- Footer -->\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </ScalarCardFooter>\n </ScalarCard>\n\n <!-- Fallback card with just method and path in the case of no examples -->\n <ScalarCard\n v-else-if=\"fallback\"\n class=\"request-card dark-mode\">\n <!-- A single row of method, path and actions reads as a header, so it stays on the card -->\n <ScalarCardSection class=\"request-card-simple bg-transparent shadow-none\">\n <div class=\"request-header\">\n <HttpMethod\n as=\"span\"\n class=\"request-method\"\n :method=\"method\" />\n <slot name=\"header\" />\n </div>\n <div\n v-if=\"$slots.footer\"\n class=\"request-card-actions relative max-w-full\">\n <slot\n :exampleName=\"localExampleKey\"\n name=\"footer\" />\n </div>\n </ScalarCardSection>\n </ScalarCard>\n</template>\n<style scoped>\n.request-card {\n color: var(--scalar-color-1);\n font-size: var(--scalar-font-size-3);\n}\n.request-method {\n font-family: var(--scalar-font-code);\n margin-right: 6px;\n}\n.request-card-footer {\n display: flex;\n justify-content: flex-end;\n padding: 6px;\n flex-shrink: 0;\n position: relative;\n}\n/*\n * The example picker or footer-start content keeps room for itself; when the footer is too narrow\n * for everything, the end controls wrap onto a second line instead of squeezing or covering it.\n */\n.request-card-footer--wraps {\n flex-wrap: wrap;\n row-gap: 4px;\n}\n.request-card-footer-start {\n display: flex;\n align-items: center;\n flex: 1 0 auto;\n}\n/*\n * The picker asks for its example name's width, capped at 7em (about eight characters), so on a\n * narrow card the end controls wrap rather than squeeze the name out of view. The cap keeps a long\n * name truncating beside them on wider cards, as before. The picker never grows past its name, and\n * the end margin holds it at the start of the line.\n */\n.request-card-footer-addon {\n display: flex;\n align-items: center;\n\n flex: 1 1 7em;\n min-width: 0;\n max-width: max-content;\n margin-inline-end: auto;\n}\n.request-editor-section {\n display: flex;\n flex: 1;\n}\n/*\n * A long sample is drawn as virtual text with its own copy button rather than a code block, so\n * that button gets the same raised fill a code block gives its button on a card's surface.\n */\n.code-snippet > .scalar-code-copy {\n background: var(--scalar-card-surface-raised, var(--scalar-background-2));\n}\n.request-card-simple {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n\n padding: 8px 8px 8px 12px;\n\n font-size: var(--scalar-small);\n}\n.request-header {\n /* Give spare inline space to the path, while actions fill their own row after wrapping. */\n flex: 999 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.request-card-actions {\n flex: 1 0 auto;\n}\n.code-snippet {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6NA,IAAM6B,KAAOD,GA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EAAsB2F,EAAA,QAAA,UAAA,CAAA,GAAA,KAAA,GAAA,EAAA,C,IAGhBrG,EAAAA,OAAO,UADfE,EAAA,GAAAO,EAMM,OANNiB,GAMM,CAHJhB,EAEkB2F,EAAA,QAAA,UAAA,EADf,aAAajE,EAAA,MAAe,GAAA,KAAA,GAAA,EAAA,C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import e from "./ExamplePicker.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
-
|
|
2
|
+
// src/code-example/components/ExamplePicker.vue
|
|
3
3
|
var t = e;
|
|
4
|
-
//#endregion
|
|
5
4
|
export { t as default };
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=ExamplePicker.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExamplePicker.vue.js","names":["
|
|
1
|
+
{"version":3,"file":"ExamplePicker.vue.js","names":["ExamplePicker_vue_vue_type_script_setup_true_lang_default","ExamplePicker_default"],"sources":[],"mappings":""}
|
|
@@ -3,7 +3,7 @@ import { computed as t, createBlock as n, createElementVNode as r, createVNode a
|
|
|
3
3
|
import { ScalarButton as m } from "@scalar/components/button";
|
|
4
4
|
import { ScalarListbox as h } from "@scalar/components/listbox";
|
|
5
5
|
import { ScalarIconCaretDown as g } from "@scalar/icons";
|
|
6
|
-
|
|
6
|
+
// src/code-example/components/ExamplePicker.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var _ = { class: "min-w-0 flex-1 truncate" }, v = /*@__PURE__*/ a({
|
|
8
8
|
inheritAttrs: !1,
|
|
9
9
|
__name: "ExamplePicker",
|
|
@@ -43,7 +43,6 @@ var _ = { class: "min-w-0 flex-1 truncate" }, v = /*@__PURE__*/ a({
|
|
|
43
43
|
}, 8, ["modelValue", "options"]));
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
//#endregion
|
|
47
46
|
export { v as default };
|
|
48
47
|
|
|
49
48
|
//# sourceMappingURL=ExamplePicker.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import e from "./HttpMethod.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
-
|
|
2
|
+
// src/code-example/components/HttpMethod.vue
|
|
3
3
|
var t = e;
|
|
4
|
-
//#endregion
|
|
5
4
|
export { t as default };
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=HttpMethod.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMethod.vue.js","names":["
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.js","names":["HttpMethod_vue_vue_type_script_setup_true_lang_default","HttpMethod_default"],"sources":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed as e, createBlock as t, createTextVNode as n, defineComponent as r, normalizeClass as i, normalizeStyle as a, openBlock as o, renderSlot as s, resolveDynamicComponent as c, toDisplayString as l, unref as u, withCtx as d } from "vue";
|
|
2
2
|
import { getHttpMethodInfo as f } from "@scalar/helpers/http/http-info";
|
|
3
3
|
import { isHttpMethod as p } from "@scalar/helpers/http/is-http-method";
|
|
4
|
-
|
|
4
|
+
// src/code-example/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var m = /*@__PURE__*/ r({
|
|
6
6
|
__name: "HttpMethod",
|
|
7
7
|
props: {
|
|
@@ -25,7 +25,6 @@ var m = /*@__PURE__*/ r({
|
|
|
25
25
|
}, 8, ["class", "style"]));
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
//#endregion
|
|
29
28
|
export { m as default };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=HttpMethod.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/code-example/helpers/filter-clients-by-query.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
let n = t.toLowerCase();
|
|
4
4
|
return e.label.toLowerCase().includes(n) || e.clientKey.toLowerCase().includes(n) || e.lang.toLowerCase().includes(n);
|
|
@@ -15,7 +15,6 @@ var e = (e, t) => {
|
|
|
15
15
|
}
|
|
16
16
|
return r.filter((t) => e(t, a));
|
|
17
17
|
});
|
|
18
|
-
//#endregion
|
|
19
18
|
export { n as filterClientsByQuery };
|
|
20
19
|
|
|
21
20
|
//# sourceMappingURL=filter-clients-by-query.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AVAILABLE_CLIENTS as e } from "@scalar/snippetz";
|
|
2
|
-
|
|
2
|
+
// src/code-example/helpers/find-client.ts
|
|
3
3
|
var t = "shell/curl", n = (t) => e.includes(t), r = (e) => n(e) || typeof e == "string" && e.startsWith("custom/"), i = (e, t) => {
|
|
4
4
|
let n = (t) => {
|
|
5
5
|
for (let n of e) {
|
|
@@ -14,7 +14,6 @@ var t = "shell/curl", n = (t) => e.includes(t), r = (e) => n(e) || typeof e == "
|
|
|
14
14
|
}
|
|
15
15
|
return r || (n("shell/curl") ?? e[0]?.options[0]);
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { t as DEFAULT_CLIENT, i as findClient, n as isClient, r as isSelectedClient };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=find-client.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { capitalize as e } from "@scalar/helpers/string/capitalize";
|
|
2
|
-
|
|
2
|
+
// src/code-example/helpers/format-language.ts
|
|
3
3
|
var t = {
|
|
4
4
|
c: "C",
|
|
5
5
|
clojure: "Clojure",
|
|
@@ -50,7 +50,6 @@ var t = {
|
|
|
50
50
|
}, n = (n) => {
|
|
51
51
|
if (n) return t[n.toLowerCase()] ?? e(n);
|
|
52
52
|
};
|
|
53
|
-
//#endregion
|
|
54
53
|
export { n as formatLanguage };
|
|
55
54
|
|
|
56
55
|
//# sourceMappingURL=format-language.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { capitalize as e } from "vue";
|
|
2
2
|
import { AVAILABLE_CLIENTS as t, snippetz as n } from "@scalar/snippetz";
|
|
3
|
-
|
|
3
|
+
// src/code-example/helpers/generate-client-options.ts
|
|
4
4
|
var r = (e) => {
|
|
5
5
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
6
6
|
return e.map((e) => {
|
|
@@ -37,7 +37,6 @@ var r = (e) => {
|
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
//#endregion
|
|
41
40
|
export { i as generateClientOptions, r as getCustomClientIds };
|
|
42
41
|
|
|
43
42
|
//# sourceMappingURL=generate-client-options.js.map
|
|
@@ -30,11 +30,12 @@ type GenerateCodeSnippetProps = {
|
|
|
30
30
|
/** Selected oneOf/anyOf variants for nested request body example generation. */
|
|
31
31
|
/** Originating OpenAPI version, used for XML mapping rules. */
|
|
32
32
|
openapiVersion?: string;
|
|
33
|
+
jsonSchemaDialect?: string;
|
|
33
34
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
34
35
|
/** Whether to disable parameters by default. */
|
|
35
36
|
defaultDisabledParameters?: boolean;
|
|
36
37
|
};
|
|
37
38
|
/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */
|
|
38
|
-
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, openapiVersion, requestBodyCompositionSelection, defaultDisabledParameters, }: GenerateCodeSnippetProps) => string | null;
|
|
39
|
+
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, defaultDisabledParameters, }: GenerateCodeSnippetProps) => string | null;
|
|
39
40
|
export {};
|
|
40
41
|
//# sourceMappingURL=generate-code-snippet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/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AACpH,eAAO,MAAM,mBAAmB,GAAI,
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAE3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAEjH,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,2BAA2B,CAAA;AAKvF,KAAK,wBAAwB,GAAG;IAC9B,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,EAAE,0BAA0B,EAAE,CAAA;IAC7C,mEAAmE;IACnE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B,qFAAqF;IACrF,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,gFAAgF;IAChF,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD,gDAAgD;IAChD,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED,oHAAoH;AACpH,eAAO,MAAM,mBAAmB,GAAI,+OAgBjC,wBAAwB,KAAG,MAAM,GAAG,IAqDtC,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getCustomClientIds as e } from "./generate-client-options.js";
|
|
2
2
|
import { getSnippet as t } from "./get-snippet.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { operationToHar as n } from "./operation-to-har/operation-to-har.js";
|
|
4
|
+
import { CookieSerializationError as r } from "./operation-to-har/process-parameters.js";
|
|
5
5
|
import { getResolvedRef as i } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
|
-
|
|
7
|
-
var a = ({ clientId: a, customCodeSamples: o, includeDefaultHeaders: s = !1, operation: c, method: l, path: u, example: d, contentType: f, server: p, securitySchemes: m, globalCookies: h, openapiVersion: g,
|
|
6
|
+
// src/code-example/helpers/generate-code-snippet.ts
|
|
7
|
+
var a = ({ clientId: a, customCodeSamples: o, includeDefaultHeaders: s = !1, operation: c, method: l, path: u, example: d, contentType: f, server: p, securitySchemes: m, globalCookies: h, openapiVersion: g, jsonSchemaDialect: _, requestBodyCompositionSelection: v, defaultDisabledParameters: y }) => {
|
|
8
8
|
try {
|
|
9
9
|
if (!a) return "";
|
|
10
10
|
if (a.startsWith("custom")) {
|
|
@@ -16,7 +16,7 @@ var a = ({ clientId: a, customCodeSamples: o, includeDefaultHeaders: s = !1, ope
|
|
|
16
16
|
let r = i(c.requestBody)?.content ?? {}, s = f ?? Object.keys(r)[0], l = d ?? Object.keys(r[s ?? ""]?.examples ?? {})[0], u = n.find((e) => e.example === l && e.contentType === s) ?? n.find((e) => e.example === l && e.contentType === void 0);
|
|
17
17
|
return typeof u?.source == "string" ? u.source : null;
|
|
18
18
|
}
|
|
19
|
-
let
|
|
19
|
+
let r = n({
|
|
20
20
|
operation: c,
|
|
21
21
|
contentType: f,
|
|
22
22
|
method: l,
|
|
@@ -27,15 +27,15 @@ var a = ({ clientId: a, customCodeSamples: o, includeDefaultHeaders: s = !1, ope
|
|
|
27
27
|
globalCookies: h,
|
|
28
28
|
includeDefaultHeaders: s,
|
|
29
29
|
openapiVersion: g,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
jsonSchemaDialect: _,
|
|
31
|
+
requestBodyCompositionSelection: v,
|
|
32
|
+
defaultDisabledParameters: y
|
|
33
|
+
}), [b, x] = a.split("/"), [S, C] = t(b, x, r);
|
|
34
|
+
return S ? (console.error("[generateCodeSnippet]", S), S.message ?? "Error generating code snippet") : C;
|
|
34
35
|
} catch (e) {
|
|
35
|
-
return console.error("[generateCodeSnippet]", e), e instanceof
|
|
36
|
+
return console.error("[generateCodeSnippet]", e), e instanceof r ? e.message : "Error generating code snippet";
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
//#endregion
|
|
39
39
|
export { a as generateCodeSnippet };
|
|
40
40
|
|
|
41
41
|
//# sourceMappingURL=generate-code-snippet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.js","names":["generateCodeSnippet","clientId","ids","getCustomClientIds","customCodeSamples","samples","index","sample","source","content","getResolvedRef","operation","mediaType","contentType","exampleKey","example","harRequest","operationToHar","targetKey","clientKey","error","payload","getSnippet","CookieSerializationError"],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\nimport { CookieSerializationError } from './operation-to-har/process-parameters'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: string\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string | null => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const samples = customCodeSamples.filter((_, index) => ids[index] === clientId)\n if (!samples.some((sample) => sample.example !== undefined)) {\n const source = samples[0]?.source\n return typeof source === 'object' ? null : (source ?? 'Custom example not found')\n }\n\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const mediaType = contentType ?? Object.keys(content)[0]\n const exampleKey = example ?? Object.keys(content[mediaType ?? '']?.examples ?? {})[0]\n const sample =\n samples.find((sample) => sample.example === exampleKey && sample.contentType === mediaType) ??\n samples.find((sample) => sample.example === exampleKey && sample.contentType === undefined)\n return typeof sample?.source === 'string' ? sample.source : null\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n openapiVersion,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return error instanceof CookieSerializationError ? error.message : 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.js","names":["generateCodeSnippet","clientId","ids","getCustomClientIds","customCodeSamples","samples","index","sample","source","content","getResolvedRef","operation","mediaType","contentType","exampleKey","example","harRequest","operationToHar","targetKey","clientKey","error","payload","getSnippet","CookieSerializationError"],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\nimport { CookieSerializationError } from './operation-to-har/process-parameters'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: string\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n /** Originating OpenAPI version, used for XML mapping rules. */\n openapiVersion?: string\n jsonSchemaDialect?: string\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string | null => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const samples = customCodeSamples.filter((_, index) => ids[index] === clientId)\n if (!samples.some((sample) => sample.example !== undefined)) {\n const source = samples[0]?.source\n return typeof source === 'object' ? null : (source ?? 'Custom example not found')\n }\n\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const mediaType = contentType ?? Object.keys(content)[0]\n const exampleKey = example ?? Object.keys(content[mediaType ?? '']?.examples ?? {})[0]\n const sample =\n samples.find((sample) => sample.example === exampleKey && sample.contentType === mediaType) ??\n samples.find((sample) => sample.example === exampleKey && sample.contentType === undefined)\n return typeof sample?.source === 'string' ? sample.source : null\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return error instanceof CookieSerializationError ? error.message : 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;;;AA6CA,IAAaA,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,mBACA,sBACA,oCACA,mCAC6C;CAC7C,IAAI;EACF,IAAI,CAACC,GACH,OAAO;EAIT,IAAIA,EAAS,WAAW,QAAQ,GAAG;GACjC,IAAMC,IAAMC,EAAmBC,CAAiB,GAC1CC,IAAUD,EAAkB,QAAQ,GAAG,MAAUF,EAAII,OAAWL,CAAQ;GAC9E,IAAI,CAACI,EAAQ,MAAM,MAAWE,EAAO,YAAY,KAAA,CAAS,GAAG;IAC3D,IAAMC,IAASH,EAAQ,EAAE,EAAE;IAC3B,OAAO,OAAOG,KAAW,WAAW,OAAQA,KAAU;GACxD;GAEA,IAAMC,IAAUC,EAAeC,EAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7DC,IAAYC,KAAe,OAAO,KAAKJ,CAAO,CAAC,CAAC,IAChDK,IAAaC,KAAW,OAAO,KAAKN,EAAQG,KAAa,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,IAC9EL,IACJF,EAAQ,MAAM,MAAWE,EAAO,YAAYO,KAAcP,EAAO,gBAAgBK,CAAS,KAC1FP,EAAQ,MAAM,MAAWE,EAAO,YAAYO,KAAcP,EAAO,gBAAgB,KAAA,CAAS;GAC5F,OAAO,OAAOA,GAAQ,UAAW,WAAWA,EAAO,SAAS;EAC9D;EAEA,IAAMS,IAAaC,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GAEK,CAACC,GAAWC,KAAalB,EAAS,MAAM,GAAG,GAE3C,CAACmB,GAAOC,KAAWC,EAAWJ,GAAWC,GAAWH,CAAU;EAMpE,OALII,KACF,QAAQ,MAAM,yBAAyBA,CAAK,GACrCA,EAAM,WAAW,mCAGnBC;CACT,SAASD,GAAO;EAEd,OADA,QAAQ,MAAM,yBAAyBA,CAAK,GACrCA,aAAiBG,IAA2BH,EAAM,UAAU;CACrE;AACF"}
|
|
@@ -2,7 +2,7 @@ import { getResolvedAsyncApiRef as e } from "@scalar/workspace-store/helpers/get
|
|
|
2
2
|
import { getAllChannelMessages as t, resolveOperationChannel as n, resolveOperationWithTraits as r } from "@scalar/workspace-store/channel-example";
|
|
3
3
|
import { getNameFromRef as i } from "@scalar/workspace-store/helpers/get-name-from-ref";
|
|
4
4
|
import { resolveTraits as a } from "@scalar/workspace-store/helpers/resolve-traits";
|
|
5
|
-
|
|
5
|
+
// src/code-example/helpers/get-asyncapi-example-context.ts
|
|
6
6
|
var o = (o, s) => {
|
|
7
7
|
let c = e(o.operations?.[s]);
|
|
8
8
|
if (!c) return;
|
|
@@ -27,7 +27,6 @@ var o = (o, s) => {
|
|
|
27
27
|
messages: f
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { o as getAsyncApiExampleContext };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=get-asyncapi-example-context.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { formatLanguage as e } from "./format-language.js";
|
|
2
|
+
import { getCustomClientIds as t } from "./generate-client-options.js";
|
|
3
3
|
import { CODE_EXAMPLES_GROUP_LABEL as n } from "./get-custom-code-samples.js";
|
|
4
|
-
|
|
4
|
+
// src/code-example/helpers/get-clients.ts
|
|
5
5
|
var r = (r, i, a = n) => {
|
|
6
6
|
if (!r.length) return i;
|
|
7
|
-
let o =
|
|
8
|
-
for (let [
|
|
9
|
-
let r = o[
|
|
10
|
-
if (!r || o.indexOf(r) !==
|
|
7
|
+
let o = t(r), s = /* @__PURE__ */ new Map();
|
|
8
|
+
for (let [t, n] of r.entries()) {
|
|
9
|
+
let r = o[t];
|
|
10
|
+
if (!r || o.indexOf(r) !== t) continue;
|
|
11
11
|
let i = typeof n.group == "string" && n.group.trim() || a, c = s.get(i) ?? {
|
|
12
12
|
label: i,
|
|
13
13
|
key: "custom",
|
|
14
14
|
options: []
|
|
15
|
-
}, l = n.label ||
|
|
15
|
+
}, l = n.label || e(n.lang) || r;
|
|
16
16
|
c.options.push({
|
|
17
17
|
id: r,
|
|
18
18
|
lang: n.lang || "plaintext",
|
|
@@ -23,7 +23,6 @@ var r = (r, i, a = n) => {
|
|
|
23
23
|
}
|
|
24
24
|
return [...s.values(), ...i];
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { r as getClients };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=get-clients.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/code-example/helpers/get-custom-code-samples.ts
|
|
2
2
|
var e = (e, t) => Object.entries(e ?? {}).map(([e, n]) => ({
|
|
3
3
|
lang: e,
|
|
4
4
|
source: n,
|
|
@@ -36,7 +36,6 @@ var e = (e, t) => Object.entries(e ?? {}).map(([e, n]) => ({
|
|
|
36
36
|
].flatMap((e) => a[e] ?? [])
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
-
//#endregion
|
|
40
39
|
export { i as CODE_EXAMPLES_GROUP_LABEL, a as getCustomCodeSamples };
|
|
41
40
|
|
|
42
41
|
//# sourceMappingURL=get-custom-code-samples.js.map
|
|
@@ -3,7 +3,7 @@ import { isObject as t } from "@scalar/helpers/object/is-object";
|
|
|
3
3
|
import { resolveAsyncApiSchema as n } from "@scalar/workspace-store/helpers/resolve-async-api-schema";
|
|
4
4
|
import { snapshotSchema as r } from "@scalar/workspace-store/helpers/snapshot-schema";
|
|
5
5
|
import { getExampleFromSchema as i } from "@scalar/workspace-store/request-example";
|
|
6
|
-
|
|
6
|
+
// src/code-example/helpers/get-generated-payload-example.ts
|
|
7
7
|
var a = (n, r = /* @__PURE__ */ new Set()) => {
|
|
8
8
|
let i = e(n);
|
|
9
9
|
return i === !1 ? !0 : !t(i) || r.has(i) ? !1 : (r.add(i), Array.isArray(i.allOf) && i.allOf.some((e) => a(e, r)));
|
|
@@ -16,7 +16,6 @@ var a = (n, r = /* @__PURE__ */ new Set()) => {
|
|
|
16
16
|
let u = r(l);
|
|
17
17
|
return i(u, { emptyString: "string" });
|
|
18
18
|
};
|
|
19
|
-
//#endregion
|
|
20
19
|
export { o as getGeneratedPayloadExample };
|
|
21
20
|
|
|
22
21
|
//# sourceMappingURL=get-generated-payload-example.js.map
|
|
@@ -3,7 +3,7 @@ import { isJsonMediaType as t } from "@scalar/helpers/http/is-json-media-type";
|
|
|
3
3
|
import { isXmlMediaType as n } from "@scalar/helpers/http/is-xml-media-type";
|
|
4
4
|
import { parseMimeType as r } from "@scalar/helpers/http/mime-type";
|
|
5
5
|
import { prettyPrintJson as i } from "@scalar/helpers/json/pretty-print-json";
|
|
6
|
-
|
|
6
|
+
// src/code-example/helpers/get-message-example-content.ts
|
|
7
7
|
var a = (a, o) => {
|
|
8
8
|
if (a === void 0) return;
|
|
9
9
|
let s = o === void 0 || t(o), c = Array.isArray(a) || e(a), l = !s && c, { subtype: u } = r(o), d = s || l ? "json" : n(o) ? "xml" : u === "yaml" || u === "x-yaml" || u.endsWith("+yaml") ? "yaml" : "plaintext";
|
|
@@ -23,7 +23,6 @@ var a = (a, o) => {
|
|
|
23
23
|
structural: l
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { a as getMessageExampleContent };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=get-message-example-content.js.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { encode as e } from "js-base64";
|
|
2
|
-
|
|
2
|
+
// src/code-example/helpers/get-secrets.ts
|
|
3
3
|
var t = (t) => t.flatMap((t) => t.type === "apiKey" ? t["x-scalar-secret-token"] : t?.type === "http" ? [
|
|
4
4
|
t["x-scalar-secret-token"],
|
|
5
5
|
t["x-scalar-secret-username"],
|
|
6
6
|
t["x-scalar-secret-password"],
|
|
7
7
|
e(`${t["x-scalar-secret-username"]}:${t["x-scalar-secret-password"]}`)
|
|
8
8
|
] : t.type === "oauth2" ? Object.values(t.flows).map((e) => e["x-scalar-secret-token"]) : []).filter(Boolean);
|
|
9
|
-
//#endregion
|
|
10
9
|
export { t as getSecrets };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=get-secrets.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { snippetz as e } from "@scalar/snippetz";
|
|
2
|
-
|
|
2
|
+
// src/code-example/helpers/get-snippet.ts
|
|
3
3
|
var t = "ws://replace.me", n = (n, r, i) => {
|
|
4
4
|
try {
|
|
5
5
|
if (!i.url) return [/* @__PURE__ */ Error("Please enter a URL to see a code snippet"), null];
|
|
@@ -23,7 +23,6 @@ var t = "ws://replace.me", n = (n, r, i) => {
|
|
|
23
23
|
}
|
|
24
24
|
return [/* @__PURE__ */ Error("No snippet found"), null];
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { n as getSnippet };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=get-snippet.js.map
|
|
@@ -40,6 +40,7 @@ export type OperationToHarProps = {
|
|
|
40
40
|
*/
|
|
41
41
|
/** Originating OpenAPI version, used for version-specific serialization. */
|
|
42
42
|
openapiVersion?: string;
|
|
43
|
+
jsonSchemaDialect?: string;
|
|
43
44
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
44
45
|
/**
|
|
45
46
|
* Whether to disable parameters by default.
|
|
@@ -69,5 +70,5 @@ export type OperationToHarProps = {
|
|
|
69
70
|
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
70
71
|
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
71
72
|
*/
|
|
72
|
-
export declare const operationToHar: ({ includeDefaultHeaders, operation, contentType, method, path, server, example, securitySchemes, globalCookies, openapiVersion, requestBodyCompositionSelection, defaultDisabledParameters, }: OperationToHarProps) => HarRequest;
|
|
73
|
+
export declare const operationToHar: ({ includeDefaultHeaders, operation, contentType, method, path, server, example, securitySchemes, globalCookies, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, defaultDisabledParameters, }: OperationToHarProps) => HarRequest;
|
|
73
74
|
//# sourceMappingURL=operation-to-har.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI
|
|
1
|
+
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,kNAc5B,mBAAmB,KAAG,UA+JxB,CAAA"}
|