@scalar/workspace-store 0.40.2 → 0.40.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 +13 -0
- package/dist/client.d.ts +7 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +820 -681
- package/dist/entities/auth/index.js +96 -101
- package/dist/entities/auth/schema.d.ts +10 -0
- package/dist/entities/auth/schema.d.ts.map +1 -1
- package/dist/entities/auth/schema.js +42 -116
- package/dist/entities/history/index.js +80 -60
- package/dist/entities/history/schema.js +94 -88
- package/dist/events/bus.js +146 -93
- package/dist/events/definitions/analytics.js +1 -1
- package/dist/events/definitions/auth.js +1 -1
- package/dist/events/definitions/common.js +1 -1
- package/dist/events/definitions/cookie.js +1 -1
- package/dist/events/definitions/document.js +1 -1
- package/dist/events/definitions/environment.js +1 -1
- package/dist/events/definitions/hooks.js +1 -1
- package/dist/events/definitions/index.js +1 -1
- package/dist/events/definitions/meta.js +1 -1
- package/dist/events/definitions/operation.js +1 -1
- package/dist/events/definitions/server.js +1 -1
- package/dist/events/definitions/tabs.js +1 -1
- package/dist/events/definitions/tag.js +1 -1
- package/dist/events/definitions/ui.js +1 -1
- package/dist/events/definitions/workspace.js +1 -1
- package/dist/events/index.js +3 -9
- package/dist/events/listeners.js +20 -22
- package/dist/events/old-definitions.js +15 -12
- package/dist/helpers/deep-clone.js +33 -17
- package/dist/helpers/detect-changes-proxy.js +95 -57
- package/dist/helpers/general.js +78 -23
- package/dist/helpers/generate-unique-value.js +77 -45
- package/dist/helpers/get-fetch.js +12 -10
- package/dist/helpers/get-resolved-ref.js +11 -10
- package/dist/helpers/is-non-optional-security-requirement.js +3 -6
- package/dist/helpers/merge-object.js +71 -30
- package/dist/helpers/overrides-proxy.js +98 -58
- package/dist/helpers/unpack-proxy.js +60 -58
- package/dist/mutators/auth.js +358 -230
- package/dist/mutators/cookie.js +59 -42
- package/dist/mutators/document.js +104 -66
- package/dist/mutators/environment.js +97 -72
- package/dist/mutators/helpers.js +9 -13
- package/dist/mutators/index.js +62 -49
- package/dist/mutators/operation/body.js +88 -57
- package/dist/mutators/operation/extensions.js +20 -12
- package/dist/mutators/operation/helpers/fetch-request-to-har.js +144 -107
- package/dist/mutators/operation/helpers/fetch-response-to-har.js +143 -95
- package/dist/mutators/operation/helpers/get-parameter-position.js +12 -12
- package/dist/mutators/operation/helpers/har-to-operation.js +169 -132
- package/dist/mutators/operation/helpers/sync-path-parameters.js +109 -60
- package/dist/mutators/operation/history.js +60 -64
- package/dist/mutators/operation/index.js +25 -49
- package/dist/mutators/operation/operation.js +349 -240
- package/dist/mutators/operation/parameters.js +157 -93
- package/dist/mutators/server.js +213 -152
- package/dist/mutators/tabs.js +173 -130
- package/dist/mutators/tag.js +131 -97
- package/dist/mutators/workspace.js +72 -42
- package/dist/navigation/get-navigation-options.js +97 -84
- package/dist/navigation/helpers/get-openapi-object.js +46 -29
- package/dist/navigation/helpers/get-operation-entries.js +72 -32
- package/dist/navigation/helpers/get-parent-entry.js +16 -12
- package/dist/navigation/helpers/get-tag-entries.js +56 -29
- package/dist/navigation/helpers/get-tag.js +22 -23
- package/dist/navigation/helpers/get-x-keys.js +13 -9
- package/dist/navigation/helpers/traverse-description.js +90 -72
- package/dist/navigation/helpers/traverse-document.js +111 -98
- package/dist/navigation/helpers/traverse-examples.js +35 -31
- package/dist/navigation/helpers/traverse-paths.js +118 -106
- package/dist/navigation/helpers/traverse-schemas.js +65 -64
- package/dist/navigation/helpers/traverse-tags.js +158 -129
- package/dist/navigation/helpers/traverse-webhooks.js +96 -90
- package/dist/navigation/helpers/update-order-ids.js +59 -51
- package/dist/navigation/helpers/utils.js +71 -21
- package/dist/navigation/index.js +5 -13
- package/dist/navigation/types.js +1 -1
- package/dist/persistence/index.js +283 -285
- package/dist/persistence/indexdb.js +263 -126
- package/dist/plugins/bundler/helpers.js +21 -12
- package/dist/plugins/bundler/index.d.ts +7 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +305 -171
- package/dist/plugins/client/index.js +1 -5
- package/dist/plugins/client/persistence.js +95 -90
- package/dist/resolve.js +18 -25
- package/dist/schemas/compose.js +6 -7
- package/dist/schemas/extensions/document/x-internal.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js +16 -22
- package/dist/schemas/extensions/document/x-scalar-icon.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js +3 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js +21 -8
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +17 -8
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js +15 -21
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +5 -13
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js +4 -8
- package/dist/schemas/extensions/document/x-tags.js +3 -7
- package/dist/schemas/extensions/example/x-disabled.js +17 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js +4 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js +9 -14
- package/dist/schemas/extensions/general/x-scalar-order.js +8 -7
- package/dist/schemas/extensions/operation/index.js +4 -23
- package/dist/schemas/extensions/operation/x-badge.js +42 -50
- package/dist/schemas/extensions/operation/x-code-samples.js +8 -12
- package/dist/schemas/extensions/operation/x-draft-examples.js +3 -7
- package/dist/schemas/extensions/operation/x-post-response.js +18 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +57 -13
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js +15 -14
- package/dist/schemas/extensions/parameter/x-global.js +12 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js +10 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js +17 -12
- package/dist/schemas/extensions/schema/x-enum-varnames.js +21 -8
- package/dist/schemas/extensions/schema/x-examples.js +3 -7
- package/dist/schemas/extensions/schema/x-variable.js +3 -7
- package/dist/schemas/extensions/security/index.js +1 -1
- package/dist/schemas/extensions/security/x-default-scopes.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js +16 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js +14 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js +66 -37
- package/dist/schemas/extensions/security/x-tokenName.js +11 -7
- package/dist/schemas/extensions/security/x-use-pkce.js +6 -10
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +3 -7
- package/dist/schemas/extensions/tag/index.js +1 -1
- package/dist/schemas/extensions/tag/x-display-name.js +11 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js +13 -15
- package/dist/schemas/extensions/workspace/index.js +2 -11
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +13 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js +15 -13
- package/dist/schemas/extensions.js +11 -15
- package/dist/schemas/inmemory-workspace.d.ts +6 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +13 -21
- package/dist/schemas/navigation.js +48 -85
- package/dist/schemas/reference-config/appearance.js +15 -22
- package/dist/schemas/reference-config/features.js +14 -21
- package/dist/schemas/reference-config/index.d.ts +2 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js +42 -44
- package/dist/schemas/reference-config/meta.js +11 -18
- package/dist/schemas/reference-config/routing.js +7 -14
- package/dist/schemas/reference-config/settings.d.ts +2 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.js +10 -17
- package/dist/schemas/typebox-coerce.js +23 -6
- package/dist/schemas/v3.1/strict/callback.js +6 -12
- package/dist/schemas/v3.1/strict/components.js +26 -48
- package/dist/schemas/v3.1/strict/contact.js +9 -12
- package/dist/schemas/v3.1/strict/discriminator.js +11 -10
- package/dist/schemas/v3.1/strict/encoding.js +15 -12
- package/dist/schemas/v3.1/strict/example.js +11 -13
- package/dist/schemas/v3.1/strict/external-documentation.js +7 -10
- package/dist/schemas/v3.1/strict/header.js +27 -28
- package/dist/schemas/v3.1/strict/info.js +10 -16
- package/dist/schemas/v3.1/strict/license.js +9 -12
- package/dist/schemas/v3.1/strict/link.js +22 -19
- package/dist/schemas/v3.1/strict/media-type.js +17 -16
- package/dist/schemas/v3.1/strict/oauth-flow.js +28 -62
- package/dist/schemas/v3.1/strict/oauthflows.js +14 -20
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +70 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +126 -210
- package/dist/schemas/v3.1/strict/operation.js +16 -43
- package/dist/schemas/v3.1/strict/parameter.d.ts +6 -0
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.js +29 -35
- package/dist/schemas/v3.1/strict/path-item.js +36 -40
- package/dist/schemas/v3.1/strict/paths.js +8 -11
- package/dist/schemas/v3.1/strict/ref-definitions.js +76 -100
- package/dist/schemas/v3.1/strict/reference.js +18 -21
- package/dist/schemas/v3.1/strict/request-body.js +8 -16
- package/dist/schemas/v3.1/strict/response.js +12 -16
- package/dist/schemas/v3.1/strict/responses.js +13 -11
- package/dist/schemas/v3.1/strict/schema.js +149 -157
- package/dist/schemas/v3.1/strict/security-requirement.js +13 -12
- package/dist/schemas/v3.1/strict/security-scheme.js +29 -41
- package/dist/schemas/v3.1/strict/server-variable.js +9 -12
- package/dist/schemas/v3.1/strict/server.js +10 -13
- package/dist/schemas/v3.1/strict/tag.js +11 -20
- package/dist/schemas/v3.1/strict/type-guards.js +20 -20
- package/dist/schemas/v3.1/strict/xml.js +17 -16
- package/dist/schemas/workspace-specification/index.js +11 -23
- package/dist/schemas/workspace-specification/info.js +4 -8
- package/dist/schemas/workspace.d.ts +6 -0
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +25 -51
- package/dist/schemas.js +2 -6
- package/dist/server.js +286 -176
- package/dist/workspace-plugin.js +1 -1
- package/package.json +13 -19
- package/dist/client.js.map +0 -7
- package/dist/entities/auth/index.js.map +0 -7
- package/dist/entities/auth/schema.js.map +0 -7
- package/dist/entities/history/index.js.map +0 -7
- package/dist/entities/history/schema.js.map +0 -7
- package/dist/events/bus.js.map +0 -7
- package/dist/events/definitions/analytics.js.map +0 -7
- package/dist/events/definitions/auth.js.map +0 -7
- package/dist/events/definitions/common.js.map +0 -7
- package/dist/events/definitions/cookie.js.map +0 -7
- package/dist/events/definitions/document.js.map +0 -7
- package/dist/events/definitions/environment.js.map +0 -7
- package/dist/events/definitions/hooks.js.map +0 -7
- package/dist/events/definitions/index.js.map +0 -7
- package/dist/events/definitions/meta.js.map +0 -7
- package/dist/events/definitions/operation.js.map +0 -7
- package/dist/events/definitions/server.js.map +0 -7
- package/dist/events/definitions/tabs.js.map +0 -7
- package/dist/events/definitions/tag.js.map +0 -7
- package/dist/events/definitions/ui.js.map +0 -7
- package/dist/events/definitions/workspace.js.map +0 -7
- package/dist/events/index.js.map +0 -7
- package/dist/events/listeners.js.map +0 -7
- package/dist/events/old-definitions.js.map +0 -7
- package/dist/helpers/apply-selective-updates.d.ts +0 -19
- package/dist/helpers/apply-selective-updates.d.ts.map +0 -1
- package/dist/helpers/apply-selective-updates.js +0 -37
- package/dist/helpers/apply-selective-updates.js.map +0 -7
- package/dist/helpers/deep-clone.js.map +0 -7
- package/dist/helpers/detect-changes-proxy.js.map +0 -7
- package/dist/helpers/general.js.map +0 -7
- package/dist/helpers/generate-unique-value.js.map +0 -7
- package/dist/helpers/get-fetch.js.map +0 -7
- package/dist/helpers/get-resolved-ref.js.map +0 -7
- package/dist/helpers/is-non-optional-security-requirement.js.map +0 -7
- package/dist/helpers/merge-object.js.map +0 -7
- package/dist/helpers/overrides-proxy.js.map +0 -7
- package/dist/helpers/unpack-proxy.js.map +0 -7
- package/dist/mutators/auth.js.map +0 -7
- package/dist/mutators/cookie.js.map +0 -7
- package/dist/mutators/document.js.map +0 -7
- package/dist/mutators/environment.js.map +0 -7
- package/dist/mutators/helpers.js.map +0 -7
- package/dist/mutators/index.js.map +0 -7
- package/dist/mutators/operation/body.js.map +0 -7
- package/dist/mutators/operation/extensions.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-request-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/fetch-response-to-har.js.map +0 -7
- package/dist/mutators/operation/helpers/get-parameter-position.js.map +0 -7
- package/dist/mutators/operation/helpers/har-to-operation.js.map +0 -7
- package/dist/mutators/operation/helpers/sync-path-parameters.js.map +0 -7
- package/dist/mutators/operation/history.js.map +0 -7
- package/dist/mutators/operation/index.js.map +0 -7
- package/dist/mutators/operation/operation.js.map +0 -7
- package/dist/mutators/operation/parameters.js.map +0 -7
- package/dist/mutators/server.js.map +0 -7
- package/dist/mutators/tabs.js.map +0 -7
- package/dist/mutators/tag.js.map +0 -7
- package/dist/mutators/workspace.js.map +0 -7
- package/dist/navigation/get-navigation-options.js.map +0 -7
- package/dist/navigation/helpers/get-openapi-object.js.map +0 -7
- package/dist/navigation/helpers/get-operation-entries.js.map +0 -7
- package/dist/navigation/helpers/get-parent-entry.js.map +0 -7
- package/dist/navigation/helpers/get-tag-entries.js.map +0 -7
- package/dist/navigation/helpers/get-tag.js.map +0 -7
- package/dist/navigation/helpers/get-x-keys.js.map +0 -7
- package/dist/navigation/helpers/traverse-description.js.map +0 -7
- package/dist/navigation/helpers/traverse-document.js.map +0 -7
- package/dist/navigation/helpers/traverse-examples.js.map +0 -7
- package/dist/navigation/helpers/traverse-paths.js.map +0 -7
- package/dist/navigation/helpers/traverse-schemas.js.map +0 -7
- package/dist/navigation/helpers/traverse-tags.js.map +0 -7
- package/dist/navigation/helpers/traverse-webhooks.js.map +0 -7
- package/dist/navigation/helpers/update-order-ids.js.map +0 -7
- package/dist/navigation/helpers/utils.js.map +0 -7
- package/dist/navigation/index.js.map +0 -7
- package/dist/navigation/types.js.map +0 -7
- package/dist/persistence/index.js.map +0 -7
- package/dist/persistence/indexdb.js.map +0 -7
- package/dist/plugins/bundler/helpers.js.map +0 -7
- package/dist/plugins/bundler/index.js.map +0 -7
- package/dist/plugins/client/index.js.map +0 -7
- package/dist/plugins/client/persistence.js.map +0 -7
- package/dist/resolve.js.map +0 -7
- package/dist/schemas/compose.js.map +0 -7
- package/dist/schemas/extensions/document/x-internal.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-icon.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-ignore.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js.map +0 -7
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js.map +0 -7
- package/dist/schemas/extensions/document/x-tags.js.map +0 -7
- package/dist/schemas/extensions/example/x-disabled.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-active-environment.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-cookies.js.map +0 -7
- package/dist/schemas/extensions/general/x-scalar-order.js.map +0 -7
- package/dist/schemas/extensions/operation/index.js.map +0 -7
- package/dist/schemas/extensions/operation/x-badge.js.map +0 -7
- package/dist/schemas/extensions/operation/x-code-samples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-draft-examples.js.map +0 -7
- package/dist/schemas/extensions/operation/x-post-response.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +0 -7
- package/dist/schemas/extensions/operation/x-scalar-stability.js.map +0 -7
- package/dist/schemas/extensions/parameter/x-global.js.map +0 -7
- package/dist/schemas/extensions/schema/x-additional-properties-name.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-descriptions.js.map +0 -7
- package/dist/schemas/extensions/schema/x-enum-varnames.js.map +0 -7
- package/dist/schemas/extensions/schema/x-examples.js.map +0 -7
- package/dist/schemas/extensions/schema/x-variable.js.map +0 -7
- package/dist/schemas/extensions/security/index.js.map +0 -7
- package/dist/schemas/extensions/security/x-default-scopes.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-body.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-query.js.map +0 -7
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js.map +0 -7
- package/dist/schemas/extensions/security/x-tokenName.js.map +0 -7
- package/dist/schemas/extensions/security/x-use-pkce.js.map +0 -7
- package/dist/schemas/extensions/server/x-scalar-selected-server.js.map +0 -7
- package/dist/schemas/extensions/tag/index.js.map +0 -7
- package/dist/schemas/extensions/tag/x-display-name.js.map +0 -7
- package/dist/schemas/extensions/tag/x-tag-groups.js.map +0 -7
- package/dist/schemas/extensions/workspace/index.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js.map +0 -7
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js.map +0 -7
- package/dist/schemas/extensions.js.map +0 -7
- package/dist/schemas/inmemory-workspace.js.map +0 -7
- package/dist/schemas/navigation.js.map +0 -7
- package/dist/schemas/reference-config/appearance.js.map +0 -7
- package/dist/schemas/reference-config/features.js.map +0 -7
- package/dist/schemas/reference-config/index.js.map +0 -7
- package/dist/schemas/reference-config/meta.js.map +0 -7
- package/dist/schemas/reference-config/routing.js.map +0 -7
- package/dist/schemas/reference-config/settings.js.map +0 -7
- package/dist/schemas/typebox-coerce.js.map +0 -7
- package/dist/schemas/v3.1/strict/callback.js.map +0 -7
- package/dist/schemas/v3.1/strict/components.js.map +0 -7
- package/dist/schemas/v3.1/strict/contact.js.map +0 -7
- package/dist/schemas/v3.1/strict/discriminator.js.map +0 -7
- package/dist/schemas/v3.1/strict/encoding.js.map +0 -7
- package/dist/schemas/v3.1/strict/example.js.map +0 -7
- package/dist/schemas/v3.1/strict/external-documentation.js.map +0 -7
- package/dist/schemas/v3.1/strict/header.js.map +0 -7
- package/dist/schemas/v3.1/strict/info.js.map +0 -7
- package/dist/schemas/v3.1/strict/license.js.map +0 -7
- package/dist/schemas/v3.1/strict/link.js.map +0 -7
- package/dist/schemas/v3.1/strict/media-type.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +0 -7
- package/dist/schemas/v3.1/strict/oauthflows.js.map +0 -7
- package/dist/schemas/v3.1/strict/openapi-document.js.map +0 -7
- package/dist/schemas/v3.1/strict/operation.js.map +0 -7
- package/dist/schemas/v3.1/strict/parameter.js.map +0 -7
- package/dist/schemas/v3.1/strict/path-item.js.map +0 -7
- package/dist/schemas/v3.1/strict/paths.js.map +0 -7
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +0 -7
- package/dist/schemas/v3.1/strict/reference.js.map +0 -7
- package/dist/schemas/v3.1/strict/request-body.js.map +0 -7
- package/dist/schemas/v3.1/strict/response.js.map +0 -7
- package/dist/schemas/v3.1/strict/responses.js.map +0 -7
- package/dist/schemas/v3.1/strict/schema.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-requirement.js.map +0 -7
- package/dist/schemas/v3.1/strict/security-scheme.js.map +0 -7
- package/dist/schemas/v3.1/strict/server-variable.js.map +0 -7
- package/dist/schemas/v3.1/strict/server.js.map +0 -7
- package/dist/schemas/v3.1/strict/tag.js.map +0 -7
- package/dist/schemas/v3.1/strict/type-guards.js.map +0 -7
- package/dist/schemas/v3.1/strict/xml.js.map +0 -7
- package/dist/schemas/workspace-specification/index.js.map +0 -7
- package/dist/schemas/workspace-specification/info.js.map +0 -7
- package/dist/schemas/workspace.js.map +0 -7
- package/dist/schemas.js.map +0 -7
- package/dist/server.js.map +0 -7
- package/dist/workspace-plugin.js.map +0 -7
|
@@ -1,104 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
headersSize,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Fetch API Response object to HAR (HTTP Archive) Response format.
|
|
3
|
+
*
|
|
4
|
+
* This function transforms a standard JavaScript Fetch API Response into the
|
|
5
|
+
* HAR format, which is useful for:
|
|
6
|
+
* - Recording HTTP responses for replay or analysis
|
|
7
|
+
* - Creating test fixtures from real API responses
|
|
8
|
+
* - Debugging and monitoring HTTP traffic
|
|
9
|
+
* - Generating API documentation from real responses
|
|
10
|
+
*
|
|
11
|
+
* The conversion handles:
|
|
12
|
+
* - Response status and status text
|
|
13
|
+
* - Headers extraction (including Set-Cookie headers converted to cookies)
|
|
14
|
+
* - Response body reading (with automatic cloning to preserve the original)
|
|
15
|
+
* - Content-Type detection and MIME type extraction
|
|
16
|
+
* - Size calculations for headers and body
|
|
17
|
+
* - Redirect URL extraction from Location header
|
|
18
|
+
*
|
|
19
|
+
* Note: The Fetch API does not expose the HTTP version, so it defaults to HTTP/1.1
|
|
20
|
+
* unless specified otherwise.
|
|
21
|
+
*
|
|
22
|
+
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
23
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const response = await fetch('https://api.example.com/users')
|
|
27
|
+
* const harResponse = await fetchResponseToHar({ response })
|
|
28
|
+
* console.log(harResponse.status) // 200
|
|
29
|
+
*/
|
|
30
|
+
export const fetchResponseToHar = async ({ response, includeBody = true, httpVersion = 'HTTP/1.1', bodySizeLimit = 1048576, }) => {
|
|
31
|
+
// Extract the headers from the response
|
|
32
|
+
const { headers, headersSize, cookies } = processResponseHeaders(response);
|
|
33
|
+
// Extract redirect URL from Location header
|
|
34
|
+
const redirectURL = response.headers.get('location') || '';
|
|
35
|
+
// Get content type
|
|
36
|
+
const contentType = response.headers.get('content-type') ?? 'text/plain';
|
|
37
|
+
// Read the response body if requested
|
|
38
|
+
const bodyDetails = await (async () => {
|
|
39
|
+
if (includeBody && response.body) {
|
|
40
|
+
const details = await processResponseBody(response.clone());
|
|
41
|
+
if (details.size <= bodySizeLimit) {
|
|
42
|
+
return details;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { text: '', size: -1, encoding: undefined };
|
|
46
|
+
})();
|
|
47
|
+
// Create the HAR response object
|
|
48
|
+
const harResponse = {
|
|
49
|
+
status: response.status,
|
|
50
|
+
statusText: response.statusText,
|
|
51
|
+
httpVersion,
|
|
52
|
+
headers,
|
|
53
|
+
cookies,
|
|
54
|
+
content: {
|
|
55
|
+
size: bodyDetails.size,
|
|
56
|
+
mimeType: contentType,
|
|
57
|
+
text: bodyDetails.text,
|
|
58
|
+
encoding: bodyDetails.encoding,
|
|
59
|
+
},
|
|
60
|
+
redirectURL,
|
|
61
|
+
headersSize,
|
|
62
|
+
bodySize: bodyDetails.size,
|
|
63
|
+
};
|
|
64
|
+
return harResponse;
|
|
36
65
|
};
|
|
37
66
|
const processResponseHeaders = (response) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
return Array.from(response.headers.entries()).reduce((acc, [name, value]) => {
|
|
68
|
+
acc.headers.push({ name, value });
|
|
69
|
+
acc.headersSize += name.length + 2 + value.length + 2;
|
|
70
|
+
// Parse Set-Cookie headers into cookies array
|
|
71
|
+
if (name.toLowerCase() === 'set-cookie') {
|
|
72
|
+
const cookie = parseSetCookieHeader(value);
|
|
73
|
+
if (cookie) {
|
|
74
|
+
acc.cookies.push(cookie);
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
{ headers: [], headersSize: 0, cookies: [] }
|
|
51
|
-
);
|
|
77
|
+
return acc;
|
|
78
|
+
}, { headers: [], headersSize: 0, cookies: [] });
|
|
52
79
|
};
|
|
53
80
|
const processResponseBody = async (response) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
const contentType = response.headers.get('content-type');
|
|
82
|
+
if (!contentType || !isTextBasedContent(contentType)) {
|
|
83
|
+
return { text: '', size: -1, encoding: undefined };
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
// Read as ArrayBuffer to get the size
|
|
87
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
88
|
+
const bodySize = arrayBuffer.byteLength;
|
|
89
|
+
const text = new TextDecoder('utf-8').decode(arrayBuffer);
|
|
90
|
+
return { text, size: bodySize, encoding: undefined };
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// If body cannot be read, leave it empty
|
|
94
|
+
return { text: '', size: -1, encoding: undefined };
|
|
95
|
+
}
|
|
66
96
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Checks if the content type is text-based and should be included in HAR.
|
|
99
|
+
* Text-based content types include:
|
|
100
|
+
* - text/* (text/plain, text/html, text/css, etc.)
|
|
101
|
+
* - application/json
|
|
102
|
+
* - application/xml and text/xml
|
|
103
|
+
* - application/javascript
|
|
104
|
+
* - application/*+json and application/*+xml variants
|
|
105
|
+
*/
|
|
106
|
+
export const isTextBasedContent = (contentType) => {
|
|
107
|
+
const lowerContentType = contentType.toLowerCase();
|
|
108
|
+
// Check for text/* types
|
|
109
|
+
if (lowerContentType.startsWith('text/')) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
// Check for JSON types
|
|
113
|
+
if (lowerContentType.includes('application/json') || lowerContentType.includes('+json')) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
// Check for XML types
|
|
117
|
+
if (lowerContentType.includes('application/xml') ||
|
|
118
|
+
lowerContentType.includes('text/xml') ||
|
|
119
|
+
lowerContentType.includes('+xml')) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
// Check for JavaScript
|
|
123
|
+
if (lowerContentType.includes('application/javascript') || lowerContentType.includes('application/x-javascript')) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
// Check for common text-based formats
|
|
127
|
+
if (lowerContentType.includes('application/x-www-form-urlencoded') ||
|
|
128
|
+
lowerContentType.includes('application/graphql')) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
85
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Parses a Set-Cookie header value into a cookie object.
|
|
135
|
+
* This is a simplified parser that extracts the name and value.
|
|
136
|
+
* For full cookie parsing with attributes, a more robust parser would be needed.
|
|
137
|
+
*/
|
|
86
138
|
const parseSetCookieHeader = (setCookieValue) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
100
|
-
export {
|
|
101
|
-
fetchResponseToHar,
|
|
102
|
-
isTextBasedContent
|
|
139
|
+
// Set-Cookie format: name=value; attribute1=value1; attribute2=value2
|
|
140
|
+
const parts = setCookieValue.split(';');
|
|
141
|
+
if (parts.length === 0 || !parts[0]) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const cookiePart = parts[0].trim();
|
|
145
|
+
const equalIndex = cookiePart.indexOf('=');
|
|
146
|
+
if (equalIndex === -1) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const name = cookiePart.substring(0, equalIndex).trim();
|
|
150
|
+
const value = cookiePart.substring(equalIndex + 1).trim();
|
|
151
|
+
return { name, value };
|
|
103
152
|
};
|
|
104
|
-
//# sourceMappingURL=fetch-response-to-har.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates a map of parameter names to their character positions in a path.
|
|
3
|
+
* Used to detect renamed path parameters by position matching.
|
|
4
|
+
*/
|
|
5
|
+
export const getParameterPositions = (path, parameters) => {
|
|
6
|
+
const positions = {};
|
|
7
|
+
for (const paramName of parameters) {
|
|
8
|
+
const position = path.indexOf(`{${paramName}}`);
|
|
9
|
+
if (position !== -1) {
|
|
10
|
+
positions[paramName] = position;
|
|
11
|
+
}
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
return positions;
|
|
13
|
+
return positions;
|
|
10
14
|
};
|
|
11
|
-
export {
|
|
12
|
-
getParameterPositions
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=get-parameter-position.js.map
|
|
@@ -1,146 +1,183 @@
|
|
|
1
|
-
import { getResolvedRef } from
|
|
2
|
-
import { isContentTypeParameterObject } from
|
|
1
|
+
import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
2
|
+
import { isContentTypeParameterObject } from '../../../schemas/v3.1/strict/type-guards.js';
|
|
3
3
|
const preprocessParameters = (parameters, pathVariables, exampleKey) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
parameters.forEach((param) => {
|
|
5
|
+
const resolvedParam = getResolvedRef(param);
|
|
6
|
+
if (isContentTypeParameterObject(resolvedParam)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
setParameterDisabled(getResolvedRef(param), exampleKey, true);
|
|
10
|
+
if (resolvedParam.in === 'path') {
|
|
11
|
+
resolvedParam.examples ||= {};
|
|
12
|
+
resolvedParam.examples[exampleKey] = {
|
|
13
|
+
value: pathVariables[resolvedParam.name] ?? '',
|
|
14
|
+
'x-disabled': false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Converts a HAR request back to an OpenAPI Operation object with populated examples.
|
|
21
|
+
*
|
|
22
|
+
* This function is the reverse of operationToHar - it takes a HAR request and
|
|
23
|
+
* converts it back into an OpenAPI operation structure, populating the example
|
|
24
|
+
* values based on the HAR request data.
|
|
25
|
+
*
|
|
26
|
+
* The conversion handles:
|
|
27
|
+
* - URL parsing to extract path and query parameters
|
|
28
|
+
* - Header extraction and mapping to operation parameters
|
|
29
|
+
* - Query string parsing and mapping to parameters
|
|
30
|
+
* - Cookie extraction and mapping to cookie parameters
|
|
31
|
+
* - Request body extraction and mapping to requestBody with examples
|
|
32
|
+
* - Content-Type detection and media type assignment
|
|
33
|
+
*
|
|
34
|
+
* Note: This function focuses on populating examples and does not reconstruct
|
|
35
|
+
* schema definitions. If you need full schema generation, consider combining
|
|
36
|
+
* this with a schema inference tool.
|
|
37
|
+
*
|
|
38
|
+
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
39
|
+
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
40
|
+
*/
|
|
41
|
+
export const harToOperation = ({ harRequest, exampleKey, baseOperation = {}, pathVariables = {}, }) => {
|
|
42
|
+
// Ensure parameters array exists on the base operation
|
|
43
|
+
if (!baseOperation.parameters) {
|
|
44
|
+
baseOperation.parameters = [];
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (const cookie of harRequest.cookies) {
|
|
57
|
-
const param = findOrCreateParameter(baseOperation.parameters, cookie.name, "cookie");
|
|
58
|
-
if (!param || isContentTypeParameterObject(param)) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
param.examples ||= {};
|
|
62
|
-
param.examples[exampleKey] = {
|
|
63
|
-
value: cookie.value,
|
|
64
|
-
"x-disabled": false
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (harRequest.postData) {
|
|
69
|
-
const { mimeType, text, params } = harRequest.postData;
|
|
70
|
-
if (!baseOperation.requestBody) {
|
|
71
|
-
baseOperation.requestBody = {
|
|
72
|
-
content: {}
|
|
73
|
-
};
|
|
46
|
+
// Set any other parameters as disabled and set the path variables
|
|
47
|
+
preprocessParameters(baseOperation.parameters, pathVariables, exampleKey);
|
|
48
|
+
// Process query string parameters from the HAR request
|
|
49
|
+
if (harRequest.queryString && harRequest.queryString.length > 0) {
|
|
50
|
+
for (const queryParam of harRequest.queryString) {
|
|
51
|
+
const param = findOrCreateParameter(baseOperation.parameters, queryParam.name, 'query');
|
|
52
|
+
if (!param || isContentTypeParameterObject(param)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
param.examples ||= {};
|
|
56
|
+
param.examples[exampleKey] = {
|
|
57
|
+
value: queryParam.value,
|
|
58
|
+
'x-disabled': false,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
74
61
|
}
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
// Process headers from the HAR request
|
|
63
|
+
if (harRequest.headers && harRequest.headers.length > 0) {
|
|
64
|
+
for (const header of harRequest.headers) {
|
|
65
|
+
const param = findOrCreateParameter(baseOperation.parameters, header.name, 'header');
|
|
66
|
+
if (!param || isContentTypeParameterObject(param)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
param.examples ||= {};
|
|
70
|
+
param.examples[exampleKey] = {
|
|
71
|
+
value: header.value,
|
|
72
|
+
'x-disabled': false,
|
|
73
|
+
};
|
|
80
74
|
}
|
|
81
|
-
};
|
|
82
75
|
}
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
76
|
+
// Process cookies from the HAR request
|
|
77
|
+
if (harRequest.cookies && harRequest.cookies.length > 0) {
|
|
78
|
+
for (const cookie of harRequest.cookies) {
|
|
79
|
+
const param = findOrCreateParameter(baseOperation.parameters, cookie.name, 'cookie');
|
|
80
|
+
if (!param || isContentTypeParameterObject(param)) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
param.examples ||= {};
|
|
84
|
+
param.examples[exampleKey] = {
|
|
85
|
+
value: cookie.value,
|
|
86
|
+
'x-disabled': false,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
// Process request body from the HAR request
|
|
91
|
+
if (harRequest.postData) {
|
|
92
|
+
const { mimeType, text, params } = harRequest.postData;
|
|
93
|
+
// Ensure requestBody exists on the base operation
|
|
94
|
+
if (!baseOperation.requestBody) {
|
|
95
|
+
baseOperation.requestBody = {
|
|
96
|
+
content: {},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Resolve the request body in case it is a reference
|
|
100
|
+
const requestBody = getResolvedRef(baseOperation.requestBody);
|
|
101
|
+
// Ensure the content type exists in the requestBody
|
|
102
|
+
if (!requestBody.content[mimeType]) {
|
|
103
|
+
requestBody.content[mimeType] = {
|
|
104
|
+
schema: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Get the media type object
|
|
110
|
+
const mediaType = requestBody.content[mimeType];
|
|
111
|
+
if (!mediaType) {
|
|
112
|
+
return baseOperation;
|
|
113
|
+
}
|
|
114
|
+
// Ensure examples object exists
|
|
115
|
+
mediaType.examples ||= {};
|
|
116
|
+
// Convert the HAR postData to an example value
|
|
117
|
+
let exampleValue;
|
|
118
|
+
// If params exist (form data), convert to array
|
|
119
|
+
if (params && params.length > 0) {
|
|
120
|
+
exampleValue = [];
|
|
121
|
+
for (const param of params) {
|
|
122
|
+
exampleValue.push({
|
|
123
|
+
name: param.name,
|
|
124
|
+
value: param.value,
|
|
125
|
+
'x-disabled': false,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
exampleValue = text;
|
|
131
|
+
}
|
|
132
|
+
// Add the example to the media type
|
|
133
|
+
mediaType.examples[exampleKey] = {
|
|
134
|
+
value: exampleValue,
|
|
135
|
+
'x-disabled': false,
|
|
136
|
+
};
|
|
137
|
+
// Update the selected media type
|
|
138
|
+
requestBody['x-scalar-selected-content-type'] ||= {};
|
|
139
|
+
requestBody['x-scalar-selected-content-type'][exampleKey] = mimeType;
|
|
100
140
|
}
|
|
101
|
-
|
|
102
|
-
value: exampleValue,
|
|
103
|
-
"x-disabled": false
|
|
104
|
-
};
|
|
105
|
-
requestBody["x-scalar-selected-content-type"] ||= {};
|
|
106
|
-
requestBody["x-scalar-selected-content-type"][exampleKey] = mimeType;
|
|
107
|
-
}
|
|
108
|
-
return baseOperation;
|
|
141
|
+
return baseOperation;
|
|
109
142
|
};
|
|
110
143
|
const setParameterDisabled = (param, exampleKey, disabled) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
if (!param.examples?.[exampleKey]) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
getResolvedRef(param.examples[exampleKey])["x-disabled"] = disabled;
|
|
118
|
-
};
|
|
119
|
-
const findOrCreateParameter = (parameters, name, inValue) => {
|
|
120
|
-
for (const param of parameters) {
|
|
121
|
-
const resolved = getResolvedRef(param);
|
|
122
|
-
if (isContentTypeParameterObject(resolved)) {
|
|
123
|
-
continue;
|
|
144
|
+
if (isContentTypeParameterObject(param)) {
|
|
145
|
+
return;
|
|
124
146
|
}
|
|
125
|
-
if (
|
|
126
|
-
|
|
147
|
+
if (!param.examples?.[exampleKey]) {
|
|
148
|
+
return;
|
|
127
149
|
}
|
|
128
|
-
|
|
129
|
-
if (namesMatch) {
|
|
130
|
-
return resolved;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const newParam = {
|
|
134
|
-
name,
|
|
135
|
-
in: inValue,
|
|
136
|
-
schema: {
|
|
137
|
-
type: "string"
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
parameters.push(newParam);
|
|
141
|
-
return newParam;
|
|
150
|
+
getResolvedRef(param.examples[exampleKey])['x-disabled'] = disabled;
|
|
142
151
|
};
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Finds an existing parameter in the parameters array or creates a new one.
|
|
154
|
+
* This ensures we do not create duplicate parameters.
|
|
155
|
+
*/
|
|
156
|
+
const findOrCreateParameter = (parameters, name, inValue) => {
|
|
157
|
+
// Try to find existing parameter using getResolvedRef to handle references
|
|
158
|
+
for (const param of parameters) {
|
|
159
|
+
const resolved = getResolvedRef(param);
|
|
160
|
+
if (isContentTypeParameterObject(resolved)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// Check if parameter location matches
|
|
164
|
+
if (resolved.in !== inValue) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// For headers, use case-insensitive comparison; otherwise use exact match
|
|
168
|
+
const namesMatch = inValue === 'header' ? resolved.name.toLowerCase() === name.toLowerCase() : resolved.name === name;
|
|
169
|
+
if (namesMatch) {
|
|
170
|
+
return resolved;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Create new parameter with schema
|
|
174
|
+
const newParam = {
|
|
175
|
+
name,
|
|
176
|
+
in: inValue,
|
|
177
|
+
schema: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
parameters.push(newParam);
|
|
182
|
+
return newParam;
|
|
145
183
|
};
|
|
146
|
-
//# sourceMappingURL=har-to-operation.js.map
|