@scalar/api-client 2.39.3 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/AddressBar/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.js +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.js.map +1 -1
- package/dist/components/AddressBar/AddressBarHistory.vue.script.js +2 -2
- package/dist/components/AddressBar/AddressBarHistory.vue.script.js.map +1 -1
- package/dist/hooks/useClientConfig.d.ts +12 -0
- package/dist/hooks/useClientConfig.d.ts.map +1 -1
- package/dist/hooks/useClientConfig.js +14 -1
- package/dist/hooks/useClientConfig.js.map +1 -1
- package/dist/hooks/useResponseBody.js +2 -2
- package/dist/hooks/useResponseBody.js.map +1 -1
- package/dist/libs/index.d.ts +0 -1
- package/dist/libs/index.d.ts.map +1 -1
- package/dist/libs/index.js +1 -2
- package/dist/libs/send-request/decode-buffer.js +2 -2
- package/dist/libs/send-request/decode-buffer.js.map +1 -1
- package/dist/style.css +222 -263
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +14 -10
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +57 -35
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +1 -5
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +18 -33
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
- package/dist/v2/blocks/operation-block/index.d.ts +0 -3
- package/dist/v2/blocks/operation-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/index.js +1 -4
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +3 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +4 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +3 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +7 -2
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +4 -3
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +2 -3
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +3 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +5 -8
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts +0 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.js +2 -3
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +7 -9
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +49 -42
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +2 -3
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +1 -0
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +11 -9
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +2 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/get-content-length.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/helpers/get-content-length.js +2 -2
- package/dist/v2/blocks/response-block/helpers/get-content-length.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -2
- package/dist/v2/blocks/response-block/helpers/process-response-body.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js +76 -25
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +8 -4
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +6 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +0 -3
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/index.js +1 -3
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +16 -8
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.script.js +15 -10
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js.map +1 -1
- package/dist/v2/features/app/App.vue.script.js +1 -5
- package/dist/v2/features/app/App.vue.script.js.map +1 -1
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +1 -1
- package/dist/v2/features/app/app-events.js.map +1 -1
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +2 -2
- package/dist/v2/features/app/app-state.js.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.script.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.script.js.map +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +0 -3
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js +1 -1
- package/dist/v2/features/app/helpers/routes.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js +30 -52
- package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js +0 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js +0 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.script.js +6 -8
- package/dist/v2/features/collection/components/Authentication.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Cookies.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Cookies.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Environment.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Environment.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Overview.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Overview.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js +0 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.script.js +2 -3
- package/dist/v2/features/collection/components/Settings.vue.script.js.map +1 -1
- package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js +3 -4
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/map-hidden-clients-config.js +1 -1
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js +50 -84
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/features/operation/index.d.ts +0 -4
- package/dist/v2/features/operation/index.d.ts.map +1 -1
- package/dist/v2/features/operation/index.js +1 -5
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js +11 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.script.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.script.js +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.script.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.script.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.script.js.map +1 -1
- package/dist/views/Request/libs/oauth2.js +1 -1
- package/dist/views/Request/libs/oauth2.js.map +1 -1
- package/package.json +25 -31
- package/dist/libs/formatters.d.ts +0 -12
- package/dist/libs/formatters.d.ts.map +0 -1
- package/dist/libs/formatters.js +0 -36
- package/dist/libs/formatters.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts +0 -6
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js +0 -58
- package/dist/v2/blocks/operation-block/helpers/apply-allow-reserved-to-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts +0 -12
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js +0 -65
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +0 -31
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +0 -55
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts +0 -27
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +0 -159
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts +0 -25
- package/dist/v2/blocks/operation-block/helpers/build-request-security.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-security.js +0 -53
- package/dist/v2/blocks/operation-block/helpers/build-request-security.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts +0 -46
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +0 -102
- package/dist/v2/blocks/operation-block/helpers/build-request.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts +0 -4
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js +0 -41
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts +0 -14
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js +0 -20
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts +0 -8
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts +0 -9
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js +0 -17
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts +0 -10
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.js +0 -41
- package/dist/v2/blocks/operation-block/helpers/get-example.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts +0 -26
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js +0 -32
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts +0 -10
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js +0 -15
- package/dist/v2/blocks/operation-block/helpers/get-selected-body-content-type.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts +0 -3
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/get-server-url.js +0 -18
- package/dist/v2/blocks/operation-block/helpers/get-server-url.js.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts +0 -96
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts.map +0 -1
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js +0 -160
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +0 -40
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +0 -437
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js.map +0 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts +0 -6
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts.map +0 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js +0 -25
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +0 -141
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts +0 -4
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.d.ts.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js +0 -10
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/is-auth-optional.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts +0 -9
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.d.ts.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js +0 -27
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/merge-security.js.map +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts +0 -25
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts.map +0 -1
- package/dist/v2/components/callout/Callout.vue.js +0 -9
- package/dist/v2/components/callout/Callout.vue.js.map +0 -1
- package/dist/v2/components/callout/Callout.vue.script.js +0 -35
- package/dist/v2/components/callout/Callout.vue.script.js.map +0 -1
- package/dist/v2/features/operation/helpers/combine-params.d.ts +0 -4
- package/dist/v2/features/operation/helpers/combine-params.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/combine-params.js +0 -20
- package/dist/v2/features/operation/helpers/combine-params.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts +0 -17
- package/dist/v2/features/operation/helpers/get-operation-header.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts +0 -12
- package/dist/v2/features/operation/helpers/get-security-requirements.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-security-requirements.js +0 -17
- package/dist/v2/features/operation/helpers/get-security-requirements.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts +0 -15
- package/dist/v2/features/operation/helpers/get-selected-security.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-security.js +0 -41
- package/dist/v2/features/operation/helpers/get-selected-security.js.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts +0 -13
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts.map +0 -1
- package/dist/v2/features/operation/helpers/get-selected-server.js +0 -21
- package/dist/v2/features/operation/helpers/get-selected-server.js.map +0 -1
- package/dist/v2/helpers/get-active-environment.d.ts +0 -5
- package/dist/v2/helpers/get-active-environment.d.ts.map +0 -1
- package/dist/v2/helpers/get-active-environment.js +0 -19
- package/dist/v2/helpers/get-active-environment.js.map +0 -1
- package/dist/v2/helpers/get-active-proxy-url.d.ts +0 -18
- package/dist/v2/helpers/get-active-proxy-url.d.ts.map +0 -1
- package/dist/v2/helpers/get-active-proxy-url.js +0 -26
- package/dist/v2/helpers/get-active-proxy-url.js.map +0 -1
- package/dist/v2/helpers/get-servers.d.ts +0 -23
- package/dist/v2/helpers/get-servers.d.ts.map +0 -1
- package/dist/v2/helpers/get-servers.js +0 -106
- package/dist/v2/helpers/get-servers.js.map +0 -1
- package/dist/v2/helpers/index.d.ts +0 -3
- package/dist/v2/helpers/index.d.ts.map +0 -1
- package/dist/v2/helpers/index.js +0 -3
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { isDefined } from "@scalar/helpers/array/is-defined";
|
|
2
|
-
import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
|
|
3
|
-
import { resolve } from "@scalar/workspace-store/resolve";
|
|
4
|
-
//#region src/v2/blocks/operation-code-sample/helpers/get-example-from-schema.ts
|
|
5
|
-
/** Maximum recursion depth to prevent infinite loops in circular references */
|
|
6
|
-
var MAX_LEVELS_DEEP = 10;
|
|
7
|
-
/** Default name used for additional properties when no custom name is provided */
|
|
8
|
-
var DEFAULT_ADDITIONAL_PROPERTIES_NAME = "additionalProperty";
|
|
9
|
-
/**
|
|
10
|
-
* Pre-computed date/time values to avoid expensive Date operations on every call.
|
|
11
|
-
* These are calculated once at module load time for better performance.
|
|
12
|
-
*/
|
|
13
|
-
var currentISOString = (/* @__PURE__ */ new Date()).toISOString();
|
|
14
|
-
var currentDateString = currentISOString.split("T")[0];
|
|
15
|
-
var currentTimeString = currentISOString.split("T")[1].split(".")[0];
|
|
16
|
-
/**
|
|
17
|
-
* Mapping of OpenAPI string formats to example values.
|
|
18
|
-
* Used to generate realistic examples for different string formats.
|
|
19
|
-
*/
|
|
20
|
-
var genericExampleValues = {
|
|
21
|
-
"date-time": currentISOString,
|
|
22
|
-
"date": currentDateString,
|
|
23
|
-
"email": "hello@example.com",
|
|
24
|
-
"hostname": "example.com",
|
|
25
|
-
"idn-email": "jane.doe@example.com",
|
|
26
|
-
"idn-hostname": "example.com",
|
|
27
|
-
"ipv4": "127.0.0.1",
|
|
28
|
-
"ipv6": "51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998",
|
|
29
|
-
"iri-reference": "/entitiy/1",
|
|
30
|
-
"iri": "https://example.com/entity/123",
|
|
31
|
-
"json-pointer": "/nested/objects",
|
|
32
|
-
"password": "super-secret",
|
|
33
|
-
"regex": "/[a-z]/",
|
|
34
|
-
"relative-json-pointer": "1/nested/objects",
|
|
35
|
-
"time": currentTimeString,
|
|
36
|
-
"uri-reference": "../folder",
|
|
37
|
-
"uri-template": "https://example.com/{id}",
|
|
38
|
-
"uri": "https://example.com",
|
|
39
|
-
"uuid": "123e4567-e89b-12d3-a456-426614174000",
|
|
40
|
-
"object-id": "6592008029c8c3e4dc76256c"
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Extract enum values from the propertyNames keyword of an object schema.
|
|
44
|
-
* JSON Schema's propertyNames constrains which keys are valid in a map/dict.
|
|
45
|
-
*/
|
|
46
|
-
var getPropertyNamesEnumValues = (schema) => {
|
|
47
|
-
if (!("propertyNames" in schema) || !schema.propertyNames) return;
|
|
48
|
-
const resolved = resolve.schema(schema.propertyNames);
|
|
49
|
-
if (resolved && "enum" in resolved && Array.isArray(resolved.enum) && resolved.enum.length > 0) return resolved.enum;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Generate example values for string types based on their format.
|
|
53
|
-
* Special handling for binary format which returns a File object.
|
|
54
|
-
*/
|
|
55
|
-
var guessFromFormat = (schema, makeUpRandomData = false, fallback = "") => {
|
|
56
|
-
if ("type" in schema && schema.type === "string" && "format" in schema && schema.format === "binary") return "@filename";
|
|
57
|
-
if (makeUpRandomData && "format" in schema && schema.format) return genericExampleValues[schema.format] ?? fallback;
|
|
58
|
-
return fallback;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* WeakMap cache for memoizing resolved example results.
|
|
62
|
-
* Uses the resolved schema object as the key for efficient lookups.
|
|
63
|
-
*/
|
|
64
|
-
var resultCache = /* @__PURE__ */ new WeakMap();
|
|
65
|
-
/** Cache required property names per parent schema for O(1) membership checks */
|
|
66
|
-
var requiredNamesCache = /* @__PURE__ */ new WeakMap();
|
|
67
|
-
/** Normalize schema identity for cache and cycle tracking */
|
|
68
|
-
var getSchemaCacheTarget = (schema) => unpackProxyObject(schema, { depth: 1 });
|
|
69
|
-
/**
|
|
70
|
-
* Retrieves the set of required property names from a schema.
|
|
71
|
-
* Caches the result in a WeakMap for efficient lookups.
|
|
72
|
-
*/
|
|
73
|
-
var getRequiredNames = (parentSchema) => {
|
|
74
|
-
if (!parentSchema) return;
|
|
75
|
-
const cached = requiredNamesCache.get(parentSchema);
|
|
76
|
-
if (cached) return cached;
|
|
77
|
-
if ("required" in parentSchema) {
|
|
78
|
-
const required = parentSchema.required;
|
|
79
|
-
if (Array.isArray(required) && required.length > 0) {
|
|
80
|
-
const set = new Set(required);
|
|
81
|
-
requiredNamesCache.set(parentSchema, set);
|
|
82
|
-
return set;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Cache the result for a schema if it is an object type.
|
|
88
|
-
* Primitive values are not cached to avoid unnecessary WeakMap operations.
|
|
89
|
-
* Stores a map of cacheKey strings which is made up of the options object.
|
|
90
|
-
*/
|
|
91
|
-
var cache = (schema, result, cacheKey) => {
|
|
92
|
-
if (typeof result !== "object" || result === null) return result;
|
|
93
|
-
const rawSchema = getSchemaCacheTarget(schema);
|
|
94
|
-
const cacheMap = resultCache.get(rawSchema) ?? /* @__PURE__ */ new Map();
|
|
95
|
-
if (cacheMap) cacheMap.set(cacheKey, result);
|
|
96
|
-
resultCache.set(rawSchema, cacheMap);
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Check if a schema uses composition keywords (allOf, oneOf, anyOf).
|
|
101
|
-
* These require special handling for merging or selecting schemas.
|
|
102
|
-
*/
|
|
103
|
-
var isComposed = (schema) => !!(schema.allOf || schema.oneOf || schema.anyOf);
|
|
104
|
-
/**
|
|
105
|
-
* Determine if a property should be omitted based on the options.
|
|
106
|
-
* Properties are omitted if they are not required and the option is enabled.
|
|
107
|
-
*/
|
|
108
|
-
var shouldOmitProperty = (schema, parentSchema, propertyName, options) => {
|
|
109
|
-
if (schema.deprecated || options?.mode === "write" && schema.readOnly || options?.mode === "read" && schema.writeOnly) return true;
|
|
110
|
-
if (options?.omitEmptyAndOptionalProperties !== true) return false;
|
|
111
|
-
if ("type" in schema && (schema.type === "object" || schema.type === "array") || isComposed(schema)) return false;
|
|
112
|
-
if ("examples" in schema && Array.isArray(schema.examples) && schema.examples.length > 0 || "example" in schema && schema.example !== void 0 || "default" in schema && schema.default !== void 0 || "const" in schema && schema.const !== void 0 || "enum" in schema && Array.isArray(schema.enum) && schema.enum.length > 0) return false;
|
|
113
|
-
const name = propertyName ?? schema.title ?? "";
|
|
114
|
-
const requiredNames = getRequiredNames(parentSchema);
|
|
115
|
-
return !(requiredNames ? requiredNames.has(name) : false);
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Merge two example values with predictable semantics.
|
|
119
|
-
* Arrays are concatenated, objects are merged, otherwise the new value wins.
|
|
120
|
-
*/
|
|
121
|
-
var mergeExamples = (baseValue, newValue) => {
|
|
122
|
-
if (Array.isArray(baseValue) && Array.isArray(newValue)) return [...baseValue, ...newValue];
|
|
123
|
-
if (baseValue && typeof baseValue === "object" && newValue && typeof newValue === "object") return {
|
|
124
|
-
...baseValue,
|
|
125
|
-
...newValue
|
|
126
|
-
};
|
|
127
|
-
return newValue;
|
|
128
|
-
};
|
|
129
|
-
var getCompositionSelectionKey = (schemaPath, composition) => [...schemaPath, composition].join(".");
|
|
130
|
-
var getCompositionSelectionIndex = (schemaPath, composition, options, length) => {
|
|
131
|
-
const rawIndex = options?.compositionSelection?.[getCompositionSelectionKey(schemaPath, composition)];
|
|
132
|
-
if (typeof rawIndex !== "number" || Number.isNaN(rawIndex)) return;
|
|
133
|
-
return Math.max(0, Math.min(rawIndex, length - 1));
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Build an example for an object schema, including properties, patternProperties,
|
|
137
|
-
* additionalProperties, and composition (allOf/oneOf/anyOf) merging.
|
|
138
|
-
*/
|
|
139
|
-
var handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath) => {
|
|
140
|
-
const response = {};
|
|
141
|
-
if ("properties" in schema && schema.properties) {
|
|
142
|
-
const propertyNames = Object.keys(schema.properties);
|
|
143
|
-
const limit = propertyNames.length;
|
|
144
|
-
for (let i = 0; i < limit; i++) {
|
|
145
|
-
const propertyName = propertyNames[i];
|
|
146
|
-
const propertySchema = resolve.schema(schema.properties[propertyName]);
|
|
147
|
-
if (!propertySchema) continue;
|
|
148
|
-
const propertyXmlName = options?.xml && "xml" in propertySchema ? propertySchema.xml?.name : void 0;
|
|
149
|
-
const value = getExampleFromSchema(propertySchema, options, {
|
|
150
|
-
level: level + 1,
|
|
151
|
-
parentSchema: schema,
|
|
152
|
-
name: propertyName,
|
|
153
|
-
schemaPath: [...schemaPath, propertyName],
|
|
154
|
-
seen
|
|
155
|
-
});
|
|
156
|
-
if (typeof value !== "undefined") response[propertyXmlName ?? propertyName] = value;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if ("patternProperties" in schema && schema.patternProperties) for (const pattern of Object.keys(schema.patternProperties)) {
|
|
160
|
-
const propertySchema = resolve.schema(schema.patternProperties[pattern]);
|
|
161
|
-
if (!propertySchema) continue;
|
|
162
|
-
response[pattern] = getExampleFromSchema(propertySchema, options, {
|
|
163
|
-
level: level + 1,
|
|
164
|
-
parentSchema: schema,
|
|
165
|
-
name: pattern,
|
|
166
|
-
schemaPath: [...schemaPath, pattern],
|
|
167
|
-
seen
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if ("additionalProperties" in schema && schema.additionalProperties) {
|
|
171
|
-
const additional = typeof schema.additionalProperties === "boolean" ? schema.additionalProperties : resolve.schema(schema.additionalProperties);
|
|
172
|
-
const isAnyType = schema.additionalProperties === true || typeof schema.additionalProperties === "object" && Object.keys(schema.additionalProperties).length === 0;
|
|
173
|
-
const hasCustomName = typeof additional === "object" && "x-additionalPropertiesName" in additional && typeof additional["x-additionalPropertiesName"] === "string" && additional["x-additionalPropertiesName"].trim().length > 0;
|
|
174
|
-
const propertyNamesEnum = hasCustomName ? void 0 : getPropertyNamesEnumValues(schema);
|
|
175
|
-
const additionalName = hasCustomName ? additional["x-additionalPropertiesName"].trim() : DEFAULT_ADDITIONAL_PROPERTIES_NAME;
|
|
176
|
-
const additionalValue = isAnyType ? "anything" : typeof additional === "object" ? getExampleFromSchema(additional, options, {
|
|
177
|
-
level: level + 1,
|
|
178
|
-
schemaPath: [...schemaPath, additionalName],
|
|
179
|
-
seen
|
|
180
|
-
}) : "anything";
|
|
181
|
-
if (propertyNamesEnum && propertyNamesEnum.length > 0) response[String(propertyNamesEnum[0])] = additionalValue;
|
|
182
|
-
else response[additionalName] = additionalValue;
|
|
183
|
-
}
|
|
184
|
-
const compositionKeyword = schema.oneOf ? "oneOf" : schema.anyOf ? "anyOf" : void 0;
|
|
185
|
-
const oneOfAnyOf = compositionKeyword ? schema[compositionKeyword] : void 0;
|
|
186
|
-
if (compositionKeyword && oneOfAnyOf?.length) {
|
|
187
|
-
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, oneOfAnyOf.length) ?? 0;
|
|
188
|
-
const chosen = resolve.schema(oneOfAnyOf[index]);
|
|
189
|
-
if (chosen) Object.assign(response, getExampleFromSchema(chosen, options, {
|
|
190
|
-
level: level + 1,
|
|
191
|
-
schemaPath,
|
|
192
|
-
seen
|
|
193
|
-
}));
|
|
194
|
-
} else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {
|
|
195
|
-
let merged = response;
|
|
196
|
-
for (const item of schema.allOf) {
|
|
197
|
-
const ex = getExampleFromSchema(resolve.schema(item), options, {
|
|
198
|
-
level: level + 1,
|
|
199
|
-
parentSchema: schema,
|
|
200
|
-
seen
|
|
201
|
-
});
|
|
202
|
-
merged = mergeExamples(merged, ex);
|
|
203
|
-
}
|
|
204
|
-
if (merged && typeof merged === "object") Object.assign(response, merged);
|
|
205
|
-
}
|
|
206
|
-
if (options?.xml && "xml" in schema && schema.xml?.name && level === 0) {
|
|
207
|
-
const wrapped = {};
|
|
208
|
-
wrapped[schema.xml.name] = response;
|
|
209
|
-
return cache(schema, wrapped, cacheKey);
|
|
210
|
-
}
|
|
211
|
-
return cache(schema, response, cacheKey);
|
|
212
|
-
};
|
|
213
|
-
/** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */
|
|
214
|
-
var handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath) => {
|
|
215
|
-
const items = "items" in schema ? resolve.schema(schema.items) : void 0;
|
|
216
|
-
const itemsSchemaPath = [...schemaPath, "items"];
|
|
217
|
-
const itemsXmlTagName = items && typeof items === "object" && "xml" in items ? items.xml?.name : void 0;
|
|
218
|
-
const wrapItems = !!(options?.xml && "xml" in schema && schema.xml?.wrapped && itemsXmlTagName);
|
|
219
|
-
if (schema.example !== void 0) return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example, cacheKey);
|
|
220
|
-
if (items && typeof items === "object") {
|
|
221
|
-
if (Array.isArray(items.allOf) && items.allOf.length > 0) {
|
|
222
|
-
const allOf = items.allOf.filter(isDefined);
|
|
223
|
-
const first = resolve.schema(allOf[0]);
|
|
224
|
-
if (first && typeof first === "object" && "type" in first && first.type === "object") {
|
|
225
|
-
const merged = getExampleFromSchema({
|
|
226
|
-
type: "object",
|
|
227
|
-
allOf
|
|
228
|
-
}, options, {
|
|
229
|
-
level: level + 1,
|
|
230
|
-
parentSchema: schema,
|
|
231
|
-
schemaPath: itemsSchemaPath,
|
|
232
|
-
seen
|
|
233
|
-
});
|
|
234
|
-
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: merged }] : [merged], cacheKey);
|
|
235
|
-
}
|
|
236
|
-
const examples = allOf.map((s) => getExampleFromSchema(resolve.schema(s), options, {
|
|
237
|
-
level: level + 1,
|
|
238
|
-
parentSchema: schema,
|
|
239
|
-
schemaPath: itemsSchemaPath,
|
|
240
|
-
seen
|
|
241
|
-
})).filter(isDefined);
|
|
242
|
-
return cache(schema, wrapItems ? examples.map((e) => ({ [itemsXmlTagName]: e })) : examples, cacheKey);
|
|
243
|
-
}
|
|
244
|
-
const compositionKeyword = items.oneOf ? "oneOf" : items.anyOf ? "anyOf" : void 0;
|
|
245
|
-
const union = compositionKeyword ? items[compositionKeyword] : void 0;
|
|
246
|
-
if (compositionKeyword && union && union.length > 0) {
|
|
247
|
-
const selected = union[getCompositionSelectionIndex(itemsSchemaPath, compositionKeyword, options, union.length) ?? 0];
|
|
248
|
-
const ex = getExampleFromSchema(resolve.schema(selected), options, {
|
|
249
|
-
level: level + 1,
|
|
250
|
-
parentSchema: schema,
|
|
251
|
-
schemaPath: itemsSchemaPath,
|
|
252
|
-
seen
|
|
253
|
-
});
|
|
254
|
-
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const isObject = items && typeof items === "object" && ("type" in items && items.type === "object" || "properties" in items);
|
|
258
|
-
const isArray = items && typeof items === "object" && ("type" in items && items.type === "array" || "items" in items);
|
|
259
|
-
if (items && typeof items === "object" && ("type" in items && items.type || isObject || isArray)) {
|
|
260
|
-
const ex = getExampleFromSchema(items, options, {
|
|
261
|
-
level: level + 1,
|
|
262
|
-
schemaPath: itemsSchemaPath,
|
|
263
|
-
seen
|
|
264
|
-
});
|
|
265
|
-
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: ex }] : [ex], cacheKey);
|
|
266
|
-
}
|
|
267
|
-
return cache(schema, [], cacheKey);
|
|
268
|
-
};
|
|
269
|
-
/** Return primitive example value for single-type schemas, or undefined if not primitive */
|
|
270
|
-
var getPrimitiveValue = (schema, makeUpRandomData, emptyString) => {
|
|
271
|
-
if ("type" in schema && schema.type && !Array.isArray(schema.type)) switch (schema.type) {
|
|
272
|
-
case "string": return guessFromFormat(schema, makeUpRandomData, emptyString ?? "");
|
|
273
|
-
case "boolean": return true;
|
|
274
|
-
case "integer": return "minimum" in schema && typeof schema.minimum === "number" ? schema.minimum : 1;
|
|
275
|
-
case "number": return "minimum" in schema && typeof schema.minimum === "number" ? schema.minimum : 1;
|
|
276
|
-
case "array": return [];
|
|
277
|
-
default: return;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
/** Return primitive example value for union-type schemas (type: string[]) */
|
|
281
|
-
var getUnionPrimitiveValue = (schema, makeUpRandomData, emptyString) => {
|
|
282
|
-
if ("type" in schema && Array.isArray(schema.type)) {
|
|
283
|
-
if (schema.type.includes("null")) return null;
|
|
284
|
-
const first = schema.type[0];
|
|
285
|
-
if (first) switch (first) {
|
|
286
|
-
case "string": return guessFromFormat(schema, makeUpRandomData, emptyString ?? "");
|
|
287
|
-
case "boolean": return true;
|
|
288
|
-
case "integer": return "minimum" in schema && typeof schema.minimum === "number" ? schema.minimum : 1;
|
|
289
|
-
case "number": return "minimum" in schema && typeof schema.minimum === "number" ? schema.minimum : 1;
|
|
290
|
-
case "null": return null;
|
|
291
|
-
default: return;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
/** Create stable cache key from the options object */
|
|
296
|
-
var createOptionsCacheKey = (options) => JSON.stringify({
|
|
297
|
-
emptyString: options?.emptyString,
|
|
298
|
-
xml: options?.xml,
|
|
299
|
-
mode: options?.mode,
|
|
300
|
-
variables: options?.variables,
|
|
301
|
-
omitEmptyAndOptionalProperties: options?.omitEmptyAndOptionalProperties,
|
|
302
|
-
compositionSelection: options?.compositionSelection ? Object.entries(options.compositionSelection).sort(([a], [b]) => a.localeCompare(b)) : void 0
|
|
303
|
-
});
|
|
304
|
-
/**
|
|
305
|
-
* Generate an example value from a given OpenAPI SchemaObject.
|
|
306
|
-
*
|
|
307
|
-
* This function recursively processes OpenAPI schemas to create realistic example data.
|
|
308
|
-
* It handles all OpenAPI schema types including primitives, objects, arrays, and
|
|
309
|
-
* composition schemas (allOf, oneOf, anyOf).
|
|
310
|
-
* Uses a tonne of caching for maximum performance.
|
|
311
|
-
*
|
|
312
|
-
* @param schema - The OpenAPI SchemaObject to generate an example from.
|
|
313
|
-
* @param options - Options to customize example generation.
|
|
314
|
-
* @param level - The current recursion depth.
|
|
315
|
-
* @param parentSchema - The parent schema, if any.
|
|
316
|
-
* @param name - The name of the property being processed.
|
|
317
|
-
* @returns An example value for the given schema.
|
|
318
|
-
*/
|
|
319
|
-
var getExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = /* @__PURE__ */ new WeakSet(), schemaPath = [] } = {}) => {
|
|
320
|
-
const _schema = resolve.schema(schema);
|
|
321
|
-
if (!isDefined(_schema)) return;
|
|
322
|
-
const targetValue = getSchemaCacheTarget(_schema);
|
|
323
|
-
if (seen.has(targetValue)) return;
|
|
324
|
-
seen.add(targetValue);
|
|
325
|
-
/** Make the cache key unique per options and schema path */
|
|
326
|
-
const cacheKey = createOptionsCacheKey(options) + (schemaPath.length > 0 ? `:path:${schemaPath.join(".")}` : "");
|
|
327
|
-
const cached = resultCache.get(targetValue)?.get(cacheKey);
|
|
328
|
-
if (typeof cached !== "undefined") {
|
|
329
|
-
seen.delete(targetValue);
|
|
330
|
-
return cached;
|
|
331
|
-
}
|
|
332
|
-
if (level > MAX_LEVELS_DEEP) {
|
|
333
|
-
seen.delete(targetValue);
|
|
334
|
-
return "[Max Depth Exceeded]";
|
|
335
|
-
}
|
|
336
|
-
const makeUpRandomData = !!options?.emptyString;
|
|
337
|
-
if (shouldOmitProperty(_schema, parentSchema, name, options)) {
|
|
338
|
-
seen.delete(targetValue);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
if ("x-variable" in _schema && _schema["x-variable"]) {
|
|
342
|
-
const value = options?.variables?.[_schema["x-variable"]];
|
|
343
|
-
if (value !== void 0) {
|
|
344
|
-
if ("type" in _schema && (_schema.type === "number" || _schema.type === "integer")) {
|
|
345
|
-
seen.delete(targetValue);
|
|
346
|
-
return cache(_schema, Number(value), cacheKey);
|
|
347
|
-
}
|
|
348
|
-
seen.delete(targetValue);
|
|
349
|
-
return cache(_schema, value, cacheKey);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {
|
|
353
|
-
seen.delete(targetValue);
|
|
354
|
-
return cache(_schema, _schema.examples[0], cacheKey);
|
|
355
|
-
}
|
|
356
|
-
if (_schema.example !== void 0) {
|
|
357
|
-
seen.delete(targetValue);
|
|
358
|
-
return cache(_schema, _schema.example, cacheKey);
|
|
359
|
-
}
|
|
360
|
-
if (_schema.default !== void 0) {
|
|
361
|
-
seen.delete(targetValue);
|
|
362
|
-
return cache(_schema, _schema.default, cacheKey);
|
|
363
|
-
}
|
|
364
|
-
if (_schema.const !== void 0) {
|
|
365
|
-
seen.delete(targetValue);
|
|
366
|
-
return cache(_schema, _schema.const, cacheKey);
|
|
367
|
-
}
|
|
368
|
-
if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {
|
|
369
|
-
seen.delete(targetValue);
|
|
370
|
-
return cache(_schema, _schema.enum[0], cacheKey);
|
|
371
|
-
}
|
|
372
|
-
if ("properties" in _schema || "type" in _schema && _schema.type === "object") {
|
|
373
|
-
const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath);
|
|
374
|
-
seen.delete(targetValue);
|
|
375
|
-
return result;
|
|
376
|
-
}
|
|
377
|
-
if ("type" in _schema && _schema.type === "array" || "items" in _schema) {
|
|
378
|
-
const result = handleArraySchema(_schema, options, level, seen, cacheKey, schemaPath);
|
|
379
|
-
seen.delete(targetValue);
|
|
380
|
-
return result;
|
|
381
|
-
}
|
|
382
|
-
const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString);
|
|
383
|
-
if (primitive !== void 0) {
|
|
384
|
-
seen.delete(targetValue);
|
|
385
|
-
return cache(_schema, primitive, cacheKey);
|
|
386
|
-
}
|
|
387
|
-
const compositionKeyword = _schema.oneOf ? "oneOf" : _schema.anyOf ? "anyOf" : void 0;
|
|
388
|
-
const discriminate = compositionKeyword ? _schema[compositionKeyword] : void 0;
|
|
389
|
-
if (compositionKeyword && Array.isArray(discriminate) && discriminate.length > 0) {
|
|
390
|
-
const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, discriminate.length);
|
|
391
|
-
const candidate = index !== void 0 ? discriminate[index] : discriminate.find((item) => {
|
|
392
|
-
const resolved = resolve.schema(item);
|
|
393
|
-
return resolved && (!("type" in resolved) || resolved.type !== "null");
|
|
394
|
-
});
|
|
395
|
-
if (candidate) {
|
|
396
|
-
const resolved = resolve.schema(candidate);
|
|
397
|
-
if (resolved) {
|
|
398
|
-
seen.delete(targetValue);
|
|
399
|
-
return cache(_schema, getExampleFromSchema(resolved, options, {
|
|
400
|
-
level: level + 1,
|
|
401
|
-
schemaPath,
|
|
402
|
-
seen
|
|
403
|
-
}), cacheKey);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
seen.delete(targetValue);
|
|
407
|
-
return cache(_schema, null, cacheKey);
|
|
408
|
-
}
|
|
409
|
-
if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {
|
|
410
|
-
let merged = void 0;
|
|
411
|
-
const items = _schema.allOf;
|
|
412
|
-
for (const item of items) {
|
|
413
|
-
const ex = getExampleFromSchema(item, options, {
|
|
414
|
-
level: level + 1,
|
|
415
|
-
parentSchema: _schema,
|
|
416
|
-
schemaPath,
|
|
417
|
-
seen
|
|
418
|
-
});
|
|
419
|
-
if (merged === void 0) merged = ex;
|
|
420
|
-
else if (merged && typeof merged === "object" && ex && typeof ex === "object") merged = mergeExamples(merged, ex);
|
|
421
|
-
else if (ex !== void 0) merged = ex;
|
|
422
|
-
}
|
|
423
|
-
seen.delete(targetValue);
|
|
424
|
-
return cache(_schema, merged ?? null, cacheKey);
|
|
425
|
-
}
|
|
426
|
-
const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString);
|
|
427
|
-
if (unionPrimitive !== void 0) {
|
|
428
|
-
seen.delete(targetValue);
|
|
429
|
-
return cache(_schema, unionPrimitive, cacheKey);
|
|
430
|
-
}
|
|
431
|
-
seen.delete(targetValue);
|
|
432
|
-
return cache(_schema, null, cacheKey);
|
|
433
|
-
};
|
|
434
|
-
//#endregion
|
|
435
|
-
export { getExampleFromSchema };
|
|
436
|
-
|
|
437
|
-
//# sourceMappingURL=get-example-from-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-example-from-schema.js","names":[],"sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-example-from-schema.ts"],"sourcesContent":["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/** Maximum recursion depth to prevent infinite loops in circular references */\nconst MAX_LEVELS_DEEP = 10\n\n/** Default name used for additional properties when no custom name is provided */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty'\n\n/**\n * Pre-computed date/time values to avoid expensive Date operations on every call.\n * These are calculated once at module load time for better performance.\n */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\n/**\n * Mapping of OpenAPI string formats to example values.\n * Used to generate realistic examples for different string formats.\n */\nconst genericExampleValues: Record<string, string> = {\n 'date-time': currentISOString,\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * Extract enum values from the propertyNames keyword of an object schema.\n * JSON Schema's propertyNames constrains which keys are valid in a map/dict.\n */\nconst getPropertyNamesEnumValues = (schema: SchemaObject): unknown[] | undefined => {\n if (!('propertyNames' in schema) || !schema.propertyNames) {\n return undefined\n }\n\n const resolved = resolve.schema(schema.propertyNames as SchemaObject)\n if (resolved && 'enum' in resolved && Array.isArray(resolved.enum) && resolved.enum.length > 0) {\n return resolved.enum\n }\n\n return undefined\n}\n\n/**\n * Generate example values for string types based on their format.\n * Special handling for binary format which returns a File object.\n */\nconst guessFromFormat = (\n schema: SchemaObject,\n makeUpRandomData: boolean = false,\n fallback: string = '',\n): string | File => {\n // Handle binary format specially - return a File object\n if ('type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary') {\n return '@filename'\n }\n\n // Return format-specific example if we have one and are making up data\n if (makeUpRandomData && 'format' in schema && schema.format) {\n return genericExampleValues[schema.format] ?? fallback\n }\n\n return fallback\n}\n\n/**\n * WeakMap cache for memoizing resolved example results.\n * Uses the resolved schema object as the key for efficient lookups.\n */\nconst resultCache = new WeakMap<object, Map<string, unknown>>()\n\n/** Cache required property names per parent schema for O(1) membership checks */\nconst requiredNamesCache = new WeakMap<object, ReadonlySet<string>>()\n\n/** Normalize schema identity for cache and cycle tracking */\nconst getSchemaCacheTarget = (schema: SchemaObject): object => unpackProxyObject(schema, { depth: 1 }) as object\n\n/**\n * Retrieves the set of required property names from a schema.\n * Caches the result in a WeakMap for efficient lookups.\n */\nconst getRequiredNames = (parentSchema: SchemaObject | undefined): ReadonlySet<string> | undefined => {\n if (!parentSchema) {\n return undefined\n }\n\n const cached = requiredNamesCache.get(parentSchema)\n if (cached) {\n return cached\n }\n\n if ('required' in parentSchema) {\n const required = parentSchema.required\n if (Array.isArray(required) && required.length > 0) {\n const set = new Set<string>(required)\n requiredNamesCache.set(parentSchema, set)\n return set\n }\n }\n\n return undefined\n}\n\n/**\n * Cache the result for a schema if it is an object type.\n * Primitive values are not cached to avoid unnecessary WeakMap operations.\n * Stores a map of cacheKey strings which is made up of the options object.\n */\nconst cache = (schema: SchemaObject, result: unknown, cacheKey: string) => {\n if (typeof result !== 'object' || result === null) {\n return result\n }\n const rawSchema = getSchemaCacheTarget(schema)\n\n const cacheMap = resultCache.get(rawSchema) ?? new Map()\n if (cacheMap) {\n cacheMap.set(cacheKey, result)\n }\n resultCache.set(rawSchema, cacheMap)\n return result\n}\n\n/**\n * Check if a schema uses composition keywords (allOf, oneOf, anyOf).\n * These require special handling for merging or selecting schemas.\n */\nconst isComposed = (schema: SchemaObject): boolean => !!(schema.allOf || schema.oneOf || schema.anyOf)\n\n/**\n * Determine if a property should be omitted based on the options.\n * Properties are omitted if they are not required and the option is enabled.\n */\nconst shouldOmitProperty = (\n schema: SchemaObject,\n parentSchema: SchemaObject | undefined,\n propertyName: string | undefined,\n options: Pick<GetExampleFromSchemaOptions, 'omitEmptyAndOptionalProperties' | 'mode'> | undefined,\n): boolean => {\n // Early exits for schemas that should not be included (deprecated, readOnly, writeOnly)\n if (\n schema.deprecated ||\n (options?.mode === 'write' && schema.readOnly) ||\n (options?.mode === 'read' && schema.writeOnly)\n ) {\n return true\n }\n\n if (options?.omitEmptyAndOptionalProperties !== true) {\n return false\n }\n\n // Never omit container types (objects/arrays) or composed schemas\n const isContainer = ('type' in schema && (schema.type === 'object' || schema.type === 'array')) || isComposed(schema)\n if (isContainer) {\n return false\n }\n\n // Do not omit if explicit example-like values are present\n if (\n ('examples' in schema && Array.isArray(schema.examples) && schema.examples.length > 0) ||\n ('example' in schema && schema.example !== undefined) ||\n ('default' in schema && schema.default !== undefined) ||\n ('const' in schema && schema.const !== undefined) ||\n ('enum' in schema && Array.isArray(schema.enum) && schema.enum.length > 0)\n ) {\n return false\n }\n\n // Check if the property is required\n const name = propertyName ?? schema.title ?? ''\n const requiredNames = getRequiredNames(parentSchema)\n const isRequired = requiredNames ? requiredNames.has(name) : false\n\n return !isRequired\n}\n\n/**\n * Merge two example values with predictable semantics.\n * Arrays are concatenated, objects are merged, otherwise the new value wins.\n */\nconst mergeExamples = (baseValue: unknown, newValue: unknown): unknown => {\n if (Array.isArray(baseValue) && Array.isArray(newValue)) {\n return [...baseValue, ...newValue]\n }\n if (baseValue && typeof baseValue === 'object' && newValue && typeof newValue === 'object') {\n return { ...(baseValue as Record<string, unknown>), ...(newValue as Record<string, unknown>) }\n }\n return newValue\n}\n\ntype CompositionKeyword = 'anyOf' | 'oneOf'\n\nconst getCompositionSelectionKey = (schemaPath: string[], composition: CompositionKeyword): string =>\n [...schemaPath, composition].join('.')\n\nconst getCompositionSelectionIndex = (\n schemaPath: string[],\n composition: CompositionKeyword,\n options: GetExampleFromSchemaOptions | undefined,\n length: number,\n): number | undefined => {\n const rawIndex = options?.compositionSelection?.[getCompositionSelectionKey(schemaPath, composition)]\n\n if (typeof rawIndex !== 'number' || Number.isNaN(rawIndex)) {\n return undefined\n }\n\n return Math.max(0, Math.min(rawIndex, length - 1))\n}\n\n/**\n * Build an example for an object schema, including properties, patternProperties,\n * additionalProperties, and composition (allOf/oneOf/anyOf) merging.\n */\nconst handleObjectSchema = (\n schema: SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n cacheKey: string,\n schemaPath: string[],\n): unknown => {\n const response: Record<string, unknown> = {}\n\n if ('properties' in schema && schema.properties) {\n const propertyNames = Object.keys(schema.properties)\n const limit = propertyNames.length\n\n for (let i = 0; i < limit; i++) {\n const propertyName = propertyNames[i]!\n const propertySchema = resolve.schema(schema.properties[propertyName])\n if (!propertySchema) {\n continue\n }\n\n const propertyXmlName = options?.xml && 'xml' in propertySchema ? propertySchema.xml?.name : undefined\n const value = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: propertyName,\n schemaPath: [...schemaPath, propertyName],\n seen,\n })\n\n if (typeof value !== 'undefined') {\n response[propertyXmlName ?? propertyName] = value\n }\n }\n }\n\n if ('patternProperties' in schema && schema.patternProperties) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const propertySchema = resolve.schema(schema.patternProperties[pattern])\n if (!propertySchema) {\n continue\n }\n response[pattern] = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: pattern,\n schemaPath: [...schemaPath, pattern],\n seen,\n })\n }\n }\n\n if ('additionalProperties' in schema && schema.additionalProperties) {\n const additional =\n typeof schema.additionalProperties === 'boolean'\n ? schema.additionalProperties\n : resolve.schema(schema.additionalProperties)\n const isAnyType =\n schema.additionalProperties === true ||\n (typeof schema.additionalProperties === 'object' && Object.keys(schema.additionalProperties).length === 0)\n\n // Check for explicit x-additionalPropertiesName first\n const hasCustomName =\n typeof additional === 'object' &&\n 'x-additionalPropertiesName' in additional &&\n typeof additional['x-additionalPropertiesName'] === 'string' &&\n additional['x-additionalPropertiesName'].trim().length > 0\n\n // Use propertyNames enum values as example keys when no custom name is set\n const propertyNamesEnum = hasCustomName ? undefined : getPropertyNamesEnumValues(schema)\n\n const additionalName = hasCustomName\n ? (additional as unknown as Record<string, string>)['x-additionalPropertiesName']!.trim()\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n const additionalValue = isAnyType\n ? 'anything'\n : typeof additional === 'object'\n ? getExampleFromSchema(additional, options, {\n level: level + 1,\n schemaPath: [...schemaPath, additionalName],\n seen,\n })\n : 'anything'\n\n if (propertyNamesEnum && propertyNamesEnum.length > 0) {\n // Use the first enum value as a realistic example key\n response[String(propertyNamesEnum[0])] = additionalValue\n } else {\n response[additionalName] = additionalValue\n }\n }\n\n const compositionKeyword = schema.oneOf ? 'oneOf' : schema.anyOf ? 'anyOf' : undefined\n const oneOfAnyOf = compositionKeyword ? schema[compositionKeyword] : undefined\n if (compositionKeyword && oneOfAnyOf?.length) {\n const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, oneOfAnyOf.length) ?? 0\n const chosen = resolve.schema(oneOfAnyOf[index])\n if (chosen) {\n Object.assign(\n response,\n getExampleFromSchema(chosen, options, {\n level: level + 1,\n schemaPath,\n seen,\n }),\n )\n }\n }\n // allOf\n else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n let merged: unknown = response\n for (const item of schema.allOf) {\n const ex = getExampleFromSchema(resolve.schema(item), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n merged = mergeExamples(merged, ex)\n }\n if (merged && typeof merged === 'object') {\n Object.assign(response, merged as Record<string, unknown>)\n }\n }\n\n if (options?.xml && 'xml' in schema && schema.xml?.name && level === 0) {\n const wrapped: Record<string, unknown> = {}\n wrapped[schema.xml.name] = response\n return cache(schema, wrapped, cacheKey)\n }\n\n return cache(schema, response, cacheKey)\n}\n\n/** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */\nconst handleArraySchema = (\n schema: SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n cacheKey: string,\n schemaPath: string[],\n) => {\n const items = 'items' in schema ? resolve.schema(schema.items) : undefined\n const itemsSchemaPath = [...schemaPath, 'items']\n const itemsXmlTagName = items && typeof items === 'object' && 'xml' in items ? items.xml?.name : undefined\n const wrapItems = !!(options?.xml && 'xml' in schema && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName as string]: schema.example } : schema.example, cacheKey)\n }\n\n if (items && typeof items === 'object') {\n if (Array.isArray(items.allOf) && items.allOf.length > 0) {\n const allOf = items.allOf.filter(isDefined)\n const first = resolve.schema(allOf[0])\n\n if (first && typeof first === 'object' && 'type' in first && first.type === 'object') {\n const combined: SchemaObject = { type: 'object', allOf }\n const merged = getExampleFromSchema(combined, options, {\n level: level + 1,\n parentSchema: schema,\n schemaPath: itemsSchemaPath,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: merged }] : [merged], cacheKey)\n }\n\n const examples = allOf\n .map((s) =>\n getExampleFromSchema(resolve.schema(s), options, {\n level: level + 1,\n parentSchema: schema,\n schemaPath: itemsSchemaPath,\n seen,\n }),\n )\n .filter(isDefined)\n return cache(\n schema,\n wrapItems ? (examples as unknown[]).map((e) => ({ [itemsXmlTagName as string]: e })) : examples,\n cacheKey,\n )\n }\n\n const compositionKeyword = items.oneOf ? 'oneOf' : items.anyOf ? 'anyOf' : undefined\n const union = compositionKeyword ? items[compositionKeyword] : undefined\n if (compositionKeyword && union && union.length > 0) {\n const selectedIndex =\n getCompositionSelectionIndex(itemsSchemaPath, compositionKeyword, options, union.length) ?? 0\n const selected = union[selectedIndex]!\n const ex = getExampleFromSchema(resolve.schema(selected), options, {\n level: level + 1,\n parentSchema: schema,\n schemaPath: itemsSchemaPath,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex], cacheKey)\n }\n }\n\n const isObject =\n items && typeof items === 'object' && (('type' in items && items.type === 'object') || 'properties' in items)\n const isArray =\n items && typeof items === 'object' && (('type' in items && items.type === 'array') || 'items' in items)\n\n if (items && typeof items === 'object' && (('type' in items && items.type) || isObject || isArray)) {\n const ex = getExampleFromSchema(items as SchemaObject, options, {\n level: level + 1,\n schemaPath: itemsSchemaPath,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex], cacheKey)\n }\n\n return cache(schema, [], cacheKey)\n}\n\n/** Return primitive example value for single-type schemas, or undefined if not primitive */\nconst getPrimitiveValue = (schema: SchemaObject, makeUpRandomData: boolean, emptyString: string | undefined) => {\n if ('type' in schema && schema.type && !Array.isArray(schema.type)) {\n switch (schema.type) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'array':\n return []\n default:\n return undefined\n }\n }\n return undefined\n}\n\n/** Return primitive example value for union-type schemas (type: string[]) */\nconst getUnionPrimitiveValue = (schema: SchemaObject, makeUpRandomData: boolean, emptyString: string | undefined) => {\n if ('type' in schema && Array.isArray(schema.type)) {\n if (schema.type.includes('null')) {\n return null\n }\n\n const first = schema.type[0]\n if (first) {\n switch (first) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'null':\n return null\n default:\n return undefined\n }\n }\n }\n return undefined\n}\n\ntype GetExampleFromSchemaOptions = {\n /** Fallback string for empty string values. */\n emptyString?: string\n /** Whether to use XML tag names as keys. */\n xml?: boolean\n /** Whether to show read-only/write-only properties. */\n mode?: 'read' | 'write'\n /** Dynamic variables which can replace values via x-variable. */\n variables?: Record<string, unknown>\n /** Whether to omit empty and optional properties. */\n omitEmptyAndOptionalProperties?: boolean\n /** Selected oneOf/anyOf variants keyed by schema path. */\n compositionSelection?: Record<string, number>\n}\n\n/** Create stable cache key from the options object */\nconst createOptionsCacheKey = (options: GetExampleFromSchemaOptions | undefined) =>\n JSON.stringify({\n emptyString: options?.emptyString,\n xml: options?.xml,\n mode: options?.mode,\n variables: options?.variables,\n omitEmptyAndOptionalProperties: options?.omitEmptyAndOptionalProperties,\n compositionSelection: options?.compositionSelection\n ? Object.entries(options.compositionSelection).sort(([a], [b]) => a.localeCompare(b))\n : undefined,\n })\n\n/**\n * Generate an example value from a given OpenAPI SchemaObject.\n *\n * This function recursively processes OpenAPI schemas to create realistic example data.\n * It handles all OpenAPI schema types including primitives, objects, arrays, and\n * composition schemas (allOf, oneOf, anyOf).\n * Uses a tonne of caching for maximum performance.\n *\n * @param schema - The OpenAPI SchemaObject to generate an example from.\n * @param options - Options to customize example generation.\n * @param level - The current recursion depth.\n * @param parentSchema - The parent schema, if any.\n * @param name - The name of the property being processed.\n * @returns An example value for the given schema.\n */\nexport const getExampleFromSchema = (\n schema: SchemaObject,\n options?: GetExampleFromSchemaOptions,\n {\n level = 0,\n parentSchema,\n name,\n seen = new WeakSet(),\n schemaPath = [],\n }: Partial<{\n level: number\n parentSchema: SchemaObject\n name: string\n seen: WeakSet<object>\n /** Internal traversal path used to resolve nested composition selections. */\n schemaPath: string[]\n }> = {},\n): unknown => {\n // Resolve any $ref references to get the actual schema\n const _schema = resolve.schema(schema)\n if (!isDefined(_schema)) {\n return undefined\n }\n\n // Unpack from all proxies to get the raw schema object for cycle detection\n const targetValue = getSchemaCacheTarget(_schema)\n if (seen.has(targetValue)) {\n return undefined\n }\n seen.add(targetValue)\n\n /** Make the cache key unique per options and schema path */\n const cacheKey = createOptionsCacheKey(options) + (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '')\n\n // Check cache first for performance - avoid recomputing the same schema\n const cached = resultCache.get(targetValue)?.get(cacheKey)\n if (typeof cached !== 'undefined') {\n seen.delete(targetValue)\n return cached\n }\n\n // Prevent infinite recursion in circular references\n if (level > MAX_LEVELS_DEEP) {\n seen.delete(targetValue)\n return '[Max Depth Exceeded]'\n }\n\n // Determine if we should generate realistic example data\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for schemas that should not be included (deprecated, readOnly, writeOnly, omitEmptyAndOptionalProperties)\n if (shouldOmitProperty(_schema, parentSchema, name, options)) {\n seen.delete(targetValue)\n return undefined\n }\n\n // Handle custom variables (x-variable extension)\n if ('x-variable' in _schema && _schema['x-variable']) {\n const value = options?.variables?.[_schema['x-variable']]\n if (value !== undefined) {\n // Type coercion for numeric types\n if ('type' in _schema && (_schema.type === 'number' || _schema.type === 'integer')) {\n seen.delete(targetValue)\n return cache(_schema, Number(value), cacheKey)\n }\n seen.delete(targetValue)\n return cache(_schema, value, cacheKey)\n }\n }\n\n // Priority order: examples > example > default > const > enum\n if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.examples[0], cacheKey)\n }\n if (_schema.example !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.example, cacheKey)\n }\n if (_schema.default !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.default, cacheKey)\n }\n if (_schema.const !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.const, cacheKey)\n }\n if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.enum[0], cacheKey)\n }\n\n // Handle object types - check for properties to identify objects\n if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {\n const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath)\n seen.delete(targetValue)\n return result\n }\n\n // Handle array types\n if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {\n const result = handleArraySchema(_schema, options, level, seen, cacheKey, schemaPath)\n seen.delete(targetValue)\n return result\n }\n\n // Handle primitive types without allocating temporary objects\n const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (primitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, primitive, cacheKey)\n }\n\n // Handle composition schemas (oneOf, anyOf)\n const compositionKeyword = _schema.oneOf ? 'oneOf' : _schema.anyOf ? 'anyOf' : undefined\n const discriminate = compositionKeyword ? _schema[compositionKeyword] : undefined\n if (compositionKeyword && Array.isArray(discriminate) && discriminate.length > 0) {\n const index = getCompositionSelectionIndex(schemaPath, compositionKeyword, options, discriminate.length)\n const candidate =\n index !== undefined\n ? discriminate[index]\n : discriminate.find((item) => {\n const resolved = resolve.schema(item)\n return resolved && (!('type' in resolved) || resolved.type !== 'null')\n })\n if (candidate) {\n const resolved = resolve.schema(candidate)\n if (resolved) {\n seen.delete(targetValue)\n return cache(\n _schema,\n getExampleFromSchema(resolved, options, {\n level: level + 1,\n schemaPath,\n seen,\n }),\n cacheKey,\n )\n }\n }\n seen.delete(targetValue)\n return cache(_schema, null, cacheKey)\n }\n\n // Handle allOf at root level (non-object/array schemas)\n if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {\n let merged: unknown = undefined\n const items = _schema.allOf\n for (const item of items) {\n const ex = getExampleFromSchema(item as SchemaObject, options, {\n level: level + 1,\n parentSchema: _schema,\n schemaPath,\n seen,\n })\n if (merged === undefined) {\n merged = ex\n } else if (merged && typeof merged === 'object' && ex && typeof ex === 'object') {\n merged = mergeExamples(merged, ex)\n } else if (ex !== undefined) {\n // Prefer the latest defined primitive value\n merged = ex\n }\n }\n seen.delete(targetValue)\n return cache(_schema, merged ?? null, cacheKey)\n }\n\n // Handle union types (array of types)\n const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (unionPrimitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, unionPrimitive, cacheKey)\n }\n\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SAAS;GAC1B,MAAM,WAAW,QAAQ,OAAO,KAAK;AACrC,UAAO,aAAa,EAAE,UAAU,aAAa,SAAS,SAAS;IAC/D;AACR,MAAI,WAAW;GACb,MAAM,WAAW,QAAQ,OAAO,UAAU;AAC1C,OAAI,UAAU;AACZ,SAAK,OAAO,YAAY;AACxB,WAAO,MACL,SACA,qBAAqB,UAAU,SAAS;KACtC,OAAO,QAAQ;KACf;KACA;KACD,CAAC,EACF,SACD;;;AAGL,OAAK,OAAO,YAAY;AACxB,SAAO,MAAM,SAAS,MAAM,SAAS;;AAIvC,KAAI,MAAM,QAAQ,QAAQ,MAAM,IAAI,QAAQ,MAAM,SAAS,GAAG;EAC5D,IAAI,SAAkB,KAAA;EACtB,MAAM,QAAQ,QAAQ;AACtB,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,KAAK,qBAAqB,MAAsB,SAAS;IAC7D,OAAO,QAAQ;IACf,cAAc;IACd;IACA;IACD,CAAC;AACF,OAAI,WAAW,KAAA,EACb,UAAS;YACA,UAAU,OAAO,WAAW,YAAY,MAAM,OAAO,OAAO,SACrE,UAAS,cAAc,QAAQ,GAAG;YACzB,OAAO,KAAA,EAEhB,UAAS;;AAGb,OAAK,OAAO,YAAY;AACxB,SAAO,MAAM,SAAS,UAAU,MAAM,SAAS;;CAIjD,MAAM,iBAAiB,uBAAuB,SAAS,kBAAkB,SAAS,YAAY;AAC9F,KAAI,mBAAmB,KAAA,GAAW;AAChC,OAAK,OAAO,YAAY;AACxB,SAAO,MAAM,SAAS,gBAAgB,SAAS;;AAIjD,MAAK,OAAO,YAAY;AACxB,QAAO,MAAM,SAAS,MAAM,SAAS"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ExampleObject, RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
-
/**
|
|
3
|
-
* Basically getExample + we generate an example from the schema if no example is found
|
|
4
|
-
*/
|
|
5
|
-
export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleKey: string, requestBodyCompositionSelection?: Record<string, number>) => ExampleObject | null;
|
|
6
|
-
//# sourceMappingURL=get-request-body-example.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-request-body-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAMrE;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,YAAY,MAAM,EAClB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,aAAa,GAAG,IAgClB,CAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getResolvedRefDeep } from "../../operation-code-sample/helpers/get-resolved-ref-deep.js";
|
|
2
|
-
import { getExample } from "../../operation-block/helpers/get-example.js";
|
|
3
|
-
import { getExampleFromSchema } from "../../operation-code-sample/helpers/get-example-from-schema.js";
|
|
4
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
5
|
-
//#region src/v2/blocks/request-block/helpers/get-request-body-example.ts
|
|
6
|
-
/**
|
|
7
|
-
* Basically getExample + we generate an example from the schema if no example is found
|
|
8
|
-
*/
|
|
9
|
-
var getExampleFromBody = (requestBody, contentType, exampleKey, requestBodyCompositionSelection) => {
|
|
10
|
-
const content = requestBody.content?.[contentType];
|
|
11
|
-
const example = getExample(requestBody, exampleKey, contentType);
|
|
12
|
-
if (example) return example;
|
|
13
|
-
const schema = getResolvedRef(content?.schema);
|
|
14
|
-
if (!schema) return null;
|
|
15
|
-
const schemaExample = getExampleFromSchema(getResolvedRefDeep(schema), {
|
|
16
|
-
mode: "write",
|
|
17
|
-
compositionSelection: requestBodyCompositionSelection
|
|
18
|
-
}, { schemaPath: ["requestBody"] });
|
|
19
|
-
if (!schemaExample) return null;
|
|
20
|
-
return { value: schemaExample };
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { getExampleFromBody };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=get-request-body-example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-request-body-example.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/get-request-body-example.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type {\n ExampleObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nimport { getExample } from '@/v2/blocks/operation-block/helpers/get-example'\nimport { getExampleFromSchema } from '@/v2/blocks/operation-code-sample/helpers/get-example-from-schema'\nimport { getResolvedRefDeep } from '@/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep'\n\n/**\n * Basically getExample + we generate an example from the schema if no example is found\n */\nexport const getExampleFromBody = (\n requestBody: RequestBodyObject,\n contentType: string,\n exampleKey: string,\n requestBodyCompositionSelection?: Record<string, number>,\n): ExampleObject | null => {\n const content = requestBody.content?.[contentType]\n\n // Return existing example value if we have one\n const example = getExample(requestBody, exampleKey, contentType)\n if (example) {\n return example\n }\n\n const schema = getResolvedRef(content?.schema)\n if (!schema) {\n return null\n }\n\n const resolvedSchema = getResolvedRefDeep(schema) as SchemaObject\n\n // Generate an example from the schema\n const schemaExample = getExampleFromSchema(\n resolvedSchema,\n {\n mode: 'write',\n compositionSelection: requestBodyCompositionSelection,\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n if (!schemaExample) {\n return null\n }\n\n return { value: schemaExample }\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,sBACX,aACA,aACA,YACA,oCACyB;CACzB,MAAM,UAAU,YAAY,UAAU;CAGtC,MAAM,UAAU,WAAW,aAAa,YAAY,YAAY;AAChE,KAAI,QACF,QAAO;CAGT,MAAM,SAAS,eAAe,SAAS,OAAO;AAC9C,KAAI,CAAC,OACH,QAAO;CAMT,MAAM,gBAAgB,qBAHC,mBAAmB,OAAO,EAK/C;EACE,MAAM;EACN,sBAAsB;EACvB,EACD,EACE,YAAY,CAAC,cAAc,EAC5B,CACF;AACD,KAAI,CAAC,cACH,QAAO;AAGT,QAAO,EAAE,OAAO,eAAe"}
|