@scalar/api-client 3.28.1 → 3.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/style.css +20 -20
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js +4 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +1 -4
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +2 -0
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue_vue_type_script_setup_true_lang.js +5 -0
- package/dist/v2/blocks/request-block/RequestBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +2 -0
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue_vue_type_script_setup_true_lang.js +6 -2
- package/dist/v2/blocks/request-block/components/RequestBody.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts +1 -0
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js +7 -5
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js +2 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +10 -3
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/types/options.d.ts +1 -1
- package/dist/v2/types/options.d.ts.map +1 -1
- package/dist/vue-styles.css +7 -7
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestBodyForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","RequestTable"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport { computed, ref, watch } from 'vue'\n\nimport { useFileDialog } from '@/hooks/use-file-dialog'\nimport RequestTable from '@/v2/blocks/request-block/components/RequestTable.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n getFormBodyRows,\n getFormBodyValue,\n} from '@/v2/blocks/request-block/helpers/get-form-body-rows'\nimport { groupFormBodyFiles } from '@/v2/blocks/request-block/helpers/group-form-body-files'\n\nconst {\n example,\n bodySchema,\n encoding,\n selectedContentType,\n environment,\n compositionSelection,\n} = defineProps<{\n example: ExampleObject | undefined | null\n /** Resolved schema for the form body so the table can show enums and validation per field */\n bodySchema?: SchemaObject\n /** Encoding overrides for individual multipart fields. */\n encoding?: MediaTypeObject['encoding']\n /** Selected request-body variants, shared with example generation and serialization. */\n compositionSelection?: Record<string, number>\n selectedContentType: string\n environment: XScalarEnvironment\n}>()\n\nconst emit = defineEmits<{\n (\n e: 'update:formValue',\n payload: ApiReferenceEvents['operation:update:requestBody:formValue']['payload'],\n ): void\n}>()\n\n/** Local state for form body rows */\nconst localFormBodyRows = ref<TableRow[]>([])\n\nconst formFields = computed(() =>\n selectedContentType === 'multipart/form-data'\n ? groupFormBodyFiles(localFormBodyRows.value)\n : localFormBodyRows.value.map((data, index) => ({\n data,\n sourceIndices: [index],\n })),\n)\nconst displayedRows = computed<TableRow[]>(() =>\n formFields.value.map((field) => field.data),\n)\n\n/** Sync the local form body rows with the example and schema */\nwatch(\n () =>\n [\n example,\n bodySchema,\n selectedContentType,\n compositionSelection,\n encoding,\n ] as const,\n ([newExample, schema, contentType, selection, fieldEncoding]) => {\n localFormBodyRows.value = getFormBodyRows(\n newExample,\n contentType,\n schema,\n selection,\n fieldEncoding,\n )\n },\n { immediate: true },\n)\n\n/** Undeclared fields follow additionalProperties instead of losing uploads whenever a schema exists. */\nconst allowUnknownFileUploads = computed<boolean>(() => {\n const schema = resolveFormSchema(bodySchema, compositionSelection)\n const additional =\n schema && 'additionalProperties' in schema\n ? schema.additionalProperties\n : undefined\n return typeof additional === 'object'\n ? isFileSchema(resolveFormSchema(additional) ?? { __scalar_: '' })\n : additional !== false\n})\n\nconst handleUpdateFormValue = (rows: TableRow[]): void => {\n emit(\n 'update:formValue',\n rows.map((row) => ({\n name: row.name,\n value:\n selectedContentType === 'multipart/form-data'\n ? getFormBodyValue(row)\n : (row.value as string | File),\n isDisabled: row.isDisabled ?? false,\n ...(row.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n ...(selectedContentType === 'multipart/form-data' && row.isArray\n ? { isArray: true }\n : {}),\n })),\n )\n}\n\n/** Update a row in the table, combines with the previous data so we emit a whole row */\nconst handleUpsertRow = (\n index: number | number[],\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n): void => {\n const indices = Array.isArray(index) ? index : [index]\n // Add new row\n if (\n indices[0] !== undefined &&\n indices[0] >= localFormBodyRows.value.length\n ) {\n localFormBodyRows.value = [\n ...localFormBodyRows.value,\n { name: '', value: '', ...payload, isDisabled: false },\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!indices.includes(i)) {\n return row\n }\n\n const valueChanged = 'value' in payload && payload.value !== row.value\n const disabledChanged =\n payload.isDisabled !== undefined && payload.isDisabled !== row.isDisabled\n\n return {\n ...row,\n ...payload,\n // File selection bypasses the text input, but also expresses intent to send a value.\n ...(valueChanged && payload.value !== undefined && row.isDisabledByDefault\n ? { isDisabled: false }\n : {}),\n // Preserve untouched defaults while keeping deliberate checkbox choices explicit.\n isDisabledByDefault:\n row.isDisabledByDefault && !valueChanged && !disabledChanged,\n }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remember individual choices while the whole file field is temporarily disabled. */\nconst disabledFileChoices = new WeakMap<File, boolean>()\n\n/** Apply field edits to all its parts without replacing sibling files with the first file. */\nconst handleFieldUpsert = (\n index: number,\n payload: Parameters<typeof handleUpsertRow>[1],\n): void => {\n const field = formFields.value[index]\n if (\n field?.data.files?.length &&\n payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ) {\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!field.sourceIndices.includes(i) || !(row.value instanceof File)) {\n return row\n }\n if (payload.isDisabled) {\n disabledFileChoices.set(row.value, row.isDisabled ?? false)\n }\n const isDisabled =\n payload.isDisabled || (disabledFileChoices.get(row.value) ?? false)\n if (!payload.isDisabled) {\n disabledFileChoices.delete(row.value)\n }\n return { ...row, isDisabled, isDisabledByDefault: false }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(\n field?.sourceIndices ?? localFormBodyRows.value.length,\n field?.data.files\n ? {\n ...(payload.name !== undefined ? { name: payload.name } : {}),\n ...(payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ? { isDisabled: payload.isDisabled }\n : {}),\n }\n : payload,\n )\n}\n\n/** Delete a row from the table */\nconst handleDeleteRow = (index: number): void => {\n const indices = formFields.value[index]?.sourceIndices ?? [index]\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => !indices.includes(i),\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remove a selected file, retaining one empty field after the last file is removed. */\nconst handleRemoveFile = (index: number, fileIndex?: number): void => {\n const field = formFields.value[index]\n const sourceIndex = fileIndex ?? field?.sourceIndices[0] ?? index\n if (field?.data.files) {\n const remaining = localFormBodyRows.value.filter(\n (row, i) =>\n field.sourceIndices.includes(i) &&\n i !== sourceIndex &&\n row.value instanceof File,\n )\n const original = localFormBodyRows.value[sourceIndex]\n if (!original) {\n return\n }\n const replacement = remaining.length\n ? remaining\n : [{ ...original, value: '[]', isArray: true }]\n localFormBodyRows.value = localFormBodyRows.value.flatMap((row, i) => {\n if (i === field.sourceIndices[0]) {\n return replacement\n }\n return field.sourceIndices.includes(i) ? [] : [row]\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(sourceIndex, { value: undefined })\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number): void => {\n const field = formFields.value[index]\n const sourceIndices = field?.sourceIndices ?? [localFormBodyRows.value.length]\n const sourceIndex = sourceIndices[0] ?? localFormBodyRows.value.length\n const currentRow = localFormBodyRows.value[sourceIndex]\n // Array fields accept multiple files, serialized as separate multipart parts under the same name.\n const allowMultiple = Boolean(\n currentRow?.schema && isArraySchema(currentRow.schema),\n )\n\n const { open } = useFileDialog({\n onChange: (files) => {\n const selected = files ? Array.from(files) : []\n if (selected.length === 0) {\n return\n }\n\n // Every selected file shares the field key, falling back to the first file name when\n // the row has no name yet (e.g. schema-less requests).\n const fieldName = currentRow?.name || selected[0]?.name || ''\n\n // Keep a selection together beside its field, and emit once so consumers never\n // observe a partially applied selection.\n const selectedRows: TableRow[] = selected.map((file) => ({\n ...currentRow,\n name: fieldName,\n value: file,\n // Selecting files enables untouched optional fields while preserving explicit choices.\n isDisabled: field?.data.isDisabledByDefault\n ? false\n : (field?.data.isDisabled ?? false),\n isDisabledByDefault: false,\n }))\n const existingFiles = field?.data.files\n ? localFormBodyRows.value.filter(\n (row, i) => sourceIndices.includes(i) && row.value instanceof File,\n )\n : []\n const remaining = localFormBodyRows.value.filter(\n (_, i) => !sourceIndices.includes(i),\n )\n localFormBodyRows.value = [\n ...remaining.slice(0, sourceIndex),\n ...existingFiles,\n ...selectedRows,\n ...remaining.slice(sourceIndex),\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n },\n multiple: allowMultiple,\n accept: '*/*',\n })\n void open()\n}\n</script>\n\n<template>\n <!-- Form Data -->\n <template v-if=\"selectedContentType === 'multipart/form-data'\">\n <RequestTable\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"displayedRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"handleRemoveFile\"\n @updateFile=\"\n (index, disabled) => handleUpsertRow(index, { isDisabled: disabled })\n \"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleFieldUpsert\" />\n </template>\n\n <!-- Form URL Encoded -->\n <template v-else>\n <RequestTable\n :data=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n @deleteRow=\"handleDeleteRow\"\n @upsertRow=\"handleUpsertRow\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,OAAO;;EAQb,MAAM,oBAAoB,IAAgB,CAAC,CA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}
|
|
1
|
+
{"version":3,"file":"RequestBodyForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","RequestTable"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestBodyForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport { computed, ref, watch } from 'vue'\n\nimport { useFileDialog } from '@/hooks/use-file-dialog'\nimport RequestTable from '@/v2/blocks/request-block/components/RequestTable.vue'\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\nimport {\n getFormBodyRows,\n getFormBodyValue,\n} from '@/v2/blocks/request-block/helpers/get-form-body-rows'\nimport { groupFormBodyFiles } from '@/v2/blocks/request-block/helpers/group-form-body-files'\n\nconst {\n example,\n bodySchema,\n encoding,\n aspNetFormNaming,\n selectedContentType,\n environment,\n compositionSelection,\n} = defineProps<{\n example: ExampleObject | undefined | null\n /** Resolved schema for the form body so the table can show enums and validation per field */\n bodySchema?: SchemaObject\n /** Encoding overrides for individual multipart fields. */\n encoding?: MediaTypeObject['encoding']\n aspNetFormNaming?: boolean\n /** Selected request-body variants, shared with example generation and serialization. */\n compositionSelection?: Record<string, number>\n selectedContentType: string\n environment: XScalarEnvironment\n}>()\n\nconst emit = defineEmits<{\n (\n e: 'update:formValue',\n payload: ApiReferenceEvents['operation:update:requestBody:formValue']['payload'],\n ): void\n}>()\n\n/** Local state for form body rows */\nconst localFormBodyRows = ref<TableRow[]>([])\n\nconst formFields = computed(() =>\n selectedContentType === 'multipart/form-data'\n ? groupFormBodyFiles(localFormBodyRows.value)\n : localFormBodyRows.value.map((data, index) => ({\n data,\n sourceIndices: [index],\n })),\n)\nconst displayedRows = computed<TableRow[]>(() =>\n formFields.value.map((field) => field.data),\n)\n\n/** Sync the local form body rows with the example and schema */\nwatch(\n () =>\n [\n example,\n bodySchema,\n selectedContentType,\n compositionSelection,\n encoding,\n aspNetFormNaming,\n ] as const,\n ([\n newExample,\n schema,\n contentType,\n selection,\n fieldEncoding,\n aspNetNaming,\n ]) => {\n localFormBodyRows.value = getFormBodyRows(\n newExample,\n contentType,\n schema,\n selection,\n fieldEncoding,\n aspNetNaming,\n )\n },\n { immediate: true },\n)\n\n/** Undeclared fields follow additionalProperties instead of losing uploads whenever a schema exists. */\nconst allowUnknownFileUploads = computed<boolean>(() => {\n const schema = resolveFormSchema(bodySchema, compositionSelection)\n const additional =\n schema && 'additionalProperties' in schema\n ? schema.additionalProperties\n : undefined\n return typeof additional === 'object'\n ? isFileSchema(resolveFormSchema(additional) ?? { __scalar_: '' })\n : additional !== false\n})\n\nconst handleUpdateFormValue = (rows: TableRow[]): void => {\n emit(\n 'update:formValue',\n rows.map((row) => ({\n name: row.name,\n value:\n selectedContentType === 'multipart/form-data' || aspNetFormNaming\n ? getFormBodyValue(row)\n : (row.value as string | File),\n isDisabled: row.isDisabled ?? false,\n ...(row.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n ...((selectedContentType === 'multipart/form-data' || aspNetFormNaming) &&\n row.isArray\n ? { isArray: true }\n : {}),\n })),\n )\n}\n\n/** Update a row in the table, combines with the previous data so we emit a whole row */\nconst handleUpsertRow = (\n index: number | number[],\n payload: Partial<{\n name: string\n value: string | File | undefined\n isDisabled: boolean\n }>,\n): void => {\n const indices = Array.isArray(index) ? index : [index]\n // Add new row\n if (\n indices[0] !== undefined &&\n indices[0] >= localFormBodyRows.value.length\n ) {\n localFormBodyRows.value = [\n ...localFormBodyRows.value,\n { name: '', value: '', ...payload, isDisabled: false },\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!indices.includes(i)) {\n return row\n }\n\n const valueChanged = 'value' in payload && payload.value !== row.value\n const disabledChanged =\n payload.isDisabled !== undefined && payload.isDisabled !== row.isDisabled\n\n return {\n ...row,\n ...payload,\n // File selection bypasses the text input, but also expresses intent to send a value.\n ...(valueChanged && payload.value !== undefined && row.isDisabledByDefault\n ? { isDisabled: false }\n : {}),\n // Preserve untouched defaults while keeping deliberate checkbox choices explicit.\n isDisabledByDefault:\n row.isDisabledByDefault && !valueChanged && !disabledChanged,\n }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remember individual choices while the whole file field is temporarily disabled. */\nconst disabledFileChoices = new WeakMap<File, boolean>()\n\n/** Apply field edits to all its parts without replacing sibling files with the first file. */\nconst handleFieldUpsert = (\n index: number,\n payload: Parameters<typeof handleUpsertRow>[1],\n): void => {\n const field = formFields.value[index]\n if (\n field?.data.files?.length &&\n payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ) {\n localFormBodyRows.value = localFormBodyRows.value.map((row, i) => {\n if (!field.sourceIndices.includes(i) || !(row.value instanceof File)) {\n return row\n }\n if (payload.isDisabled) {\n disabledFileChoices.set(row.value, row.isDisabled ?? false)\n }\n const isDisabled =\n payload.isDisabled || (disabledFileChoices.get(row.value) ?? false)\n if (!payload.isDisabled) {\n disabledFileChoices.delete(row.value)\n }\n return { ...row, isDisabled, isDisabledByDefault: false }\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(\n field?.sourceIndices ?? localFormBodyRows.value.length,\n field?.data.files\n ? {\n ...(payload.name !== undefined ? { name: payload.name } : {}),\n ...(payload.isDisabled !== undefined &&\n payload.isDisabled !== field.data.isDisabled\n ? { isDisabled: payload.isDisabled }\n : {}),\n }\n : payload,\n )\n}\n\n/** Delete a row from the table */\nconst handleDeleteRow = (index: number): void => {\n const indices = formFields.value[index]?.sourceIndices ?? [index]\n localFormBodyRows.value = localFormBodyRows.value.filter(\n (_, i) => !indices.includes(i),\n )\n handleUpdateFormValue(localFormBodyRows.value)\n}\n\n/** Remove a selected file, retaining one empty field after the last file is removed. */\nconst handleRemoveFile = (index: number, fileIndex?: number): void => {\n const field = formFields.value[index]\n const sourceIndex = fileIndex ?? field?.sourceIndices[0] ?? index\n if (field?.data.files) {\n const remaining = localFormBodyRows.value.filter(\n (row, i) =>\n field.sourceIndices.includes(i) &&\n i !== sourceIndex &&\n row.value instanceof File,\n )\n const original = localFormBodyRows.value[sourceIndex]\n if (!original) {\n return\n }\n const replacement = remaining.length\n ? remaining\n : [{ ...original, value: '[]', isArray: true }]\n localFormBodyRows.value = localFormBodyRows.value.flatMap((row, i) => {\n if (i === field.sourceIndices[0]) {\n return replacement\n }\n return field.sourceIndices.includes(i) ? [] : [row]\n })\n handleUpdateFormValue(localFormBodyRows.value)\n return\n }\n handleUpsertRow(sourceIndex, { value: undefined })\n}\n\n/** Handle file upload for a specific row index */\nconst handleFileUpload = (index: number): void => {\n const field = formFields.value[index]\n const sourceIndices = field?.sourceIndices ?? [localFormBodyRows.value.length]\n const sourceIndex = sourceIndices[0] ?? localFormBodyRows.value.length\n const currentRow = localFormBodyRows.value[sourceIndex]\n // Array fields accept multiple files, serialized as separate multipart parts under the same name.\n const allowMultiple = Boolean(\n currentRow?.schema && isArraySchema(currentRow.schema),\n )\n\n const { open } = useFileDialog({\n onChange: (files) => {\n const selected = files ? Array.from(files) : []\n if (selected.length === 0) {\n return\n }\n\n // Every selected file shares the field key, falling back to the first file name when\n // the row has no name yet (e.g. schema-less requests).\n const fieldName = currentRow?.name || selected[0]?.name || ''\n\n // Keep a selection together beside its field, and emit once so consumers never\n // observe a partially applied selection.\n const selectedRows: TableRow[] = selected.map((file) => ({\n ...currentRow,\n name: fieldName,\n value: file,\n // Selecting files enables untouched optional fields while preserving explicit choices.\n isDisabled: field?.data.isDisabledByDefault\n ? false\n : (field?.data.isDisabled ?? false),\n isDisabledByDefault: false,\n }))\n const existingFiles = field?.data.files\n ? localFormBodyRows.value.filter(\n (row, i) => sourceIndices.includes(i) && row.value instanceof File,\n )\n : []\n const remaining = localFormBodyRows.value.filter(\n (_, i) => !sourceIndices.includes(i),\n )\n localFormBodyRows.value = [\n ...remaining.slice(0, sourceIndex),\n ...existingFiles,\n ...selectedRows,\n ...remaining.slice(sourceIndex),\n ]\n handleUpdateFormValue(localFormBodyRows.value)\n },\n multiple: allowMultiple,\n accept: '*/*',\n })\n void open()\n}\n</script>\n\n<template>\n <!-- Form Data -->\n <template v-if=\"selectedContentType === 'multipart/form-data'\">\n <RequestTable\n :allowUnknownFileUploads=\"allowUnknownFileUploads\"\n :data=\"displayedRows\"\n deferKeyUpdates\n :environment=\"environment\"\n showUploadButton\n @deleteRow=\"handleDeleteRow\"\n @removeFile=\"handleRemoveFile\"\n @updateFile=\"\n (index, disabled) => handleUpsertRow(index, { isDisabled: disabled })\n \"\n @uploadFile=\"handleFileUpload\"\n @upsertRow=\"handleFieldUpsert\" />\n </template>\n\n <!-- Form URL Encoded -->\n <template v-else>\n <RequestTable\n :data=\"localFormBodyRows\"\n deferKeyUpdates\n :environment=\"environment\"\n @deleteRow=\"handleDeleteRow\"\n @upsertRow=\"handleUpsertRow\" />\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,OAAO;;EAQb,MAAM,oBAAoB,IAAgB,CAAC,CAAC;EAE5C,MAAM,aAAa,eACjB,QAAA,wBAAwB,wBACpB,mBAAmB,kBAAkB,KAAK,IAC1C,kBAAkB,MAAM,KAAK,MAAM,WAAW;GAC5C;GACA,eAAe,CAAC,KAAK;EACvB,EAAE,CACR;EACA,MAAM,gBAAgB,eACpB,WAAW,MAAM,KAAK,UAAU,MAAM,IAAI,CAC5C;;EAGA,YAEI;GACE,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;GACA,QAAA;E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KAI3D,MAAM,eAA2B,SAAS,KAAK,UAAU;MACvD,GAAG;MACH,MAAM;MACN,OAAO;MAEP,YAAY,OAAO,KAAK,sBACpB,QACC,OAAO,KAAK,cAAc;MAC/B,qBAAqB;KACvB,EAAE;KACF,MAAM,gBAAgB,OAAO,KAAK,QAC9B,kBAAkB,MAAM,QACrB,KAAK,MAAM,cAAc,SAAS,CAAC,KAAK,IAAI,iBAAiB,IAChE,IACA,CAAC;KACL,MAAM,YAAY,kBAAkB,MAAM,QACvC,GAAG,MAAM,CAAC,cAAc,SAAS,CAAC,CACrC;KACA,kBAAkB,QAAQ;MACxB,GAAG,UAAU,MAAM,GAAG,WAAW;MACjC,GAAG;MACH,GAAG;MACH,GAAG,UAAU,MAAM,WAAW;KAChC;KACA,sBAAsB,kBAAkB,KAAK;IAC/C;IACA,UAAU;IACV,QAAQ;GACV,CAAC;GACD,KAAU;EACZ;;GAKkB,OAAA,QAAA,wBAAmB,yBACjCA,UAAA,GAAAC,YAYmCC,sBAAA;;IAXhC,yBAAyB,wBAAA;IACzB,MAAM,cAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACd,kBAAA;IACC,aAAW;IACX,cAAY;IACZ,cAAU,OAAA,OAAA,OAAA,MAAY,OAAO,aAAa,gBAAgB,OAAK,EAAA,YAAgB,SAAQ,CAAA;IAGvF,cAAY;IACZ,aAAW;;;;;G,OAKdF,UAAA,GAAAC,YAKiCC,sBAAA;;IAJ9B,MAAM,kBAAA;IACP,iBAAA;IACC,aAAa,QAAA;IACb,aAAW;IACX,aAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"AAuLA,OAAO,EAOL,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAA;AAMpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAOvE,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAsUtE,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -41,6 +41,7 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /*@__PURE__
|
|
|
41
41
|
globalCookies: {},
|
|
42
42
|
openapiVersion: {},
|
|
43
43
|
jsonSchemaDialect: {},
|
|
44
|
+
multipartNaming: {},
|
|
44
45
|
requestBodyCompositionSelection: {}
|
|
45
46
|
},
|
|
46
47
|
setup(__props) {
|
|
@@ -86,6 +87,7 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /*@__PURE__
|
|
|
86
87
|
globalCookies: __props.globalCookies,
|
|
87
88
|
openapiVersion: __props.openapiVersion,
|
|
88
89
|
jsonSchemaDialect: __props.jsonSchemaDialect,
|
|
90
|
+
multipartNaming: __props.multipartNaming,
|
|
89
91
|
requestBodyCompositionSelection: __props.requestBodyCompositionSelection,
|
|
90
92
|
includeDefaultHeaders: __props.integration === "client"
|
|
91
93
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","CollapsibleSection","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createVNode","_normalizeClass","DataTable","DataTableRow","_createElementBlock"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n findClient,\n generateCodeSnippet,\n getClients,\n getCustomCodeSamples,\n getSecrets,\n type ClientOption,\n type CodeExampleProps,\n type CustomClientOption,\n} from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n integration,\n} = defineProps<CodeExampleProps & { eventBus: WorkspaceEventBus }>()\n\nconst { translate } = useLocalization()\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/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\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/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string | null>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-if=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>\n {{ translate('apiClient.requestCodeSnippet.codeSnippet') }}\n </template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\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 <ScalarIconCaretDown\n class=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <div\n v-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ translate('apiClient.requestCodeSnippet.unavailable') }}\n </div>\n <ScalarCodeBlock\n v-else\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"translate('apiClient.requestCodeSnippet.codeSnippet')\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </DataTable>\n </ScalarErrorBoundary>\n </CollapsibleSection>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestCodeSnippet.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","CollapsibleSection","_withCtx","_createTextVNode","_toDisplayString","_createElementVNode","_createVNode","_normalizeClass","DataTable","DataTableRow","_createElementBlock"],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n findClient,\n generateCodeSnippet,\n getClients,\n getCustomCodeSamples,\n getSecrets,\n type ClientOption,\n type CodeExampleProps,\n type CustomClientOption,\n} from '@scalar/blocks/code-example'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\nimport { useLocalization } from '@/v2/features/localization'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n integration,\n} = defineProps<CodeExampleProps & { eventBus: WorkspaceEventBus }>()\n\nconst { translate } = useLocalization()\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/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\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/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string | null>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n openapiVersion,\n jsonSchemaDialect,\n multipartNaming,\n requestBodyCompositionSelection,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-if=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>\n {{ translate('apiClient.requestCodeSnippet.codeSnippet') }}\n </template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\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 <ScalarIconCaretDown\n class=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <div\n v-if=\"generatedCode === null\"\n class=\"text-c-2 p-4\"\n role=\"status\">\n {{ translate('apiClient.requestCodeSnippet.unavailable') }}\n </div>\n <ScalarCodeBlock\n v-else\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :label=\"translate('apiClient.requestCodeSnippet.codeSnippet')\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </DataTable>\n </ScalarErrorBoundary>\n </CollapsibleSection>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,EAAE,cAAc,gBAAgB;;EAGtC,MAAM,oBAAoB,eAAe,qBAAqB,QAAA,SAAS,CAAC;;EAGxE,MAAM,UAAU,eACd,WACE,kBAAkB,MAAM,SACxB,QAAA,eACA,kBAAkB,MAAM,KAC1B,CACF;;;;;EAMA,MAAM,sBAAsB,IAC1B,WAAW,QAAQ,OAAO,QAAA,cAAc,CAC1C;;;;;;;EAQA,MAAM,OAAO,QAAA,gBAAgB,OAAO,IAAI,CAAC,eAAe;GACtD,MAAM,SAAS,WAAW,QAAQ,OAAO,SAAS;GAClD,IAAI,QACF,oBAAoB,QAAQ;EAEhC,CAAC;;EAGD,MAAM,oBAAoB,eAAe,WAAW,QAAA,mBAAmB,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AAA,CAAA;OACZ,QAAO;;;;;;IAQnB,SAAAL,cAuBsB,CAvBtBI,YAuBsBN,MAAA,mBAAA,GAAA,MAAA;KAtBpB,SAAAE,cAqBY,CArBZI,YAqBYN,MAAAQ,iBAAA,GAAA;MApBT,SAAS,CAAA,EAAA;MACV,gBAAA;;MACA,SAAAN,cAiBe,CAjBfI,YAiBeN,MAAAS,oBAAA,GAAA,MAAA;OAhBb,SAAAP,cAeM,CAfNG,mBAeM,OAfN,YAeM,CAbI,cAAA,UAAa,QADrBP,UAAA,GAAAY,mBAKM,OALN,YAKMN,gBADDJ,MAAA,SAAA,CAAS,CAAA,0CAAA,CAAA,GAAA,CAAA,MAEdF,UAAA,GAAAC,YAOgBC,MAAA,eAAA,GAAA;;QALd,OAAM;QACL,SAAS,cAAA;QACT,iBAAiB,kBAAA;QACjB,OAAOA,MAAA,SAAA,CAAS,CAAA,0CAAA;QAChB,MAAM,oBAAA,OAAqB,QAAI;QAChC,aAAA"}
|
|
@@ -32,5 +32,5 @@ export declare const collectExampleRows: (example: unknown, schema: SchemaObject
|
|
|
32
32
|
/** Restore array values after text editing without parsing ordinary string fields. */
|
|
33
33
|
export declare const getFormBodyValue: (row: TableRow) => string | File | unknown[] | undefined;
|
|
34
34
|
/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
|
|
35
|
-
export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject, compositionSelection?: Record<string, number>, encoding?: MediaTypeObject["encoding"]) => TableRow[];
|
|
35
|
+
export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject, compositionSelection?: Record<string, number>, encoding?: MediaTypeObject["encoding"], aspNetFormNaming?: boolean) => TableRow[];
|
|
36
36
|
//# sourceMappingURL=get-form-body-rows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,EACrB,oBAAoB,MAAM,KACzB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,EAC7B,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7C,WAAW,eAAe,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,EACrB,oBAAoB,MAAM,KACzB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,EAC7B,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7C,WAAW,eAAe,CAAC,UAAU,CAAC,EACtC,0BAAwB,KACvB,QAAQ,EA0KV,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { objectEntries } from "@scalar/helpers/object/object-entries";
|
|
2
|
-
import { coerceLeafValueToSchemaType } from "@scalar/workspace-store/request-example";
|
|
2
|
+
import { coerceLeafValueToSchemaType, getAspNetFormFields } from "@scalar/workspace-store/request-example";
|
|
3
3
|
import { isObject } from "@scalar/helpers/object/is-object";
|
|
4
4
|
import { isObjectSchema } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
|
|
5
5
|
import { resolveFormSchema } from "@scalar/workspace-store/helpers/resolve-form-schema";
|
|
@@ -79,7 +79,7 @@ var getFormBodyValue = (row) => {
|
|
|
79
79
|
return Array.isArray(value) ? value : row.value ?? void 0;
|
|
80
80
|
};
|
|
81
81
|
/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
|
|
82
|
-
var getFormBodyRows = (example, contentType, formBodySchema, compositionSelection, encoding) => {
|
|
82
|
+
var getFormBodyRows = (example, contentType, formBodySchema, compositionSelection, encoding, aspNetFormNaming = false) => {
|
|
83
83
|
const value = example?.dataValue !== void 0 ? example.dataValue : example?.value;
|
|
84
84
|
if (!value || contentType !== "multipart/form-data" && contentType !== "application/x-www-form-urlencoded") return [];
|
|
85
85
|
const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection);
|
|
@@ -121,9 +121,16 @@ var getFormBodyRows = (example, contentType, formBodySchema, compositionSelectio
|
|
|
121
121
|
value: value instanceof File || value == null ? value ?? "" : stringifyValue(value),
|
|
122
122
|
isDisabled
|
|
123
123
|
});
|
|
124
|
-
if (contentType === "multipart/form-data" && (Array.isArray(value) || isArray)) row.isArray = true;
|
|
124
|
+
if ((contentType === "multipart/form-data" || aspNetFormNaming) && (Array.isArray(value) || isArray)) row.isArray = true;
|
|
125
125
|
return [row];
|
|
126
126
|
};
|
|
127
|
+
if (aspNetFormNaming) return getAspNetFormFields(value, schemaWithProperties, compositionSelection, true).flatMap((field) => mapValue(field.name, field.value, field.isDisabled, field.isArray).map((row) => ({
|
|
128
|
+
...row,
|
|
129
|
+
schema: field.schema ?? row.schema,
|
|
130
|
+
description: field.schema?.description ?? row.description,
|
|
131
|
+
isRequired: field.isRequired || row.isRequired,
|
|
132
|
+
...field.isDisabledByDefault ? { isDisabledByDefault: true } : {}
|
|
133
|
+
})));
|
|
127
134
|
if (Array.isArray(value)) return value.flatMap((exampleValue) => {
|
|
128
135
|
if (isObject(exampleValue)) {
|
|
129
136
|
const name = String(exampleValue.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-form-body-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations'\nimport { coerceLeafValueToSchemaType } from '@scalar/workspace-store/request-example'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\nexport const stringifyValue = (value: unknown) => {\n if (value instanceof File) {\n return value.name\n }\n if (typeof value === 'object' && value !== null) {\n return JSON.stringify(value)\n }\n return String(value)\n}\n\nexport type LeafRow = {\n path: string[]\n schema: SchemaObject | undefined\n isRequired: boolean\n description?: string\n}\n\n/**\n * Walk a (possibly nested) object schema and collect one entry per leaf property.\n *\n * A \"leaf\" is any property whose resolved schema is not an `{ type: 'object' }` schema\n * with named `properties` — i.e. primitives, arrays, files, and `additionalProperties`\n * placeholders all stop the recursion. Object properties recurse, so the widget example\n * (`file` + `props.{name,description,created_at}`) yields four leaves.\n */\nexport const collectLeafProperties = (\n schema: SchemaObject,\n parentPath: string[] = [],\n parentRequired = true,\n parentDescription?: string,\n): LeafRow[] => {\n // Nothing to walk if this is not an object schema or has no declared properties.\n if (!isObjectSchema(schema) || !schema.properties) {\n return []\n }\n\n // `required` is a list of property names on *this* schema, so build it once per level.\n const requiredSet = new Set(schema.required ?? [])\n const leaves: LeafRow[] = []\n\n for (const [key, rawChildSchema] of objectEntries(schema.properties)) {\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, String(key)]\n\n // A leaf is only required when *every* ancestor was also required — a non-required\n // parent makes the whole subtree optional regardless of inner `required` lists.\n const isRequired = parentRequired && requiredSet.has(String(key))\n\n // Nested objects with named properties recurse so each leaf gets its own row;\n // everything else (primitives, arrays, files, additionalProperties placeholders)\n // is treated as a leaf and stops the descent.\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n leaves.push(...collectLeafProperties(childSchema, path, isRequired, childSchema.description ?? parentDescription))\n } else {\n leaves.push({ path, schema: childSchema, isRequired, description: childSchema?.description ?? parentDescription })\n }\n }\n\n return leaves\n}\n\n/**\n * Walk a schema + example together and collect one row per leaf, including example-only\n * keys that the schema does not declare. Schema-declared properties come first in schema\n * order; extras present in the example follow in example order at each level.\n *\n * Unlike `collectLeafProperties` (which is schema-only and feeds the dotted-name index),\n * this walker drives what the user actually sees in the form: a row for every leaf the\n * example contains, even when the schema is partial or out of date.\n */\nexport const collectExampleRows = (\n example: unknown,\n schema: SchemaObject | undefined,\n parentPath: string[] = [],\n): { path: string[]; value: unknown }[] => {\n const rows: { path: string[]; value: unknown }[] = []\n const exampleEntries = isObject(example) ? objectEntries(example) : []\n const exampleByKey = new Map<string, unknown>(exampleEntries.map(([key, value]) => [String(key), value]))\n const declaredKeys = new Set<string>()\n const schemaProperties = schema && isObjectSchema(schema) ? (schema.properties ?? {}) : {}\n\n // Schema-declared properties first, in schema order. Nested object schemas recurse so\n // each leaf gets its own row; otherwise the schema-declared key is a leaf and uses the\n // matching example value (or `undefined` when the example does not provide one).\n for (const [key, rawChildSchema] of objectEntries(schemaProperties)) {\n const keyStr = String(key)\n declaredKeys.add(keyStr)\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, keyStr]\n const exampleSubvalue = exampleByKey.get(keyStr)\n\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n rows.push(...collectExampleRows(exampleSubvalue, childSchema, path))\n } else {\n rows.push({ path, value: exampleSubvalue })\n }\n }\n\n // Example-only properties at this level (preserve example order). Their inner shape is\n // not descended into — without a schema saying \"this is a nested object\" we have no\n // signal to flatten, so an object value becomes a single JSON-stringified row, matching\n // the schema-less fallback below.\n for (const [key, value] of exampleEntries) {\n const keyStr = String(key)\n if (declaredKeys.has(keyStr)) {\n continue\n }\n rows.push({ path: [...parentPath, keyStr], value })\n }\n\n return rows\n}\n\n/** Restore array values after text editing without parsing ordinary string fields. */\nexport const getFormBodyValue = (row: TableRow): string | File | unknown[] | undefined => {\n const value = coerceLeafValueToSchemaType(row.value, row.isArray ? { type: 'array' } : row.schema)\n return Array.isArray(value) ? value : (row.value ?? undefined)\n}\n\n/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */\nexport const getFormBodyRows = (\n example: ExampleObject | undefined | null,\n contentType: string,\n formBodySchema?: SchemaObject,\n compositionSelection?: Record<string, number>,\n encoding?: MediaTypeObject['encoding'],\n): TableRow[] => {\n // Forms use structured data even when the raw example also supplies wire text.\n const value = example?.dataValue !== undefined ? example.dataValue : example?.value\n // We only need the rows for formData\n if (!value || (contentType !== 'multipart/form-data' && contentType !== 'application/x-www-form-urlencoded')) {\n return []\n }\n\n // Get all the schema properties if the schema is an object schema\n const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection)\n const schemaWithProperties =\n resolvedBodySchema &&\n (isObjectSchema(resolvedBodySchema) ||\n 'properties' in resolvedBodySchema ||\n 'additionalProperties' in resolvedBodySchema)\n ? { ...resolvedBodySchema, type: 'object' as const }\n : undefined\n // The request builder preserves composed fields because members can make them required.\n // Keep those fields checked so the initial form matches the body that will be sent.\n const isComposed = Boolean(schemaWithProperties?.allOf || schemaWithProperties?.oneOf || schemaWithProperties?.anyOf)\n const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : undefined\n\n // Pre-compute the leaf-by-dotted-name index up front so both the array and the\n // schema-driven branches can pull each row's leaf schema and required flag without\n // re-walking the schema. Without this, edited rows lose the per-leaf `Required`\n // badge because a top-level `properties[name]` lookup misses dotted names.\n const leafByDottedName = new Map<string, LeafRow>()\n if (schemaWithProperties) {\n for (const leaf of collectLeafProperties(schemaWithProperties)) {\n leafByDottedName.set(leaf.path.join('.'), leaf)\n }\n }\n\n const mapRow = ({\n name,\n value,\n isDisabled,\n }: {\n name: string\n value: string | File\n isDisabled?: boolean\n }): TableRow => {\n const row: TableRow = {\n name,\n value,\n isDisabled: isDisabled ?? false,\n ...(encoding?.[name]?.contentType ? { contentType: encoding[name].contentType } : {}),\n }\n if (!schemaWithProperties || !name) {\n return row\n }\n // Prefer the pre-resolved leaf (handles dotted names like `props.name`); fall back\n // to a top-level property lookup so user-added rows keep working.\n const leaf = leafByDottedName.get(name)\n const propSchema =\n leaf?.schema ??\n resolveSchemaWithAnnotations(\n schemaWithProperties.properties?.[name] ??\n (typeof schemaWithProperties.additionalProperties === 'object'\n ? schemaWithProperties.additionalProperties\n : schemaWithProperties.additionalProperties === false\n ? undefined\n : { __scalar_: '' }),\n )\n row.schema = propSchema\n row.description = leaf?.description ?? propSchema?.description\n row.isRequired = leaf?.isRequired ?? requiredSet?.has(name) ?? false\n\n // Top-level optional properties default to disabled (unchecked), matching how optional\n // parameters behave. Scoped to top-level declared properties on purpose: the send side\n // (`build-request-body`) only drops top-level optional keys, so auto-disabling a nested\n // leaf (e.g. `props.name`) would leave it unchecked yet still transmitted. `Object.hasOwn`\n // (not `in`) keeps example-only keys named like `Object.prototype` members enabled. An\n // explicit `isDisabled` (from a stored form-row array) always wins.\n if (\n isDisabled === undefined &&\n !isComposed &&\n schemaWithProperties.properties &&\n Object.hasOwn(schemaWithProperties.properties, name)\n ) {\n row.isDisabled = !row.isRequired\n // Mark the row as disabled by default (no explicit `isDisabled` was stored) so typing a\n // value auto-enables it in `RequestTableRow`, matching how optional parameters behave. An\n // explicit `isDisabled` from a stored form-row array skips this branch and keeps winning.\n row.isDisabledByDefault = row.isDisabled\n }\n return row\n }\n\n const mapValue = (name: string, value: unknown, isDisabled?: boolean, isArray?: boolean): TableRow[] => {\n // Uploaded files must never pass through JSON.stringify, which discards their bytes.\n if (\n contentType === 'multipart/form-data' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => item instanceof File)\n ) {\n return value.map((file) => mapRow({ name, value: file, isDisabled }))\n }\n const row = mapRow({\n name,\n value: value instanceof File || value == null ? (value ?? '') : stringifyValue(value),\n isDisabled,\n })\n if (contentType === 'multipart/form-data' && (Array.isArray(value) || isArray)) {\n // Example-only arrays also need their type to survive a form-table round trip.\n row.isArray = true\n }\n return [row]\n }\n\n // We have form data stored as an array\n if (Array.isArray(value)) {\n return value.flatMap((exampleValue) => {\n if (isObject(exampleValue)) {\n const name = String(exampleValue.name)\n const rows =\n contentType === 'multipart/form-data'\n ? mapValue(name, exampleValue.value, Boolean(exampleValue.isDisabled), exampleValue.isArray === true)\n : [\n mapRow({\n name,\n value: exampleValue.value instanceof File ? exampleValue.value : String(exampleValue.value),\n isDisabled: Boolean(exampleValue.isDisabled),\n }),\n ]\n // An untouched optional row stays eligible for auto-enabling after another row is edited.\n return rows.map((row) =>\n row.isDisabled && exampleValue.isDisabledByDefault === true ? { ...row, isDisabledByDefault: true } : row,\n )\n }\n return { name: '', value: exampleValue, isDisabled: false }\n })\n }\n\n // Schema-driven path: when the form body schema describes nested objects, emit one row\n // per leaf so users can edit individual fields. The dotted name (`props.name`) is folded\n // back into a single JSON multipart part by `build-request-body.ts` before the request is\n // sent. Gated to `multipart/form-data` because urlencoded has no regrouping step on send,\n // so dotted leaves would otherwise reach the wire as separate `props.name`-style fields.\n //\n // We walk the example alongside the schema so example-only properties (top-level extras\n // or undeclared keys inside a nested object) are still visible and editable instead of\n // being silently dropped to whatever the schema happens to declare.\n if (contentType === 'multipart/form-data' && schemaWithProperties && typeof value === 'object') {\n return collectExampleRows(value, schemaWithProperties).flatMap(({ path, value }) => mapValue(path.join('.'), value))\n }\n\n // We got an object try to convert it to an array of rows\n if (typeof value === 'object' && value) {\n return objectEntries(value).flatMap(([key, value]) =>\n contentType === 'multipart/form-data'\n ? mapValue(String(key), value)\n : mapRow({ name: String(key), value: stringifyValue(value) }),\n )\n }\n\n return []\n}\n"],"mappings":";;;;;;;AAcA,IAAa,kBAAkB,UAAmB;CAChD,IAAI,iBAAiB,MACnB,OAAO,MAAM;CAEf,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,KAAK,UAAU,KAAK;CAE7B,OAAO,OAAO,KAAK;AACrB;;;;;;;;;AAiBA,IAAa,yBACX,QACA,aAAuB,CAAC,GACxB,iBAAiB,MACjB,sBACc;CAEd,IAAI,CAAC,eAAe,MAAM,KAAK,CAAC,OAAO,YACrC,OAAO,CAAC;CAIV,MAAM,cAAc,IAAI,IAAI,OAAO,YAAY,CAAC,CAAC;CACjD,MAAM,SAAoB,CAAC;CAE3B,KAAK,MAAM,CAAC,KAAK,mBAAmB,cAAc,OAAO,UAAU,GAAG;EACpE,MAAM,cAAc,6BAA6B,cAAc;EAC/D,MAAM,OAAO,CAAC,GAAG,YAAY,OAAO,GAAG,CAAC;EAIxC,MAAM,aAAa,kBAAkB,YAAY,IAAI,OAAO,GAAG,CAAC;EAKhE,IAAI,eAAe,eAAe,WAAW,KAAK,YAAY,YAC5D,OAAO,KAAK,GAAG,sBAAsB,aAAa,MAAM,YAAY,YAAY,eAAe,iBAAiB,CAAC;OAEjH,OAAO,KAAK;GAAE;GAAM,QAAQ;GAAa;GAAY,aAAa,aAAa,eAAe;EAAkB,CAAC;CAErH;CAEA,OAAO;AACT;;;;;;;;;;AAWA,IAAa,sBACX,SACA,QACA,aAAuB,CAAC,MACiB;CACzC,MAAM,OAA6C,CAAC;CACpD,MAAM,iBAAiB,SAAS,OAAO,IAAI,cAAc,OAAO,IAAI,CAAC;CACrE,MAAM,eAAe,IAAI,IAAqB,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file":"get-form-body-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"sourcesContent":["import { isObject } from '@scalar/helpers/object/is-object'\nimport { objectEntries } from '@scalar/helpers/object/object-entries'\nimport { resolveFormSchema } from '@scalar/workspace-store/helpers/resolve-form-schema'\nimport { resolveSchemaWithAnnotations } from '@scalar/workspace-store/helpers/resolve-schema-with-annotations'\nimport { coerceLeafValueToSchemaType, getAspNetFormFields } from '@scalar/workspace-store/request-example'\nimport type {\n ExampleObject,\n MediaTypeObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\nexport const stringifyValue = (value: unknown) => {\n if (value instanceof File) {\n return value.name\n }\n if (typeof value === 'object' && value !== null) {\n return JSON.stringify(value)\n }\n return String(value)\n}\n\nexport type LeafRow = {\n path: string[]\n schema: SchemaObject | undefined\n isRequired: boolean\n description?: string\n}\n\n/**\n * Walk a (possibly nested) object schema and collect one entry per leaf property.\n *\n * A \"leaf\" is any property whose resolved schema is not an `{ type: 'object' }` schema\n * with named `properties` — i.e. primitives, arrays, files, and `additionalProperties`\n * placeholders all stop the recursion. Object properties recurse, so the widget example\n * (`file` + `props.{name,description,created_at}`) yields four leaves.\n */\nexport const collectLeafProperties = (\n schema: SchemaObject,\n parentPath: string[] = [],\n parentRequired = true,\n parentDescription?: string,\n): LeafRow[] => {\n // Nothing to walk if this is not an object schema or has no declared properties.\n if (!isObjectSchema(schema) || !schema.properties) {\n return []\n }\n\n // `required` is a list of property names on *this* schema, so build it once per level.\n const requiredSet = new Set(schema.required ?? [])\n const leaves: LeafRow[] = []\n\n for (const [key, rawChildSchema] of objectEntries(schema.properties)) {\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, String(key)]\n\n // A leaf is only required when *every* ancestor was also required — a non-required\n // parent makes the whole subtree optional regardless of inner `required` lists.\n const isRequired = parentRequired && requiredSet.has(String(key))\n\n // Nested objects with named properties recurse so each leaf gets its own row;\n // everything else (primitives, arrays, files, additionalProperties placeholders)\n // is treated as a leaf and stops the descent.\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n leaves.push(...collectLeafProperties(childSchema, path, isRequired, childSchema.description ?? parentDescription))\n } else {\n leaves.push({ path, schema: childSchema, isRequired, description: childSchema?.description ?? parentDescription })\n }\n }\n\n return leaves\n}\n\n/**\n * Walk a schema + example together and collect one row per leaf, including example-only\n * keys that the schema does not declare. Schema-declared properties come first in schema\n * order; extras present in the example follow in example order at each level.\n *\n * Unlike `collectLeafProperties` (which is schema-only and feeds the dotted-name index),\n * this walker drives what the user actually sees in the form: a row for every leaf the\n * example contains, even when the schema is partial or out of date.\n */\nexport const collectExampleRows = (\n example: unknown,\n schema: SchemaObject | undefined,\n parentPath: string[] = [],\n): { path: string[]; value: unknown }[] => {\n const rows: { path: string[]; value: unknown }[] = []\n const exampleEntries = isObject(example) ? objectEntries(example) : []\n const exampleByKey = new Map<string, unknown>(exampleEntries.map(([key, value]) => [String(key), value]))\n const declaredKeys = new Set<string>()\n const schemaProperties = schema && isObjectSchema(schema) ? (schema.properties ?? {}) : {}\n\n // Schema-declared properties first, in schema order. Nested object schemas recurse so\n // each leaf gets its own row; otherwise the schema-declared key is a leaf and uses the\n // matching example value (or `undefined` when the example does not provide one).\n for (const [key, rawChildSchema] of objectEntries(schemaProperties)) {\n const keyStr = String(key)\n declaredKeys.add(keyStr)\n const childSchema = resolveSchemaWithAnnotations(rawChildSchema)\n const path = [...parentPath, keyStr]\n const exampleSubvalue = exampleByKey.get(keyStr)\n\n if (childSchema && isObjectSchema(childSchema) && childSchema.properties) {\n rows.push(...collectExampleRows(exampleSubvalue, childSchema, path))\n } else {\n rows.push({ path, value: exampleSubvalue })\n }\n }\n\n // Example-only properties at this level (preserve example order). Their inner shape is\n // not descended into — without a schema saying \"this is a nested object\" we have no\n // signal to flatten, so an object value becomes a single JSON-stringified row, matching\n // the schema-less fallback below.\n for (const [key, value] of exampleEntries) {\n const keyStr = String(key)\n if (declaredKeys.has(keyStr)) {\n continue\n }\n rows.push({ path: [...parentPath, keyStr], value })\n }\n\n return rows\n}\n\n/** Restore array values after text editing without parsing ordinary string fields. */\nexport const getFormBodyValue = (row: TableRow): string | File | unknown[] | undefined => {\n const value = coerceLeafValueToSchemaType(row.value, row.isArray ? { type: 'array' } : row.schema)\n return Array.isArray(value) ? value : (row.value ?? undefined)\n}\n\n/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */\nexport const getFormBodyRows = (\n example: ExampleObject | undefined | null,\n contentType: string,\n formBodySchema?: SchemaObject,\n compositionSelection?: Record<string, number>,\n encoding?: MediaTypeObject['encoding'],\n aspNetFormNaming = false,\n): TableRow[] => {\n // Forms use structured data even when the raw example also supplies wire text.\n const value = example?.dataValue !== undefined ? example.dataValue : example?.value\n // We only need the rows for formData\n if (!value || (contentType !== 'multipart/form-data' && contentType !== 'application/x-www-form-urlencoded')) {\n return []\n }\n\n // Get all the schema properties if the schema is an object schema\n const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection)\n const schemaWithProperties =\n resolvedBodySchema &&\n (isObjectSchema(resolvedBodySchema) ||\n 'properties' in resolvedBodySchema ||\n 'additionalProperties' in resolvedBodySchema)\n ? { ...resolvedBodySchema, type: 'object' as const }\n : undefined\n // The request builder preserves composed fields because members can make them required.\n // Keep those fields checked so the initial form matches the body that will be sent.\n const isComposed = Boolean(schemaWithProperties?.allOf || schemaWithProperties?.oneOf || schemaWithProperties?.anyOf)\n const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : undefined\n\n // Pre-compute the leaf-by-dotted-name index up front so both the array and the\n // schema-driven branches can pull each row's leaf schema and required flag without\n // re-walking the schema. Without this, edited rows lose the per-leaf `Required`\n // badge because a top-level `properties[name]` lookup misses dotted names.\n const leafByDottedName = new Map<string, LeafRow>()\n if (schemaWithProperties) {\n for (const leaf of collectLeafProperties(schemaWithProperties)) {\n leafByDottedName.set(leaf.path.join('.'), leaf)\n }\n }\n\n const mapRow = ({\n name,\n value,\n isDisabled,\n }: {\n name: string\n value: string | File\n isDisabled?: boolean\n }): TableRow => {\n const row: TableRow = {\n name,\n value,\n isDisabled: isDisabled ?? false,\n ...(encoding?.[name]?.contentType ? { contentType: encoding[name].contentType } : {}),\n }\n if (!schemaWithProperties || !name) {\n return row\n }\n // Prefer the pre-resolved leaf (handles dotted names like `props.name`); fall back\n // to a top-level property lookup so user-added rows keep working.\n const leaf = leafByDottedName.get(name)\n const propSchema =\n leaf?.schema ??\n resolveSchemaWithAnnotations(\n schemaWithProperties.properties?.[name] ??\n (typeof schemaWithProperties.additionalProperties === 'object'\n ? schemaWithProperties.additionalProperties\n : schemaWithProperties.additionalProperties === false\n ? undefined\n : { __scalar_: '' }),\n )\n row.schema = propSchema\n row.description = leaf?.description ?? propSchema?.description\n row.isRequired = leaf?.isRequired ?? requiredSet?.has(name) ?? false\n\n // Top-level optional properties default to disabled (unchecked), matching how optional\n // parameters behave. Scoped to top-level declared properties on purpose: the send side\n // (`build-request-body`) only drops top-level optional keys, so auto-disabling a nested\n // leaf (e.g. `props.name`) would leave it unchecked yet still transmitted. `Object.hasOwn`\n // (not `in`) keeps example-only keys named like `Object.prototype` members enabled. An\n // explicit `isDisabled` (from a stored form-row array) always wins.\n if (\n isDisabled === undefined &&\n !isComposed &&\n schemaWithProperties.properties &&\n Object.hasOwn(schemaWithProperties.properties, name)\n ) {\n row.isDisabled = !row.isRequired\n // Mark the row as disabled by default (no explicit `isDisabled` was stored) so typing a\n // value auto-enables it in `RequestTableRow`, matching how optional parameters behave. An\n // explicit `isDisabled` from a stored form-row array skips this branch and keeps winning.\n row.isDisabledByDefault = row.isDisabled\n }\n return row\n }\n\n const mapValue = (name: string, value: unknown, isDisabled?: boolean, isArray?: boolean): TableRow[] => {\n // Uploaded files must never pass through JSON.stringify, which discards their bytes.\n if (\n contentType === 'multipart/form-data' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => item instanceof File)\n ) {\n return value.map((file) => mapRow({ name, value: file, isDisabled }))\n }\n const row = mapRow({\n name,\n value: value instanceof File || value == null ? (value ?? '') : stringifyValue(value),\n isDisabled,\n })\n if ((contentType === 'multipart/form-data' || aspNetFormNaming) && (Array.isArray(value) || isArray)) {\n // Example-only arrays also need their type to survive a form-table round trip.\n row.isArray = true\n }\n return [row]\n }\n\n if (aspNetFormNaming) {\n return getAspNetFormFields(value, schemaWithProperties, compositionSelection, true).flatMap((field) =>\n mapValue(field.name, field.value, field.isDisabled, field.isArray).map((row) => ({\n ...row,\n schema: field.schema ?? row.schema,\n description: field.schema?.description ?? row.description,\n isRequired: field.isRequired || row.isRequired,\n ...(field.isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n })),\n )\n }\n\n // We have form data stored as an array\n if (Array.isArray(value)) {\n return value.flatMap((exampleValue) => {\n if (isObject(exampleValue)) {\n const name = String(exampleValue.name)\n const rows =\n contentType === 'multipart/form-data'\n ? mapValue(name, exampleValue.value, Boolean(exampleValue.isDisabled), exampleValue.isArray === true)\n : [\n mapRow({\n name,\n value: exampleValue.value instanceof File ? exampleValue.value : String(exampleValue.value),\n isDisabled: Boolean(exampleValue.isDisabled),\n }),\n ]\n // An untouched optional row stays eligible for auto-enabling after another row is edited.\n return rows.map((row) =>\n row.isDisabled && exampleValue.isDisabledByDefault === true ? { ...row, isDisabledByDefault: true } : row,\n )\n }\n return { name: '', value: exampleValue, isDisabled: false }\n })\n }\n\n // Schema-driven path: when the form body schema describes nested objects, emit one row\n // per leaf so users can edit individual fields. The dotted name (`props.name`) is folded\n // back into a single JSON multipart part by `build-request-body.ts` before the request is\n // sent. Gated to `multipart/form-data` because urlencoded has no regrouping step on send,\n // so dotted leaves would otherwise reach the wire as separate `props.name`-style fields.\n //\n // We walk the example alongside the schema so example-only properties (top-level extras\n // or undeclared keys inside a nested object) are still visible and editable instead of\n // being silently dropped to whatever the schema happens to declare.\n if (contentType === 'multipart/form-data' && schemaWithProperties && typeof value === 'object') {\n return collectExampleRows(value, schemaWithProperties).flatMap(({ path, value }) => mapValue(path.join('.'), value))\n }\n\n // We got an object try to convert it to an array of rows\n if (typeof value === 'object' && value) {\n return objectEntries(value).flatMap(([key, value]) =>\n contentType === 'multipart/form-data'\n ? mapValue(String(key), value)\n : mapRow({ name: String(key), value: stringifyValue(value) }),\n )\n }\n\n return []\n}\n"],"mappings":";;;;;;;AAcA,IAAa,kBAAkB,UAAmB;CAChD,IAAI,iBAAiB,MACnB,OAAO,MAAM;CAEf,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,KAAK,UAAU,KAAK;CAE7B,OAAO,OAAO,KAAK;AACrB;;;;;;;;;AAiBA,IAAa,yBACX,QACA,aAAuB,CAAC,GACxB,iBAAiB,MACjB,sBACc;CAEd,IAAI,CAAC,eAAe,MAAM,KAAK,CAAC,OAAO,YACrC,OAAO,CAAC;CAIV,MAAM,cAAc,IAAI,IAAI,OAAO,YAAY,CAAC,CAAC;CACjD,MAAM,SAAoB,CAAC;CAE3B,KAAK,MAAM,CAAC,KAAK,mBAAmB,cAAc,OAAO,UAAU,GAAG;EACpE,MAAM,cAAc,6BAA6B,cAAc;EAC/D,MAAM,OAAO,CAAC,GAAG,YAAY,OAAO,GAAG,CAAC;EAIxC,MAAM,aAAa,kBAAkB,YAAY,IAAI,OAAO,GAAG,CAAC;EAKhE,IAAI,eAAe,eAAe,WAAW,KAAK,YAAY,YAC5D,OAAO,KAAK,GAAG,sBAAsB,aAAa,MAAM,YAAY,YAAY,eAAe,iBAAiB,CAAC;OAEjH,OAAO,KAAK;GAAE;GAAM,QAAQ;GAAa;GAAY,aAAa,aAAa,eAAe;EAAkB,CAAC;CAErH;CAEA,OAAO;AACT;;;;;;;;;;AAWA,IAAa,sBACX,SACA,QACA,aAAuB,CAAC,MACiB;CACzC,MAAM,OAA6C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AE,MAAM;GAAI,OAAO;GAAc,YAAY;EAAM;CAC5D,CAAC;CAYH,IAAI,gBAAgB,yBAAyB,wBAAwB,OAAO,UAAU,UACpF,OAAO,mBAAmB,OAAO,oBAAoB,CAAC,CAAC,SAAS,EAAE,MAAM,YAAY,SAAS,KAAK,KAAK,GAAG,GAAG,KAAK,CAAC;CAIrH,IAAI,OAAO,UAAU,YAAY,OAC/B,OAAO,cAAc,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,WACzC,gBAAgB,wBACZ,SAAS,OAAO,GAAG,GAAG,KAAK,IAC3B,OAAO;EAAE,MAAM,OAAO,GAAG;EAAG,OAAO,eAAe,KAAK;CAAE,CAAC,CAChE;CAGF,OAAO,CAAC;AACV"}
|
package/dist/v2/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/v2/constants.ts
|
|
2
2
|
/** The version number taken from the package.json. Consumers can override at build time via define (e.g. OVERRIDE_PACKAGE_VERSION: JSON.stringify('1.2.3')). */
|
|
3
|
-
var APP_VERSION = typeof OVERRIDE_PACKAGE_VERSION !== "undefined" ? OVERRIDE_PACKAGE_VERSION : "3.
|
|
3
|
+
var APP_VERSION = typeof OVERRIDE_PACKAGE_VERSION !== "undefined" ? OVERRIDE_PACKAGE_VERSION : "3.29.0";
|
|
4
4
|
export { APP_VERSION };
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -5,7 +5,7 @@ import type { CaptureOAuth2Callback } from '../blocks/scalar-auth-selector-block
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for the API Client (app and modal).
|
|
7
7
|
*/
|
|
8
|
-
export type ApiClientOptions = Partial<Pick<ApiReferenceConfigurationRaw, 'authentication' | 'baseServerURL' | 'hideClientButton' | 'hiddenClients' | 'oauth2RedirectUri' | 'localization' | 'proxyUrl' | 'servers'>> & {
|
|
8
|
+
export type ApiClientOptions = Partial<Pick<ApiReferenceConfigurationRaw, 'authentication' | 'baseServerURL' | 'hideClientButton' | 'hiddenClients' | 'oauth2RedirectUri' | 'localization' | 'multipartNaming' | 'proxyUrl' | 'servers'>> & {
|
|
9
9
|
/**
|
|
10
10
|
* Custom fetch implementation used for all outgoing API requests.
|
|
11
11
|
* When provided, replaces the global fetch in the request execution engine (sendRequest).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/v2/types/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAA;AAEjG;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CACpC,IAAI,CACF,4BAA4B,EAC1B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,cAAc,GACd,UAAU,GACV,SAAS,CACZ,CACF,GAAG;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;CAC9C,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/v2/types/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAA;AAEjG;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CACpC,IAAI,CACF,4BAA4B,EAC1B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,SAAS,CACZ,CACF,GAAG;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;CAC9C,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAA"}
|
package/dist/vue-styles.css
CHANGED
|
@@ -429,7 +429,7 @@ to {
|
|
|
429
429
|
color: var(--scalar-color-1);
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
[data-v-
|
|
432
|
+
[data-v-efbe965b] .cm-content {
|
|
433
433
|
font-size: var(--scalar-small);
|
|
434
434
|
}
|
|
435
435
|
|
|
@@ -478,20 +478,20 @@ input[data-v-029a43f5]::placeholder {
|
|
|
478
478
|
-moz-text-security: disc;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
.request-section-content[data-v-
|
|
481
|
+
.request-section-content[data-v-2e177312] {
|
|
482
482
|
--scalar-border-width: 0.5px;
|
|
483
483
|
}
|
|
484
|
-
.request-section-content-filter[data-v-
|
|
484
|
+
.request-section-content-filter[data-v-2e177312] {
|
|
485
485
|
box-shadow: 0 -10px 0 10px var(--scalar-background-1);
|
|
486
486
|
}
|
|
487
|
-
.request-item:focus-within .request-meta-buttons[data-v-
|
|
487
|
+
.request-item:focus-within .request-meta-buttons[data-v-2e177312] {
|
|
488
488
|
opacity: 1;
|
|
489
489
|
}
|
|
490
|
-
.group-hover-input[data-v-
|
|
490
|
+
.group-hover-input[data-v-2e177312] {
|
|
491
491
|
border-width: var(--scalar-border-width);
|
|
492
492
|
border-color: transparent;
|
|
493
493
|
}
|
|
494
|
-
.group:hover .group-hover-input[data-v-
|
|
494
|
+
.group:hover .group-hover-input[data-v-2e177312] {
|
|
495
495
|
background: color-mix(
|
|
496
496
|
in srgb,
|
|
497
497
|
var(--scalar-background-1),
|
|
@@ -499,7 +499,7 @@ input[data-v-029a43f5]::placeholder {
|
|
|
499
499
|
);
|
|
500
500
|
border-color: var(--scalar-border-color);
|
|
501
501
|
}
|
|
502
|
-
.group-hover-input[data-v-
|
|
502
|
+
.group-hover-input[data-v-2e177312]:focus {
|
|
503
503
|
background: transparent !important;
|
|
504
504
|
border-color: var(--scalar-border-color) !important;
|
|
505
505
|
}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.
|
|
21
|
+
"version": "3.29.0",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=22"
|
|
24
24
|
},
|
|
@@ -305,33 +305,33 @@
|
|
|
305
305
|
"dependencies": {
|
|
306
306
|
"@headlessui/tailwindcss": "^0.2.2",
|
|
307
307
|
"@headlessui/vue": "1.7.23",
|
|
308
|
-
"@internationalized/date": "3.
|
|
309
|
-
"@scalar/blocks": "0.
|
|
310
|
-
"@scalar/components": "0.35.
|
|
308
|
+
"@internationalized/date": "3.12.4",
|
|
309
|
+
"@scalar/blocks": "0.9.0",
|
|
310
|
+
"@scalar/components": "0.35.5",
|
|
311
311
|
"@scalar/helpers": "0.19.0",
|
|
312
312
|
"@scalar/icons": "0.7.11",
|
|
313
313
|
"@scalar/localization": "0.2.15",
|
|
314
|
-
"@scalar/oas-utils": "0.20.
|
|
314
|
+
"@scalar/oas-utils": "0.20.27",
|
|
315
315
|
"@scalar/openapi-types": "0.9.10",
|
|
316
|
-
"@scalar/sidebar": "0.13.
|
|
317
|
-
"@scalar/snippetz": "0.10.
|
|
318
|
-
"@scalar/themes": "0.21.
|
|
319
|
-
"@scalar/types": "0.
|
|
316
|
+
"@scalar/sidebar": "0.13.2",
|
|
317
|
+
"@scalar/snippetz": "0.10.22",
|
|
318
|
+
"@scalar/themes": "0.21.1",
|
|
319
|
+
"@scalar/types": "0.32.0",
|
|
320
320
|
"@scalar/use-codemirror": "0.14.20",
|
|
321
321
|
"@scalar/use-hooks": "0.4.29",
|
|
322
322
|
"@scalar/use-toasts": "0.10.9",
|
|
323
323
|
"@scalar/validation": "0.6.9",
|
|
324
|
-
"@scalar/workspace-store": "0.
|
|
324
|
+
"@scalar/workspace-store": "0.76.0",
|
|
325
325
|
"@vueuse/core": "15.0.0",
|
|
326
326
|
"@vueuse/integrations": "15.0.0",
|
|
327
327
|
"focus-trap": "^8.2.5",
|
|
328
328
|
"fuse.js": "^7.5.0",
|
|
329
|
-
"js-base64": "^3.9.
|
|
329
|
+
"js-base64": "^3.9.7",
|
|
330
330
|
"jsonc-parser": "3.3.1",
|
|
331
|
-
"nanoid": "^
|
|
331
|
+
"nanoid": "^6.0.2",
|
|
332
332
|
"pretty-ms": "^10.0.0",
|
|
333
333
|
"radix-vue": "^1.9.17",
|
|
334
|
-
"set-cookie-parser": "
|
|
334
|
+
"set-cookie-parser": "4.0.0",
|
|
335
335
|
"vue": "^3.5.45",
|
|
336
336
|
"yaml": "^2.9.1",
|
|
337
337
|
"zod": "^4.6.7"
|
|
@@ -342,12 +342,12 @@
|
|
|
342
342
|
"@vitejs/plugin-vue": "^6.0.11",
|
|
343
343
|
"@vue/test-utils": "2.6.0",
|
|
344
344
|
"fake-indexeddb": "6.2.8",
|
|
345
|
-
"jsdom": "
|
|
346
|
-
"posthog-js": "1.
|
|
345
|
+
"jsdom": "31.0.1",
|
|
346
|
+
"posthog-js": "1.453.0",
|
|
347
347
|
"tailwindcss": "^4.3.5",
|
|
348
348
|
"vite": "8.3.8",
|
|
349
349
|
"vite-svg-loader": "5.1.3",
|
|
350
|
-
"vitest": "5.1.
|
|
350
|
+
"vitest": "5.1.1"
|
|
351
351
|
},
|
|
352
352
|
"scripts": {
|
|
353
353
|
"build": "vite build && pnpm build:styles && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|