@scalar/blocks 0.11.2 → 0.11.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 +28 -0
- package/dist/code-example/components/AsyncApiCodeExample.vue.js +111 -6
- package/dist/code-example/components/AsyncApiCodeExample.vue.js.map +1 -1
- package/dist/code-example/components/AsyncApiCodeExample3.vue.js +8 -0
- package/dist/code-example/components/AsyncApiCodeExample3.vue.js.map +1 -0
- package/dist/code-example/components/CodeExample.vue.d.ts +10 -0
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/CodeExample.vue.js +297 -6
- package/dist/code-example/components/CodeExample.vue.js.map +1 -1
- package/dist/code-example/components/CodeExample3.vue.js +8 -0
- package/dist/code-example/components/CodeExample3.vue.js.map +1 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts +2 -0
- package/dist/code-example/components/ExamplePicker.vue.d.ts.map +1 -1
- package/dist/code-example/components/ExamplePicker.vue.js +50 -4
- package/dist/code-example/components/ExamplePicker.vue.js.map +1 -1
- package/dist/code-example/components/ExamplePicker2.vue.js +6 -0
- package/dist/code-example/components/ExamplePicker2.vue.js.map +1 -0
- package/dist/code-example/components/HttpMethod.vue.js +32 -4
- package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
- package/dist/code-example/components/HttpMethod2.vue.js +6 -0
- package/dist/code-example/components/HttpMethod2.vue.js.map +1 -0
- package/dist/code-example/helpers/filter-clients-by-query.js.map +1 -1
- package/dist/code-example/helpers/find-client.js.map +1 -1
- package/dist/code-example/helpers/format-language.js.map +1 -1
- package/dist/code-example/helpers/generate-client-options.js.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.d.ts +8 -2
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.js +57 -27
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
- package/dist/code-example/helpers/get-asyncapi-example-context.js.map +1 -1
- package/dist/code-example/helpers/get-clients.js.map +1 -1
- package/dist/code-example/helpers/get-custom-code-samples.js.map +1 -1
- package/dist/code-example/helpers/get-generated-payload-example.js.map +1 -1
- package/dist/code-example/helpers/get-message-example-content.js.map +1 -1
- package/dist/code-example/helpers/get-secrets.js.map +1 -1
- package/dist/code-example/helpers/get-snippet.d.ts +2 -2
- package/dist/code-example/helpers/get-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/get-snippet.js +7 -9
- package/dist/code-example/helpers/get-snippet.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +1 -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 +1 -1
- 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 +102 -81
- 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.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.js +49 -47
- 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 +6 -6
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-server-url.js.map +1 -1
- package/dist/code-example/index.d.ts +1 -1
- package/dist/code-example/index.d.ts.map +1 -1
- package/dist/code-example/index.js +14 -14
- package/dist/code-example/mount-asyncapi.js +1 -1
- package/dist/code-example/mount-asyncapi.js.map +1 -1
- package/dist/code-example/mount.js +1 -1
- package/dist/code-example/mount.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/schema/LinkButton.vue.js.map +1 -1
- package/dist/schema/RenderString.vue.js +11 -4
- package/dist/schema/RenderString.vue.js.map +1 -1
- package/dist/schema/RenderString2.vue.js +6 -0
- package/dist/schema/RenderString2.vue.js.map +1 -0
- package/dist/schema/Schema.vue.d.ts.map +1 -1
- package/dist/schema/Schema.vue.js +235 -6
- package/dist/schema/Schema.vue.js.map +1 -1
- package/dist/schema/Schema3.vue.js +8 -0
- package/dist/schema/Schema3.vue.js.map +1 -0
- package/dist/schema/SchemaCollapsedPreview.vue.js +25 -4
- package/dist/schema/SchemaCollapsedPreview.vue.js.map +1 -1
- package/dist/schema/SchemaCollapsedPreview2.vue.js +6 -0
- package/dist/schema/SchemaCollapsedPreview2.vue.js.map +1 -0
- package/dist/schema/SchemaComposition.vue.js +232 -6
- package/dist/schema/SchemaComposition.vue.js.map +1 -1
- package/dist/schema/SchemaComposition3.vue.js +8 -0
- package/dist/schema/SchemaComposition3.vue.js.map +1 -0
- package/dist/schema/SchemaEnumPropertyItem.vue.d.ts +1 -0
- package/dist/schema/SchemaEnumPropertyItem.vue.d.ts.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem.vue.js +23 -4
- package/dist/schema/SchemaEnumPropertyItem.vue.js.map +1 -1
- package/dist/schema/SchemaEnumPropertyItem2.vue.js +6 -0
- package/dist/schema/SchemaEnumPropertyItem2.vue.js.map +1 -0
- package/dist/schema/SchemaEnums.vue.d.ts.map +1 -1
- package/dist/schema/SchemaEnums.vue.js +74 -6
- package/dist/schema/SchemaEnums.vue.js.map +1 -1
- package/dist/schema/SchemaEnums3.vue.js +8 -0
- package/dist/schema/SchemaEnums3.vue.js.map +1 -0
- package/dist/schema/SchemaGlyphPuck.vue.js +27 -4
- package/dist/schema/SchemaGlyphPuck.vue.js.map +1 -1
- package/dist/schema/SchemaGlyphPuck2.vue.js +6 -0
- package/dist/schema/SchemaGlyphPuck2.vue.js.map +1 -0
- package/dist/schema/SchemaGutterToggle.vue.js +40 -4
- package/dist/schema/SchemaGutterToggle.vue.js.map +1 -1
- package/dist/schema/SchemaGutterToggle2.vue.js +6 -0
- package/dist/schema/SchemaGutterToggle2.vue.js.map +1 -0
- package/dist/schema/SchemaHeading.vue.js +32 -6
- package/dist/schema/SchemaHeading.vue.js.map +1 -1
- package/dist/schema/SchemaHeading3.vue.js +8 -0
- package/dist/schema/SchemaHeading3.vue.js.map +1 -0
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js +42 -4
- package/dist/schema/SchemaObjectExampleCodeBlock.vue.js.map +1 -1
- package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js +6 -0
- package/dist/schema/SchemaObjectExampleCodeBlock2.vue.js.map +1 -0
- package/dist/schema/SchemaObjectProperties.vue.js +213 -4
- package/dist/schema/SchemaObjectProperties.vue.js.map +1 -1
- package/dist/schema/SchemaObjectProperties2.vue.js +6 -0
- package/dist/schema/SchemaObjectProperties2.vue.js.map +1 -0
- package/dist/schema/SchemaProperty.vue.d.ts +7 -2
- package/dist/schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/schema/SchemaProperty.vue.js +494 -6
- package/dist/schema/SchemaProperty.vue.js.map +1 -1
- package/dist/schema/SchemaProperty3.vue.js +8 -0
- package/dist/schema/SchemaProperty3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyDefault.vue.js +61 -6
- package/dist/schema/SchemaPropertyDefault.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDefault3.vue.js +8 -0
- package/dist/schema/SchemaPropertyDefault3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyDetail.vue.js +22 -6
- package/dist/schema/SchemaPropertyDetail.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyDetail3.vue.js +8 -0
- package/dist/schema/SchemaPropertyDetail3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyExamples.vue.js +133 -6
- package/dist/schema/SchemaPropertyExamples.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyExamples3.vue.js +8 -0
- package/dist/schema/SchemaPropertyExamples3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyHeading.vue.d.ts +4 -1
- package/dist/schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
- package/dist/schema/SchemaPropertyHeading.vue.js +313 -6
- package/dist/schema/SchemaPropertyHeading.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyHeading3.vue.js +8 -0
- package/dist/schema/SchemaPropertyHeading3.vue.js.map +1 -0
- package/dist/schema/SchemaPropertyPattern.vue.js +42 -6
- package/dist/schema/SchemaPropertyPattern.vue.js.map +1 -1
- package/dist/schema/SchemaPropertyPattern3.vue.js +8 -0
- package/dist/schema/SchemaPropertyPattern3.vue.js.map +1 -0
- package/dist/schema/SchemaRailPanel.vue.js +53 -4
- package/dist/schema/SchemaRailPanel.vue.js.map +1 -1
- package/dist/schema/SchemaRailPanel2.vue.js +6 -0
- package/dist/schema/SchemaRailPanel2.vue.js.map +1 -0
- package/dist/schema/components/CopyLinkButton.vue.js +24 -4
- package/dist/schema/components/CopyLinkButton.vue.js.map +1 -1
- package/dist/schema/components/CopyLinkButton2.vue.js +6 -0
- package/dist/schema/components/CopyLinkButton2.vue.js.map +1 -0
- package/dist/schema/components/WithBreadcrumb.vue.js +15 -4
- package/dist/schema/components/WithBreadcrumb.vue.js.map +1 -1
- package/dist/schema/components/WithBreadcrumb2.vue.js +6 -0
- package/dist/schema/components/WithBreadcrumb2.vue.js.map +1 -0
- package/dist/schema/helpers/dynamic-scope.js.map +1 -1
- package/dist/schema/helpers/format-example.js.map +1 -1
- package/dist/schema/helpers/format-structured-value.d.ts +3 -0
- package/dist/schema/helpers/format-structured-value.d.ts.map +1 -0
- package/dist/schema/helpers/format-structured-value.js +6 -0
- package/dist/schema/helpers/format-structured-value.js.map +1 -0
- package/dist/schema/helpers/format-value.js.map +1 -1
- package/dist/schema/helpers/get-compositions-to-render.d.ts.map +1 -1
- package/dist/schema/helpers/get-compositions-to-render.js +34 -31
- package/dist/schema/helpers/get-compositions-to-render.js.map +1 -1
- package/dist/schema/helpers/get-discriminator-values.js.map +1 -1
- package/dist/schema/helpers/get-enum-values.js.map +1 -1
- package/dist/schema/helpers/get-property-description.js.map +1 -1
- package/dist/schema/helpers/get-ref-name.d.ts +14 -5
- package/dist/schema/helpers/get-ref-name.d.ts.map +1 -1
- package/dist/schema/helpers/get-ref-name.js +8 -11
- package/dist/schema/helpers/get-ref-name.js.map +1 -1
- package/dist/schema/helpers/get-rendered-example.js.map +1 -1
- package/dist/schema/helpers/get-schema-type.js.map +1 -1
- package/dist/schema/helpers/get-type-signature-tokens.d.ts.map +1 -1
- package/dist/schema/helpers/get-type-signature-tokens.js +37 -36
- package/dist/schema/helpers/get-type-signature-tokens.js.map +1 -1
- package/dist/schema/helpers/has-complex-array-items.js.map +1 -1
- package/dist/schema/helpers/index.d.ts +1 -1
- package/dist/schema/helpers/index.d.ts.map +1 -1
- package/dist/schema/helpers/index.js +3 -3
- package/dist/schema/helpers/is-empty-schema-object.js.map +1 -1
- package/dist/schema/helpers/is-model-linkable.js.map +1 -1
- package/dist/schema/helpers/is-on-schema-target-path.js.map +1 -1
- package/dist/schema/helpers/is-type-object.js.map +1 -1
- package/dist/schema/helpers/merge-all-of-schemas.js.map +1 -1
- package/dist/schema/helpers/normalize-object-composition.js.map +1 -1
- package/dist/schema/helpers/optimize-value-for-display.js.map +1 -1
- package/dist/schema/helpers/partition-all-of-compositions.js.map +1 -1
- package/dist/schema/helpers/schema-cycle.js.map +1 -1
- package/dist/schema/helpers/schema-expansion.js.map +1 -1
- package/dist/schema/helpers/schema-keyboard-nav.js.map +1 -1
- package/dist/schema/helpers/schema-name.d.ts +7 -3
- package/dist/schema/helpers/schema-name.d.ts.map +1 -1
- package/dist/schema/helpers/schema-name.js +36 -26
- package/dist/schema/helpers/schema-name.js.map +1 -1
- package/dist/schema/helpers/should-display-description.js.map +1 -1
- package/dist/schema/helpers/should-display-heading.js.map +1 -1
- package/dist/schema/helpers/should-render-array-item-composition.js.map +1 -1
- package/dist/schema/helpers/sort-property-names.js.map +1 -1
- package/dist/schema/helpers/unwrap-for-read.js.map +1 -1
- package/dist/schema/index.js +8 -8
- package/dist/schema/localization/index.js.map +1 -1
- package/dist/schema/localization/translations.js.map +1 -1
- package/dist/shared/Badge.vue.js +13 -6
- package/dist/shared/Badge.vue.js.map +1 -1
- package/dist/shared/Badge3.vue.js +8 -0
- package/dist/shared/Badge3.vue.js.map +1 -0
- package/dist/shared/ExternalDocs.vue.d.ts +2 -0
- package/dist/shared/ExternalDocs.vue.d.ts.map +1 -1
- package/dist/shared/ExternalDocs.vue.js +50 -4
- package/dist/shared/ExternalDocs.vue.js.map +1 -1
- package/dist/shared/ExternalDocs2.vue.js +6 -0
- package/dist/shared/ExternalDocs2.vue.js.map +1 -0
- package/dist/shared/ExternalExampleStatus.vue.js +24 -4
- package/dist/shared/ExternalExampleStatus.vue.js.map +1 -1
- package/dist/shared/ExternalExampleStatus2.vue.js +6 -0
- package/dist/shared/ExternalExampleStatus2.vue.js.map +1 -0
- package/dist/shared/ScreenReader.vue.js +16 -4
- package/dist/shared/ScreenReader.vue.js.map +1 -1
- package/dist/shared/ScreenReader2.vue.js +6 -0
- package/dist/shared/ScreenReader2.vue.js.map +1 -0
- package/dist/shared/external-example-localization/index.js.map +1 -1
- package/dist/shared/external-example-localization/translations.js.map +1 -1
- package/dist/shared/index.js +4 -4
- package/dist/specification-extensions/ExtensionValue.vue.js +89 -4
- package/dist/specification-extensions/ExtensionValue.vue.js.map +1 -1
- package/dist/specification-extensions/ExtensionValue2.vue.js +6 -0
- package/dist/specification-extensions/ExtensionValue2.vue.js.map +1 -0
- package/dist/specification-extensions/SpecificationExtensions.vue.js +76 -4
- package/dist/specification-extensions/SpecificationExtensions.vue.js.map +1 -1
- package/dist/specification-extensions/SpecificationExtensions2.vue.js +6 -0
- package/dist/specification-extensions/SpecificationExtensions2.vue.js.map +1 -0
- package/dist/specification-extensions/index.js +1 -1
- package/dist/style.css +23 -19
- package/dist/vue-styles.css +1 -1
- package/package.json +19 -19
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js +0 -113
- package/dist/code-example/components/AsyncApiCodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js +0 -269
- package/dist/code-example/components/CodeExample.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js +0 -48
- package/dist/code-example/components/ExamplePicker.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js +0 -34
- package/dist/code-example/components/HttpMethod.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js +0 -13
- package/dist/schema/RenderString.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js +0 -237
- package/dist/schema/Schema.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js +0 -27
- package/dist/schema/SchemaCollapsedPreview.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js +0 -234
- package/dist/schema/SchemaComposition.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js +0 -23
- package/dist/schema/SchemaEnumPropertyItem.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js +0 -77
- package/dist/schema/SchemaEnums.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js +0 -29
- package/dist/schema/SchemaGlyphPuck.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js +0 -42
- package/dist/schema/SchemaGutterToggle.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js +0 -34
- package/dist/schema/SchemaHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js +0 -44
- package/dist/schema/SchemaObjectExampleCodeBlock.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js +0 -215
- package/dist/schema/SchemaObjectProperties.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js +0 -474
- package/dist/schema/SchemaProperty.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js +0 -63
- package/dist/schema/SchemaPropertyDefault.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js +0 -24
- package/dist/schema/SchemaPropertyDetail.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js +0 -135
- package/dist/schema/SchemaPropertyExamples.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js +0 -314
- package/dist/schema/SchemaPropertyHeading.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js +0 -44
- package/dist/schema/SchemaPropertyPattern.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js +0 -55
- package/dist/schema/SchemaRailPanel.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js +0 -26
- package/dist/schema/components/CopyLinkButton.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js +0 -17
- package/dist/schema/components/WithBreadcrumb.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js +0 -15
- package/dist/shared/Badge.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js +0 -45
- package/dist/shared/ExternalDocs.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js +0 -26
- package/dist/shared/ExternalExampleStatus.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js +0 -18
- package/dist/shared/ScreenReader.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js +0 -91
- package/dist/specification-extensions/ExtensionValue.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js +0 -78
- package/dist/specification-extensions/SpecificationExtensions.vue_vue_type_script_setup_true_lang.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-body.js","names":["buildFileParam","fileName","contentType","isBinarySchema","schema","getBinaryPlaceholderFileName","value","objectToFormParams","params","entries","obj","item","key","partEncoding","parentKey","encoding","isMultipart","restored","coerceLeafValueToSchemaType","resolveLeafSchema","arrayParts","serializeMultipartArray","part","hasFormStyle","explicitContentType","binaryPlaceholderFileName","styleParams","serializeFormPropertyWithEncoding","param","file","unpackProxyObject","nestedParams","processBody","_contentType","requestBody","harMimeType","formatBinaryFile","media","aspNetNaming","usesAspNetFormNaming","multipartNaming","needsMultipartEncoding","exampleName","example","body","buildRequestBody","requestBodyCompositionSelection","openapiVersion","jsonSchemaDialect","encoded","serializeMultipartBody","chunk","isFormData","isXmlMediaType","xmlExample","getExampleFromBody","selected","getExampleValue","getExample","explicitText","getExplicitExampleText","_example","exampleValue","getResolvedRef","mergeSiblingReferences","serializeStreamExample","mediaType","contentSchema","exampleSchema","snapshotSchema","isObjectSchema","name","property","resolved","resolve","isArraySchema","isFileSchema","binary","getStreamFormat","extractedExample","getExampleFromSchema"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { getStreamFormat } from '@scalar/helpers/http/is-streaming-content-type'\nimport { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n usesAspNetFormNaming,\n} from '@scalar/workspace-store/request-example'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema, isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n | 'multipartNaming'\n | 'contentType'\n | 'example'\n | 'requestBodyCompositionSelection'\n | 'openapiVersion'\n | 'jsonSchemaDialect'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n multipartNaming,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n const aspNetNaming = usesAspNetFormNaming(_contentType, media, multipartNaming)\n if (media && (aspNetNaming || needsMultipartEncoding(_contentType, media))) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n { multipartNaming, aspNetFilePlaceholders: aspNetNaming && _contentType === 'multipart/form-data' },\n )\n if (aspNetNaming && body?.mode === 'urlencoded') {\n return { mimeType: harMimeType, params: body.value.map(({ key, value }) => ({ name: key, value })) }\n }\n if (aspNetNaming && body?.mode === 'formdata') {\n return {\n mimeType: harMimeType,\n params: body.value.flatMap((part): Param[] => {\n if (part.type === 'file') {\n return [buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type)]\n }\n if (part.type !== 'text') {\n return []\n }\n return [{ name: part.key, value: part.value, ...(part.contentType ? { contentType: part.contentType } : {}) }]\n }),\n }\n }\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return formatBinaryFile(chunk)\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // Try to extract examples from the schema\n const mediaType = requestBody.content[_contentType]\n const contentSchema = getResolvedRef(mediaType?.schema ?? mediaType?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const exampleSchema = snapshotSchema(contentSchema)\n if (_contentType === 'multipart/form-data' && isObjectSchema(exampleSchema)) {\n // Adapt upgraded upload fields only on the code example's private snapshot.\n // The generator already supports the legacy binary shape, including file arrays.\n for (const [name, property] of Object.entries(exampleSchema.properties ?? {})) {\n const resolved = resolve.schema(property)\n const file = resolved && isArraySchema(resolved) ? resolve.schema(resolved.items) : resolved\n if (\n file &&\n !('type' in file) &&\n !('properties' in file) &&\n !file.allOf &&\n !file.oneOf &&\n !file.anyOf &&\n !file.contentSchema &&\n isFileSchema(file, false)\n ) {\n const binary: SchemaObject = { ...file, type: 'string', format: 'binary' }\n exampleSchema.properties![name] =\n resolved && isArraySchema(resolved) ? { ...resolved, items: binary } : binary\n }\n }\n }\n // A migrated whole-body binary schema is empty. Do not infer files from\n // declared values, constraints, compositions, or schemas for individual stream items.\n const isEmptyBinaryBody =\n !isFormData &&\n mediaType?.schema !== undefined &&\n Object.keys(exampleSchema).every((key) => ['__scalar_', 'title', 'description'].includes(key)) &&\n !getStreamFormat(_contentType) &&\n isFileSchema(exampleSchema, false, _contentType)\n if (isEmptyBinaryBody) {\n return { mimeType: harMimeType, text: '@filename' }\n }\n const extractedExample = getExampleFromSchema(\n exampleSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n openapiVersion,\n jsonSchemaDialect,\n binaryAsFile: _contentType === 'multipart/form-data',\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, mediaType?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;AAmDA,IAAMA,KAAkB,GAAc,GAAkB,OAAiC;CACvF;CACA,OAAO,IAAIC;CACX;CAC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C,IAAmBC,EACvBZ,GACA;GACE,sBAAsBtB;GACtB,MAAM;GACN;GACA;GACA,cAAcb,MAAiB;EACjC,GACA,EACE,YAAY,CAAC,aAAa,EAC5B,CACF;EAEA,IAAI8C,MAAqB,KAAA,GAcvB,OAbI3B,KAAc,OAAO2B,KAAqB,YAAYA,IACjD;GACL,UAAU5C;GACV,QAAQ5B,EACNwE,GACAhE,GACA,KAAA,GACAkB,MAAiB,uBACjBkC,CACF;EACF,IAGK;GACL,UAAUhC;GACV,MACE8B,EAAuBc,GAAkB9C,GAAciC,GAAW,WAAW,KAAA,CAAS,MACrF,OAAOa,KAAqB,WAAWA,IAAmB,KAAK,UAAUA,CAAgB;EAC9F;CAEJ;AAGF"}
|
|
1
|
+
{"version":3,"file":"process-body.js","names":["snapshotSchema","buildRequestBody","coerceLeafValueToSchemaType","getExample","getExampleFromBody","getExampleFromSchema","needsMultipartEncoding","resolveLeafSchema","serializeFormPropertyWithEncoding","serializeMultipartArray","serializeMultipartBody","usesAspNetFormNaming","isXmlMediaType","parseMimeType","getExampleValue","getExplicitExampleText","getResolvedRef","mergeSiblingReferences","getStreamFormat","isYamlMediaType","isFileSchema","serializeStreamExample","unpackProxyObject","resolve","isArraySchema","isObjectSchema","binarySchemaMetadata","buildFileParam","name","fileName","contentType","isBinarySchema","schema","getBinaryPlaceholderFileName","value","objectToFormParams","obj","encoding","parentKey","isMultipart","params","entries","item","key","partEncoding","restored","arrayParts","part","hasFormStyle","explicitContentType","binaryPlaceholderFileName","styleParams","param","file","nestedParams","processBody","requestBody","example","openapiVersion","jsonSchemaDialect","requestBodyCompositionSelection","multipartNaming","_contentType","harMimeType","getFileName","filePostData","media","aspNetNaming","exampleName","body","encoded","chunk","isFormData","xmlExample","selected","explicitText","_example","exampleValue","streamFormat","essence","isNonFormWholeBody","supportsRawBinaryMediaType","contentSchema","exampleSchema","property","resolved","binary","schemaPath","isWholeBody","extractedExample"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { getStreamFormat } from '@scalar/helpers/http/is-streaming-content-type'\nimport { isXmlMediaType } from '@scalar/helpers/http/is-xml-media-type'\nimport { isYamlMediaType } from '@scalar/helpers/http/is-yaml-media-type'\nimport { parseMimeType } from '@scalar/helpers/http/mime-type'\nimport type { HarRequest } from '@scalar/types/snippetz'\nimport { getExampleValue, getExplicitExampleText } from '@scalar/workspace-store/helpers/get-example-value'\nimport { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { isFileSchema } from '@scalar/workspace-store/helpers/is-file-schema'\nimport { serializeStreamExample } from '@scalar/workspace-store/helpers/serialize-stream-example'\nimport { snapshotSchema } from '@scalar/workspace-store/helpers/snapshot-schema'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n buildRequestBody,\n coerceLeafValueToSchemaType,\n getExample,\n getExampleFromBody,\n getExampleFromSchema,\n needsMultipartEncoding,\n resolveLeafSchema,\n serializeFormPropertyWithEncoding,\n serializeMultipartArray,\n serializeMultipartBody,\n usesAspNetFormNaming,\n} from '@scalar/workspace-store/request-example'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema, isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\nimport type { Param } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\n// These fields describe or identify a schema without applying assertions to the body.\nconst binarySchemaMetadata = new Set([\n '__scalar_',\n '$schema',\n '$id',\n '$anchor',\n '$dynamicAnchor',\n '$comment',\n '$defs',\n '$vocabulary',\n 'definitions',\n 'title',\n 'description',\n 'deprecated',\n 'readOnly',\n 'writeOnly',\n 'externalDocs',\n 'xml',\n])\n\ntype ProcessBodyProps = Pick<\n OperationToHarProps,\n | 'multipartNaming'\n | 'contentType'\n | 'example'\n | 'requestBodyCompositionSelection'\n | 'openapiVersion'\n | 'jsonSchemaDialect'\n> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Builds a HAR param for an uploaded file. `fileName` is what snippet generators read to emit real\n * file handling (for example `files=` in Python or `new Blob` in fetch). `value` keeps the\n * `@filename` placeholder for consumers that only read the text value.\n */\nconst buildFileParam = (name: string, fileName: string, contentType?: string): Param => ({\n name,\n value: `@${fileName}`,\n fileName,\n ...(contentType ? { contentType } : {}),\n})\n\n/** True when the schema describes a binary file (`type: string, format: binary`). */\nconst isBinarySchema = (schema: SchemaObject | undefined): boolean =>\n !!schema && 'type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary'\n\n/**\n * Example generation turns a binary property into the `@filename` placeholder string.\n * Use the schema to tell that apart from a normal text field that happens to start with `@`.\n */\nconst getBinaryPlaceholderFileName = (value: unknown, schema: SchemaObject | undefined): string | undefined =>\n typeof value === 'string' && value.startsWith('@') && isBinarySchema(schema) ? value.slice(1) : undefined\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * Multipart arrays apply the encoding to each item and repeat the property name.\n * Object items default to JSON, and uploaded files retain their filename references.\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object properties and array items. Urlencoded bodies retain their existing\n * serialization and flattening behavior.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n schema?: SchemaObject,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n\n if (isMultipart && !parentKey) {\n const restored = Array.isArray(obj) ? coerceLeafValueToSchemaType(value, resolveLeafSchema(schema, [key])) : value\n const arrayParts = serializeMultipartArray(key, Array.isArray(restored) ? restored : value, partEncoding)\n if (arrayParts) {\n for (const part of arrayParts) {\n if (part.value instanceof File) {\n params.push(buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type))\n continue\n }\n params.push({\n name: part.key,\n value: part.value,\n ...(part.contentType ? { contentType: part.contentType } : {}),\n })\n }\n continue\n }\n }\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const binaryPlaceholderFileName =\n isMultipart && !parentKey ? getBinaryPlaceholderFileName(value, resolveLeafSchema(schema, [key])) : undefined\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push(buildFileParam(key, file.name, explicitContentType ?? (isMultipart ? file.type : undefined)))\n } else if (binaryPlaceholderFileName !== undefined) {\n /** A binary property filled in by example generation, so it is a file and not a text field. */\n params.push(buildFileParam(key, binaryPlaceholderFileName, explicitContentType))\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push(buildFileParam(key, file.name, isMultipart ? file.type : undefined))\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n openapiVersion,\n jsonSchemaDialect,\n requestBodyCompositionSelection,\n multipartNaming,\n}: ProcessBodyProps): HarRequest['postData'] => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const getFileName = (file: File): string => unpackProxyObject(file).name || 'filename'\n const filePostData = (fileName: string): HarRequest['postData'] => ({\n mimeType: harMimeType,\n text: `@${fileName}`,\n _fileName: fileName,\n })\n const encoding = requestBody.content[_contentType]?.encoding\n\n const media = requestBody.content[_contentType]\n const aspNetNaming = usesAspNetFormNaming(_contentType, media, multipartNaming)\n if (media && (aspNetNaming || needsMultipartEncoding(_contentType, media))) {\n const exampleName = example ?? Object.keys(media.examples ?? {})[0] ?? 'default'\n const body = buildRequestBody(\n { ...requestBody, 'x-scalar-selected-content-type': { [exampleName]: _contentType } },\n exampleName,\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n { multipartNaming, aspNetFilePlaceholders: aspNetNaming && _contentType === 'multipart/form-data' },\n )\n if (aspNetNaming && body?.mode === 'urlencoded') {\n return { mimeType: harMimeType, params: body.value.map(({ key, value }) => ({ name: key, value })) }\n }\n if (aspNetNaming && body?.mode === 'formdata') {\n return {\n mimeType: harMimeType,\n params: body.value.flatMap((part): Param[] => {\n if (part.type === 'file') {\n return [buildFileParam(part.key, part.value.name, part.contentType ?? part.value.type)]\n }\n if (part.type !== 'text') {\n return []\n }\n return [{ name: part.key, value: part.value, ...(part.contentType ? { contentType: part.contentType } : {}) }]\n }),\n }\n }\n if (body?.mode === 'multipart') {\n const encoded = serializeMultipartBody(body.value, body.contentType)\n return {\n mimeType: encoded.contentType,\n // HAR text cannot embed file bytes synchronously. Keep visible file placeholders.\n text: encoded.chunks\n .map((chunk) => {\n if (chunk instanceof File) {\n return `@${getFileName(chunk)}`\n }\n return chunk instanceof Blob ? 'BINARY' : String(chunk)\n })\n .join(''),\n }\n }\n }\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n if (isXmlMediaType(_contentType)) {\n const xmlExample = getExampleFromBody(\n requestBody,\n _contentType,\n example ?? '',\n requestBodyCompositionSelection,\n openapiVersion,\n jsonSchemaDialect,\n )\n return xmlExample ? { mimeType: harMimeType, text: xmlExample.value as string } : undefined\n }\n\n // Get the example value\n const selected = getExampleValue(getExample(requestBody, example, contentType))\n const explicitText = getExplicitExampleText(selected, _contentType)\n if (explicitText !== undefined) {\n return { mimeType: harMimeType, text: explicitText }\n }\n const _example = selected?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n exampleValue,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n getResolvedRef(requestBody.content[_contentType]?.schema, mergeSiblingReferences),\n ),\n }\n }\n\n if (exampleValue instanceof File) {\n return filePostData(getFileName(exampleValue))\n }\n\n return {\n mimeType: harMimeType,\n text:\n typeof exampleValue === 'string'\n ? exampleValue\n : (serializeStreamExample(exampleValue, _contentType, false) ?? JSON.stringify(exampleValue)),\n }\n }\n\n // OpenAPI 3.1+ can describe a raw binary body using just its media type.\n const streamFormat = getStreamFormat(_contentType)\n const { essence } = parseMimeType(_contentType)\n const isNonFormWholeBody =\n !isFormData &&\n !streamFormat &&\n !isYamlMediaType(essence) &&\n !['application/x-www-form-urlencoded', 'application/edn', 'application/graphql', 'application/javascript'].includes(\n essence,\n )\n const supportsRawBinaryMediaType = openapiVersion === undefined || /^3\\.[1-9]\\d*(?:\\.|$)/.test(openapiVersion)\n if (\n media &&\n media.schema === undefined &&\n media.itemSchema === undefined &&\n supportsRawBinaryMediaType &&\n isNonFormWholeBody &&\n !essence.includes('*') &&\n isFileSchema({ __scalar_: '' }, false, _contentType)\n ) {\n return filePostData('filename')\n }\n\n const contentSchema = getResolvedRef(media?.schema ?? media?.itemSchema)\n if (typeof contentSchema !== 'undefined') {\n const exampleSchema = snapshotSchema(contentSchema)\n if (_contentType === 'multipart/form-data' && isObjectSchema(exampleSchema)) {\n // Adapt upgraded upload fields only on the code example's private snapshot.\n // The generator already supports the legacy binary shape, including file arrays.\n for (const [name, property] of Object.entries(exampleSchema.properties ?? {})) {\n const resolved = resolve.schema(property)\n const file = resolved && isArraySchema(resolved) ? resolve.schema(resolved.items) : resolved\n if (\n file &&\n !('type' in file) &&\n !('properties' in file) &&\n !file.allOf &&\n !file.oneOf &&\n !file.anyOf &&\n !file.contentSchema &&\n isFileSchema(file, false)\n ) {\n const binary: SchemaObject = { ...file, type: 'string', format: 'binary' }\n exampleSchema.properties![name] =\n resolved && isArraySchema(resolved) ? { ...resolved, items: binary } : binary\n }\n }\n }\n // A raw binary schema can omit its type and carry only annotations.\n // Any constraints or authored examples still go through schema example generation.\n const isMetadataOnlyBinaryBody =\n isNonFormWholeBody &&\n media?.schema !== undefined &&\n !exampleSchema.readOnly &&\n Object.keys(exampleSchema).every(\n (key) => binarySchemaMetadata.has(key) || (supportsRawBinaryMediaType && key === 'contentMediaType'),\n ) &&\n isFileSchema(exampleSchema, false, _contentType)\n if (isMetadataOnlyBinaryBody) {\n return filePostData('filename')\n }\n const schemaPath = ['requestBody']\n // A legacy mixed multipart schema can describe a file containing the complete payload.\n const isWholeBody = !streamFormat || (streamFormat === 'multipart' && media?.schema !== undefined)\n const extractedExample = getExampleFromSchema(\n exampleSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n openapiVersion,\n jsonSchemaDialect,\n binaryAsFile: _contentType === 'multipart/form-data',\n generatedBinaryFilePath: !isFormData && isWholeBody ? schemaPath : undefined,\n },\n {\n schemaPath,\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(\n extractedExample,\n encoding,\n undefined,\n _contentType === 'multipart/form-data',\n contentSchema,\n ),\n }\n }\n\n if (extractedExample instanceof File) {\n return filePostData(getFileName(extractedExample))\n }\n\n return {\n mimeType: harMimeType,\n text:\n serializeStreamExample(extractedExample, _contentType, media?.schema === undefined) ??\n (typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample)),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,IAAM0B,oBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAqBKC,KAAkBC,GAAcC,GAAkBC,OAAiC;CACvFF;CACA,OAAO,IAAIC;CACXA;CACA,GAAIC,IAAc,EAAEA,eAAY,IAAI,CAAC;AACvC,IAGMC,KAAkBC,MACtB,CAAC,CAACA,KAAU,UAAUA,KAAUA,EAAO,SAAS,YAAY,YAAYA,KAAUA,EAAO,WAAW,UAMhGC,KAAgCC,GAAgBF,MACpD,OAAOE,KAAU,YAAYA,EAAM,WAAW,GAAG,KAAKH,EAAeC,CAAM,IAAIE,EAAM,MAAM,CAAC,IAAI,KAAA,GAsB5FC,KACJC,GACAC,GACAC,GACAC,IAAc,IACdP,MACY;CACZ,IAAMQ,IAAkB,CAAC,GAGnBC,IAA+B,MAAM,QAAQL,CAAG,IAClDA,EAAI,QAAQM,MAA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AAQ,kBACnF,KACAvB,EAAa+D,GAAe,IAAOrB,CAAY,GAE/C,OAAOG,EAAa,UAAU;EAEhC,IAAMsB,IAAa,CAAC,aAAa,GAE3BC,IAAc,CAACV,KAAiBA,MAAiB,eAAeZ,GAAO,WAAW,KAAA,GAClFuB,IAAmBpF,EACvB8E,GACA;GACE,sBAAsBvB;GACtB,MAAM;GACNF;GACAC;GACA,cAAcG,MAAiB;GAC/B,yBAAyB,CAACU,KAAcgB,IAAcD,IAAa,KAAA;EACrE,GACA,EACEA,cACF,CACF;EAEA,IAAIE,MAAqB,KAAA,GAkBvB,OAjBIjB,KAAc,OAAOiB,KAAqB,YAAYA,IACjD;GACL,UAAU1B;GACV,QAAQ5B,EACNsD,GACApD,GACA,KAAA,GACAyB,MAAiB,uBACjBoB,CACF;EACF,IAGEO,aAA4B,OACvBxB,EAAaD,EAAYyB,CAAgB,CAAC,IAG5C;GACL,UAAU1B;GACV,MACE1C,EAAuBoE,GAAkB3B,GAAcI,GAAO,WAAW,KAAA,CAAS,MACjF,OAAOuB,KAAqB,WAAWA,IAAmB,KAAK,UAAUA,CAAgB;EAC9F;CAEJ;AAGF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,wFAAwF;AACxF,qBAAa,wBAAyB,SAAQ,KAAK;CAAG;AAEtD,KAAK,mBAAmB,GAAG;IACzB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA;AA6GD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,0FAO/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;IACxB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,KAAG,mBAkSH,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { deSerializeParameter as e, encodeReservedQueryValue as t, filterDisabledProperties as n, getExampleFromSchema as r, isParamDisabled as i, serializeContentValue as a, serializeCookieStyle as o, serializeDeepObjectStyle as s, serializeFormStyle as c, serializeFormStyleForCookies as l, serializePipeDelimitedStyle as u, serializeSimpleStyle as d, serializeSpaceDelimitedStyle as f } from "@scalar/workspace-store/request-example";
|
|
2
2
|
import { getResolvedRef as p } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { isVersionLessThan as m } from "@scalar/helpers/general/compare-versions";
|
|
4
|
+
import { getCookieSerializationError as h } from "@scalar/helpers/http/get-cookie-serialization-error";
|
|
5
|
+
import { replacePathVariables as g } from "@scalar/helpers/regex/replace-variables";
|
|
6
|
+
import { assertReservedPathUrl as _, hasPathDotSegment as v, includesUndefinedPathPrefix as y, serializePathParameter as b, serializeReservedPathParameter as x } from "@scalar/workspace-store/helpers/encode-path-parameter";
|
|
7
|
+
import { getParameterExample as S } from "@scalar/workspace-store/helpers/get-parameter-example";
|
|
8
|
+
import { getQuerystringParameter as C, serializeQuerystringParameter as w } from "@scalar/workspace-store/helpers/querystring-parameter";
|
|
8
9
|
// src/code-example/helpers/operation-to-har/process-parameters.ts
|
|
9
|
-
var
|
|
10
|
+
var T = class extends Error {}, E = (e) => (e ?? []).map((e) => p(e)).filter((e) => e !== void 0), D = (e) => "allowReserved" in e && e.allowReserved !== void 0 ? e.allowReserved : "schema" in e && e.schema && typeof e.schema == "object" && "allowReserved" in e.schema ? e.schema.allowReserved === !0 : !1, O = (e) => {
|
|
10
11
|
if (e.in === "header") return {
|
|
11
12
|
style: "simple",
|
|
12
13
|
explode: "explode" in e && e.explode !== void 0 && e.explode
|
|
@@ -29,8 +30,8 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
29
30
|
style: n,
|
|
30
31
|
explode: "explode" in e && e.explode !== void 0 ? e.explode : n === "form"
|
|
31
32
|
};
|
|
32
|
-
},
|
|
33
|
-
let l =
|
|
33
|
+
}, k = (t, a, o, s, c) => {
|
|
34
|
+
let l = S(t, a, s), u = l.example, d = t.in === "query" && !l.serialized && !l.mediaSerialized ? u?.["x-scalar-disabled-properties"] : void 0;
|
|
34
35
|
if (d) return n(e(l.value, t), d, i(t, u, o));
|
|
35
36
|
if (i(t, u, o)) return;
|
|
36
37
|
if (l.value !== void 0) return e(l.value, t);
|
|
@@ -40,35 +41,36 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
40
41
|
jsonSchemaDialect: c,
|
|
41
42
|
...t.in === "path" ? {
|
|
42
43
|
emptyString: `{${t.name}}`,
|
|
43
|
-
preserveStringFallback: !0
|
|
44
|
+
preserveStringFallback: !0,
|
|
45
|
+
ignoreSchemaConst: s !== void 0 && m(s, "3.1.0")
|
|
44
46
|
} : {}
|
|
45
|
-
},
|
|
46
|
-
return
|
|
47
|
-
},
|
|
47
|
+
}, h = p(t.schema);
|
|
48
|
+
return h ? r(h, f) : void 0;
|
|
49
|
+
}, A = ({ harRequest: n, parameters: r, example: p, defaultDisabled: m, openapiVersion: A, jsonSchemaDialect: j }) => {
|
|
48
50
|
let M = [...n.headers], N = [...n.queryString], P = [...n.cookies], F = [], I = n.url, L = n.url, R = !1, z = !1, B = [], V = [], H = (e, t, n = !1) => {
|
|
49
|
-
I =
|
|
51
|
+
I = g(I, { [e]: t }), L = g(L, { [e]: n ? `x${t}` : t }), R ||= n;
|
|
50
52
|
}, U = (e, n, r) => {
|
|
51
|
-
|
|
53
|
+
D(r) ? B.push(`${encodeURIComponent(e)}=${t(n)}`) : N.push({
|
|
52
54
|
name: e,
|
|
53
55
|
value: n
|
|
54
56
|
});
|
|
55
|
-
}, W =
|
|
57
|
+
}, W = E(r);
|
|
56
58
|
for (let t of W) {
|
|
57
59
|
if (!t.in || !t.name) continue;
|
|
58
60
|
if (t.in === "querystring") {
|
|
59
|
-
let e =
|
|
60
|
-
defaultDisabled:
|
|
61
|
+
let e = C(t, p, {
|
|
62
|
+
defaultDisabled: m,
|
|
61
63
|
openapiVersion: A,
|
|
62
64
|
jsonSchemaDialect: j
|
|
63
65
|
});
|
|
64
66
|
if (e) {
|
|
65
|
-
let t = I.indexOf("#"), n = t === -1 ? "" : I.slice(t), r = (t === -1 ? I : I.slice(0, t)).split("?")[0], i =
|
|
67
|
+
let t = I.indexOf("#"), n = t === -1 ? "" : I.slice(t), r = (t === -1 ? I : I.slice(0, t)).split("?")[0], i = w(e);
|
|
66
68
|
I = `${r}${i ? `?${i}` : ""}${n}`;
|
|
67
69
|
}
|
|
68
70
|
continue;
|
|
69
71
|
}
|
|
70
|
-
let n =
|
|
71
|
-
if (n.serialized && !i(t, n.example,
|
|
72
|
+
let n = S(t, p, A);
|
|
73
|
+
if (n.serialized && !i(t, n.example, m)) {
|
|
72
74
|
let e = String(n.value);
|
|
73
75
|
switch (t.in) {
|
|
74
76
|
case "path":
|
|
@@ -87,7 +89,7 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
87
89
|
}
|
|
88
90
|
continue;
|
|
89
91
|
}
|
|
90
|
-
if (n.mediaSerialized && !i(t, n.example,
|
|
92
|
+
if (n.mediaSerialized && !i(t, n.example, m)) {
|
|
91
93
|
let e = String(n.value);
|
|
92
94
|
switch (t.in) {
|
|
93
95
|
case "query":
|
|
@@ -109,67 +111,67 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
109
111
|
}
|
|
110
112
|
continue;
|
|
111
113
|
}
|
|
112
|
-
let { style: r, explode:
|
|
113
|
-
if (!(
|
|
114
|
+
let { style: r, explode: g } = O(t), _ = t.in === "path" && (r === "matrix" || r === "label"), v = _ ? e(n.value, t) : k(t, p, m, A, j);
|
|
115
|
+
if (!(_ ? !n.example || i(t, n.example, m) : v === void 0)) switch (t.in) {
|
|
114
116
|
case "path": {
|
|
115
117
|
let e = A?.startsWith("3.2.") && "schema" in t && t.allowReserved === !0;
|
|
116
|
-
if (z ||= !!e,
|
|
117
|
-
let n =
|
|
118
|
-
value:
|
|
118
|
+
if (z ||= !!e, _) {
|
|
119
|
+
let n = b(t.name, {
|
|
120
|
+
value: v,
|
|
119
121
|
style: r,
|
|
120
|
-
explode:
|
|
121
|
-
includeUndefinedPrefix:
|
|
122
|
+
explode: g,
|
|
123
|
+
includeUndefinedPrefix: y(A)
|
|
122
124
|
}, void 0, e), i = r === "matrix" ? ";" : ".";
|
|
123
125
|
H(I.includes(`{${t.name}}`) ? t.name : `${i}${t.name}`, n, r === "label" && !e);
|
|
124
|
-
} else if (e) H(t.name,
|
|
125
|
-
value:
|
|
126
|
+
} else if (e) H(t.name, x(t.name, {
|
|
127
|
+
value: v,
|
|
126
128
|
style: r,
|
|
127
|
-
explode:
|
|
129
|
+
explode: g
|
|
128
130
|
}));
|
|
129
131
|
else {
|
|
130
|
-
let e = r === "simple" ? d(
|
|
132
|
+
let e = r === "simple" ? d(v, g) : v;
|
|
131
133
|
H(t.name, String(e));
|
|
132
134
|
}
|
|
133
135
|
break;
|
|
134
136
|
}
|
|
135
137
|
case "query":
|
|
136
138
|
if ("content" in t && t.content) {
|
|
137
|
-
let e = Object.keys(t.content)[0] ?? "application/json", n = a(
|
|
139
|
+
let e = Object.keys(t.content)[0] ?? "application/json", n = a(v, e);
|
|
138
140
|
U(t.name, n, t);
|
|
139
141
|
break;
|
|
140
142
|
}
|
|
141
143
|
switch (r) {
|
|
142
144
|
case "form": {
|
|
143
|
-
let e = c(
|
|
145
|
+
let e = c(v, g);
|
|
144
146
|
if (Array.isArray(e)) for (let n of e) U(n.key || t.name, String(n.value), t);
|
|
145
147
|
else U(t.name, String(e), t);
|
|
146
148
|
break;
|
|
147
149
|
}
|
|
148
150
|
case "spaceDelimited": {
|
|
149
|
-
let e = f(
|
|
151
|
+
let e = f(v);
|
|
150
152
|
U(t.name, e, t);
|
|
151
153
|
break;
|
|
152
154
|
}
|
|
153
155
|
case "pipeDelimited": {
|
|
154
|
-
let e = u(
|
|
156
|
+
let e = u(v);
|
|
155
157
|
U(t.name, e, t);
|
|
156
158
|
break;
|
|
157
159
|
}
|
|
158
160
|
case "deepObject":
|
|
159
|
-
if (Array.isArray(
|
|
160
|
-
let e = c(
|
|
161
|
+
if (Array.isArray(v)) {
|
|
162
|
+
let e = c(v, !0);
|
|
161
163
|
if (Array.isArray(e)) for (let n of e) U(n.key || t.name, String(n.value), t);
|
|
162
164
|
else U(t.name, String(e), t);
|
|
163
165
|
} else {
|
|
164
|
-
let e = s(t.name,
|
|
166
|
+
let e = s(t.name, v);
|
|
165
167
|
for (let n of e) U(n.key, n.value, t);
|
|
166
168
|
}
|
|
167
169
|
break;
|
|
168
|
-
default: U(t.name, String(
|
|
170
|
+
default: U(t.name, String(v), t);
|
|
169
171
|
}
|
|
170
172
|
break;
|
|
171
173
|
case "header": {
|
|
172
|
-
let e = d(
|
|
174
|
+
let e = d(v, g);
|
|
173
175
|
M.push({
|
|
174
176
|
name: t.name,
|
|
175
177
|
value: String(e)
|
|
@@ -177,13 +179,13 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
177
179
|
break;
|
|
178
180
|
}
|
|
179
181
|
case "cookie": {
|
|
180
|
-
let [e, n] = (A ?? "").split("."), i = e === "3" && n === "2" && !("content" in t) ?
|
|
181
|
-
if (i) throw new
|
|
182
|
+
let [e, n] = (A ?? "").split("."), i = e === "3" && n === "2" && !("content" in t) ? h(t, v) : void 0;
|
|
183
|
+
if (i) throw new T(i);
|
|
182
184
|
if (r === "cookie") {
|
|
183
|
-
F.push(...o(t.name,
|
|
185
|
+
F.push(...o(t.name, v, g));
|
|
184
186
|
break;
|
|
185
187
|
}
|
|
186
|
-
let a = l(
|
|
188
|
+
let a = l(v, g);
|
|
187
189
|
if (Array.isArray(a)) for (let e of a) {
|
|
188
190
|
let n = e.key || t.name, r = e.value === null ? "null" : String(e.value);
|
|
189
191
|
P.push({
|
|
@@ -220,7 +222,7 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
220
222
|
let e = I.indexOf("#"), t = e < 0 ? "" : I.slice(e), n = e < 0 ? I : I.slice(0, e);
|
|
221
223
|
I = `${n}${n.includes("?") ? "&" : "?"}${B.join("&")}${t}`;
|
|
222
224
|
}
|
|
223
|
-
if (z &&
|
|
225
|
+
if (z && _(I), R && v(I, L)) throw URIError("A label-style path parameter produces a dot segment that browsers remove.");
|
|
224
226
|
return {
|
|
225
227
|
url: I,
|
|
226
228
|
headers: M,
|
|
@@ -230,6 +232,6 @@ var w = class extends Error {}, T = (e) => (e ?? []).map((e) => p(e)).filter((e)
|
|
|
230
232
|
...B.length ? { hasSerializedQuery: !0 } : {}
|
|
231
233
|
};
|
|
232
234
|
};
|
|
233
|
-
export {
|
|
235
|
+
export { T as CookieSerializationError, A as processParameters };
|
|
234
236
|
|
|
235
237
|
//# sourceMappingURL=process-parameters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.js","names":["CookieSerializationError","deReferenceParams","params","getResolvedRef","param","isAllowReserved","getParameterStyleAndExplode","explode","defaultStyle","style","getParameterValue","selected","getParameterExample","example","exampleValue","propertyStates","filterDisabledProperties","deSerializeParameter","isParamDisabled","defaultDisabled","options","schema","getExampleFromSchema","processParameters","newHeaders","harRequest","newQueryString","newCookies","cookieStyleEntries","newUrl","markedPathUrl","hasStyledLabel","hasReservedPathParameter","serializedQuery","serializedCookies","substitutePathParameter","replacePathVariables","name","value","markLabel","appendQueryParameter","encodeReservedQueryValue","deReferencedParams","parameters","querystring","getQuerystringParameter","hashIndex","hash","base","query","serializeQuerystringParameter","wireValue","text","isStyledPath","paramValue","openapiVersion","jsonSchemaDialect","allowReserved","serializePathParameter","includesUndefinedPathPrefix","operator","serializeReservedPathParameter","serializeSimpleStyle","paramContentType","serializedValue","serializeContentValue","serialized","serializeFormStyle","entry","serializeSpaceDelimitedStyle","serializePipeDelimitedStyle","entries","serializeDeepObjectStyle","major","minor","error","getCookieSerializationError","serializeCookieStyle","serializeFormStyleForCookies","key","cookieValue","cookie","existing","header","assertReservedPathUrl","hasPathDotSegment"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getCookieSerializationError } from '@scalar/helpers/http/get-cookie-serialization-error'\nimport { replacePathVariables } from '@scalar/helpers/regex/replace-variables'\nimport {\n assertReservedPathUrl,\n hasPathDotSegment,\n includesUndefinedPathPrefix,\n serializePathParameter,\n serializeReservedPathParameter,\n} from '@scalar/workspace-store/helpers/encode-path-parameter'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n encodeReservedQueryValue,\n filterDisabledProperties,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\n/** An invalid cookie declaration that authors can repair before generating a sample. */\nexport class CookieSerializationError extends Error {}\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n defaultDisabled: boolean,\n openapiVersion?: string,\n jsonSchemaDialect?: string,\n): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example)\n const exampleValue = selected.example\n\n const propertyStates =\n param.in === 'query' && !selected.serialized && !selected.mediaSerialized\n ? exampleValue?.['x-scalar-disabled-properties']\n : undefined\n if (propertyStates) {\n return filterDisabledProperties(\n deSerializeParameter(selected.value, param),\n propertyStates,\n isParamDisabled(param, exampleValue, defaultDisabled),\n )\n }\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = {\n openapiVersion,\n jsonSchemaDialect,\n ...(param.in === 'path' ? { emptyString: `{${param.name}}`, preserveStringFallback: true } : {}),\n }\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n openapiVersion,\n jsonSchemaDialect,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n /** Originating API description version. */\n openapiVersion?: string\n jsonSchemaDialect?: string\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n let markedPathUrl = harRequest.url\n let hasStyledLabel = false\n let hasReservedPathParameter = false\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n const substitutePathParameter = (name: string, value: string, markLabel = false): void => {\n newUrl = replacePathVariables(newUrl, { [name]: value })\n // Mark only label substitutions so literal dot segments keep their usual URL semantics.\n markedPathUrl = replacePathVariables(markedPathUrl, { [name]: markLabel ? `x${value}` : value })\n hasStyledLabel ||= markLabel\n }\n\n const appendQueryParameter = (name: string, value: string, param: ParameterObject): void => {\n if (isAllowReserved(param)) {\n // HTTP clients cannot infer reserved expansion from a HAR name/value pair.\n serializedQuery.push(`${encodeURIComponent(name)}=${encodeReservedQueryValue(value)}`)\n } else {\n newQueryString.push({ name, value })\n }\n }\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, {\n defaultDisabled,\n openapiVersion,\n jsonSchemaDialect,\n })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n substitutePathParameter(param.name, wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n appendQueryParameter(param.name, text, param)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n substitutePathParameter(param.name, encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const { style, explode } = getParameterStyleAndExplode(param)\n const isStyledPath = param.in === 'path' && (style === 'matrix' || style === 'label')\n // Like Test Request, leave the template visible when no example supplies a styled path value.\n const paramValue = isStyledPath\n ? deSerializeParameter(selected.value, param)\n : getParameterValue(param, example, defaultDisabled, openapiVersion, jsonSchemaDialect)\n if (\n isStyledPath\n ? !selected.example || isParamDisabled(param, selected.example, defaultDisabled)\n : paramValue === undefined\n ) {\n continue\n }\n\n switch (param.in) {\n case 'path': {\n const allowReserved = openapiVersion?.startsWith('3.2.') && 'schema' in param && param.allowReserved === true\n hasReservedPathParameter ||= Boolean(allowReserved)\n\n if (isStyledPath) {\n const value = serializePathParameter(\n param.name,\n {\n value: paramValue,\n style,\n explode,\n includeUndefinedPrefix: includesUndefinedPathPrefix(openapiVersion),\n },\n undefined,\n allowReserved,\n )\n // Support older samples that include a URI template operator in the path.\n const operator = style === 'matrix' ? ';' : '.'\n const name = newUrl.includes(`{${param.name}}`) ? param.name : `${operator}${param.name}`\n substitutePathParameter(name, value, style === 'label' && !allowReserved)\n } else if (allowReserved) {\n substitutePathParameter(\n param.name,\n serializeReservedPathParameter(param.name, { value: paramValue, style, explode }),\n )\n } else {\n const value = style === 'simple' ? serializeSimpleStyle(paramValue, explode) : paramValue\n substitutePathParameter(param.name, String(value))\n }\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n appendQueryParameter(param.name, serializedValue, param)\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n }\n // Otherwise, convert to string\n else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n } else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n appendQueryParameter(entry.key, entry.value, param)\n }\n }\n break\n }\n\n // Default to form style\n default:\n appendQueryParameter(param.name, String(paramValue), param)\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n const [major, minor] = (openapiVersion ?? '').split('.')\n const error =\n major === '3' && minor === '2' && !('content' in param)\n ? getCookieSerializationError(param, paramValue)\n : undefined\n if (error) {\n throw new CookieSerializationError(error)\n }\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n if (hasReservedPathParameter) {\n assertReservedPathUrl(newUrl)\n }\n if (hasStyledLabel && hasPathDotSegment(newUrl, markedPathUrl)) {\n throw new URIError('A label-style path parameter produces a dot segment that browsers remove.')\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n"],"mappings":";;;;;;;;AAkCA,IAAaA,IAAb,cAA8C,MAAM,CAAC,GAc/CC,KAAqB,OACxBC,KAAU,CAAC,EAAA,CAAG,KAAK,MAAUC,EAAeC,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAUA,MAAU,KAAA,CAAS,GAGtFC,KAAmB,MACnB,mBAAmBD,KAASA,EAAM,kBAAkB,KAAA,IAC/CA,EAAM,gBAEX,YAAYA,KAASA,EAAM,UAAU,OAAOA,EAAM,UAAW,YAAY,mBAAmBA,EAAM,SAC5FA,EAAM,OAAuC,kBAAkB,KAElE,IAOHE,KAA+B,MAAgE;CAEnG,IAAIF,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAaA,KAASA,EAAM,YAAY,KAAA,KAAYA,EAAM;CACxC;CAIpC,IAAIA,EAAM,OAAO,UAAU;EACzB,IAAMG,IAAU,aAAaH,KAASA,EAAM,YAAY,KAAA,IAAYA,EAAM,UAAU;EACpF,OAAO;GAAE,OAAO,WAAWA,KAASA,EAAM,UAAU,WAAW,WAAW;GAAQ;EAAQ;CAC5F;CAEA,IAAMI,IAAe;EACnB,MAAM;EACN,OAAO;EACP,aAAa;EACb,QAAQ;EACR,QAAQ;CACV,EAAEJ,EAAM,KAGFK,IAAQ,WAAWL,KAASA,EAAM,QAAQA,EAAM,QAAQI;CAK9D,OAAO;EAAE;EAAO,SAFA,aAAaJ,KAASA,EAAM,YAAY,KAAA,IAAYA,EAAM,UAAUK,MAAU;CAEtE;AAC1B,GAOMC,KACJ,GACA,GACA,GACA,GACA,MACY;CAEZ,IAAMC,IAAWC,EAAoBR,GAAOS,CAAO,GAC7CC,IAAeH,EAAS,SAExBI,IACJX,EAAM,OAAO,WAAW,CAACO,EAAS,cAAc,CAACA,EAAS,k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Q,GAAG,GAAG;GACjD,GAAGA;GACH,OAAOA,EAAS,QAAQ,GAAGA,EAAS,MAAM,IAAIF,MAAgBA;EAChE,CAAC,IAEDxD,EAAW,KAAK;GAAE,MAAM;GAAU,OAAOwD;EAAY,CAAC;CAE1D;CAEA,IAAI/C,EAAgB,QAAQ;EAC1B,IAAMa,IAAYjB,EAAO,QAAQ,GAAG,GAC9BkB,IAAOD,IAAY,IAAI,KAAKjB,EAAO,MAAMiB,CAAS,GAClDE,IAAOF,IAAY,IAAIjB,IAASA,EAAO,MAAM,GAAGiB,CAAS;EAC/D,IAAS,GAAGE,IAAOA,EAAK,SAAS,GAAG,IAAI,MAAM,MAAMf,EAAgB,KAAK,GAAG,IAAIc;CAClF;CAKA,IAHIf,KACFoD,EAAsBvD,CAAM,GAE1BE,KAAkBsD,EAAkBxD,GAAQC,CAAa,GAC3D,MAAU,SAAS,2EAA2E;CAGhG,OAAO;EACL,KAAKD;EACL,SAASL;EACT,aAAaE;EACb,SAASE,EAAmB,UAAUM,EAAkB,SAAS,CAAC,IAAIP;EACtE,uBAAuBC,EAAmB,SAAS,KAAKM,EAAkB,SAAS;EACnF,GAAID,EAAgB,SAAS,EAAE,oBAAoB,GAAK,IAAI,CAAC;CAC/D;AACF"}
|
|
1
|
+
{"version":3,"file":"process-parameters.js","names":["deSerializeParameter","encodeReservedQueryValue","filterDisabledProperties","getExampleFromSchema","isParamDisabled","serializeContentValue","serializeCookieStyle","serializeDeepObjectStyle","serializeFormStyle","serializeFormStyleForCookies","serializePipeDelimitedStyle","serializeSimpleStyle","serializeSpaceDelimitedStyle","getResolvedRef","isVersionLessThan","getCookieSerializationError","replacePathVariables","assertReservedPathUrl","hasPathDotSegment","includesUndefinedPathPrefix","serializePathParameter","serializeReservedPathParameter","getParameterExample","getQuerystringParameter","serializeQuerystringParameter","CookieSerializationError","deReferenceParams","params","param","isAllowReserved","getParameterStyleAndExplode","explode","defaultStyle","style","getParameterValue","example","defaultDisabled","openapiVersion","jsonSchemaDialect","selected","exampleValue","propertyStates","options","schema","processParameters","harRequest","parameters","newHeaders","newQueryString","newCookies","cookieStyleEntries","newUrl","markedPathUrl","hasStyledLabel","hasReservedPathParameter","serializedQuery","serializedCookies","substitutePathParameter","name","value","markLabel","appendQueryParameter","deReferencedParams","querystring","hashIndex","hash","base","query","wireValue","text","isStyledPath","paramValue","allowReserved","operator","paramContentType","serializedValue","serialized","entry","entries","major","minor","error","key","cookieValue","cookie","existing","header"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { isVersionLessThan } from '@scalar/helpers/general/compare-versions'\nimport { getCookieSerializationError } from '@scalar/helpers/http/get-cookie-serialization-error'\nimport { replacePathVariables } from '@scalar/helpers/regex/replace-variables'\nimport {\n assertReservedPathUrl,\n hasPathDotSegment,\n includesUndefinedPathPrefix,\n serializePathParameter,\n serializeReservedPathParameter,\n} from '@scalar/workspace-store/helpers/encode-path-parameter'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n encodeReservedQueryValue,\n filterDisabledProperties,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\n/** An invalid cookie declaration that authors can repair before generating a sample. */\nexport class CookieSerializationError extends Error {}\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n defaultDisabled: boolean,\n openapiVersion?: string,\n jsonSchemaDialect?: string,\n): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example, openapiVersion)\n const exampleValue = selected.example\n\n const propertyStates =\n param.in === 'query' && !selected.serialized && !selected.mediaSerialized\n ? exampleValue?.['x-scalar-disabled-properties']\n : undefined\n if (propertyStates) {\n return filterDisabledProperties(\n deSerializeParameter(selected.value, param),\n propertyStates,\n isParamDisabled(param, exampleValue, defaultDisabled),\n )\n }\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = {\n openapiVersion,\n jsonSchemaDialect,\n ...(param.in === 'path'\n ? {\n emptyString: `{${param.name}}`,\n preserveStringFallback: true,\n ignoreSchemaConst: openapiVersion !== undefined && isVersionLessThan(openapiVersion, '3.1.0'),\n }\n : {}),\n }\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n openapiVersion,\n jsonSchemaDialect,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n /** Originating API description version. */\n openapiVersion?: string\n jsonSchemaDialect?: string\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n let markedPathUrl = harRequest.url\n let hasStyledLabel = false\n let hasReservedPathParameter = false\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n const substitutePathParameter = (name: string, value: string, markLabel = false): void => {\n newUrl = replacePathVariables(newUrl, { [name]: value })\n // Mark only label substitutions so literal dot segments keep their usual URL semantics.\n markedPathUrl = replacePathVariables(markedPathUrl, { [name]: markLabel ? `x${value}` : value })\n hasStyledLabel ||= markLabel\n }\n\n const appendQueryParameter = (name: string, value: string, param: ParameterObject): void => {\n if (isAllowReserved(param)) {\n // HTTP clients cannot infer reserved expansion from a HAR name/value pair.\n serializedQuery.push(`${encodeURIComponent(name)}=${encodeReservedQueryValue(value)}`)\n } else {\n newQueryString.push({ name, value })\n }\n }\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, {\n defaultDisabled,\n openapiVersion,\n jsonSchemaDialect,\n })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example, openapiVersion)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n substitutePathParameter(param.name, wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n appendQueryParameter(param.name, text, param)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n substitutePathParameter(param.name, encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const { style, explode } = getParameterStyleAndExplode(param)\n const isStyledPath = param.in === 'path' && (style === 'matrix' || style === 'label')\n // Like Test Request, leave the template visible when no example supplies a styled path value.\n const paramValue = isStyledPath\n ? deSerializeParameter(selected.value, param)\n : getParameterValue(param, example, defaultDisabled, openapiVersion, jsonSchemaDialect)\n if (\n isStyledPath\n ? !selected.example || isParamDisabled(param, selected.example, defaultDisabled)\n : paramValue === undefined\n ) {\n continue\n }\n\n switch (param.in) {\n case 'path': {\n const allowReserved = openapiVersion?.startsWith('3.2.') && 'schema' in param && param.allowReserved === true\n hasReservedPathParameter ||= Boolean(allowReserved)\n\n if (isStyledPath) {\n const value = serializePathParameter(\n param.name,\n {\n value: paramValue,\n style,\n explode,\n includeUndefinedPrefix: includesUndefinedPathPrefix(openapiVersion),\n },\n undefined,\n allowReserved,\n )\n // Support older samples that include a URI template operator in the path.\n const operator = style === 'matrix' ? ';' : '.'\n const name = newUrl.includes(`{${param.name}}`) ? param.name : `${operator}${param.name}`\n substitutePathParameter(name, value, style === 'label' && !allowReserved)\n } else if (allowReserved) {\n substitutePathParameter(\n param.name,\n serializeReservedPathParameter(param.name, { value: paramValue, style, explode }),\n )\n } else {\n const value = style === 'simple' ? serializeSimpleStyle(paramValue, explode) : paramValue\n substitutePathParameter(param.name, String(value))\n }\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n appendQueryParameter(param.name, serializedValue, param)\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n }\n // Otherwise, convert to string\n else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n appendQueryParameter(param.name, serialized, param)\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n appendQueryParameter(key, String(entry.value), param)\n }\n } else {\n appendQueryParameter(param.name, String(serialized), param)\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n appendQueryParameter(entry.key, entry.value, param)\n }\n }\n break\n }\n\n // Default to form style\n default:\n appendQueryParameter(param.name, String(paramValue), param)\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n const [major, minor] = (openapiVersion ?? '').split('.')\n const error =\n major === '3' && minor === '2' && !('content' in param)\n ? getCookieSerializationError(param, paramValue)\n : undefined\n if (error) {\n throw new CookieSerializationError(error)\n }\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n if (hasReservedPathParameter) {\n assertReservedPathUrl(newUrl)\n }\n if (hasStyledLabel && hasPathDotSegment(newUrl, markedPathUrl)) {\n throw new URIError('A label-style path parameter produces a dot segment that browsers remove.')\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAayB,IAAb,cAA8C,MAAM,CAAC,GAc/CC,KAAqBC,OACxBA,KAAU,CAAC,EAAA,CAAG,KAAKC,MAAUf,EAAee,CAAK,CAAC,CAAC,CAAC,QAAQA,MAAUA,MAAU,KAAA,CAAS,GAGtFC,KAAmBD,MACnB,mBAAmBA,KAASA,EAAM,kBAAkB,KAAA,IAC/CA,EAAM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gB,QAAQ;EAC1B,IAAMS,IAAYb,EAAO,QAAQ,GAAG,GAC9Bc,IAAOD,IAAY,IAAI,KAAKb,EAAO,MAAMa,CAAS,GAClDE,IAAOF,IAAY,IAAIb,IAASA,EAAO,MAAM,GAAGa,CAAS;EAC/Db,IAAS,GAAGe,IAAOA,EAAK,SAAS,GAAG,IAAI,MAAM,MAAMX,EAAgB,KAAK,GAAG,IAAIU;CAClF;CAKA,IAHIX,KACFrC,EAAsBkC,CAAM,GAE1BE,KAAkBnC,EAAkBiC,GAAQC,CAAa,GAC3D,MAAU,SAAS,2EAA2E;CAGhG,OAAO;EACL,KAAKD;EACL,SAASJ;EACT,aAAaC;EACb,SAASE,EAAmB,UAAUM,EAAkB,SAAS,CAAC,IAAIP;EACtE,uBAAuBC,EAAmB,SAAS,KAAKM,EAAkB,SAAS;EACnF,GAAID,EAAgB,SAAS,EAAE,oBAAoB,GAAK,IAAI,CAAC;CAC/D;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { encode as e } from "js-base64";
|
|
2
|
+
import { formatTokenPrefix as t } from "@scalar/helpers/http/format-token-prefix";
|
|
3
3
|
// src/code-example/helpers/operation-to-har/process-security-schemes.ts
|
|
4
4
|
var n = (n) => {
|
|
5
5
|
let r = {
|
|
@@ -8,17 +8,17 @@ var n = (n) => {
|
|
|
8
8
|
cookies: []
|
|
9
9
|
};
|
|
10
10
|
for (let i of n) if (i.type === "apiKey") {
|
|
11
|
-
let
|
|
11
|
+
let e = i["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
12
12
|
if (!i.name) continue;
|
|
13
13
|
let n = {
|
|
14
14
|
name: i.name,
|
|
15
|
-
value:
|
|
15
|
+
value: e
|
|
16
16
|
};
|
|
17
17
|
switch (i.in) {
|
|
18
18
|
case "header":
|
|
19
19
|
r.headers.push({
|
|
20
20
|
...n,
|
|
21
|
-
value: e
|
|
21
|
+
value: t(e, i["x-scalar-token-prefix"])
|
|
22
22
|
});
|
|
23
23
|
break;
|
|
24
24
|
case "query":
|
|
@@ -28,7 +28,7 @@ var n = (n) => {
|
|
|
28
28
|
}
|
|
29
29
|
} else if (i.type === "http") {
|
|
30
30
|
if (i.scheme === "basic") {
|
|
31
|
-
let
|
|
31
|
+
let t = `${i["x-scalar-secret-username"] || ""}:${i["x-scalar-secret-password"] || ""}`, n = t === ":" ? "username:password" : e(t);
|
|
32
32
|
r.headers.push({
|
|
33
33
|
name: "Authorization",
|
|
34
34
|
value: `Basic ${n}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-security-schemes.js","names":["
|
|
1
|
+
{"version":3,"file":"process-security-schemes.js","names":["encode","formatTokenPrefix","processSecuritySchemes","securitySchemes","result","scheme","value","param","auth","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push({ ...param, value: formatTokenPrefix(value, scheme['x-scalar-token-prefix']) })\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;AAgBA,IAAaE,KACXC,MACmC;CACnC,IAAMC,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAMC,KAAUF,GAEnB,IAAIE,EAAO,SAAS,UAAU;EAC5B,IAAMC,IAAQD,EAAO,4BAA4B;EACjD,IAAI,CAACA,EAAO,MACV;EAGF,IAAME,IAAQ;GAAE,MAAMF,EAAO;GAAMC;EAAM;EAEzC,QAAQD,EAAO,IAAf;GACE,KAAK;IACHD,EAAO,QAAQ,KAAK;KAAE,GAAGG;KAAO,OAAON,EAAkBK,GAAOD,EAAO,wBAAwB;IAAE,CAAC;IAClG;GACF,KAAK;IACHD,EAAO,YAAY,KAAKG,CAAK;IAC7B;GACF,KAAK,UACHH,EAAO,QAAQ,KAAKG,CAAK;EAE7B;CAEF,OAGA,IAAIF,EAAO,SAAS,QAAQ;EAC1B,IAAIA,EAAO,WAAW,SAAS;GAQ7B,IAAMC,IAAQ,GAPGD,EAAO,+BAA+B,GAO7B,GANTA,EAAO,+BAA+B,MAOjDG,IAAOF,MAAU,MAAM,sBAAsBN,EAAOM,CAAK;GAE/DF,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,SAASI;GAClB,CAAC;EACH,OAAO,IAAIH,EAAO,WAAW,UAAU;GACrC,IAAMI,IAAQJ,EAAO,4BAA4B;GAEjDD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAUK;GACnB,CAAC;EACH;CAEF,OAGA,IAAIJ,EAAO,SAAS,YAAYA,EAAO,OAAO;EAK5C,IAAMI,IAJQ,OAAO,OAAOJ,EAAO,KAGtB,CAAA,CAAM,MAAMK,MAAMA,EAAE,wBACnB,CAAA,GAAO,4BAA4B;EAEjDN,EAAO,QAAQ,KAAK;GAClB,MAAM;GACN,OAAO,UAAUK;EACnB,CAAC;CACH;CAGF,OAAOL;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-server-url.js","names":["
|
|
1
|
+
{"version":3,"file":"process-server-url.js","names":["getResolvedUrl","processServerUrl","server","path"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { getResolvedUrl } from '@scalar/workspace-store/request-example'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Resolves server variable defaults before joining the operation path. */\nexport const processServerUrl = (server: ServerObject | null, path: string): string =>\n server?.url ? getResolvedUrl({ server, path }) : path\n"],"mappings":";;AAIA,IAAaC,KAAoBC,GAA6BC,MAC5DD,GAAQ,MAAMF,EAAe;CAAEE;CAAQC;AAAK,CAAC,IAAIA"}
|
|
@@ -7,7 +7,7 @@ export { default as HttpMethod } from './components/HttpMethod.vue';
|
|
|
7
7
|
export { filterClientsByQuery } from './helpers/filter-clients-by-query';
|
|
8
8
|
export { DEFAULT_CLIENT, type SelectedClientId, findClient, isClient, isSelectedClient } from './helpers/find-client';
|
|
9
9
|
export { generateClientOptions, getCustomClientIds } from './helpers/generate-client-options';
|
|
10
|
-
export { generateCodeSnippet } from './helpers/generate-code-snippet';
|
|
10
|
+
export { generateCodeSnippet, generateCodeSnippetWithPreview } from './helpers/generate-code-snippet';
|
|
11
11
|
export { getClients } from './helpers/get-clients';
|
|
12
12
|
export { getCustomCodeSamples } from './helpers/get-custom-code-samples';
|
|
13
13
|
export { getGeneratedPayloadExample } from './helpers/get-generated-payload-example';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-example/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAA;AAE1F,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACrF,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3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