@apiboost/omnispec 1.0.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/LICENSE.md +202 -0
- package/README.md +166 -0
- package/core/package.json +5 -0
- package/dist/cjs/asyncapi/index.js +17 -0
- package/dist/cjs/asyncapi/index.js.map +1 -0
- package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js +819 -0
- package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js.map +1 -0
- package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js +7527 -0
- package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js.map +1 -0
- package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js +36 -0
- package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js.map +1 -0
- package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js +104 -0
- package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js.map +1 -0
- package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js +3157 -0
- package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js.map +1 -0
- package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js +2416 -0
- package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js.map +1 -0
- package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js +24 -0
- package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js.map +1 -0
- package/dist/cjs/chunks/binary-response-CSrPCI-1.js +77 -0
- package/dist/cjs/chunks/binary-response-CSrPCI-1.js.map +1 -0
- package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js +7108 -0
- package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js.map +1 -0
- package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js +25 -0
- package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js.map +1 -0
- package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js +252 -0
- package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js.map +1 -0
- package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js +13669 -0
- package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js.map +1 -0
- package/dist/cjs/core/public.js +198 -0
- package/dist/cjs/core/public.js.map +1 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/openapi/index.js +19 -0
- package/dist/cjs/openapi/index.js.map +1 -0
- package/dist/cjs/server/index.js +154 -0
- package/dist/cjs/server/index.js.map +1 -0
- package/dist/cjs/wc/index.js +428 -0
- package/dist/cjs/wc/index.js.map +1 -0
- package/dist/esm/asyncapi/index.js +11 -0
- package/dist/esm/asyncapi/index.js.map +1 -0
- package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js +817 -0
- package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js.map +1 -0
- package/dist/esm/chunks/Collapsible-DA6-nS46.js +7482 -0
- package/dist/esm/chunks/Collapsible-DA6-nS46.js.map +1 -0
- package/dist/esm/chunks/ErrorBoundary-posRNrbt.js +34 -0
- package/dist/esm/chunks/ErrorBoundary-posRNrbt.js.map +1 -0
- package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js +102 -0
- package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js.map +1 -0
- package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js +3153 -0
- package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js.map +1 -0
- package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js +2393 -0
- package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js.map +1 -0
- package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js +21 -0
- package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js.map +1 -0
- package/dist/esm/chunks/binary-response-Cre_H-Rt.js +72 -0
- package/dist/esm/chunks/binary-response-Cre_H-Rt.js.map +1 -0
- package/dist/esm/chunks/ref-resolver-BIrHJOjz.js +7105 -0
- package/dist/esm/chunks/ref-resolver-BIrHJOjz.js.map +1 -0
- package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js +23 -0
- package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js.map +1 -0
- package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js +248 -0
- package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js.map +1 -0
- package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js +13625 -0
- package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js.map +1 -0
- package/dist/esm/core/public.js +102 -0
- package/dist/esm/core/public.js.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/openapi/index.js +13 -0
- package/dist/esm/openapi/index.js.map +1 -0
- package/dist/esm/server/index.js +152 -0
- package/dist/esm/server/index.js.map +1 -0
- package/dist/esm/wc/index.js +403 -0
- package/dist/esm/wc/index.js.map +1 -0
- package/dist/types/asyncapi/AsyncApiSpec.d.ts +12 -0
- package/dist/types/asyncapi/AsyncApiSpec.d.ts.map +1 -0
- package/dist/types/asyncapi/components/AsyncOverview.d.ts +16 -0
- package/dist/types/asyncapi/components/AsyncOverview.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ChannelDetail.d.ts +19 -0
- package/dist/types/asyncapi/components/ChannelDetail.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ComponentsSection.d.ts +16 -0
- package/dist/types/asyncapi/components/ComponentsSection.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ProtocolBadge.d.ts +16 -0
- package/dist/types/asyncapi/components/ProtocolBadge.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ServerList.d.ts +16 -0
- package/dist/types/asyncapi/components/ServerList.d.ts.map +1 -0
- package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts +12 -0
- package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts.map +1 -0
- package/dist/types/asyncapi/index.d.ts +11 -0
- package/dist/types/asyncapi/index.d.ts.map +1 -0
- package/dist/types/asyncapi/parser/asyncapi-parser.d.ts +12 -0
- package/dist/types/asyncapi/parser/asyncapi-parser.d.ts.map +1 -0
- package/dist/types/asyncapi/types/asyncapi.types.d.ts +125 -0
- package/dist/types/asyncapi/types/asyncapi.types.d.ts.map +1 -0
- package/dist/types/core/components/Auth/ApiKeyAuth.d.ts +30 -0
- package/dist/types/core/components/Auth/ApiKeyAuth.d.ts.map +1 -0
- package/dist/types/core/components/Auth/AuthPanel.d.ts +18 -0
- package/dist/types/core/components/Auth/AuthPanel.d.ts.map +1 -0
- package/dist/types/core/components/Auth/AuthPanelModal.d.ts +24 -0
- package/dist/types/core/components/Auth/AuthPanelModal.d.ts.map +1 -0
- package/dist/types/core/components/Auth/BasicAuth.d.ts +20 -0
- package/dist/types/core/components/Auth/BasicAuth.d.ts.map +1 -0
- package/dist/types/core/components/Auth/BearerAuth.d.ts +20 -0
- package/dist/types/core/components/Auth/BearerAuth.d.ts.map +1 -0
- package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts +37 -0
- package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts.map +1 -0
- package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts +33 -0
- package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts.map +1 -0
- package/dist/types/core/components/Auth/SecretInput.d.ts +27 -0
- package/dist/types/core/components/Auth/SecretInput.d.ts.map +1 -0
- package/dist/types/core/components/Auth/index.d.ts +16 -0
- package/dist/types/core/components/Auth/index.d.ts.map +1 -0
- package/dist/types/core/components/CodeBlock/CodeBlock.d.ts +32 -0
- package/dist/types/core/components/CodeBlock/CodeBlock.d.ts.map +1 -0
- package/dist/types/core/components/CodeBlock/index.d.ts +12 -0
- package/dist/types/core/components/CodeBlock/index.d.ts.map +1 -0
- package/dist/types/core/components/Layout/DocLayout.d.ts +24 -0
- package/dist/types/core/components/Layout/DocLayout.d.ts.map +1 -0
- package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts +20 -0
- package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts.map +1 -0
- package/dist/types/core/components/Layout/SpecStatusScreen.d.ts +38 -0
- package/dist/types/core/components/Layout/SpecStatusScreen.d.ts.map +1 -0
- package/dist/types/core/components/Layout/index.d.ts +11 -0
- package/dist/types/core/components/Layout/index.d.ts.map +1 -0
- package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts +16 -0
- package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts.map +1 -0
- package/dist/types/core/components/MarkdownRenderer/index.d.ts +11 -0
- package/dist/types/core/components/MarkdownRenderer/index.d.ts.map +1 -0
- package/dist/types/core/components/Navigation/CustomNavSection.d.ts +16 -0
- package/dist/types/core/components/Navigation/CustomNavSection.d.ts.map +1 -0
- package/dist/types/core/components/Navigation/NavTree.d.ts +32 -0
- package/dist/types/core/components/Navigation/NavTree.d.ts.map +1 -0
- package/dist/types/core/components/Navigation/SearchBar.d.ts +16 -0
- package/dist/types/core/components/Navigation/SearchBar.d.ts.map +1 -0
- package/dist/types/core/components/Navigation/buildSidebar.d.ts +13 -0
- package/dist/types/core/components/Navigation/buildSidebar.d.ts.map +1 -0
- package/dist/types/core/components/Navigation/index.d.ts +13 -0
- package/dist/types/core/components/Navigation/index.d.ts.map +1 -0
- package/dist/types/core/components/Reference/ReferenceLayout.d.ts +19 -0
- package/dist/types/core/components/Reference/ReferenceLayout.d.ts.map +1 -0
- package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts +42 -0
- package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts.map +1 -0
- package/dist/types/core/components/Reference/SamplesPanel.d.ts +33 -0
- package/dist/types/core/components/Reference/SamplesPanel.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts +147 -0
- package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts +66 -0
- package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts +16 -0
- package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts +26 -0
- package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/index.d.ts +16 -0
- package/dist/types/core/components/SchemaViewer/index.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/schema-style.d.ts +45 -0
- package/dist/types/core/components/SchemaViewer/schema-style.d.ts.map +1 -0
- package/dist/types/core/components/SchemaViewer/schema-utils.d.ts +83 -0
- package/dist/types/core/components/SchemaViewer/schema-utils.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/CodeSamples.d.ts +26 -0
- package/dist/types/core/components/TryIt/CodeSamples.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/CustomHeaders.d.ts +24 -0
- package/dist/types/core/components/TryIt/CustomHeaders.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/InlineTryIt.d.ts +26 -0
- package/dist/types/core/components/TryIt/InlineTryIt.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/ParameterForm.d.ts +34 -0
- package/dist/types/core/components/TryIt/ParameterForm.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts +34 -0
- package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/ResponseViewer.d.ts +18 -0
- package/dist/types/core/components/TryIt/ResponseViewer.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/TryItPanel.d.ts +38 -0
- package/dist/types/core/components/TryIt/TryItPanel.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/code-generators.d.ts +23 -0
- package/dist/types/core/components/TryIt/code-generators.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/curl-generator.d.ts +12 -0
- package/dist/types/core/components/TryIt/curl-generator.d.ts.map +1 -0
- package/dist/types/core/components/TryIt/index.d.ts +16 -0
- package/dist/types/core/components/TryIt/index.d.ts.map +1 -0
- package/dist/types/core/components/common/Badge.d.ts +19 -0
- package/dist/types/core/components/common/Badge.d.ts.map +1 -0
- package/dist/types/core/components/common/Button.d.ts +44 -0
- package/dist/types/core/components/common/Button.d.ts.map +1 -0
- package/dist/types/core/components/common/Collapsible.d.ts +23 -0
- package/dist/types/core/components/common/Collapsible.d.ts.map +1 -0
- package/dist/types/core/components/common/CopyButton.d.ts +16 -0
- package/dist/types/core/components/common/CopyButton.d.ts.map +1 -0
- package/dist/types/core/components/common/ErrorBoundary.d.ts +40 -0
- package/dist/types/core/components/common/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/core/components/common/ErrorMessage.d.ts +16 -0
- package/dist/types/core/components/common/ErrorMessage.d.ts.map +1 -0
- package/dist/types/core/components/common/ExampleSelector.d.ts +29 -0
- package/dist/types/core/components/common/ExampleSelector.d.ts.map +1 -0
- package/dist/types/core/components/common/ExpandableCard.d.ts +27 -0
- package/dist/types/core/components/common/ExpandableCard.d.ts.map +1 -0
- package/dist/types/core/components/common/Icon.d.ts +53 -0
- package/dist/types/core/components/common/Icon.d.ts.map +1 -0
- package/dist/types/core/components/common/LinkableHeading.d.ts +19 -0
- package/dist/types/core/components/common/LinkableHeading.d.ts.map +1 -0
- package/dist/types/core/components/common/LoadingScreen.d.ts +13 -0
- package/dist/types/core/components/common/LoadingScreen.d.ts.map +1 -0
- package/dist/types/core/components/common/MethodBar.d.ts +18 -0
- package/dist/types/core/components/common/MethodBar.d.ts.map +1 -0
- package/dist/types/core/components/common/Modal.d.ts +19 -0
- package/dist/types/core/components/common/Modal.d.ts.map +1 -0
- package/dist/types/core/components/common/ResponsiveColumns.d.ts +17 -0
- package/dist/types/core/components/common/ResponsiveColumns.d.ts.map +1 -0
- package/dist/types/core/components/common/SpecToolbar.d.ts +27 -0
- package/dist/types/core/components/common/SpecToolbar.d.ts.map +1 -0
- package/dist/types/core/components/common/Tabs.d.ts +29 -0
- package/dist/types/core/components/common/Tabs.d.ts.map +1 -0
- package/dist/types/core/components/common/Tooltip.d.ts +17 -0
- package/dist/types/core/components/common/Tooltip.d.ts.map +1 -0
- package/dist/types/core/components/common/UpgradePrompt.d.ts +18 -0
- package/dist/types/core/components/common/UpgradePrompt.d.ts.map +1 -0
- package/dist/types/core/components/common/index.d.ts +18 -0
- package/dist/types/core/components/common/index.d.ts.map +1 -0
- package/dist/types/core/context/AuthContext.d.ts +35 -0
- package/dist/types/core/context/AuthContext.d.ts.map +1 -0
- package/dist/types/core/context/ConfigContext.d.ts +55 -0
- package/dist/types/core/context/ConfigContext.d.ts.map +1 -0
- package/dist/types/core/context/ExpandContext.d.ts +33 -0
- package/dist/types/core/context/ExpandContext.d.ts.map +1 -0
- package/dist/types/core/context/RendererRegistry.d.ts +24 -0
- package/dist/types/core/context/RendererRegistry.d.ts.map +1 -0
- package/dist/types/core/context/index.d.ts +14 -0
- package/dist/types/core/context/index.d.ts.map +1 -0
- package/dist/types/core/hooks/index.d.ts +12 -0
- package/dist/types/core/hooks/index.d.ts.map +1 -0
- package/dist/types/core/hooks/useHashScroll.d.ts +15 -0
- package/dist/types/core/hooks/useHashScroll.d.ts.map +1 -0
- package/dist/types/core/hooks/useScrollSpy.d.ts +33 -0
- package/dist/types/core/hooks/useScrollSpy.d.ts.map +1 -0
- package/dist/types/core/hooks/useSegmentedRouter.d.ts +19 -0
- package/dist/types/core/hooks/useSegmentedRouter.d.ts.map +1 -0
- package/dist/types/core/hooks/useSpecDetector.d.ts +13 -0
- package/dist/types/core/hooks/useSpecDetector.d.ts.map +1 -0
- package/dist/types/core/hooks/useSpecFetcher.d.ts +17 -0
- package/dist/types/core/hooks/useSpecFetcher.d.ts.map +1 -0
- package/dist/types/core/public.d.ts +86 -0
- package/dist/types/core/public.d.ts.map +1 -0
- package/dist/types/core/styles/breakpoints.d.ts +33 -0
- package/dist/types/core/styles/breakpoints.d.ts.map +1 -0
- package/dist/types/core/styles/css.d.ts +17 -0
- package/dist/types/core/styles/css.d.ts.map +1 -0
- package/dist/types/core/styles/styled.d.ts +25 -0
- package/dist/types/core/styles/styled.d.ts.map +1 -0
- package/dist/types/core/themes/ThemeProvider.d.ts +25 -0
- package/dist/types/core/themes/ThemeProvider.d.ts.map +1 -0
- package/dist/types/core/themes/index.d.ts +12 -0
- package/dist/types/core/themes/index.d.ts.map +1 -0
- package/dist/types/core/themes/tokens.d.ts +13 -0
- package/dist/types/core/themes/tokens.d.ts.map +1 -0
- package/dist/types/core/types/auth.types.d.ts +83 -0
- package/dist/types/core/types/auth.types.d.ts.map +1 -0
- package/dist/types/core/types/common.types.d.ts +141 -0
- package/dist/types/core/types/common.types.d.ts.map +1 -0
- package/dist/types/core/types/index.d.ts +16 -0
- package/dist/types/core/types/index.d.ts.map +1 -0
- package/dist/types/core/types/interactive-auth.types.d.ts +37 -0
- package/dist/types/core/types/interactive-auth.types.d.ts.map +1 -0
- package/dist/types/core/types/sidebar-nav.types.d.ts +41 -0
- package/dist/types/core/types/sidebar-nav.types.d.ts.map +1 -0
- package/dist/types/core/types/spec-detection.types.d.ts +26 -0
- package/dist/types/core/types/spec-detection.types.d.ts.map +1 -0
- package/dist/types/core/types/theme.types.d.ts +119 -0
- package/dist/types/core/types/theme.types.d.ts.map +1 -0
- package/dist/types/core/types/try-it.types.d.ts +50 -0
- package/dist/types/core/types/try-it.types.d.ts.map +1 -0
- package/dist/types/core/utils/binary-response.d.ts +24 -0
- package/dist/types/core/utils/binary-response.d.ts.map +1 -0
- package/dist/types/core/utils/detect-spec.d.ts +12 -0
- package/dist/types/core/utils/detect-spec.d.ts.map +1 -0
- package/dist/types/core/utils/direct-client.d.ts +20 -0
- package/dist/types/core/utils/direct-client.d.ts.map +1 -0
- package/dist/types/core/utils/fetch-spec.d.ts +15 -0
- package/dist/types/core/utils/fetch-spec.d.ts.map +1 -0
- package/dist/types/core/utils/index.d.ts +14 -0
- package/dist/types/core/utils/index.d.ts.map +1 -0
- package/dist/types/core/utils/proxy-client.d.ts +19 -0
- package/dist/types/core/utils/proxy-client.d.ts.map +1 -0
- package/dist/types/core/utils/ref-security.d.ts +78 -0
- package/dist/types/core/utils/ref-security.d.ts.map +1 -0
- package/dist/types/core/utils/resolve-download-link.d.ts +23 -0
- package/dist/types/core/utils/resolve-download-link.d.ts.map +1 -0
- package/dist/types/core/utils/sanitize-html.d.ts +16 -0
- package/dist/types/core/utils/sanitize-html.d.ts.map +1 -0
- package/dist/types/core/utils/tryit-storage.d.ts +45 -0
- package/dist/types/core/utils/tryit-storage.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/openapi/OpenApiSpec.d.ts +12 -0
- package/dist/types/openapi/OpenApiSpec.d.ts.map +1 -0
- package/dist/types/openapi/components/ApiOverview.d.ts +19 -0
- package/dist/types/openapi/components/ApiOverview.d.ts.map +1 -0
- package/dist/types/openapi/components/CallbacksSection.d.ts +19 -0
- package/dist/types/openapi/components/CallbacksSection.d.ts.map +1 -0
- package/dist/types/openapi/components/ComponentsSection.d.ts +19 -0
- package/dist/types/openapi/components/ComponentsSection.d.ts.map +1 -0
- package/dist/types/openapi/components/EndpointCard.d.ts +20 -0
- package/dist/types/openapi/components/EndpointCard.d.ts.map +1 -0
- package/dist/types/openapi/components/OperationDetail.d.ts +28 -0
- package/dist/types/openapi/components/OperationDetail.d.ts.map +1 -0
- package/dist/types/openapi/components/OperationView.d.ts +19 -0
- package/dist/types/openapi/components/OperationView.d.ts.map +1 -0
- package/dist/types/openapi/components/SegmentedContent.d.ts +22 -0
- package/dist/types/openapi/components/SegmentedContent.d.ts.map +1 -0
- package/dist/types/openapi/components/ServerSelector.d.ts +18 -0
- package/dist/types/openapi/components/ServerSelector.d.ts.map +1 -0
- package/dist/types/openapi/components/TagGroup.d.ts +19 -0
- package/dist/types/openapi/components/TagGroup.d.ts.map +1 -0
- package/dist/types/openapi/hooks/useOpenApiSpec.d.ts +13 -0
- package/dist/types/openapi/hooks/useOpenApiSpec.d.ts.map +1 -0
- package/dist/types/openapi/index.d.ts +11 -0
- package/dist/types/openapi/index.d.ts.map +1 -0
- package/dist/types/openapi/parser/openapi-parser.d.ts +13 -0
- package/dist/types/openapi/parser/openapi-parser.d.ts.map +1 -0
- package/dist/types/openapi/parser/ref-resolver.d.ts +18 -0
- package/dist/types/openapi/parser/ref-resolver.d.ts.map +1 -0
- package/dist/types/openapi/search.d.ts +16 -0
- package/dist/types/openapi/search.d.ts.map +1 -0
- package/dist/types/openapi/types/openapi.types.d.ts +139 -0
- package/dist/types/openapi/types/openapi.types.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +12 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/proxy-router.d.ts +44 -0
- package/dist/types/server/proxy-router.d.ts.map +1 -0
- package/dist/types/server/ssrf-guard.d.ts +20 -0
- package/dist/types/server/ssrf-guard.d.ts.map +1 -0
- package/dist/types/test-setup.d.ts +11 -0
- package/dist/types/test-setup.d.ts.map +1 -0
- package/dist/types/unified/OmniSpecRenderer.d.ts +18 -0
- package/dist/types/unified/OmniSpecRenderer.d.ts.map +1 -0
- package/dist/types/unified/index.d.ts +12 -0
- package/dist/types/unified/index.d.ts.map +1 -0
- package/dist/types/wc/OmniSpecRendererElement.d.ts +48 -0
- package/dist/types/wc/OmniSpecRendererElement.d.ts.map +1 -0
- package/dist/types/wc/attribute-bridge.d.ts +96 -0
- package/dist/types/wc/attribute-bridge.d.ts.map +1 -0
- package/dist/types/wc/index.d.ts +42 -0
- package/dist/types/wc/index.d.ts.map +1 -0
- package/dist/types/wc/style-injection.d.ts +24 -0
- package/dist/types/wc/style-injection.d.ts.map +1 -0
- package/dist/wc/standalone.js +3 -0
- package/dist/wc/standalone.js.LICENSE.txt +65 -0
- package/dist/wc/standalone.js.map +1 -0
- package/package.json +167 -0
|
@@ -0,0 +1,3153 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback, useRef, useEffect, useMemo, useId, memo } from 'react';
|
|
3
|
+
import { css, cx } from '@emotion/css';
|
|
4
|
+
import { j as useConfig, I as Icon, a as useSpecFetcher, m as mq, B as Button, S as SpecType, r as resolveSchemaStyle, T as ThemeProvider, L as LoadingScreen, b as SpecStatusScreen, E as ErrorMessage, N as NavTree, h as buildSidebar, C as ConfigProvider, e as DocLayout } from './useSpecFetcher-CZvAnU7Z.js';
|
|
5
|
+
import { M as MarkdownRenderer, T as Tabs, x as generateExample, f as MethodBar, t as SchemaTree, A as schemaToNodes, J as buildConstraints, C as CodeBlock, d as ExpandableCard, a as Collapsible, D as useHashScroll, w as flattenNavItemIds, G as useScrollSpy, u as SearchBar, H as ExpandProvider, v as SpecToolbar, z as resolveDownloadLink } from './Collapsible-DA6-nS46.js';
|
|
6
|
+
import { f as authStyles, e as SecretInput, u as useAuth, O as OAuth2AuthManual, a as OpenIdConnectManual, h as ApiKeyAuth, M as Modal, l as loadTryItState, i as saveTryItState, g as sendProxiedRequest, s as sendDirectRequest, C as CodeSamples, c as ResponseViewer, j as clearTryItState, L as LinkableHeading, E as ExampleSelector, k as getNamedExamples, R as ReferenceLayout, S as SamplesPanel, b as ReferenceOperationDetail, d as ResponsiveColumns, A as AuthProvider } from './OpenIdConnectManual-COfITasf.js';
|
|
7
|
+
import { r as resolveRefs, p as parse } from './ref-resolver-BIrHJOjz.js';
|
|
8
|
+
import { E as ErrorBoundary } from './ErrorBoundary-posRNrbt.js';
|
|
9
|
+
|
|
10
|
+
const AUTH_SCHEME_LABELS = {
|
|
11
|
+
apiKey: "API Key",
|
|
12
|
+
"http-basic": "Basic Auth",
|
|
13
|
+
"http-bearer": "Bearer Token",
|
|
14
|
+
oauth2: "OAuth2",
|
|
15
|
+
openIdConnect: "OpenID Connect"
|
|
16
|
+
};
|
|
17
|
+
function authSchemeLabel(type) {
|
|
18
|
+
return AUTH_SCHEME_LABELS[type];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function BearerAuth({ scheme, onApply, onRemove, applied, appliedValue }) {
|
|
22
|
+
const [token, setToken] = useState(appliedValue?.input?.token ?? "");
|
|
23
|
+
const handleApply = () => {
|
|
24
|
+
if (!token.trim()) return;
|
|
25
|
+
onApply({
|
|
26
|
+
schemeId: scheme.id,
|
|
27
|
+
headerName: "Authorization",
|
|
28
|
+
headerValue: `Bearer ${token}`,
|
|
29
|
+
input: { token }
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const handleRemove = () => {
|
|
33
|
+
setToken("");
|
|
34
|
+
onRemove(scheme.id);
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsxs("div", { className: authStyles.section, children: [
|
|
37
|
+
/* @__PURE__ */ jsxs("div", { className: authStyles.label, children: [
|
|
38
|
+
scheme.displayName,
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "(Bearer Token)" })
|
|
40
|
+
] }),
|
|
41
|
+
scheme.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
|
|
42
|
+
/* @__PURE__ */ jsxs("div", { className: authStyles.inputRow, children: [
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
SecretInput,
|
|
45
|
+
{
|
|
46
|
+
value: token,
|
|
47
|
+
onChange: setToken,
|
|
48
|
+
placeholder: "Enter bearer token",
|
|
49
|
+
className: authStyles.input,
|
|
50
|
+
"aria-label": `${scheme.displayName} bearer token`
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
applied ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" })
|
|
54
|
+
] })
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fieldColumnStyle = css({
|
|
59
|
+
display: "flex",
|
|
60
|
+
flexDirection: "column",
|
|
61
|
+
gap: "8px"
|
|
62
|
+
});
|
|
63
|
+
function BasicAuth({ scheme, onApply, onRemove, applied, appliedValue }) {
|
|
64
|
+
const [username, setUsername] = useState(appliedValue?.input?.username ?? "");
|
|
65
|
+
const [password, setPassword] = useState(appliedValue?.input?.password ?? "");
|
|
66
|
+
const handleApply = () => {
|
|
67
|
+
if (!username.trim()) return;
|
|
68
|
+
const encoded = btoa(`${username}:${password}`);
|
|
69
|
+
onApply({
|
|
70
|
+
schemeId: scheme.id,
|
|
71
|
+
headerName: "Authorization",
|
|
72
|
+
headerValue: `Basic ${encoded}`,
|
|
73
|
+
input: { username, password }
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const handleRemove = () => {
|
|
77
|
+
setUsername("");
|
|
78
|
+
setPassword("");
|
|
79
|
+
onRemove(scheme.id);
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", { className: authStyles.section, children: [
|
|
82
|
+
/* @__PURE__ */ jsxs("div", { className: authStyles.label, children: [
|
|
83
|
+
scheme.displayName,
|
|
84
|
+
/* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "(HTTP Basic)" })
|
|
85
|
+
] }),
|
|
86
|
+
scheme.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
|
|
87
|
+
/* @__PURE__ */ jsxs("div", { className: fieldColumnStyle, children: [
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
"input",
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
value: username,
|
|
93
|
+
onChange: (e) => setUsername(e.target.value),
|
|
94
|
+
placeholder: "Username",
|
|
95
|
+
className: authStyles.input,
|
|
96
|
+
autoComplete: "username"
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
SecretInput,
|
|
101
|
+
{
|
|
102
|
+
value: password,
|
|
103
|
+
onChange: setPassword,
|
|
104
|
+
placeholder: "Password",
|
|
105
|
+
className: authStyles.input,
|
|
106
|
+
autoComplete: "current-password",
|
|
107
|
+
"aria-label": `${scheme.displayName} password`
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ jsx("div", { className: authStyles.inputRow, children: applied ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" }) })
|
|
111
|
+
] })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function renderSchemeForm(props, Oauth2Component, OpenIdConnectComponent) {
|
|
116
|
+
const key = props.scheme.id;
|
|
117
|
+
switch (props.scheme.type) {
|
|
118
|
+
case "apiKey":
|
|
119
|
+
return /* @__PURE__ */ jsx(ApiKeyAuth, { ...props }, key);
|
|
120
|
+
case "http-bearer":
|
|
121
|
+
return /* @__PURE__ */ jsx(BearerAuth, { ...props }, key);
|
|
122
|
+
case "http-basic":
|
|
123
|
+
return /* @__PURE__ */ jsx(BasicAuth, { ...props }, key);
|
|
124
|
+
case "oauth2":
|
|
125
|
+
return /* @__PURE__ */ jsx(Oauth2Component, { ...props }, key);
|
|
126
|
+
case "openIdConnect":
|
|
127
|
+
return /* @__PURE__ */ jsx(OpenIdConnectComponent, { ...props }, key);
|
|
128
|
+
default:
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function AuthPanel({ schemes, serverUrl }) {
|
|
133
|
+
const { appliedAuth, applyAuth, removeAuth } = useAuth();
|
|
134
|
+
const { interactiveAuth, interactiveOAuth } = useConfig();
|
|
135
|
+
if (schemes.length === 0) return null;
|
|
136
|
+
const useInteractive = interactiveOAuth !== false;
|
|
137
|
+
const Oauth2Component = useInteractive && interactiveAuth?.oauth2 || OAuth2AuthManual;
|
|
138
|
+
const OpenIdConnectComponent = useInteractive && interactiveAuth?.openIdConnect || OpenIdConnectManual;
|
|
139
|
+
const buildProps = (scheme) => ({
|
|
140
|
+
scheme,
|
|
141
|
+
onApply: applyAuth,
|
|
142
|
+
onRemove: removeAuth,
|
|
143
|
+
applied: appliedAuth.has(scheme.id),
|
|
144
|
+
// Restored credential (if any) so the input can be prefilled.
|
|
145
|
+
appliedValue: appliedAuth.get(scheme.id),
|
|
146
|
+
serverUrl
|
|
147
|
+
});
|
|
148
|
+
const renderable = schemes.map((scheme) => ({ scheme, form: renderSchemeForm(buildProps(scheme), Oauth2Component, OpenIdConnectComponent) })).filter((entry) => entry.form !== null);
|
|
149
|
+
if (renderable.length === 0) return null;
|
|
150
|
+
if (renderable.length === 1) {
|
|
151
|
+
return /* @__PURE__ */ jsx("div", { className: `omnispec-auth-panel ${panelContainerStyle}`, children: renderable[0].form });
|
|
152
|
+
}
|
|
153
|
+
const typeCounts = renderable.reduce((acc, { scheme }) => {
|
|
154
|
+
acc[scheme.type] = (acc[scheme.type] ?? 0) + 1;
|
|
155
|
+
return acc;
|
|
156
|
+
}, {});
|
|
157
|
+
const tabLabel = (scheme) => {
|
|
158
|
+
const label = authSchemeLabel(scheme.type);
|
|
159
|
+
return typeCounts[scheme.type] > 1 ? `${label} (${scheme.id})` : label;
|
|
160
|
+
};
|
|
161
|
+
const tabs = renderable.map(({ scheme, form }) => ({
|
|
162
|
+
id: scheme.id,
|
|
163
|
+
label: /* @__PURE__ */ jsxs("span", { className: tabLabelStyle, children: [
|
|
164
|
+
tabLabel(scheme),
|
|
165
|
+
appliedAuth.has(scheme.id) && /* @__PURE__ */ jsx("span", { className: appliedIconStyle, title: "Authorized", role: "img", "aria-label": "Authorized", children: /* @__PURE__ */ jsx(Icon, { name: "shield-check", size: "0.875rem" }) })
|
|
166
|
+
] }),
|
|
167
|
+
content: form
|
|
168
|
+
}));
|
|
169
|
+
const defaultTab = renderable.find(({ scheme }) => appliedAuth.has(scheme.id))?.scheme.id ?? renderable[0].scheme.id;
|
|
170
|
+
return /* @__PURE__ */ jsx("div", { className: `omnispec-auth-panel ${panelContainerStyle}`, children: /* @__PURE__ */ jsx(Tabs, { tabs, defaultTab, flush: true }) });
|
|
171
|
+
}
|
|
172
|
+
const panelContainerStyle = css({
|
|
173
|
+
display: "flex",
|
|
174
|
+
flexDirection: "column",
|
|
175
|
+
gap: "1rem"
|
|
176
|
+
});
|
|
177
|
+
const tabLabelStyle = css({
|
|
178
|
+
display: "inline-flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
gap: "0.375rem"
|
|
181
|
+
});
|
|
182
|
+
const appliedIconStyle = css({
|
|
183
|
+
display: "inline-flex",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
color: "var(--omnispec-color-success)",
|
|
186
|
+
flexShrink: 0
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
function AuthPanelModal({ serverUrl } = {}) {
|
|
190
|
+
const { schemes, authPanelOpen, closeAuthPanel } = useAuth();
|
|
191
|
+
if (schemes.length === 0) return null;
|
|
192
|
+
return /* @__PURE__ */ jsx(Modal, { open: authPanelOpen, onClose: closeAuthPanel, title: "Authorization", children: /* @__PURE__ */ jsx(AuthPanel, { schemes, serverUrl }) });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function parseOpenApiSpec(specInput, refOptions) {
|
|
196
|
+
const raw = typeof specInput === "string" ? parseSpecString(specInput) : specInput;
|
|
197
|
+
const api = await resolveRefs(raw, refOptions);
|
|
198
|
+
const isSwagger2 = !!api.swagger;
|
|
199
|
+
const specVersion = api.openapi ?? api.swagger ?? "unknown";
|
|
200
|
+
const servers = extractServers(api, isSwagger2);
|
|
201
|
+
const securitySchemes = extractSecuritySchemes(api, isSwagger2);
|
|
202
|
+
const tags = extractTaggedOperations(api, isSwagger2);
|
|
203
|
+
const components = extractComponents(api, isSwagger2);
|
|
204
|
+
const webhooks = extractWebhooks(api, isSwagger2);
|
|
205
|
+
const root = api;
|
|
206
|
+
return {
|
|
207
|
+
title: api.info.title,
|
|
208
|
+
description: api.info.description,
|
|
209
|
+
version: api.info.version,
|
|
210
|
+
specVersion,
|
|
211
|
+
servers,
|
|
212
|
+
tags,
|
|
213
|
+
tagGroups: root["x-tagGroups"],
|
|
214
|
+
securitySchemes,
|
|
215
|
+
components,
|
|
216
|
+
externalDocs: api.externalDocs,
|
|
217
|
+
contact: api.info.contact,
|
|
218
|
+
license: api.info.license,
|
|
219
|
+
termsOfService: api.info.termsOfService,
|
|
220
|
+
logo: api.info["x-logo"],
|
|
221
|
+
webhooks
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function extractWebhooks(api, isSwagger2) {
|
|
225
|
+
if (!api.webhooks) return void 0;
|
|
226
|
+
const methods = ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
227
|
+
const operations = [];
|
|
228
|
+
for (const [name, pathItem] of Object.entries(api.webhooks)) {
|
|
229
|
+
const pathLevelParams = pathItem.parameters;
|
|
230
|
+
for (const method of methods) {
|
|
231
|
+
const operation = pathItem[method];
|
|
232
|
+
if (!operation) continue;
|
|
233
|
+
const op = convertOperation(method, name, operation, isSwagger2, pathLevelParams);
|
|
234
|
+
if (op.xInternal) continue;
|
|
235
|
+
operations.push(op);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return operations.length > 0 ? operations : void 0;
|
|
239
|
+
}
|
|
240
|
+
function extractServers(api, isSwagger2) {
|
|
241
|
+
if (!isSwagger2 && api.servers) {
|
|
242
|
+
return api.servers.map((s) => ({
|
|
243
|
+
url: s.url,
|
|
244
|
+
description: s.description,
|
|
245
|
+
variables: s.variables
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
if (isSwagger2 && api.host) {
|
|
249
|
+
const schemes = api.schemes ?? ["https"];
|
|
250
|
+
return schemes.map((scheme) => ({
|
|
251
|
+
url: `${scheme}://${api.host}${api.basePath ?? ""}`
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
return [{ url: "/" }];
|
|
255
|
+
}
|
|
256
|
+
function collectNoAuthSchemeIds(api, isSwagger2) {
|
|
257
|
+
const defs = isSwagger2 ? api.securityDefinitions : api.components?.securitySchemes;
|
|
258
|
+
const ids = /* @__PURE__ */ new Set();
|
|
259
|
+
if (defs) {
|
|
260
|
+
for (const [id, def] of Object.entries(defs)) {
|
|
261
|
+
if (def.type === "http" && def.scheme === "noauth") ids.add(id);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return ids;
|
|
265
|
+
}
|
|
266
|
+
function extractSecuritySchemes(api, isSwagger2) {
|
|
267
|
+
const schemes = [];
|
|
268
|
+
const defs = isSwagger2 ? api.securityDefinitions : api.components?.securitySchemes;
|
|
269
|
+
if (!defs) return schemes;
|
|
270
|
+
for (const [id, def] of Object.entries(defs)) {
|
|
271
|
+
const scheme = convertSecurityScheme(id, def);
|
|
272
|
+
if (scheme) schemes.push(scheme);
|
|
273
|
+
}
|
|
274
|
+
return schemes;
|
|
275
|
+
}
|
|
276
|
+
function pickXExtensions(obj) {
|
|
277
|
+
const out = {};
|
|
278
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
279
|
+
if (key.startsWith("x-")) out[key] = value;
|
|
280
|
+
}
|
|
281
|
+
return Object.keys(out).length ? out : void 0;
|
|
282
|
+
}
|
|
283
|
+
function convertSecurityScheme(id, def) {
|
|
284
|
+
if (def.type === "http" && def.scheme === "noauth") {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
switch (def.type) {
|
|
288
|
+
case "apiKey":
|
|
289
|
+
return {
|
|
290
|
+
id,
|
|
291
|
+
type: "apiKey",
|
|
292
|
+
displayName: id,
|
|
293
|
+
description: def.description,
|
|
294
|
+
in: def.in,
|
|
295
|
+
name: def.name
|
|
296
|
+
};
|
|
297
|
+
case "http":
|
|
298
|
+
return {
|
|
299
|
+
id,
|
|
300
|
+
type: def.scheme === "basic" ? "http-basic" : "http-bearer",
|
|
301
|
+
displayName: id,
|
|
302
|
+
description: def.description,
|
|
303
|
+
scheme: def.scheme
|
|
304
|
+
};
|
|
305
|
+
case "oauth2":
|
|
306
|
+
return {
|
|
307
|
+
id,
|
|
308
|
+
type: "oauth2",
|
|
309
|
+
displayName: id,
|
|
310
|
+
description: def.description,
|
|
311
|
+
// Raw scheme-level x-* passthrough (Pro interprets; free core does not).
|
|
312
|
+
extensions: pickXExtensions(def),
|
|
313
|
+
flows: def.flows ? Object.fromEntries(
|
|
314
|
+
Object.entries(def.flows).map(([flowType, flow]) => [
|
|
315
|
+
flowType,
|
|
316
|
+
{
|
|
317
|
+
authorizationUrl: flow.authorizationUrl,
|
|
318
|
+
tokenUrl: flow.tokenUrl,
|
|
319
|
+
refreshUrl: flow.refreshUrl,
|
|
320
|
+
scopes: flow.scopes ?? {},
|
|
321
|
+
// Raw flow-level x-* passthrough (Pro interprets; free core does not).
|
|
322
|
+
extensions: pickXExtensions(flow)
|
|
323
|
+
}
|
|
324
|
+
])
|
|
325
|
+
) : void 0
|
|
326
|
+
};
|
|
327
|
+
case "openIdConnect":
|
|
328
|
+
return {
|
|
329
|
+
id,
|
|
330
|
+
type: "openIdConnect",
|
|
331
|
+
displayName: id,
|
|
332
|
+
description: def.description,
|
|
333
|
+
openIdConnectUrl: def.openIdConnectUrl
|
|
334
|
+
};
|
|
335
|
+
case "basic":
|
|
336
|
+
return {
|
|
337
|
+
id,
|
|
338
|
+
type: "http-basic",
|
|
339
|
+
displayName: id,
|
|
340
|
+
description: def.description,
|
|
341
|
+
scheme: "basic"
|
|
342
|
+
};
|
|
343
|
+
default:
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function extractTaggedOperations(api, isSwagger2) {
|
|
348
|
+
const tagMap = /* @__PURE__ */ new Map();
|
|
349
|
+
const definedTags = /* @__PURE__ */ new Map();
|
|
350
|
+
if (api.tags) {
|
|
351
|
+
for (const tag of api.tags) {
|
|
352
|
+
const raw = tag;
|
|
353
|
+
definedTags.set(tag.name, {
|
|
354
|
+
description: tag.description,
|
|
355
|
+
displayName: raw["x-displayName"],
|
|
356
|
+
externalDocs: raw.externalDocs,
|
|
357
|
+
xInternal: raw["x-internal"]
|
|
358
|
+
});
|
|
359
|
+
tagMap.set(tag.name, []);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const noAuthSchemeIds = collectNoAuthSchemeIds(api, isSwagger2);
|
|
363
|
+
const globalSecurity = api.security?.map(
|
|
364
|
+
(s) => Object.keys(s).filter((name) => !noAuthSchemeIds.has(name))
|
|
365
|
+
);
|
|
366
|
+
for (const [path, pathItem] of Object.entries(api.paths)) {
|
|
367
|
+
const pathLevelParams = pathItem.parameters;
|
|
368
|
+
const methods = ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
369
|
+
for (const method of methods) {
|
|
370
|
+
const operation = pathItem[method];
|
|
371
|
+
if (!operation) continue;
|
|
372
|
+
const op = convertOperation(method, path, operation, isSwagger2, pathLevelParams, globalSecurity, noAuthSchemeIds);
|
|
373
|
+
if (op.xInternal) continue;
|
|
374
|
+
const opTags = op.tags.length > 0 ? op.tags : ["default"];
|
|
375
|
+
for (const tagName of opTags) {
|
|
376
|
+
if (!tagMap.has(tagName)) {
|
|
377
|
+
tagMap.set(tagName, []);
|
|
378
|
+
}
|
|
379
|
+
tagMap.get(tagName).push(op);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return Array.from(tagMap.entries()).filter(([name, ops]) => ops.length > 0 && !definedTags.get(name)?.xInternal).map(([name, operations]) => ({
|
|
384
|
+
name,
|
|
385
|
+
displayName: definedTags.get(name)?.displayName,
|
|
386
|
+
description: definedTags.get(name)?.description,
|
|
387
|
+
externalDocs: definedTags.get(name)?.externalDocs,
|
|
388
|
+
operations
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
function convertOperation(method, path, op, isSwagger2, pathLevelParams, globalSecurity, noAuthSchemeIds) {
|
|
392
|
+
const mergedRawParams = mergeParameters(pathLevelParams, op.parameters);
|
|
393
|
+
const parameters = mergedRawParams.map((p) => ({
|
|
394
|
+
name: p.name,
|
|
395
|
+
in: p.in,
|
|
396
|
+
required: p.required ?? p.in === "path",
|
|
397
|
+
description: p.description,
|
|
398
|
+
deprecated: p.deprecated,
|
|
399
|
+
schema: p.schema ?? (isSwagger2 ? { type: p.type, format: p.format, enum: p.enum } : void 0),
|
|
400
|
+
example: p.example,
|
|
401
|
+
examples: p.examples,
|
|
402
|
+
style: p.style,
|
|
403
|
+
explode: p.explode
|
|
404
|
+
}));
|
|
405
|
+
let requestBody;
|
|
406
|
+
if (op.requestBody) {
|
|
407
|
+
requestBody = {
|
|
408
|
+
description: op.requestBody.description,
|
|
409
|
+
required: op.requestBody.required,
|
|
410
|
+
content: op.requestBody.content
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const responses = op.responses ? Object.entries(op.responses).map(([code, resp]) => ({
|
|
414
|
+
statusCode: code,
|
|
415
|
+
description: resp.description ?? "",
|
|
416
|
+
content: resp.content,
|
|
417
|
+
headers: resp.headers
|
|
418
|
+
})) : [];
|
|
419
|
+
const rawSecurity = op.security ? op.security.map((s) => Object.keys(s)) : globalSecurity;
|
|
420
|
+
const security = noAuthSchemeIds ? rawSecurity?.map((group) => group.filter((name) => !noAuthSchemeIds.has(name))) : rawSecurity;
|
|
421
|
+
return {
|
|
422
|
+
operationId: op.operationId,
|
|
423
|
+
summary: op.summary,
|
|
424
|
+
description: op.description,
|
|
425
|
+
method,
|
|
426
|
+
path,
|
|
427
|
+
tags: op.tags ?? [],
|
|
428
|
+
deprecated: op.deprecated,
|
|
429
|
+
parameters,
|
|
430
|
+
requestBody,
|
|
431
|
+
responses,
|
|
432
|
+
security: security?.flat() ? security.map((s) => s) : void 0,
|
|
433
|
+
callbacks: op.callbacks,
|
|
434
|
+
externalDocs: op.externalDocs,
|
|
435
|
+
xCodeSamples: op["x-codeSamples"] ?? op["x-code-samples"],
|
|
436
|
+
xBadges: op["x-badges"],
|
|
437
|
+
xInternal: op["x-internal"]
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function extractComponents(api, isSwagger2) {
|
|
441
|
+
if (!isSwagger2 && api.components) {
|
|
442
|
+
return {
|
|
443
|
+
schemas: api.components.schemas ?? {},
|
|
444
|
+
responses: api.components.responses,
|
|
445
|
+
parameters: api.components.parameters,
|
|
446
|
+
requestBodies: api.components.requestBodies
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
const rawApi = api;
|
|
450
|
+
return {
|
|
451
|
+
schemas: rawApi.definitions ?? {}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function mergeParameters(pathLevel, operationLevel) {
|
|
455
|
+
if (!pathLevel?.length) return operationLevel ?? [];
|
|
456
|
+
if (!operationLevel?.length) return pathLevel;
|
|
457
|
+
const opKeys = new Set(operationLevel.map((p) => `${p.in}:${p.name}`));
|
|
458
|
+
const inherited = pathLevel.filter((p) => !opKeys.has(`${p.in}:${p.name}`));
|
|
459
|
+
return [...operationLevel, ...inherited];
|
|
460
|
+
}
|
|
461
|
+
function parseSpecString(input) {
|
|
462
|
+
const trimmed = input.trim();
|
|
463
|
+
if (trimmed.startsWith("{")) {
|
|
464
|
+
try {
|
|
465
|
+
return JSON.parse(trimmed);
|
|
466
|
+
} catch {
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return parse(trimmed);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function useOpenApiSpec(spec, refOptions) {
|
|
473
|
+
const parser = useCallback(async (raw) => {
|
|
474
|
+
return parseOpenApiSpec(raw, refOptions);
|
|
475
|
+
}, [refOptions]);
|
|
476
|
+
return useSpecFetcher(spec, parser);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function ApiVersionBadge({ version }) {
|
|
480
|
+
return /* @__PURE__ */ jsxs("span", { className: versionBadgeMobileStyle, children: [
|
|
481
|
+
"v",
|
|
482
|
+
version
|
|
483
|
+
] });
|
|
484
|
+
}
|
|
485
|
+
function ApiOverview({ spec }) {
|
|
486
|
+
return /* @__PURE__ */ jsxs("div", { className: `omnispec-api-overview ${containerStyle$4}`, children: [
|
|
487
|
+
/* @__PURE__ */ jsxs("div", { className: titleRowStyle$1, children: [
|
|
488
|
+
/* @__PURE__ */ jsx("h1", { className: titleStyle$4, children: spec.title }),
|
|
489
|
+
/* @__PURE__ */ jsxs("span", { className: versionBadgeStyle, children: [
|
|
490
|
+
"v",
|
|
491
|
+
spec.version
|
|
492
|
+
] })
|
|
493
|
+
] }),
|
|
494
|
+
spec.description && /* @__PURE__ */ jsx("div", { className: descriptionStyle$2, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: spec.description }) }),
|
|
495
|
+
(spec.contact || spec.license || spec.termsOfService || spec.externalDocs) && /* @__PURE__ */ jsxs("div", { className: metaRowStyle, children: [
|
|
496
|
+
spec.contact?.name && /* @__PURE__ */ jsxs("span", { className: metaItemStyle, children: [
|
|
497
|
+
spec.contact.email ? /* @__PURE__ */ jsx("a", { href: `mailto:${spec.contact.email}`, className: linkStyle, children: spec.contact.name }) : spec.contact.name,
|
|
498
|
+
spec.contact.url && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
499
|
+
" \xB7 ",
|
|
500
|
+
/* @__PURE__ */ jsx("a", { href: spec.contact.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.contact.url })
|
|
501
|
+
] })
|
|
502
|
+
] }),
|
|
503
|
+
spec.license && /* @__PURE__ */ jsx("span", { className: metaItemStyle, children: spec.license.url ? /* @__PURE__ */ jsx("a", { href: spec.license.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.license.name }) : spec.license.name }),
|
|
504
|
+
spec.termsOfService && /* @__PURE__ */ jsx("span", { className: metaItemStyle, children: /* @__PURE__ */ jsx("a", { href: spec.termsOfService, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: "Terms of Service" }) }),
|
|
505
|
+
spec.externalDocs && /* @__PURE__ */ jsx("span", { className: metaItemStyle, children: /* @__PURE__ */ jsx("a", { href: spec.externalDocs.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.externalDocs.description ?? "Docs" }) })
|
|
506
|
+
] })
|
|
507
|
+
] });
|
|
508
|
+
}
|
|
509
|
+
const containerStyle$4 = css({
|
|
510
|
+
marginBottom: 0,
|
|
511
|
+
minWidth: 0,
|
|
512
|
+
overflow: "hidden"
|
|
513
|
+
});
|
|
514
|
+
const titleRowStyle$1 = css({
|
|
515
|
+
display: "flex",
|
|
516
|
+
gap: "0.75rem",
|
|
517
|
+
marginBottom: "0.25rem",
|
|
518
|
+
flexWrap: "wrap",
|
|
519
|
+
flexDirection: "column"
|
|
520
|
+
});
|
|
521
|
+
const titleStyle$4 = css({
|
|
522
|
+
margin: 0,
|
|
523
|
+
fontSize: "var(--omnispec-h1-font-size)",
|
|
524
|
+
color: "var(--omnispec-h1-color)",
|
|
525
|
+
fontWeight: "var(--omnispec-h1-font-weight)",
|
|
526
|
+
letterSpacing: "-0.02em",
|
|
527
|
+
lineHeight: 1.2,
|
|
528
|
+
wordBreak: "break-word"
|
|
529
|
+
});
|
|
530
|
+
const versionBadgeStyle = css({
|
|
531
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
532
|
+
color: "var(--omnispec-fg-muted)",
|
|
533
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
534
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
535
|
+
padding: "0.125rem 0.5rem",
|
|
536
|
+
borderRadius: "0.25rem",
|
|
537
|
+
alignSelf: "baseline",
|
|
538
|
+
fontWeight: 500,
|
|
539
|
+
[mq.mobile]: {
|
|
540
|
+
display: "none"
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
const descriptionStyle$2 = css({
|
|
544
|
+
marginTop: "0.75rem"
|
|
545
|
+
});
|
|
546
|
+
const metaRowStyle = css({
|
|
547
|
+
display: "flex",
|
|
548
|
+
gap: "1rem",
|
|
549
|
+
marginTop: "0.75rem",
|
|
550
|
+
flexWrap: "wrap"
|
|
551
|
+
});
|
|
552
|
+
const metaItemStyle = css({
|
|
553
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
554
|
+
color: "var(--omnispec-fg-muted)"
|
|
555
|
+
});
|
|
556
|
+
const versionBadgeMobileStyle = css({
|
|
557
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
558
|
+
color: "var(--omnispec-fg-muted)",
|
|
559
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
560
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
561
|
+
padding: "0.125rem 0.5rem",
|
|
562
|
+
borderRadius: "0.25rem",
|
|
563
|
+
fontWeight: 500
|
|
564
|
+
});
|
|
565
|
+
const linkStyle = css({
|
|
566
|
+
color: "var(--omnispec-fg-link)",
|
|
567
|
+
textDecoration: "none",
|
|
568
|
+
"&:hover": {
|
|
569
|
+
textDecoration: "underline"
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
function ServerSelector({ servers, selectedUrl, onSelect }) {
|
|
574
|
+
const [variables, setVariables] = useState({});
|
|
575
|
+
const hasUsableServers = servers.length > 0 && servers.some(
|
|
576
|
+
(s) => s.url && s.url !== "/"
|
|
577
|
+
);
|
|
578
|
+
if (!hasUsableServers) return null;
|
|
579
|
+
const resolveUrl = (server, vars) => {
|
|
580
|
+
let resolved = server.url;
|
|
581
|
+
if (server.variables) {
|
|
582
|
+
for (const [key, variable] of Object.entries(server.variables)) {
|
|
583
|
+
resolved = resolved.replace(`{${key}}`, vars[key] ?? variable.default ?? "");
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return resolved;
|
|
587
|
+
};
|
|
588
|
+
const serverIndex = servers.findIndex((s) => selectedUrl.startsWith(s.url.split("{")[0]));
|
|
589
|
+
const currentIndex = serverIndex >= 0 ? serverIndex : 0;
|
|
590
|
+
const currentServer = servers[currentIndex];
|
|
591
|
+
const resolvedUrl = resolveUrl(currentServer, variables);
|
|
592
|
+
const handleServerChange = (newIndex) => {
|
|
593
|
+
setVariables({});
|
|
594
|
+
onSelect(resolveUrl(servers[newIndex], {}));
|
|
595
|
+
};
|
|
596
|
+
const handleVariableChange = (name, value) => {
|
|
597
|
+
const newVars = { ...variables, [name]: value };
|
|
598
|
+
setVariables(newVars);
|
|
599
|
+
onSelect(resolveUrl(currentServer, newVars));
|
|
600
|
+
};
|
|
601
|
+
return /* @__PURE__ */ jsxs("div", { className: `omnispec-server-selector ${serverContainerStyle}`, children: [
|
|
602
|
+
/* @__PURE__ */ jsx("label", { className: serverLabelStyle, children: "Server" }),
|
|
603
|
+
/* @__PURE__ */ jsx("div", { className: serverRowStyle, children: servers.length === 1 ? /* @__PURE__ */ jsx("code", { className: serverUrlStyle, children: resolvedUrl }) : /* @__PURE__ */ jsx(
|
|
604
|
+
"select",
|
|
605
|
+
{
|
|
606
|
+
value: currentIndex,
|
|
607
|
+
onChange: (e) => handleServerChange(Number(e.target.value)),
|
|
608
|
+
className: serverSelectStyle,
|
|
609
|
+
children: servers.map((server, idx) => /* @__PURE__ */ jsxs("option", { value: idx, children: [
|
|
610
|
+
server.url,
|
|
611
|
+
server.description ? ` - ${server.description}` : ""
|
|
612
|
+
] }, idx))
|
|
613
|
+
}
|
|
614
|
+
) }),
|
|
615
|
+
currentServer?.variables && Object.entries(currentServer.variables).length > 0 && /* @__PURE__ */ jsx("div", { className: serverVariablesStyle, children: Object.entries(currentServer.variables).map(([name, variable]) => /* @__PURE__ */ jsxs("div", { className: serverVarRowStyle, children: [
|
|
616
|
+
/* @__PURE__ */ jsx("label", { className: serverVarLabelStyle, children: name }),
|
|
617
|
+
variable.enum ? /* @__PURE__ */ jsx(
|
|
618
|
+
"select",
|
|
619
|
+
{
|
|
620
|
+
value: variables[name] ?? variable.default,
|
|
621
|
+
onChange: (e) => handleVariableChange(name, e.target.value),
|
|
622
|
+
className: serverVarInputStyle,
|
|
623
|
+
children: variable.enum.map((val) => /* @__PURE__ */ jsx("option", { value: val, children: val }, val))
|
|
624
|
+
}
|
|
625
|
+
) : /* @__PURE__ */ jsx(
|
|
626
|
+
"input",
|
|
627
|
+
{
|
|
628
|
+
type: "text",
|
|
629
|
+
value: variables[name] ?? variable.default,
|
|
630
|
+
onChange: (e) => handleVariableChange(name, e.target.value),
|
|
631
|
+
className: serverVarInputStyle
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
variable.description && /* @__PURE__ */ jsx("span", { className: serverVarDescStyle, children: variable.description })
|
|
635
|
+
] }, name)) })
|
|
636
|
+
] });
|
|
637
|
+
}
|
|
638
|
+
const serverContainerStyle = css({
|
|
639
|
+
marginBottom: "1rem",
|
|
640
|
+
padding: "0.75rem",
|
|
641
|
+
backgroundColor: "var(--omnispec-bg-secondary)",
|
|
642
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
643
|
+
border: "1px solid var(--omnispec-border-color)",
|
|
644
|
+
overflow: "hidden"
|
|
645
|
+
});
|
|
646
|
+
const serverLabelStyle = css({
|
|
647
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
648
|
+
fontWeight: 600,
|
|
649
|
+
color: "var(--omnispec-fg-muted)",
|
|
650
|
+
textTransform: "uppercase",
|
|
651
|
+
letterSpacing: "0.5px",
|
|
652
|
+
marginBottom: "6px",
|
|
653
|
+
display: "block"
|
|
654
|
+
});
|
|
655
|
+
const serverRowStyle = css({
|
|
656
|
+
display: "flex",
|
|
657
|
+
alignItems: "center",
|
|
658
|
+
gap: "8px"
|
|
659
|
+
});
|
|
660
|
+
const serverUrlStyle = css({
|
|
661
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
662
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
663
|
+
color: "var(--omnispec-fg-code)",
|
|
664
|
+
overflowX: "auto",
|
|
665
|
+
whiteSpace: "nowrap",
|
|
666
|
+
minWidth: 0,
|
|
667
|
+
maxWidth: "100%",
|
|
668
|
+
display: "block",
|
|
669
|
+
scrollbarWidth: "thin"
|
|
670
|
+
});
|
|
671
|
+
const serverSelectStyle = css({
|
|
672
|
+
flex: 1,
|
|
673
|
+
minWidth: 0,
|
|
674
|
+
maxWidth: "100%",
|
|
675
|
+
padding: "0.375rem 0.625rem",
|
|
676
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
677
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
678
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
679
|
+
color: "var(--omnispec-fg-primary)",
|
|
680
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
681
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
682
|
+
overflow: "hidden",
|
|
683
|
+
textOverflow: "ellipsis"
|
|
684
|
+
});
|
|
685
|
+
const serverVariablesStyle = css({
|
|
686
|
+
marginTop: "8px",
|
|
687
|
+
display: "flex",
|
|
688
|
+
flexDirection: "column",
|
|
689
|
+
gap: "6px"
|
|
690
|
+
});
|
|
691
|
+
const serverVarRowStyle = css({
|
|
692
|
+
display: "flex",
|
|
693
|
+
alignItems: "center",
|
|
694
|
+
gap: "0.5rem",
|
|
695
|
+
flexWrap: "wrap"
|
|
696
|
+
});
|
|
697
|
+
const serverVarLabelStyle = css({
|
|
698
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
699
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
700
|
+
color: "var(--omnispec-fg-secondary)",
|
|
701
|
+
fontWeight: 600,
|
|
702
|
+
minWidth: "80px"
|
|
703
|
+
});
|
|
704
|
+
const serverVarInputStyle = css({
|
|
705
|
+
flex: 1,
|
|
706
|
+
minWidth: 0,
|
|
707
|
+
padding: "0.25rem 0.5rem",
|
|
708
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
709
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
710
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
711
|
+
color: "var(--omnispec-fg-primary)",
|
|
712
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
713
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
714
|
+
});
|
|
715
|
+
const serverVarDescStyle = css({
|
|
716
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
717
|
+
color: "var(--omnispec-fg-muted)"
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
const MULTI_VALUE_DELIMITER = ",";
|
|
721
|
+
const sectionStyle$3 = css({
|
|
722
|
+
marginBottom: "16px"
|
|
723
|
+
});
|
|
724
|
+
const sectionTitleStyle$2 = css({
|
|
725
|
+
margin: "0 0 8px",
|
|
726
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
727
|
+
color: "var(--omnispec-fg-muted)",
|
|
728
|
+
fontWeight: 600,
|
|
729
|
+
textTransform: "uppercase",
|
|
730
|
+
letterSpacing: "0.5px"
|
|
731
|
+
});
|
|
732
|
+
const fieldStyle = css({
|
|
733
|
+
marginBottom: "14px"
|
|
734
|
+
});
|
|
735
|
+
const labelStyle$1 = css({
|
|
736
|
+
display: "flex",
|
|
737
|
+
alignItems: "center",
|
|
738
|
+
gap: "2px",
|
|
739
|
+
marginBottom: "6px"
|
|
740
|
+
});
|
|
741
|
+
const nameStyle = css({
|
|
742
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
743
|
+
fontWeight: 600,
|
|
744
|
+
color: "var(--omnispec-fg-primary)"
|
|
745
|
+
});
|
|
746
|
+
const requiredStyle = css({
|
|
747
|
+
color: "var(--omnispec-color-error)",
|
|
748
|
+
fontWeight: 600
|
|
749
|
+
});
|
|
750
|
+
const descriptionStyle$1 = css({
|
|
751
|
+
margin: "4px 0 0",
|
|
752
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
753
|
+
color: "var(--omnispec-fg-muted)"
|
|
754
|
+
});
|
|
755
|
+
const inputStyle = css({
|
|
756
|
+
width: "100%",
|
|
757
|
+
padding: "8px 12px",
|
|
758
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
759
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
760
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
761
|
+
color: "var(--omnispec-fg-primary)",
|
|
762
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
763
|
+
boxSizing: "border-box",
|
|
764
|
+
"&:focus": {
|
|
765
|
+
borderColor: "var(--omnispec-color-primary)",
|
|
766
|
+
outline: "none"
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
function ParameterForm({ parameters, values, onChange }) {
|
|
770
|
+
const grouped = groupByLocation(parameters);
|
|
771
|
+
return /* @__PURE__ */ jsx("div", { className: "adr-parameter-form", children: ["path", "query", "header", "cookie"].map((location) => {
|
|
772
|
+
const params = grouped[location];
|
|
773
|
+
if (!params || params.length === 0) return null;
|
|
774
|
+
return /* @__PURE__ */ jsxs("div", { className: sectionStyle$3, children: [
|
|
775
|
+
/* @__PURE__ */ jsx("h4", { className: sectionTitleStyle$2, children: locationLabels[location] }),
|
|
776
|
+
params.map((param) => /* @__PURE__ */ jsx(
|
|
777
|
+
ParameterInput,
|
|
778
|
+
{
|
|
779
|
+
param,
|
|
780
|
+
value: values[param.name] ?? "",
|
|
781
|
+
onChange
|
|
782
|
+
},
|
|
783
|
+
param.name
|
|
784
|
+
))
|
|
785
|
+
] }, location);
|
|
786
|
+
}) });
|
|
787
|
+
}
|
|
788
|
+
const locationLabels = {
|
|
789
|
+
path: "Path Parameters",
|
|
790
|
+
query: "Query Parameters",
|
|
791
|
+
header: "Header Parameters",
|
|
792
|
+
cookie: "Cookie Parameters"
|
|
793
|
+
};
|
|
794
|
+
function ParameterInput({ param, value, onChange }) {
|
|
795
|
+
const handleChange = useCallback((e) => {
|
|
796
|
+
onChange(param.name, e.target.value);
|
|
797
|
+
}, [param.name, onChange]);
|
|
798
|
+
const placeholder = param.example ?? param.default ?? `Filter by ${param.name}`;
|
|
799
|
+
return /* @__PURE__ */ jsxs("div", { className: fieldStyle, children: [
|
|
800
|
+
/* @__PURE__ */ jsxs("label", { className: labelStyle$1, htmlFor: `tryit-param-${param.name}`, children: [
|
|
801
|
+
/* @__PURE__ */ jsx("span", { className: nameStyle, children: param.name }),
|
|
802
|
+
param.required && /* @__PURE__ */ jsx("span", { className: requiredStyle, children: "*" })
|
|
803
|
+
] }),
|
|
804
|
+
param.itemsEnum ? /* @__PURE__ */ jsx(
|
|
805
|
+
MultiEnumSelect,
|
|
806
|
+
{
|
|
807
|
+
param,
|
|
808
|
+
value,
|
|
809
|
+
onChange
|
|
810
|
+
}
|
|
811
|
+
) : param.enum ? /* @__PURE__ */ jsxs("select", { id: `tryit-param-${param.name}`, value, onChange: handleChange, className: inputStyle, children: [
|
|
812
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
|
|
813
|
+
param.enum.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt))
|
|
814
|
+
] }) : /* @__PURE__ */ jsx(
|
|
815
|
+
"input",
|
|
816
|
+
{
|
|
817
|
+
id: `tryit-param-${param.name}`,
|
|
818
|
+
type: "text",
|
|
819
|
+
value,
|
|
820
|
+
onChange: handleChange,
|
|
821
|
+
placeholder,
|
|
822
|
+
className: inputStyle
|
|
823
|
+
}
|
|
824
|
+
),
|
|
825
|
+
param.description && /* @__PURE__ */ jsx("p", { className: descriptionStyle$1, children: param.description })
|
|
826
|
+
] });
|
|
827
|
+
}
|
|
828
|
+
function MultiEnumSelect({
|
|
829
|
+
param,
|
|
830
|
+
value,
|
|
831
|
+
onChange
|
|
832
|
+
}) {
|
|
833
|
+
const selected = new Set(value ? value.split(MULTI_VALUE_DELIMITER) : []);
|
|
834
|
+
const toggle = (option) => {
|
|
835
|
+
const next = new Set(selected);
|
|
836
|
+
if (next.has(option)) {
|
|
837
|
+
next.delete(option);
|
|
838
|
+
} else {
|
|
839
|
+
next.add(option);
|
|
840
|
+
}
|
|
841
|
+
onChange(param.name, Array.from(next).join(MULTI_VALUE_DELIMITER));
|
|
842
|
+
};
|
|
843
|
+
return /* @__PURE__ */ jsx("div", { className: multiSelectStyle, role: "group", "aria-label": `${param.name} values`, children: (param.itemsEnum ?? []).map((option) => /* @__PURE__ */ jsxs("label", { className: multiOptionStyle, children: [
|
|
844
|
+
/* @__PURE__ */ jsx(
|
|
845
|
+
"input",
|
|
846
|
+
{
|
|
847
|
+
type: "checkbox",
|
|
848
|
+
checked: selected.has(option),
|
|
849
|
+
onChange: () => toggle(option)
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
/* @__PURE__ */ jsx("span", { className: multiOptionLabelStyle, children: option })
|
|
853
|
+
] }, option)) });
|
|
854
|
+
}
|
|
855
|
+
const multiSelectStyle = css({
|
|
856
|
+
display: "flex",
|
|
857
|
+
flexWrap: "wrap",
|
|
858
|
+
gap: "0.375rem"
|
|
859
|
+
});
|
|
860
|
+
const multiOptionStyle = css({
|
|
861
|
+
display: "inline-flex",
|
|
862
|
+
alignItems: "center",
|
|
863
|
+
gap: "0.25rem",
|
|
864
|
+
padding: "0.25rem 0.5rem",
|
|
865
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
866
|
+
borderRadius: "1rem",
|
|
867
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
868
|
+
cursor: "pointer",
|
|
869
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
870
|
+
"&:hover": {
|
|
871
|
+
backgroundColor: "var(--omnispec-bg-secondary)"
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
const multiOptionLabelStyle = css({
|
|
875
|
+
color: "var(--omnispec-fg-primary)",
|
|
876
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
877
|
+
});
|
|
878
|
+
function groupByLocation(params) {
|
|
879
|
+
const grouped = {};
|
|
880
|
+
for (const param of params) {
|
|
881
|
+
if (!grouped[param.in]) grouped[param.in] = [];
|
|
882
|
+
grouped[param.in].push(param);
|
|
883
|
+
}
|
|
884
|
+
return grouped;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function getMultipartProps(schema) {
|
|
888
|
+
const properties = schema?.properties;
|
|
889
|
+
if (!properties) return [];
|
|
890
|
+
const required = schema?.required ?? [];
|
|
891
|
+
return Object.entries(properties).map(([name, prop]) => ({
|
|
892
|
+
name,
|
|
893
|
+
// `type: string, format: binary` (OAS 3.0) or `contentEncoding` (3.1)
|
|
894
|
+
// marks a file part; arrays of binary items also count.
|
|
895
|
+
isFile: prop.format === "binary" || prop.contentEncoding !== void 0 || prop.items?.format === "binary",
|
|
896
|
+
required: required.includes(name),
|
|
897
|
+
description: prop.description
|
|
898
|
+
}));
|
|
899
|
+
}
|
|
900
|
+
const containerStyle$3 = css({
|
|
901
|
+
marginBottom: "12px",
|
|
902
|
+
display: "flex",
|
|
903
|
+
flexDirection: "column"
|
|
904
|
+
});
|
|
905
|
+
const headerStyle = css({
|
|
906
|
+
display: "flex",
|
|
907
|
+
justifyContent: "space-between",
|
|
908
|
+
alignItems: "center",
|
|
909
|
+
marginBottom: "8px"
|
|
910
|
+
});
|
|
911
|
+
const labelStyle = css({
|
|
912
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
913
|
+
fontWeight: 600,
|
|
914
|
+
color: "var(--omnispec-fg-secondary)",
|
|
915
|
+
textTransform: "uppercase",
|
|
916
|
+
letterSpacing: "0.5px"
|
|
917
|
+
});
|
|
918
|
+
const contentTypeSelectStyle = css({
|
|
919
|
+
padding: "4px 8px",
|
|
920
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
921
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
922
|
+
color: "var(--omnispec-fg-primary)",
|
|
923
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
924
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
925
|
+
});
|
|
926
|
+
const textareaStyle = css({
|
|
927
|
+
width: "100%",
|
|
928
|
+
minHeight: "120px",
|
|
929
|
+
padding: "10px",
|
|
930
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
931
|
+
backgroundColor: "var(--omnispec-bg-code)",
|
|
932
|
+
color: "var(--omnispec-fg-code)",
|
|
933
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
934
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
935
|
+
resize: "vertical",
|
|
936
|
+
boxSizing: "border-box",
|
|
937
|
+
lineHeight: 1.5
|
|
938
|
+
});
|
|
939
|
+
function RequestBodyEditor({
|
|
940
|
+
value,
|
|
941
|
+
onChange,
|
|
942
|
+
contentType,
|
|
943
|
+
onContentTypeChange,
|
|
944
|
+
availableContentTypes = ["application/json"],
|
|
945
|
+
schema,
|
|
946
|
+
multipartFields = {},
|
|
947
|
+
onMultipartFieldChange
|
|
948
|
+
}) {
|
|
949
|
+
const textareaRef = useRef(null);
|
|
950
|
+
const autoResize = useCallback(() => {
|
|
951
|
+
const el = textareaRef.current;
|
|
952
|
+
if (!el) return;
|
|
953
|
+
el.style.height = "auto";
|
|
954
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
955
|
+
}, []);
|
|
956
|
+
useEffect(() => {
|
|
957
|
+
autoResize();
|
|
958
|
+
}, [value, autoResize]);
|
|
959
|
+
const isMultipart = contentType.includes("multipart/form-data");
|
|
960
|
+
const isUrlEncoded = contentType.includes("application/x-www-form-urlencoded");
|
|
961
|
+
const multipartProps = isMultipart || isUrlEncoded ? getMultipartProps(schema) : [];
|
|
962
|
+
const showMultipartForm = (isMultipart || isUrlEncoded) && multipartProps.length > 0 && onMultipartFieldChange;
|
|
963
|
+
return /* @__PURE__ */ jsxs("div", { className: `adr-request-body ${containerStyle$3}`, children: [
|
|
964
|
+
/* @__PURE__ */ jsxs("div", { className: headerStyle, children: [
|
|
965
|
+
/* @__PURE__ */ jsx("span", { className: labelStyle, children: "Request Body" }),
|
|
966
|
+
availableContentTypes.length > 1 && onContentTypeChange && /* @__PURE__ */ jsx(
|
|
967
|
+
"select",
|
|
968
|
+
{
|
|
969
|
+
value: contentType,
|
|
970
|
+
onChange: (e) => onContentTypeChange(e.target.value),
|
|
971
|
+
className: contentTypeSelectStyle,
|
|
972
|
+
children: availableContentTypes.map((ct) => /* @__PURE__ */ jsx("option", { value: ct, children: ct }, ct))
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
] }),
|
|
976
|
+
showMultipartForm ? /* @__PURE__ */ jsx("div", { className: multipartListStyle, children: multipartProps.map((prop) => {
|
|
977
|
+
const fieldValue = multipartFields[prop.name];
|
|
978
|
+
return /* @__PURE__ */ jsxs("div", { className: multipartFieldStyle, children: [
|
|
979
|
+
/* @__PURE__ */ jsxs("label", { className: multipartLabelStyle, children: [
|
|
980
|
+
/* @__PURE__ */ jsx("span", { className: multipartNameStyle, children: prop.name }),
|
|
981
|
+
prop.required && /* @__PURE__ */ jsx("span", { className: multipartRequiredStyle, children: "*" })
|
|
982
|
+
] }),
|
|
983
|
+
prop.isFile && isMultipart ? /* @__PURE__ */ jsx(
|
|
984
|
+
"input",
|
|
985
|
+
{
|
|
986
|
+
type: "file",
|
|
987
|
+
onChange: (e) => onMultipartFieldChange(prop.name, e.target.files?.[0] ?? null),
|
|
988
|
+
className: multipartFileInputStyle
|
|
989
|
+
}
|
|
990
|
+
) : /* @__PURE__ */ jsx(
|
|
991
|
+
"input",
|
|
992
|
+
{
|
|
993
|
+
type: "text",
|
|
994
|
+
value: typeof fieldValue === "string" ? fieldValue : "",
|
|
995
|
+
onChange: (e) => onMultipartFieldChange(prop.name, e.target.value),
|
|
996
|
+
placeholder: prop.description ?? prop.name,
|
|
997
|
+
className: multipartTextInputStyle
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
] }, prop.name);
|
|
1001
|
+
}) }) : /* @__PURE__ */ jsx(
|
|
1002
|
+
"textarea",
|
|
1003
|
+
{
|
|
1004
|
+
ref: textareaRef,
|
|
1005
|
+
name: "request-body",
|
|
1006
|
+
value,
|
|
1007
|
+
onChange: (e) => onChange(e.target.value),
|
|
1008
|
+
placeholder: getPlaceholder(contentType),
|
|
1009
|
+
className: textareaStyle,
|
|
1010
|
+
spellCheck: false
|
|
1011
|
+
}
|
|
1012
|
+
)
|
|
1013
|
+
] });
|
|
1014
|
+
}
|
|
1015
|
+
const multipartListStyle = css({
|
|
1016
|
+
display: "flex",
|
|
1017
|
+
flexDirection: "column",
|
|
1018
|
+
gap: "0.625rem"
|
|
1019
|
+
});
|
|
1020
|
+
const multipartFieldStyle = css({
|
|
1021
|
+
display: "flex",
|
|
1022
|
+
flexDirection: "column",
|
|
1023
|
+
gap: "0.25rem"
|
|
1024
|
+
});
|
|
1025
|
+
const multipartLabelStyle = css({
|
|
1026
|
+
display: "flex",
|
|
1027
|
+
alignItems: "center",
|
|
1028
|
+
gap: "0.125rem"
|
|
1029
|
+
});
|
|
1030
|
+
const multipartNameStyle = css({
|
|
1031
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1032
|
+
fontWeight: 600,
|
|
1033
|
+
color: "var(--omnispec-fg-primary)",
|
|
1034
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
1035
|
+
});
|
|
1036
|
+
const multipartRequiredStyle = css({
|
|
1037
|
+
color: "var(--omnispec-color-error)",
|
|
1038
|
+
fontWeight: 600
|
|
1039
|
+
});
|
|
1040
|
+
const multipartTextInputStyle = css({
|
|
1041
|
+
width: "100%",
|
|
1042
|
+
padding: "0.5rem 0.625rem",
|
|
1043
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
1044
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
1045
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
1046
|
+
color: "var(--omnispec-fg-primary)",
|
|
1047
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1048
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
1049
|
+
boxSizing: "border-box"
|
|
1050
|
+
});
|
|
1051
|
+
const multipartFileInputStyle = css({
|
|
1052
|
+
width: "100%",
|
|
1053
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1054
|
+
color: "var(--omnispec-fg-secondary)",
|
|
1055
|
+
"&::file-selector-button": {
|
|
1056
|
+
padding: "0.375rem 0.75rem",
|
|
1057
|
+
marginRight: "0.5rem",
|
|
1058
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
1059
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
1060
|
+
backgroundColor: "var(--omnispec-bg-secondary)",
|
|
1061
|
+
color: "var(--omnispec-fg-primary)",
|
|
1062
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1063
|
+
cursor: "pointer"
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
function getPlaceholder(contentType) {
|
|
1067
|
+
if (contentType.includes("json")) return '{\n "key": "value"\n}';
|
|
1068
|
+
if (contentType.includes("xml")) return "<root>\n <element>value</element>\n</root>";
|
|
1069
|
+
return "Enter request body...";
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function CustomHeaders({ headers, onChange }) {
|
|
1073
|
+
const updateRow = (index, patch) => {
|
|
1074
|
+
onChange(headers.map((h, i) => i === index ? { ...h, ...patch } : h));
|
|
1075
|
+
};
|
|
1076
|
+
const removeRow = (index) => {
|
|
1077
|
+
onChange(headers.filter((_, i) => i !== index));
|
|
1078
|
+
};
|
|
1079
|
+
return /* @__PURE__ */ jsxs("div", { className: `omnispec-custom-headers ${sectionStyle$2}`, children: [
|
|
1080
|
+
headers.length > 0 && /* @__PURE__ */ jsx("span", { className: sectionTitleStyle$1, children: "Custom Headers" }),
|
|
1081
|
+
headers.map((header, idx) => /* @__PURE__ */ jsxs("div", { className: rowStyle, children: [
|
|
1082
|
+
/* @__PURE__ */ jsx(
|
|
1083
|
+
"input",
|
|
1084
|
+
{
|
|
1085
|
+
type: "text",
|
|
1086
|
+
value: header.name,
|
|
1087
|
+
onChange: (e) => updateRow(idx, { name: e.target.value }),
|
|
1088
|
+
placeholder: "Header name",
|
|
1089
|
+
"aria-label": `Custom header ${idx + 1} name`,
|
|
1090
|
+
className: nameInputStyle
|
|
1091
|
+
}
|
|
1092
|
+
),
|
|
1093
|
+
/* @__PURE__ */ jsx(
|
|
1094
|
+
"input",
|
|
1095
|
+
{
|
|
1096
|
+
type: "text",
|
|
1097
|
+
value: header.value,
|
|
1098
|
+
onChange: (e) => updateRow(idx, { value: e.target.value }),
|
|
1099
|
+
placeholder: "Value",
|
|
1100
|
+
"aria-label": `Custom header ${idx + 1} value`,
|
|
1101
|
+
className: valueInputStyle
|
|
1102
|
+
}
|
|
1103
|
+
),
|
|
1104
|
+
/* @__PURE__ */ jsx(
|
|
1105
|
+
"button",
|
|
1106
|
+
{
|
|
1107
|
+
type: "button",
|
|
1108
|
+
onClick: () => removeRow(idx),
|
|
1109
|
+
"aria-label": `Remove custom header ${idx + 1}`,
|
|
1110
|
+
className: removeBtnStyle,
|
|
1111
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "xmark", size: "0.875rem" })
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
] }, idx)),
|
|
1115
|
+
/* @__PURE__ */ jsx(
|
|
1116
|
+
"button",
|
|
1117
|
+
{
|
|
1118
|
+
type: "button",
|
|
1119
|
+
onClick: () => onChange([...headers, { name: "", value: "" }]),
|
|
1120
|
+
className: addBtnStyle,
|
|
1121
|
+
children: "+ Add header"
|
|
1122
|
+
}
|
|
1123
|
+
)
|
|
1124
|
+
] });
|
|
1125
|
+
}
|
|
1126
|
+
const sectionStyle$2 = css({
|
|
1127
|
+
display: "flex",
|
|
1128
|
+
flexDirection: "column",
|
|
1129
|
+
gap: "0.5rem",
|
|
1130
|
+
marginBottom: "0.75rem"
|
|
1131
|
+
});
|
|
1132
|
+
const sectionTitleStyle$1 = css({
|
|
1133
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1134
|
+
fontWeight: 600,
|
|
1135
|
+
color: "var(--omnispec-fg-muted)",
|
|
1136
|
+
textTransform: "uppercase",
|
|
1137
|
+
letterSpacing: "0.5px"
|
|
1138
|
+
});
|
|
1139
|
+
const rowStyle = css({
|
|
1140
|
+
display: "flex",
|
|
1141
|
+
alignItems: "center",
|
|
1142
|
+
gap: "0.375rem"
|
|
1143
|
+
});
|
|
1144
|
+
const inputBase = {
|
|
1145
|
+
padding: "0.375rem 0.5rem",
|
|
1146
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
1147
|
+
border: "1px solid var(--omnispec-input-border)",
|
|
1148
|
+
backgroundColor: "var(--omnispec-input-bg)",
|
|
1149
|
+
color: "var(--omnispec-fg-primary)",
|
|
1150
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1151
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
1152
|
+
minWidth: 0
|
|
1153
|
+
};
|
|
1154
|
+
const nameInputStyle = css({
|
|
1155
|
+
...inputBase,
|
|
1156
|
+
flex: 1
|
|
1157
|
+
});
|
|
1158
|
+
const valueInputStyle = css({
|
|
1159
|
+
...inputBase,
|
|
1160
|
+
flex: 1.4
|
|
1161
|
+
});
|
|
1162
|
+
const removeBtnStyle = css({
|
|
1163
|
+
display: "inline-flex",
|
|
1164
|
+
alignItems: "center",
|
|
1165
|
+
justifyContent: "center",
|
|
1166
|
+
padding: "0.25rem",
|
|
1167
|
+
backgroundColor: "transparent",
|
|
1168
|
+
border: "none",
|
|
1169
|
+
color: "var(--omnispec-fg-muted)",
|
|
1170
|
+
cursor: "pointer",
|
|
1171
|
+
"&:hover": {
|
|
1172
|
+
color: "var(--omnispec-color-error)"
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
const addBtnStyle = css({
|
|
1176
|
+
alignSelf: "flex-start",
|
|
1177
|
+
padding: "0.25rem 0.625rem",
|
|
1178
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1179
|
+
fontFamily: "var(--omnispec-font-sans)",
|
|
1180
|
+
fontWeight: 500,
|
|
1181
|
+
color: "var(--omnispec-fg-link)",
|
|
1182
|
+
backgroundColor: "transparent",
|
|
1183
|
+
border: "1px solid var(--omnispec-border-color)",
|
|
1184
|
+
borderRadius: "1rem",
|
|
1185
|
+
cursor: "pointer",
|
|
1186
|
+
"&:hover": {
|
|
1187
|
+
backgroundColor: "var(--omnispec-bg-secondary)"
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
function TryItPanel({
|
|
1192
|
+
method,
|
|
1193
|
+
path,
|
|
1194
|
+
serverUrl,
|
|
1195
|
+
parameters = [],
|
|
1196
|
+
requestBodyContentTypes,
|
|
1197
|
+
defaultRequestBody,
|
|
1198
|
+
requestBodySchema,
|
|
1199
|
+
requestBodySchemas,
|
|
1200
|
+
security,
|
|
1201
|
+
xCodeSamples,
|
|
1202
|
+
docked = true,
|
|
1203
|
+
onRequest,
|
|
1204
|
+
onResponse
|
|
1205
|
+
}) {
|
|
1206
|
+
const { allowTryIt, proxyUrl, proxyHeaders, specKey, tryItPersistTtl } = useConfig();
|
|
1207
|
+
const { getAuthHeaders, appliedAuth, openAuthPanel, hasAuth, clearAuth } = useAuth();
|
|
1208
|
+
const authorized = appliedAuth.size > 0;
|
|
1209
|
+
const persistenceDisabled = tryItPersistTtl === 0;
|
|
1210
|
+
const operationKey = `${method.toUpperCase()} ${path}`;
|
|
1211
|
+
const persisted = useMemo(
|
|
1212
|
+
() => loadTryItState(specKey, operationKey, tryItPersistTtl),
|
|
1213
|
+
[specKey, operationKey, tryItPersistTtl]
|
|
1214
|
+
);
|
|
1215
|
+
const defaultParamValues = () => {
|
|
1216
|
+
const initial = {};
|
|
1217
|
+
for (const param of parameters) {
|
|
1218
|
+
const val = param.example ?? param.default;
|
|
1219
|
+
if (val !== void 0) initial[param.name] = val;
|
|
1220
|
+
}
|
|
1221
|
+
return initial;
|
|
1222
|
+
};
|
|
1223
|
+
const [paramValues, setParamValues] = useState(() => ({
|
|
1224
|
+
...defaultParamValues(),
|
|
1225
|
+
...persisted?.paramValues
|
|
1226
|
+
}));
|
|
1227
|
+
const [body, setBody] = useState(persisted?.body ?? defaultRequestBody ?? "");
|
|
1228
|
+
const [contentType, setContentType] = useState(
|
|
1229
|
+
persisted?.contentType ?? requestBodyContentTypes?.[0] ?? "application/json"
|
|
1230
|
+
);
|
|
1231
|
+
const [multipartFields, setMultipartFields] = useState(
|
|
1232
|
+
() => ({ ...persisted?.formFields })
|
|
1233
|
+
);
|
|
1234
|
+
const [customHeaders, setCustomHeaders] = useState(
|
|
1235
|
+
() => persisted?.customHeaders ?? []
|
|
1236
|
+
);
|
|
1237
|
+
const [response, setResponse] = useState(null);
|
|
1238
|
+
const [loading, setLoading] = useState(false);
|
|
1239
|
+
const [error, setError] = useState();
|
|
1240
|
+
const [codeLang, setCodeLang] = useState("curl");
|
|
1241
|
+
const touchedParams = useRef(new Set(Object.keys(persisted?.paramValues ?? {})));
|
|
1242
|
+
useEffect(() => {
|
|
1243
|
+
if (!specKey || persistenceDisabled) return;
|
|
1244
|
+
const formFields = {};
|
|
1245
|
+
for (const [name, value] of Object.entries(multipartFields)) {
|
|
1246
|
+
if (typeof value === "string" && value !== "") formFields[name] = value;
|
|
1247
|
+
}
|
|
1248
|
+
saveTryItState(specKey, operationKey, {
|
|
1249
|
+
paramValues,
|
|
1250
|
+
body,
|
|
1251
|
+
contentType,
|
|
1252
|
+
formFields,
|
|
1253
|
+
customHeaders
|
|
1254
|
+
});
|
|
1255
|
+
}, [specKey, operationKey, persistenceDisabled, paramValues, body, contentType, multipartFields, customHeaders]);
|
|
1256
|
+
const missingRequiredParams = useMemo(() => {
|
|
1257
|
+
const missing = [];
|
|
1258
|
+
for (const param of parameters) {
|
|
1259
|
+
if (!param.required) continue;
|
|
1260
|
+
if (param.in !== "path" && param.in !== "query") continue;
|
|
1261
|
+
if (!paramValues[param.name]?.trim()) missing.push(`${param.name} (${param.in})`);
|
|
1262
|
+
}
|
|
1263
|
+
return missing;
|
|
1264
|
+
}, [parameters, paramValues]);
|
|
1265
|
+
const authSatisfied = useMemo(() => {
|
|
1266
|
+
if (!security || security.length === 0) return true;
|
|
1267
|
+
return security.some((group) => group.length === 0 || group.every((name) => appliedAuth.has(name)));
|
|
1268
|
+
}, [security, appliedAuth]);
|
|
1269
|
+
const authMismatch = !authSatisfied && appliedAuth.size > 0;
|
|
1270
|
+
const authBlocked = !authSatisfied && appliedAuth.size === 0;
|
|
1271
|
+
const declaredSchemes = useMemo(
|
|
1272
|
+
() => Array.from(new Set((security ?? []).flat())),
|
|
1273
|
+
[security]
|
|
1274
|
+
);
|
|
1275
|
+
const sendBlocked = missingRequiredParams.length > 0 || authBlocked;
|
|
1276
|
+
const handleReset = () => {
|
|
1277
|
+
clearTryItState(specKey, operationKey);
|
|
1278
|
+
touchedParams.current = /* @__PURE__ */ new Set();
|
|
1279
|
+
setParamValues(defaultParamValues());
|
|
1280
|
+
setBody(defaultRequestBody ?? "");
|
|
1281
|
+
setContentType(requestBodyContentTypes?.[0] ?? "application/json");
|
|
1282
|
+
setMultipartFields({});
|
|
1283
|
+
setCustomHeaders([]);
|
|
1284
|
+
clearAuth();
|
|
1285
|
+
};
|
|
1286
|
+
const handleParamChange = useCallback((name, value) => {
|
|
1287
|
+
touchedParams.current.add(name);
|
|
1288
|
+
setParamValues((prev) => ({ ...prev, [name]: value }));
|
|
1289
|
+
}, []);
|
|
1290
|
+
const exampleSignature = parameters.map((p) => `${p.name}=${p.example ?? ""}`).join("|");
|
|
1291
|
+
useEffect(() => {
|
|
1292
|
+
setParamValues((prev) => {
|
|
1293
|
+
let changed = false;
|
|
1294
|
+
const next = { ...prev };
|
|
1295
|
+
for (const param of parameters) {
|
|
1296
|
+
if (param.example === void 0) continue;
|
|
1297
|
+
if (touchedParams.current.has(param.name)) continue;
|
|
1298
|
+
if (next[param.name] !== param.example) {
|
|
1299
|
+
next[param.name] = param.example;
|
|
1300
|
+
changed = true;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
return changed ? next : prev;
|
|
1304
|
+
});
|
|
1305
|
+
}, [exampleSignature]);
|
|
1306
|
+
const buildRequest = useCallback(() => {
|
|
1307
|
+
const authHeaders = getAuthHeaders();
|
|
1308
|
+
const headers = { ...authHeaders };
|
|
1309
|
+
for (const param of parameters) {
|
|
1310
|
+
if (param.in === "header" && paramValues[param.name]) {
|
|
1311
|
+
headers[param.name] = paramValues[param.name];
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
for (const header of customHeaders) {
|
|
1315
|
+
const name = header.name.trim();
|
|
1316
|
+
if (name) headers[name] = header.value;
|
|
1317
|
+
}
|
|
1318
|
+
const bodyCapable = ["post", "put", "patch"].includes(method.toLowerCase());
|
|
1319
|
+
const isMultipart = contentType.includes("multipart/form-data");
|
|
1320
|
+
const isUrlEncoded = contentType.includes("application/x-www-form-urlencoded");
|
|
1321
|
+
const hasFormFieldValues = Object.values(multipartFields).some((v) => v !== null && v !== "");
|
|
1322
|
+
const pathParams = {};
|
|
1323
|
+
const queryParams = {};
|
|
1324
|
+
for (const param of parameters) {
|
|
1325
|
+
const val = paramValues[param.name];
|
|
1326
|
+
if (!val) continue;
|
|
1327
|
+
if (param.in === "path") pathParams[param.name] = val;
|
|
1328
|
+
if (param.in === "query") {
|
|
1329
|
+
if (param.itemsEnum) {
|
|
1330
|
+
const values = val.split(MULTI_VALUE_DELIMITER).filter(Boolean);
|
|
1331
|
+
queryParams[param.name] = param.explode === false ? values.join(",") : values;
|
|
1332
|
+
} else {
|
|
1333
|
+
queryParams[param.name] = val;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
let encodedBody;
|
|
1338
|
+
if (bodyCapable && isMultipart) {
|
|
1339
|
+
const formData = new FormData();
|
|
1340
|
+
let hasEntries = false;
|
|
1341
|
+
for (const [name, value] of Object.entries(multipartFields)) {
|
|
1342
|
+
if (value === null || value === "") continue;
|
|
1343
|
+
formData.append(name, value);
|
|
1344
|
+
hasEntries = true;
|
|
1345
|
+
}
|
|
1346
|
+
if (hasEntries) encodedBody = formData;
|
|
1347
|
+
} else if (bodyCapable && isUrlEncoded && hasFormFieldValues) {
|
|
1348
|
+
headers["Content-Type"] = contentType;
|
|
1349
|
+
const params = new URLSearchParams();
|
|
1350
|
+
for (const [name, value] of Object.entries(multipartFields)) {
|
|
1351
|
+
if (value === null || value === "" || typeof value !== "string") continue;
|
|
1352
|
+
params.set(name, value);
|
|
1353
|
+
}
|
|
1354
|
+
encodedBody = params.toString();
|
|
1355
|
+
} else if (bodyCapable && body) {
|
|
1356
|
+
headers["Content-Type"] = contentType;
|
|
1357
|
+
encodedBody = body;
|
|
1358
|
+
if (isUrlEncoded) {
|
|
1359
|
+
try {
|
|
1360
|
+
const parsed = JSON.parse(body);
|
|
1361
|
+
const params = new URLSearchParams();
|
|
1362
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
1363
|
+
params.set(key, String(value));
|
|
1364
|
+
}
|
|
1365
|
+
encodedBody = params.toString();
|
|
1366
|
+
} catch {
|
|
1367
|
+
encodedBody = body;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
return {
|
|
1372
|
+
url: path,
|
|
1373
|
+
method: method.toUpperCase(),
|
|
1374
|
+
headers,
|
|
1375
|
+
pathParams,
|
|
1376
|
+
queryParams,
|
|
1377
|
+
body: encodedBody,
|
|
1378
|
+
bodyType: contentType
|
|
1379
|
+
};
|
|
1380
|
+
}, [parameters, paramValues, body, contentType, multipartFields, customHeaders, method, path, getAuthHeaders]);
|
|
1381
|
+
const handleSend = useCallback(async () => {
|
|
1382
|
+
setLoading(true);
|
|
1383
|
+
setError(void 0);
|
|
1384
|
+
setResponse(null);
|
|
1385
|
+
const request2 = buildRequest();
|
|
1386
|
+
onRequest?.(request2);
|
|
1387
|
+
const fullRequest = {
|
|
1388
|
+
...request2,
|
|
1389
|
+
url: serverUrl + request2.url
|
|
1390
|
+
};
|
|
1391
|
+
try {
|
|
1392
|
+
const res = proxyUrl ? await sendProxiedRequest(proxyUrl, fullRequest, proxyHeaders) : await sendDirectRequest(fullRequest);
|
|
1393
|
+
setResponse(res);
|
|
1394
|
+
onResponse?.(res);
|
|
1395
|
+
} catch (err) {
|
|
1396
|
+
const message = err instanceof Error ? err.message : "Request failed";
|
|
1397
|
+
if (!proxyUrl && message.includes("Failed to fetch")) {
|
|
1398
|
+
const isHttpTarget = /^http:\/\//i.test(fullRequest.url);
|
|
1399
|
+
const hint = isHttpTarget ? "The spec's server URL uses http://, which browsers block from an https page and often can't follow to https (the redirect carries no CORS headers). Use an https:// server URL, or route requests through a proxyUrl." : "This is usually a CORS restriction \u2014 the API does not allow browser cross-origin requests. Configure a proxyUrl to route requests through your backend.";
|
|
1400
|
+
setError(`${message}. ${hint}`);
|
|
1401
|
+
} else {
|
|
1402
|
+
setError(message);
|
|
1403
|
+
}
|
|
1404
|
+
} finally {
|
|
1405
|
+
setLoading(false);
|
|
1406
|
+
}
|
|
1407
|
+
}, [proxyUrl, proxyHeaders, buildRequest, serverUrl, onRequest, onResponse]);
|
|
1408
|
+
const schemaBody = useMemo(() => {
|
|
1409
|
+
if (!requestBodySchema) return void 0;
|
|
1410
|
+
return JSON.stringify(generateExample(requestBodySchema), null, 2);
|
|
1411
|
+
}, [requestBodySchema]);
|
|
1412
|
+
if (!allowTryIt) return null;
|
|
1413
|
+
const request = buildRequest();
|
|
1414
|
+
const hasBodyMethods = ["post", "put", "patch"].includes(method.toLowerCase());
|
|
1415
|
+
const codeSampleRequest = useMemo(() => {
|
|
1416
|
+
const r = { ...request };
|
|
1417
|
+
if (hasBodyMethods && !r.body && schemaBody) {
|
|
1418
|
+
r.body = schemaBody;
|
|
1419
|
+
if (!r.headers["Content-Type"]) {
|
|
1420
|
+
r.headers = { ...r.headers, "Content-Type": contentType };
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return r;
|
|
1424
|
+
}, [request, hasBodyMethods, schemaBody, contentType]);
|
|
1425
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("omnispec-tryit", docked && dockedContainerStyle), children: [
|
|
1426
|
+
/* @__PURE__ */ jsxs("div", { className: titleRowStyle, children: [
|
|
1427
|
+
/* @__PURE__ */ jsx("h4", { className: titleStyle$3, children: "Try it" }),
|
|
1428
|
+
/* @__PURE__ */ jsx("div", { className: statusRowStyle, children: /* @__PURE__ */ jsxs("div", { className: headerActionsStyle, children: [
|
|
1429
|
+
hasAuth && /* @__PURE__ */ jsxs(
|
|
1430
|
+
"button",
|
|
1431
|
+
{
|
|
1432
|
+
type: "button",
|
|
1433
|
+
onClick: openAuthPanel,
|
|
1434
|
+
className: headerBtnStyle,
|
|
1435
|
+
title: authorized ? "Update authorization credentials" : "Set authorization credentials",
|
|
1436
|
+
children: [
|
|
1437
|
+
/* @__PURE__ */ jsx(
|
|
1438
|
+
Icon,
|
|
1439
|
+
{
|
|
1440
|
+
name: authorized ? "lock-keyhole" : "lock-keyhole-open",
|
|
1441
|
+
size: "0.875rem",
|
|
1442
|
+
color: authorized ? "var(--omnispec-color-success)" : void 0
|
|
1443
|
+
}
|
|
1444
|
+
),
|
|
1445
|
+
authorized ? "Authorized" : "Authorize"
|
|
1446
|
+
]
|
|
1447
|
+
}
|
|
1448
|
+
),
|
|
1449
|
+
/* @__PURE__ */ jsxs(
|
|
1450
|
+
"button",
|
|
1451
|
+
{
|
|
1452
|
+
type: "button",
|
|
1453
|
+
onClick: handleReset,
|
|
1454
|
+
className: headerBtnStyle,
|
|
1455
|
+
title: "Reset Try-It inputs for this operation and clear all applied authorization",
|
|
1456
|
+
children: [
|
|
1457
|
+
/* @__PURE__ */ jsx(Icon, { name: "rotate-ccw", size: "0.875rem" }),
|
|
1458
|
+
"Reset"
|
|
1459
|
+
]
|
|
1460
|
+
}
|
|
1461
|
+
)
|
|
1462
|
+
] }) })
|
|
1463
|
+
] }),
|
|
1464
|
+
parameters.length > 0 && /* @__PURE__ */ jsx(
|
|
1465
|
+
ParameterForm,
|
|
1466
|
+
{
|
|
1467
|
+
parameters,
|
|
1468
|
+
values: paramValues,
|
|
1469
|
+
onChange: handleParamChange
|
|
1470
|
+
}
|
|
1471
|
+
),
|
|
1472
|
+
/* @__PURE__ */ jsx(CustomHeaders, { headers: customHeaders, onChange: setCustomHeaders }),
|
|
1473
|
+
hasBodyMethods && requestBodyContentTypes && /* @__PURE__ */ jsx(
|
|
1474
|
+
RequestBodyEditor,
|
|
1475
|
+
{
|
|
1476
|
+
value: body,
|
|
1477
|
+
onChange: setBody,
|
|
1478
|
+
contentType,
|
|
1479
|
+
onContentTypeChange: setContentType,
|
|
1480
|
+
availableContentTypes: requestBodyContentTypes,
|
|
1481
|
+
schema: requestBodySchemas?.[contentType] ?? requestBodySchema,
|
|
1482
|
+
multipartFields,
|
|
1483
|
+
onMultipartFieldChange: (name, value) => setMultipartFields((prev) => ({ ...prev, [name]: value }))
|
|
1484
|
+
}
|
|
1485
|
+
),
|
|
1486
|
+
/* @__PURE__ */ jsx("div", { className: actionsStyle, children: /* @__PURE__ */ jsx(
|
|
1487
|
+
Button,
|
|
1488
|
+
{
|
|
1489
|
+
variant: "primary",
|
|
1490
|
+
onClick: handleSend,
|
|
1491
|
+
disabled: loading || sendBlocked,
|
|
1492
|
+
className: fullWidthBtnStyle,
|
|
1493
|
+
children: loading ? "Sending..." : "Send"
|
|
1494
|
+
}
|
|
1495
|
+
) }),
|
|
1496
|
+
(sendBlocked || authMismatch) && /* @__PURE__ */ jsxs("div", { className: validationMsgStyle, role: "status", children: [
|
|
1497
|
+
missingRequiredParams.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
1498
|
+
"Required: ",
|
|
1499
|
+
missingRequiredParams.join(", ")
|
|
1500
|
+
] }),
|
|
1501
|
+
authBlocked && /* @__PURE__ */ jsx("span", { children: "Authorization required \u2014 apply credentials in the Authorization panel." }),
|
|
1502
|
+
authMismatch && /* @__PURE__ */ jsxs("span", { children: [
|
|
1503
|
+
"This operation declares ",
|
|
1504
|
+
declaredSchemes.join(", "),
|
|
1505
|
+
" \u2014 your applied credentials will be sent with the request."
|
|
1506
|
+
] })
|
|
1507
|
+
] }),
|
|
1508
|
+
/* @__PURE__ */ jsx(
|
|
1509
|
+
CodeSamples,
|
|
1510
|
+
{
|
|
1511
|
+
request: codeSampleRequest,
|
|
1512
|
+
serverUrl,
|
|
1513
|
+
selectedLanguage: codeLang,
|
|
1514
|
+
onLanguageChange: setCodeLang,
|
|
1515
|
+
xCodeSamples
|
|
1516
|
+
}
|
|
1517
|
+
),
|
|
1518
|
+
/* @__PURE__ */ jsx(ResponseViewer, { response, loading, error })
|
|
1519
|
+
] });
|
|
1520
|
+
}
|
|
1521
|
+
const dockedContainerStyle = css({
|
|
1522
|
+
position: "sticky",
|
|
1523
|
+
top: "calc(var(--omnispec-offset-top, 0px) + 1.25rem)",
|
|
1524
|
+
[mq.desktop]: {
|
|
1525
|
+
// When the panel is taller than the viewport, a sticky element would pin
|
|
1526
|
+
// its top and push its bottom off-screen with no way to reach it (the page
|
|
1527
|
+
// scroll tracks the taller left column). Cap it to the viewport and let the
|
|
1528
|
+
// panel scroll its own overflow so every control stays reachable.
|
|
1529
|
+
maxHeight: "calc(100vh - var(--omnispec-offset-top, 0px) - 2.5rem)",
|
|
1530
|
+
overflowY: "auto",
|
|
1531
|
+
// Keep the internal scrollbar off the content edge.
|
|
1532
|
+
paddingRight: "0.25rem"
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
const titleRowStyle = css({
|
|
1536
|
+
display: "flex",
|
|
1537
|
+
alignItems: "center",
|
|
1538
|
+
gap: "8px",
|
|
1539
|
+
marginBottom: "12px"
|
|
1540
|
+
});
|
|
1541
|
+
const titleStyle$3 = css({
|
|
1542
|
+
margin: 0,
|
|
1543
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
1544
|
+
fontWeight: 600,
|
|
1545
|
+
color: "var(--omnispec-fg-primary)"
|
|
1546
|
+
});
|
|
1547
|
+
const actionsStyle = css({
|
|
1548
|
+
display: "flex",
|
|
1549
|
+
gap: "8px",
|
|
1550
|
+
marginBottom: "12px"
|
|
1551
|
+
});
|
|
1552
|
+
const fullWidthBtnStyle = css({
|
|
1553
|
+
width: "100%"
|
|
1554
|
+
});
|
|
1555
|
+
const statusRowStyle = css({
|
|
1556
|
+
display: "flex",
|
|
1557
|
+
alignItems: "center",
|
|
1558
|
+
gap: "6px",
|
|
1559
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1560
|
+
flex: 1
|
|
1561
|
+
});
|
|
1562
|
+
const validationMsgStyle = css({
|
|
1563
|
+
display: "flex",
|
|
1564
|
+
flexDirection: "column",
|
|
1565
|
+
gap: "0.25rem",
|
|
1566
|
+
marginBottom: "0.75rem",
|
|
1567
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1568
|
+
color: "var(--omnispec-color-warning)",
|
|
1569
|
+
lineHeight: 1.4
|
|
1570
|
+
});
|
|
1571
|
+
const headerActionsStyle = css({
|
|
1572
|
+
marginLeft: "auto",
|
|
1573
|
+
display: "flex",
|
|
1574
|
+
alignItems: "center",
|
|
1575
|
+
gap: "6px"
|
|
1576
|
+
});
|
|
1577
|
+
const headerBtnStyle = css({
|
|
1578
|
+
display: "inline-flex",
|
|
1579
|
+
alignItems: "center",
|
|
1580
|
+
gap: "0.375rem",
|
|
1581
|
+
padding: "0.25rem 0.625rem",
|
|
1582
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1583
|
+
fontFamily: "var(--omnispec-font-sans)",
|
|
1584
|
+
color: "var(--omnispec-fg-muted)",
|
|
1585
|
+
backgroundColor: "transparent",
|
|
1586
|
+
border: "1px solid var(--omnispec-border-color)",
|
|
1587
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
1588
|
+
cursor: "pointer",
|
|
1589
|
+
"&:hover": {
|
|
1590
|
+
color: "var(--omnispec-fg-primary)",
|
|
1591
|
+
backgroundColor: "var(--omnispec-bg-secondary)"
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
function InlineTryIt(props) {
|
|
1596
|
+
const [open, setOpen] = useState(false);
|
|
1597
|
+
const regionId = useId();
|
|
1598
|
+
const regionRef = useRef(null);
|
|
1599
|
+
useEffect(() => {
|
|
1600
|
+
if (open) {
|
|
1601
|
+
regionRef.current?.scrollIntoView({ block: "nearest" });
|
|
1602
|
+
}
|
|
1603
|
+
}, [open]);
|
|
1604
|
+
return /* @__PURE__ */ jsxs("div", { className: wrapperStyle, children: [
|
|
1605
|
+
/* @__PURE__ */ jsxs(
|
|
1606
|
+
"button",
|
|
1607
|
+
{
|
|
1608
|
+
type: "button",
|
|
1609
|
+
className: triggerStyle,
|
|
1610
|
+
onClick: () => setOpen((prev) => !prev),
|
|
1611
|
+
"aria-expanded": open,
|
|
1612
|
+
"aria-controls": regionId,
|
|
1613
|
+
children: [
|
|
1614
|
+
/* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "0.875rem", className: cx(chevronStyle$1, open && chevronOpenStyle) }),
|
|
1615
|
+
/* @__PURE__ */ jsx("span", { children: open ? "Hide Try it" : "Try it" })
|
|
1616
|
+
]
|
|
1617
|
+
}
|
|
1618
|
+
),
|
|
1619
|
+
/* @__PURE__ */ jsx("div", { id: regionId, ref: regionRef, hidden: !open, className: regionStyle, children: /* @__PURE__ */ jsx(TryItPanel, { ...props, docked: false }) })
|
|
1620
|
+
] });
|
|
1621
|
+
}
|
|
1622
|
+
const wrapperStyle = css({
|
|
1623
|
+
marginTop: "1rem"
|
|
1624
|
+
});
|
|
1625
|
+
const triggerStyle = css({
|
|
1626
|
+
display: "flex",
|
|
1627
|
+
alignItems: "center",
|
|
1628
|
+
gap: "0.5rem",
|
|
1629
|
+
width: "100%",
|
|
1630
|
+
padding: "0.625rem 1rem",
|
|
1631
|
+
background: "var(--omnispec-bg-secondary)",
|
|
1632
|
+
color: "var(--omnispec-fg-primary)",
|
|
1633
|
+
border: "none",
|
|
1634
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
1635
|
+
boxShadow: "var(--omnispec-btn-secondary-shadow)",
|
|
1636
|
+
cursor: "pointer",
|
|
1637
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
1638
|
+
fontWeight: 600,
|
|
1639
|
+
textAlign: "left",
|
|
1640
|
+
"&:hover": {
|
|
1641
|
+
background: "var(--omnispec-btn-secondary-bg-hover)"
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
const chevronStyle$1 = css({
|
|
1645
|
+
display: "inline-flex",
|
|
1646
|
+
flexShrink: 0,
|
|
1647
|
+
transition: "transform 0.2s ease"
|
|
1648
|
+
});
|
|
1649
|
+
const chevronOpenStyle = css({
|
|
1650
|
+
transform: "rotate(90deg)"
|
|
1651
|
+
});
|
|
1652
|
+
const regionStyle = css({
|
|
1653
|
+
paddingTop: "0.75rem"
|
|
1654
|
+
});
|
|
1655
|
+
|
|
1656
|
+
const HTTP_METHODS = ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
1657
|
+
function parseCallbacks(callbacks) {
|
|
1658
|
+
const result = [];
|
|
1659
|
+
for (const [name, callbackValue] of Object.entries(callbacks)) {
|
|
1660
|
+
if (!callbackValue || typeof callbackValue !== "object") continue;
|
|
1661
|
+
const pathItemMap = callbackValue;
|
|
1662
|
+
for (const [urlExpression, pathItem] of Object.entries(pathItemMap)) {
|
|
1663
|
+
if (!pathItem || typeof pathItem !== "object") continue;
|
|
1664
|
+
const pathItemObj = pathItem;
|
|
1665
|
+
for (const method of HTTP_METHODS) {
|
|
1666
|
+
const operation = pathItemObj[method];
|
|
1667
|
+
if (!operation || typeof operation !== "object") continue;
|
|
1668
|
+
const op = operation;
|
|
1669
|
+
let requestBodySchema;
|
|
1670
|
+
const requestBody = op.requestBody;
|
|
1671
|
+
if (requestBody?.content && typeof requestBody.content === "object") {
|
|
1672
|
+
const content = requestBody.content;
|
|
1673
|
+
const firstMedia = Object.values(content)[0];
|
|
1674
|
+
if (firstMedia?.schema && typeof firstMedia.schema === "object") {
|
|
1675
|
+
requestBodySchema = firstMedia.schema;
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
const responseStatuses = [];
|
|
1679
|
+
const responses = op.responses;
|
|
1680
|
+
if (responses && typeof responses === "object") {
|
|
1681
|
+
for (const [code, responseValue] of Object.entries(responses)) {
|
|
1682
|
+
const response = responseValue;
|
|
1683
|
+
responseStatuses.push({
|
|
1684
|
+
code,
|
|
1685
|
+
description: typeof response?.description === "string" ? response.description : ""
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
result.push({
|
|
1690
|
+
name,
|
|
1691
|
+
urlExpression,
|
|
1692
|
+
method,
|
|
1693
|
+
summary: typeof op.summary === "string" ? op.summary : void 0,
|
|
1694
|
+
description: typeof op.description === "string" ? op.description : void 0,
|
|
1695
|
+
requestBodySchema,
|
|
1696
|
+
responseStatuses
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
return result;
|
|
1702
|
+
}
|
|
1703
|
+
function CallbackCard({ callback }) {
|
|
1704
|
+
const [expanded, setExpanded] = useState(false);
|
|
1705
|
+
const method = callback.method;
|
|
1706
|
+
return /* @__PURE__ */ jsxs("div", { className: cardStyle, children: [
|
|
1707
|
+
/* @__PURE__ */ jsxs(
|
|
1708
|
+
"button",
|
|
1709
|
+
{
|
|
1710
|
+
type: "button",
|
|
1711
|
+
className: cardHeaderStyle,
|
|
1712
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
1713
|
+
"aria-expanded": expanded,
|
|
1714
|
+
children: [
|
|
1715
|
+
/* @__PURE__ */ jsx("span", { className: cx(chevronStyle, expanded && chevronExpandedStyle), children: /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "0.75rem" }) }),
|
|
1716
|
+
/* @__PURE__ */ jsx("span", { className: callbackNameStyle, children: callback.name }),
|
|
1717
|
+
/* @__PURE__ */ jsx("code", { className: urlExpressionStyle, children: callback.urlExpression })
|
|
1718
|
+
]
|
|
1719
|
+
}
|
|
1720
|
+
),
|
|
1721
|
+
expanded && /* @__PURE__ */ jsxs("div", { className: cardBodyStyle, children: [
|
|
1722
|
+
/* @__PURE__ */ jsx(
|
|
1723
|
+
MethodBar,
|
|
1724
|
+
{
|
|
1725
|
+
label: callback.method.toUpperCase(),
|
|
1726
|
+
path: callback.urlExpression,
|
|
1727
|
+
method
|
|
1728
|
+
}
|
|
1729
|
+
),
|
|
1730
|
+
callback.summary && /* @__PURE__ */ jsx("p", { className: summaryStyle$1, children: callback.summary }),
|
|
1731
|
+
callback.description && /* @__PURE__ */ jsx("p", { className: descriptionStyle, children: callback.description }),
|
|
1732
|
+
callback.requestBodySchema && /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
|
|
1733
|
+
/* @__PURE__ */ jsx("span", { className: sectionLabelStyle, children: "Request Body" }),
|
|
1734
|
+
/* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(callback.requestBodySchema), context: "request" })
|
|
1735
|
+
] }),
|
|
1736
|
+
callback.responseStatuses.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
|
|
1737
|
+
/* @__PURE__ */ jsx("span", { className: sectionLabelStyle, children: "Responses" }),
|
|
1738
|
+
/* @__PURE__ */ jsx("div", { className: responseListStyle$1, children: callback.responseStatuses.map(({ code, description }) => /* @__PURE__ */ jsxs("div", { className: responseRowStyle, children: [
|
|
1739
|
+
/* @__PURE__ */ jsx("span", { className: cx(statusBadgeStyle$1, css({
|
|
1740
|
+
backgroundColor: getStatusBg$1(code),
|
|
1741
|
+
color: getStatusColor$1(code)
|
|
1742
|
+
})), children: code }),
|
|
1743
|
+
description && /* @__PURE__ */ jsx("span", { className: responseDescStyle$1, children: description })
|
|
1744
|
+
] }, code)) })
|
|
1745
|
+
] })
|
|
1746
|
+
] })
|
|
1747
|
+
] });
|
|
1748
|
+
}
|
|
1749
|
+
function CallbacksSection({ callbacks }) {
|
|
1750
|
+
const parsed = parseCallbacks(callbacks);
|
|
1751
|
+
if (parsed.length === 0) return null;
|
|
1752
|
+
return /* @__PURE__ */ jsxs("div", { className: containerStyle$2, children: [
|
|
1753
|
+
/* @__PURE__ */ jsx("h4", { className: titleStyle$2, children: "Callbacks" }),
|
|
1754
|
+
/* @__PURE__ */ jsx("div", { className: cardListStyle, children: parsed.map((cb, idx) => /* @__PURE__ */ jsx(CallbackCard, { callback: cb }, `${cb.name}-${cb.method}-${idx}`)) })
|
|
1755
|
+
] });
|
|
1756
|
+
}
|
|
1757
|
+
function getStatusColor$1(code) {
|
|
1758
|
+
const num = parseInt(code, 10);
|
|
1759
|
+
if (num >= 200 && num < 300) return "var(--omnispec-color-success)";
|
|
1760
|
+
if (num >= 300 && num < 400) return "var(--omnispec-color-info)";
|
|
1761
|
+
if (num >= 400 && num < 500) return "var(--omnispec-color-warning)";
|
|
1762
|
+
if (num >= 500) return "var(--omnispec-color-error)";
|
|
1763
|
+
return "var(--omnispec-fg-primary)";
|
|
1764
|
+
}
|
|
1765
|
+
function getStatusBg$1(code) {
|
|
1766
|
+
const num = parseInt(code, 10);
|
|
1767
|
+
if (num >= 200 && num < 300) return "rgba(26, 127, 55, 0.1)";
|
|
1768
|
+
if (num >= 300 && num < 400) return "rgba(5, 80, 174, 0.1)";
|
|
1769
|
+
if (num >= 400 && num < 500) return "rgba(191, 135, 0, 0.1)";
|
|
1770
|
+
if (num >= 500) return "rgba(207, 34, 46, 0.1)";
|
|
1771
|
+
return "var(--omnispec-bg-tertiary)";
|
|
1772
|
+
}
|
|
1773
|
+
const containerStyle$2 = css({
|
|
1774
|
+
marginBottom: "1.5rem"
|
|
1775
|
+
});
|
|
1776
|
+
const titleStyle$2 = css({
|
|
1777
|
+
margin: "0 0 0.75rem",
|
|
1778
|
+
fontSize: "var(--omnispec-font-size-md)",
|
|
1779
|
+
fontWeight: 700,
|
|
1780
|
+
color: "var(--omnispec-fg-primary)",
|
|
1781
|
+
letterSpacing: "0.02em"
|
|
1782
|
+
});
|
|
1783
|
+
const cardListStyle = css({
|
|
1784
|
+
display: "flex",
|
|
1785
|
+
flexDirection: "column",
|
|
1786
|
+
gap: "0.5rem"
|
|
1787
|
+
});
|
|
1788
|
+
const cardStyle = css({
|
|
1789
|
+
borderRadius: "0.375rem",
|
|
1790
|
+
border: "1px dashed var(--omnispec-border-color)",
|
|
1791
|
+
overflow: "hidden"
|
|
1792
|
+
});
|
|
1793
|
+
const cardHeaderStyle = css({
|
|
1794
|
+
display: "flex",
|
|
1795
|
+
alignItems: "center",
|
|
1796
|
+
gap: "0.625rem",
|
|
1797
|
+
width: "100%",
|
|
1798
|
+
padding: "0.625rem 0.75rem",
|
|
1799
|
+
background: "var(--omnispec-bg-secondary)",
|
|
1800
|
+
border: "none",
|
|
1801
|
+
cursor: "pointer",
|
|
1802
|
+
textAlign: "left",
|
|
1803
|
+
flexWrap: "wrap",
|
|
1804
|
+
[mq.desktop]: {
|
|
1805
|
+
flexWrap: "nowrap",
|
|
1806
|
+
gap: "0.75rem",
|
|
1807
|
+
padding: "0.625rem 1rem"
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
const chevronStyle = css({
|
|
1811
|
+
color: "var(--omnispec-fg-muted)",
|
|
1812
|
+
flexShrink: 0,
|
|
1813
|
+
transition: "transform 0.2s ease"
|
|
1814
|
+
});
|
|
1815
|
+
const chevronExpandedStyle = css({
|
|
1816
|
+
transform: "rotate(90deg)"
|
|
1817
|
+
});
|
|
1818
|
+
const callbackNameStyle = css({
|
|
1819
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1820
|
+
fontWeight: 600,
|
|
1821
|
+
color: "var(--omnispec-fg-primary)",
|
|
1822
|
+
flexShrink: 0
|
|
1823
|
+
});
|
|
1824
|
+
const urlExpressionStyle = css({
|
|
1825
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1826
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
1827
|
+
color: "var(--omnispec-fg-muted)",
|
|
1828
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
1829
|
+
padding: "0.125rem 0.375rem",
|
|
1830
|
+
borderRadius: "0.25rem",
|
|
1831
|
+
minWidth: 0,
|
|
1832
|
+
wordBreak: "break-all",
|
|
1833
|
+
[mq.desktop]: {
|
|
1834
|
+
wordBreak: "normal"
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
const cardBodyStyle = css({
|
|
1838
|
+
padding: "0",
|
|
1839
|
+
borderTop: "1px solid var(--omnispec-border-color)"
|
|
1840
|
+
});
|
|
1841
|
+
const summaryStyle$1 = css({
|
|
1842
|
+
margin: "0.75rem 1rem 0",
|
|
1843
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
1844
|
+
color: "var(--omnispec-fg-secondary)",
|
|
1845
|
+
lineHeight: 1.5
|
|
1846
|
+
});
|
|
1847
|
+
const descriptionStyle = css({
|
|
1848
|
+
margin: "0.5rem 1rem 0",
|
|
1849
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1850
|
+
color: "var(--omnispec-fg-secondary)",
|
|
1851
|
+
lineHeight: 1.5
|
|
1852
|
+
});
|
|
1853
|
+
const sectionStyle$1 = css({
|
|
1854
|
+
padding: "0.75rem 1rem",
|
|
1855
|
+
borderTop: "1px solid color-mix(in srgb, var(--omnispec-border-color) 60%, transparent)"
|
|
1856
|
+
});
|
|
1857
|
+
const sectionLabelStyle = css({
|
|
1858
|
+
display: "block",
|
|
1859
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
1860
|
+
fontWeight: 600,
|
|
1861
|
+
color: "var(--omnispec-fg-muted)",
|
|
1862
|
+
textTransform: "uppercase",
|
|
1863
|
+
letterSpacing: "0.05em",
|
|
1864
|
+
marginBottom: "0.5rem"
|
|
1865
|
+
});
|
|
1866
|
+
const responseListStyle$1 = css({
|
|
1867
|
+
display: "flex",
|
|
1868
|
+
flexDirection: "column",
|
|
1869
|
+
gap: "0.375rem"
|
|
1870
|
+
});
|
|
1871
|
+
const responseRowStyle = css({
|
|
1872
|
+
display: "flex",
|
|
1873
|
+
alignItems: "center",
|
|
1874
|
+
gap: "0.625rem"
|
|
1875
|
+
});
|
|
1876
|
+
const statusBadgeStyle$1 = css({
|
|
1877
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
1878
|
+
fontWeight: 700,
|
|
1879
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1880
|
+
padding: "0.125rem 0.5rem",
|
|
1881
|
+
borderRadius: "0.25rem",
|
|
1882
|
+
flexShrink: 0
|
|
1883
|
+
});
|
|
1884
|
+
const responseDescStyle$1 = css({
|
|
1885
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
1886
|
+
color: "var(--omnispec-fg-secondary)"
|
|
1887
|
+
});
|
|
1888
|
+
|
|
1889
|
+
function ExampleBlock({ media }) {
|
|
1890
|
+
const namedExamples = getNamedExamples(media);
|
|
1891
|
+
const [selectedExample, setSelectedExample] = useState(namedExamples[0]?.name ?? "");
|
|
1892
|
+
const activeExample = namedExamples.find((ex) => ex.name === selectedExample);
|
|
1893
|
+
const exampleValue = activeExample?.value;
|
|
1894
|
+
const displayCode = exampleValue !== void 0 ? typeof exampleValue === "string" ? exampleValue : JSON.stringify(exampleValue, null, 2) : media.schema ? JSON.stringify(generateExample(media.schema), null, 2) : "{}";
|
|
1895
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1896
|
+
/* @__PURE__ */ jsx(
|
|
1897
|
+
ExampleSelector,
|
|
1898
|
+
{
|
|
1899
|
+
examples: namedExamples,
|
|
1900
|
+
selectedName: selectedExample,
|
|
1901
|
+
onSelect: setSelectedExample
|
|
1902
|
+
}
|
|
1903
|
+
),
|
|
1904
|
+
/* @__PURE__ */ jsx(CodeBlock, { code: displayCode, language: "json" })
|
|
1905
|
+
] });
|
|
1906
|
+
}
|
|
1907
|
+
function OperationDetail({
|
|
1908
|
+
operation,
|
|
1909
|
+
paramExampleSelections,
|
|
1910
|
+
onParamExampleSelect
|
|
1911
|
+
}) {
|
|
1912
|
+
const opId = operation.operationId ?? `${operation.method}-${operation.path}`;
|
|
1913
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1914
|
+
operation.deprecated && /* @__PURE__ */ jsxs("div", { className: deprecatedBannerStyle, role: "alert", children: [
|
|
1915
|
+
/* @__PURE__ */ jsx(Icon, { name: "warning", size: "1rem" }),
|
|
1916
|
+
/* @__PURE__ */ jsx("span", { children: "This operation is deprecated and may be removed in a future release. Avoid using it in new integrations." })
|
|
1917
|
+
] }),
|
|
1918
|
+
operation.summary && /* @__PURE__ */ jsx("p", { className: summaryStyle, children: operation.summary }),
|
|
1919
|
+
operation.externalDocs && /* @__PURE__ */ jsxs(
|
|
1920
|
+
"a",
|
|
1921
|
+
{
|
|
1922
|
+
href: operation.externalDocs.url,
|
|
1923
|
+
target: "_blank",
|
|
1924
|
+
rel: "noopener noreferrer",
|
|
1925
|
+
className: externalDocsLinkStyle,
|
|
1926
|
+
children: [
|
|
1927
|
+
operation.externalDocs.description ?? "External docs",
|
|
1928
|
+
/* @__PURE__ */ jsx("span", { className: externalDocsArrowStyle$1, children: "\u2197" })
|
|
1929
|
+
]
|
|
1930
|
+
}
|
|
1931
|
+
),
|
|
1932
|
+
operation.description && /* @__PURE__ */ jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: operation.description }) }),
|
|
1933
|
+
operation.security && operation.security.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
1934
|
+
/* @__PURE__ */ jsx(LinkableHeading, { id: `${opId}-security`, as: "h4", className: sectionTitleStyle, children: "Security" }),
|
|
1935
|
+
/* @__PURE__ */ jsx("div", { className: securitySchemesList, children: operation.security.map((schemes, idx) => /* @__PURE__ */ jsxs("div", { className: securitySchemesRow, children: [
|
|
1936
|
+
schemes.map((scheme) => /* @__PURE__ */ jsxs("span", { className: securitySchemeBadge, children: [
|
|
1937
|
+
/* @__PURE__ */ jsx(Icon, { name: "lock", size: "0.625rem", strokeWidth: 2.5 }),
|
|
1938
|
+
scheme
|
|
1939
|
+
] }, scheme)),
|
|
1940
|
+
idx < operation.security.length - 1 && /* @__PURE__ */ jsx("span", { className: securityOrLabel, children: "or" })
|
|
1941
|
+
] }, idx)) })
|
|
1942
|
+
] }),
|
|
1943
|
+
operation.parameters.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
1944
|
+
/* @__PURE__ */ jsx(LinkableHeading, { id: `${opId}-parameters`, as: "h4", className: sectionTitleStyle, children: "Parameters" }),
|
|
1945
|
+
/* @__PURE__ */ jsx("div", { className: paramListStyle, children: operation.parameters.map((param) => {
|
|
1946
|
+
const paramKey = `${param.in}-${param.name}`;
|
|
1947
|
+
const paramSchema = param.schema ?? {};
|
|
1948
|
+
const constraintBadges = buildConstraints(paramSchema);
|
|
1949
|
+
const paramFormat = paramSchema.format;
|
|
1950
|
+
const paramEnum = paramSchema.enum;
|
|
1951
|
+
const namedExamples = param.examples ? Object.entries(param.examples).map(([name, ex]) => ({
|
|
1952
|
+
name,
|
|
1953
|
+
summary: ex.summary,
|
|
1954
|
+
value: ex.value
|
|
1955
|
+
})) : [];
|
|
1956
|
+
const selectedName = paramExampleSelections?.[paramKey] ?? namedExamples[0]?.name ?? "";
|
|
1957
|
+
const activeExample = namedExamples.find((ex) => ex.name === selectedName);
|
|
1958
|
+
return /* @__PURE__ */ jsxs("div", { className: paramRowStyle, children: [
|
|
1959
|
+
/* @__PURE__ */ jsxs("div", { className: paramHeaderStyle, children: [
|
|
1960
|
+
/* @__PURE__ */ jsx("span", { className: paramNameStyle, children: param.name }),
|
|
1961
|
+
/* @__PURE__ */ jsx("pre", { className: typeBadgeStyle, children: param.schema?.type ?? "any" }),
|
|
1962
|
+
param.required && /* @__PURE__ */ jsx("span", { className: requiredBadgeStyle, children: "Required" }),
|
|
1963
|
+
/* @__PURE__ */ jsx("span", { className: inBadgeStyle, children: param.in })
|
|
1964
|
+
] }),
|
|
1965
|
+
(paramFormat || constraintBadges.length > 0 || paramEnum && paramEnum.length > 0) && /* @__PURE__ */ jsxs("div", { className: paramConstraintsStyle, children: [
|
|
1966
|
+
paramFormat && /* @__PURE__ */ jsx("span", { className: paramConstraintBadgeStyle, children: paramFormat }),
|
|
1967
|
+
constraintBadges.map((c) => /* @__PURE__ */ jsx("span", { className: paramConstraintBadgeStyle, children: c }, c)),
|
|
1968
|
+
paramEnum && paramEnum.length > 0 && /* @__PURE__ */ jsxs("span", { className: paramEnumBadgeStyle, children: [
|
|
1969
|
+
"enum: ",
|
|
1970
|
+
paramEnum.map(String).join(" | ")
|
|
1971
|
+
] })
|
|
1972
|
+
] }),
|
|
1973
|
+
param.description && /* @__PURE__ */ jsx("p", { className: paramDescStyle, children: param.description }),
|
|
1974
|
+
namedExamples.length > 1 && /* @__PURE__ */ jsx(
|
|
1975
|
+
ExampleSelector,
|
|
1976
|
+
{
|
|
1977
|
+
examples: namedExamples,
|
|
1978
|
+
selectedName,
|
|
1979
|
+
onSelect: (name) => onParamExampleSelect?.(paramKey, name)
|
|
1980
|
+
}
|
|
1981
|
+
),
|
|
1982
|
+
activeExample?.value !== void 0 && /* @__PURE__ */ jsx("code", { className: paramExampleValueStyle, children: typeof activeExample.value === "string" ? activeExample.value : JSON.stringify(activeExample.value) })
|
|
1983
|
+
] }, paramKey);
|
|
1984
|
+
}) })
|
|
1985
|
+
] }),
|
|
1986
|
+
operation.requestBody && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
1987
|
+
/* @__PURE__ */ jsxs(LinkableHeading, { id: `${opId}-request-body`, as: "h4", className: sectionTitleStyle, children: [
|
|
1988
|
+
"Request Body",
|
|
1989
|
+
operation.requestBody.required && /* @__PURE__ */ jsx("span", { className: requiredBadgeStyle, children: " Required" })
|
|
1990
|
+
] }),
|
|
1991
|
+
operation.requestBody.description && /* @__PURE__ */ jsx("p", { className: paramDescStyle, children: operation.requestBody.description }),
|
|
1992
|
+
Object.entries(operation.requestBody.content).map(([contentType, media]) => /* @__PURE__ */ jsxs("div", { className: mediaTypeStyle, children: [
|
|
1993
|
+
/* @__PURE__ */ jsx("code", { className: contentTypeBadgeStyle, children: contentType }),
|
|
1994
|
+
media.schema && /* @__PURE__ */ jsx(
|
|
1995
|
+
Tabs,
|
|
1996
|
+
{
|
|
1997
|
+
tabs: [
|
|
1998
|
+
{
|
|
1999
|
+
id: "schema",
|
|
2000
|
+
label: "Schema",
|
|
2001
|
+
content: /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(media.schema), context: "request" })
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
id: "example",
|
|
2005
|
+
label: "Example",
|
|
2006
|
+
content: /* @__PURE__ */ jsx(ExampleBlock, { media })
|
|
2007
|
+
}
|
|
2008
|
+
]
|
|
2009
|
+
}
|
|
2010
|
+
)
|
|
2011
|
+
] }, contentType))
|
|
2012
|
+
] }),
|
|
2013
|
+
operation.responses.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
2014
|
+
/* @__PURE__ */ jsx(LinkableHeading, { id: `${opId}-responses`, as: "h4", className: sectionTitleStyle, children: "Responses" }),
|
|
2015
|
+
/* @__PURE__ */ jsx("div", { className: responseListStyle, children: operation.responses.map((response) => /* @__PURE__ */ jsxs("div", { className: responseCardStyle, children: [
|
|
2016
|
+
/* @__PURE__ */ jsxs("div", { className: responseHeaderStyle, children: [
|
|
2017
|
+
/* @__PURE__ */ jsx("span", { className: cx(statusBadgeStyle, css({
|
|
2018
|
+
backgroundColor: getStatusBg(response.statusCode),
|
|
2019
|
+
color: getStatusColor(response.statusCode)
|
|
2020
|
+
})), children: response.statusCode }),
|
|
2021
|
+
/* @__PURE__ */ jsx("span", { className: responseDescStyle, children: response.description })
|
|
2022
|
+
] }),
|
|
2023
|
+
response.headers && Object.keys(response.headers).length > 0 && /* @__PURE__ */ jsxs("div", { className: responseHeadersSection, children: [
|
|
2024
|
+
/* @__PURE__ */ jsx("span", { className: responseHeadersLabel, children: "Headers" }),
|
|
2025
|
+
/* @__PURE__ */ jsx("div", { className: responseHeadersList, children: Object.entries(response.headers).map(([headerName, header]) => /* @__PURE__ */ jsxs("div", { className: responseHeaderWrapper, children: [
|
|
2026
|
+
/* @__PURE__ */ jsxs("div", { className: responseHeaderRow, children: [
|
|
2027
|
+
/* @__PURE__ */ jsx("span", { className: responseHeaderName, children: headerName }),
|
|
2028
|
+
header.schema && /* @__PURE__ */ jsx("pre", { className: typeBadgeStyle, children: header.schema.type ?? "string" })
|
|
2029
|
+
] }),
|
|
2030
|
+
header.description && /* @__PURE__ */ jsx("div", { className: responseHeaderDesc, children: header.description })
|
|
2031
|
+
] }, headerName)) })
|
|
2032
|
+
] }),
|
|
2033
|
+
response.content && Object.entries(response.content).map(([contentType, media]) => {
|
|
2034
|
+
const hasNamedExamples = getNamedExamples(media).length > 0;
|
|
2035
|
+
const hasSchema = !!media.schema;
|
|
2036
|
+
const hasExample = hasNamedExamples;
|
|
2037
|
+
if (!hasSchema && !hasExample) return null;
|
|
2038
|
+
const tabs = [];
|
|
2039
|
+
if (hasSchema) {
|
|
2040
|
+
tabs.push({
|
|
2041
|
+
id: `schema-${response.statusCode}-${contentType}`,
|
|
2042
|
+
label: "Schema",
|
|
2043
|
+
content: /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(media.schema), context: "response" })
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
if (hasExample || hasSchema) {
|
|
2047
|
+
tabs.push({
|
|
2048
|
+
id: `example-${response.statusCode}-${contentType}`,
|
|
2049
|
+
label: "Example",
|
|
2050
|
+
content: /* @__PURE__ */ jsx(ExampleBlock, { media })
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
return /* @__PURE__ */ jsxs("div", { className: mediaTypeStyle, children: [
|
|
2054
|
+
/* @__PURE__ */ jsx("code", { className: contentTypeLabel, children: contentType }),
|
|
2055
|
+
/* @__PURE__ */ jsx(Tabs, { tabs, defaultTab: hasExample && !hasSchema ? tabs[0]?.id : void 0 })
|
|
2056
|
+
] }, contentType);
|
|
2057
|
+
})
|
|
2058
|
+
] }, response.statusCode)) })
|
|
2059
|
+
] }),
|
|
2060
|
+
operation.callbacks && Object.keys(operation.callbacks).length > 0 && /* @__PURE__ */ jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsx(CallbacksSection, { callbacks: operation.callbacks }) })
|
|
2061
|
+
] });
|
|
2062
|
+
}
|
|
2063
|
+
function getStatusColor(code) {
|
|
2064
|
+
const num = parseInt(code, 10);
|
|
2065
|
+
if (num >= 200 && num < 300) return "var(--omnispec-color-success)";
|
|
2066
|
+
if (num >= 300 && num < 400) return "var(--omnispec-color-info)";
|
|
2067
|
+
if (num >= 400 && num < 500) return "var(--omnispec-color-warning)";
|
|
2068
|
+
if (num >= 500) return "var(--omnispec-color-error)";
|
|
2069
|
+
return "var(--omnispec-fg-primary)";
|
|
2070
|
+
}
|
|
2071
|
+
function getStatusBg(code) {
|
|
2072
|
+
const num = parseInt(code, 10);
|
|
2073
|
+
if (num >= 200 && num < 300) return "rgba(26, 127, 55, 0.1)";
|
|
2074
|
+
if (num >= 300 && num < 400) return "rgba(5, 80, 174, 0.1)";
|
|
2075
|
+
if (num >= 400 && num < 500) return "rgba(191, 135, 0, 0.1)";
|
|
2076
|
+
if (num >= 500) return "rgba(207, 34, 46, 0.1)";
|
|
2077
|
+
return "var(--omnispec-bg-tertiary)";
|
|
2078
|
+
}
|
|
2079
|
+
const summaryStyle = css({
|
|
2080
|
+
margin: "0 0 16px",
|
|
2081
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
2082
|
+
color: "var(--omnispec-fg-secondary)",
|
|
2083
|
+
lineHeight: 1.5
|
|
2084
|
+
});
|
|
2085
|
+
const sectionStyle = css({
|
|
2086
|
+
marginBottom: "24px"
|
|
2087
|
+
});
|
|
2088
|
+
const sectionTitleStyle = css({
|
|
2089
|
+
margin: "0 0 12px",
|
|
2090
|
+
fontSize: "var(--omnispec-font-size-md)",
|
|
2091
|
+
fontWeight: 700,
|
|
2092
|
+
color: "var(--omnispec-fg-primary)",
|
|
2093
|
+
letterSpacing: "0.02em"
|
|
2094
|
+
});
|
|
2095
|
+
const paramListStyle = css({
|
|
2096
|
+
display: "flex",
|
|
2097
|
+
flexDirection: "column"
|
|
2098
|
+
});
|
|
2099
|
+
const paramRowStyle = css({
|
|
2100
|
+
padding: "12px 0"
|
|
2101
|
+
});
|
|
2102
|
+
const paramHeaderStyle = css({
|
|
2103
|
+
display: "flex",
|
|
2104
|
+
alignItems: "center",
|
|
2105
|
+
gap: "8px",
|
|
2106
|
+
flexWrap: "wrap"
|
|
2107
|
+
});
|
|
2108
|
+
const paramNameStyle = css({
|
|
2109
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2110
|
+
fontWeight: 700,
|
|
2111
|
+
backgroundColor: "transparent",
|
|
2112
|
+
padding: 0
|
|
2113
|
+
});
|
|
2114
|
+
const typeBadgeStyle = css({
|
|
2115
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2116
|
+
fontWeight: 400
|
|
2117
|
+
});
|
|
2118
|
+
const requiredBadgeStyle = css({
|
|
2119
|
+
fontSize: "var(--omnispec-font-size-xxs)",
|
|
2120
|
+
fontWeight: 600,
|
|
2121
|
+
color: "var(--omnispec-color-error)",
|
|
2122
|
+
textTransform: "uppercase",
|
|
2123
|
+
letterSpacing: "0.05em"
|
|
2124
|
+
});
|
|
2125
|
+
const inBadgeStyle = css({
|
|
2126
|
+
fontSize: "var(--omnispec-font-size-xxs)",
|
|
2127
|
+
color: "var(--omnispec-fg-muted)",
|
|
2128
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
2129
|
+
padding: "1px 6px",
|
|
2130
|
+
borderRadius: "3px",
|
|
2131
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
2132
|
+
});
|
|
2133
|
+
const paramDescStyle = css({
|
|
2134
|
+
margin: "4px 0 0",
|
|
2135
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
2136
|
+
color: "var(--omnispec-fg-secondary)",
|
|
2137
|
+
lineHeight: 1.5
|
|
2138
|
+
});
|
|
2139
|
+
const deprecatedBannerStyle = css({
|
|
2140
|
+
display: "flex",
|
|
2141
|
+
alignItems: "flex-start",
|
|
2142
|
+
gap: "0.5rem",
|
|
2143
|
+
padding: "0.625rem 0.75rem",
|
|
2144
|
+
marginBottom: "1rem",
|
|
2145
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
2146
|
+
backgroundColor: "color-mix(in srgb, var(--omnispec-color-warning) 12%, transparent)",
|
|
2147
|
+
color: "var(--omnispec-color-warning)",
|
|
2148
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2149
|
+
lineHeight: 1.4
|
|
2150
|
+
});
|
|
2151
|
+
const paramConstraintsStyle = css({
|
|
2152
|
+
display: "flex",
|
|
2153
|
+
flexWrap: "wrap",
|
|
2154
|
+
gap: "0.375rem",
|
|
2155
|
+
marginTop: "0.375rem"
|
|
2156
|
+
});
|
|
2157
|
+
const paramConstraintBadgeStyle = css({
|
|
2158
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2159
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2160
|
+
color: "var(--omnispec-fg-muted)",
|
|
2161
|
+
backgroundColor: "var(--omnispec-bg-secondary)",
|
|
2162
|
+
padding: "0.0625rem 0.375rem",
|
|
2163
|
+
borderRadius: "var(--omnispec-border-radius)"
|
|
2164
|
+
});
|
|
2165
|
+
const paramEnumBadgeStyle = css({
|
|
2166
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2167
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2168
|
+
color: "var(--omnispec-color-info)",
|
|
2169
|
+
backgroundColor: "var(--omnispec-bg-secondary)",
|
|
2170
|
+
padding: "0.0625rem 0.375rem",
|
|
2171
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
2172
|
+
wordBreak: "break-word"
|
|
2173
|
+
});
|
|
2174
|
+
const paramExampleValueStyle = css({
|
|
2175
|
+
display: "block",
|
|
2176
|
+
marginTop: "0.375rem",
|
|
2177
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2178
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2179
|
+
color: "var(--omnispec-fg-code)",
|
|
2180
|
+
wordBreak: "break-all"
|
|
2181
|
+
});
|
|
2182
|
+
const mediaTypeStyle = css({
|
|
2183
|
+
marginTop: "1rem",
|
|
2184
|
+
overflow: "hidden",
|
|
2185
|
+
minWidth: 0
|
|
2186
|
+
});
|
|
2187
|
+
const contentTypeLabel = css({
|
|
2188
|
+
display: "inline-block",
|
|
2189
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2190
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2191
|
+
color: "var(--omnispec-fg-muted)",
|
|
2192
|
+
marginBottom: "4px"
|
|
2193
|
+
});
|
|
2194
|
+
const contentTypeBadgeStyle = css({
|
|
2195
|
+
marginBottom: "8px",
|
|
2196
|
+
fontSize: "var(--omnispec-font-size-sm)"
|
|
2197
|
+
});
|
|
2198
|
+
const responseListStyle = css({
|
|
2199
|
+
display: "flex",
|
|
2200
|
+
flexDirection: "column",
|
|
2201
|
+
gap: "8px"
|
|
2202
|
+
});
|
|
2203
|
+
const responseCardStyle = css({
|
|
2204
|
+
minWidth: 0,
|
|
2205
|
+
[mq.desktop]: {
|
|
2206
|
+
padding: "0.625rem 1rem",
|
|
2207
|
+
borderRadius: "var(--omnispec-border-radius)",
|
|
2208
|
+
border: "1px solid color-mix(in srgb, var(--omnispec-border-color) 80%, transparent)"
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
const responseHeaderStyle = css({
|
|
2212
|
+
display: "flex",
|
|
2213
|
+
alignItems: "center",
|
|
2214
|
+
gap: "10px"
|
|
2215
|
+
});
|
|
2216
|
+
const statusBadgeStyle = css({
|
|
2217
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2218
|
+
fontWeight: 700,
|
|
2219
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2220
|
+
padding: "2px 8px",
|
|
2221
|
+
borderRadius: "4px"
|
|
2222
|
+
});
|
|
2223
|
+
const responseDescStyle = css({
|
|
2224
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2225
|
+
color: "var(--omnispec-fg-secondary)"
|
|
2226
|
+
});
|
|
2227
|
+
const securitySchemesList = css({
|
|
2228
|
+
display: "flex",
|
|
2229
|
+
gap: "8px"
|
|
2230
|
+
});
|
|
2231
|
+
const securitySchemesRow = css({
|
|
2232
|
+
display: "flex",
|
|
2233
|
+
alignItems: "center",
|
|
2234
|
+
gap: "6px",
|
|
2235
|
+
flexWrap: "wrap"
|
|
2236
|
+
});
|
|
2237
|
+
const securitySchemeBadge = css({
|
|
2238
|
+
display: "inline-flex",
|
|
2239
|
+
alignItems: "center",
|
|
2240
|
+
gap: "5px",
|
|
2241
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2242
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2243
|
+
color: "var(--omnispec-fg-primary)",
|
|
2244
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
2245
|
+
padding: "3px 10px",
|
|
2246
|
+
borderRadius: "4px",
|
|
2247
|
+
fontWeight: 500
|
|
2248
|
+
});
|
|
2249
|
+
const securityOrLabel = css({
|
|
2250
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2251
|
+
color: "var(--omnispec-fg-muted)",
|
|
2252
|
+
fontStyle: "italic"
|
|
2253
|
+
});
|
|
2254
|
+
const externalDocsLinkStyle = css({
|
|
2255
|
+
display: "inline-flex",
|
|
2256
|
+
alignItems: "center",
|
|
2257
|
+
gap: "4px",
|
|
2258
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2259
|
+
color: "var(--omnispec-fg-link)",
|
|
2260
|
+
textDecoration: "none",
|
|
2261
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
2262
|
+
padding: "3px 10px",
|
|
2263
|
+
borderRadius: "12px",
|
|
2264
|
+
fontWeight: 500,
|
|
2265
|
+
marginBottom: "12px",
|
|
2266
|
+
"&:hover": {
|
|
2267
|
+
textDecoration: "underline"
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
const externalDocsArrowStyle$1 = css({
|
|
2271
|
+
fontSize: "11px"
|
|
2272
|
+
});
|
|
2273
|
+
const responseHeadersSection = css({
|
|
2274
|
+
marginTop: "8px",
|
|
2275
|
+
paddingTop: "8px",
|
|
2276
|
+
borderTop: "1px dashed var(--omnispec-border-color)"
|
|
2277
|
+
});
|
|
2278
|
+
const responseHeadersLabel = css({
|
|
2279
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2280
|
+
fontWeight: 600,
|
|
2281
|
+
color: "var(--omnispec-fg-muted)",
|
|
2282
|
+
textTransform: "uppercase",
|
|
2283
|
+
letterSpacing: "0.05em",
|
|
2284
|
+
display: "block",
|
|
2285
|
+
marginBottom: "10px"
|
|
2286
|
+
});
|
|
2287
|
+
const responseHeadersList = css({
|
|
2288
|
+
display: "flex",
|
|
2289
|
+
flexDirection: "column",
|
|
2290
|
+
gap: "10px"
|
|
2291
|
+
});
|
|
2292
|
+
const responseHeaderWrapper = css({
|
|
2293
|
+
display: "flex",
|
|
2294
|
+
flexDirection: "column"
|
|
2295
|
+
});
|
|
2296
|
+
const responseHeaderRow = css({
|
|
2297
|
+
display: "flex",
|
|
2298
|
+
alignItems: "center",
|
|
2299
|
+
gap: "8px",
|
|
2300
|
+
padding: "4px 0"
|
|
2301
|
+
});
|
|
2302
|
+
const responseHeaderName = css({
|
|
2303
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2304
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2305
|
+
fontWeight: 600,
|
|
2306
|
+
color: "var(--omnispec-fg-primary)",
|
|
2307
|
+
backgroundColor: "transparent",
|
|
2308
|
+
padding: 0
|
|
2309
|
+
});
|
|
2310
|
+
const responseHeaderDesc = css({
|
|
2311
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2312
|
+
color: "var(--omnispec-fg-secondary)"
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2315
|
+
function EndpointCard({ operation, serverUrl, id, expandAll, expandGeneration }) {
|
|
2316
|
+
const { allowTryIt, displayMode, tryItLayout } = useConfig();
|
|
2317
|
+
const title = operation.summary || operation.operationId || operation.path;
|
|
2318
|
+
const paramCount = operation.parameters.length + (operation.requestBody ? 1 : 0);
|
|
2319
|
+
const rightLabel = paramCount > 0 ? `${paramCount} param${paramCount !== 1 ? "s" : ""}` : void 0;
|
|
2320
|
+
const [paramExampleSelections, setParamExampleSelections] = useState({});
|
|
2321
|
+
const tryItParams = operation.parameters.map((p) => {
|
|
2322
|
+
const schema = p.schema;
|
|
2323
|
+
const items = schema?.items;
|
|
2324
|
+
const itemsEnum = schema?.type === "array" && Array.isArray(items?.enum) ? items.enum.map(String) : void 0;
|
|
2325
|
+
const exampleValue = resolveParamExampleValue(p, paramExampleSelections[`${p.in}-${p.name}`]);
|
|
2326
|
+
return {
|
|
2327
|
+
name: p.name,
|
|
2328
|
+
in: p.in,
|
|
2329
|
+
required: p.required,
|
|
2330
|
+
description: p.description,
|
|
2331
|
+
type: schema?.type,
|
|
2332
|
+
format: schema?.format,
|
|
2333
|
+
enum: schema?.enum,
|
|
2334
|
+
itemsEnum,
|
|
2335
|
+
explode: p.explode,
|
|
2336
|
+
example: exampleValue !== null && exampleValue !== void 0 ? String(exampleValue) : void 0,
|
|
2337
|
+
default: schema?.default !== null && schema?.default !== void 0 ? String(schema.default) : void 0
|
|
2338
|
+
};
|
|
2339
|
+
});
|
|
2340
|
+
const requestBodyContentTypes = operation.requestBody?.content ? Object.keys(operation.requestBody.content) : void 0;
|
|
2341
|
+
const defaultContentType = requestBodyContentTypes?.[0];
|
|
2342
|
+
const defaultBodySchema = defaultContentType ? operation.requestBody?.content[defaultContentType]?.schema : void 0;
|
|
2343
|
+
const requestBodySchemas = operation.requestBody?.content ? Object.fromEntries(
|
|
2344
|
+
Object.entries(operation.requestBody.content).map(([ct, media]) => [
|
|
2345
|
+
ct,
|
|
2346
|
+
media.schema
|
|
2347
|
+
])
|
|
2348
|
+
) : void 0;
|
|
2349
|
+
const defaultBodyExample = defaultBodySchema ? JSON.stringify(generateExample(defaultBodySchema), null, 2) : void 0;
|
|
2350
|
+
const tryItPanelProps = {
|
|
2351
|
+
method: operation.method,
|
|
2352
|
+
path: operation.path,
|
|
2353
|
+
serverUrl,
|
|
2354
|
+
parameters: tryItParams,
|
|
2355
|
+
requestBodyContentTypes,
|
|
2356
|
+
defaultRequestBody: defaultBodyExample,
|
|
2357
|
+
requestBodySchema: defaultBodySchema,
|
|
2358
|
+
requestBodySchemas,
|
|
2359
|
+
security: operation.security,
|
|
2360
|
+
xCodeSamples: operation.xCodeSamples
|
|
2361
|
+
};
|
|
2362
|
+
return /* @__PURE__ */ jsxs(
|
|
2363
|
+
ExpandableCard,
|
|
2364
|
+
{
|
|
2365
|
+
id,
|
|
2366
|
+
title,
|
|
2367
|
+
rightLabel,
|
|
2368
|
+
deprecated: operation.deprecated,
|
|
2369
|
+
badges: operation.xBadges,
|
|
2370
|
+
expandAll,
|
|
2371
|
+
expandGeneration,
|
|
2372
|
+
children: [
|
|
2373
|
+
/* @__PURE__ */ jsx(
|
|
2374
|
+
MethodBar,
|
|
2375
|
+
{
|
|
2376
|
+
label: operation.method,
|
|
2377
|
+
path: operation.path,
|
|
2378
|
+
method: operation.method
|
|
2379
|
+
}
|
|
2380
|
+
),
|
|
2381
|
+
displayMode === "reference" ? /* @__PURE__ */ jsx(
|
|
2382
|
+
ReferenceLayout,
|
|
2383
|
+
{
|
|
2384
|
+
operationId: id ?? `${operation.method}-${operation.path}`,
|
|
2385
|
+
schema: /* @__PURE__ */ jsx(
|
|
2386
|
+
ReferenceOperationDetail,
|
|
2387
|
+
{
|
|
2388
|
+
operationId: id ?? `${operation.method}-${operation.path}`,
|
|
2389
|
+
description: operation.description,
|
|
2390
|
+
parameters: operation.parameters,
|
|
2391
|
+
requestBody: operation.requestBody,
|
|
2392
|
+
responses: operation.responses,
|
|
2393
|
+
security: operation.security
|
|
2394
|
+
}
|
|
2395
|
+
),
|
|
2396
|
+
samples: /* @__PURE__ */ jsx(
|
|
2397
|
+
SamplesPanel,
|
|
2398
|
+
{
|
|
2399
|
+
method: operation.method,
|
|
2400
|
+
path: operation.path,
|
|
2401
|
+
serverUrl,
|
|
2402
|
+
operationId: id ?? `${operation.method}-${operation.path}`,
|
|
2403
|
+
requestBodySchema: defaultBodySchema,
|
|
2404
|
+
requestBodyContentType: defaultContentType,
|
|
2405
|
+
responses: operation.responses
|
|
2406
|
+
}
|
|
2407
|
+
),
|
|
2408
|
+
tryIt: allowTryIt ? /* @__PURE__ */ jsx(TryItPanel, { ...tryItPanelProps }) : /* @__PURE__ */ jsx("div", {})
|
|
2409
|
+
}
|
|
2410
|
+
) : tryItLayout === "inline" ? (
|
|
2411
|
+
// Inline (compact only): operation detail spans full width, with the
|
|
2412
|
+
// Try-It console in a collapsed-by-default disclosure below it.
|
|
2413
|
+
/* @__PURE__ */ jsxs("div", { className: inlineWrapperStyle, children: [
|
|
2414
|
+
/* @__PURE__ */ jsx(
|
|
2415
|
+
OperationDetail,
|
|
2416
|
+
{
|
|
2417
|
+
operation,
|
|
2418
|
+
paramExampleSelections,
|
|
2419
|
+
onParamExampleSelect: (key, name) => setParamExampleSelections((prev) => ({ ...prev, [key]: name }))
|
|
2420
|
+
}
|
|
2421
|
+
),
|
|
2422
|
+
allowTryIt && /* @__PURE__ */ jsx(InlineTryIt, { ...tryItPanelProps })
|
|
2423
|
+
] })
|
|
2424
|
+
) : /* @__PURE__ */ jsx(
|
|
2425
|
+
ResponsiveColumns,
|
|
2426
|
+
{
|
|
2427
|
+
left: /* @__PURE__ */ jsx(
|
|
2428
|
+
OperationDetail,
|
|
2429
|
+
{
|
|
2430
|
+
operation,
|
|
2431
|
+
paramExampleSelections,
|
|
2432
|
+
onParamExampleSelect: (key, name) => setParamExampleSelections((prev) => ({ ...prev, [key]: name }))
|
|
2433
|
+
}
|
|
2434
|
+
),
|
|
2435
|
+
right: allowTryIt ? /* @__PURE__ */ jsx(TryItPanel, { ...tryItPanelProps }) : void 0,
|
|
2436
|
+
rightLabel: "Try It"
|
|
2437
|
+
}
|
|
2438
|
+
)
|
|
2439
|
+
]
|
|
2440
|
+
}
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
const inlineWrapperStyle = css({
|
|
2444
|
+
padding: "0.75rem 0",
|
|
2445
|
+
minWidth: 0,
|
|
2446
|
+
[mq.desktop]: {
|
|
2447
|
+
padding: "1rem 1.25rem"
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
function resolveParamExampleValue(param, selectedName) {
|
|
2451
|
+
if (param.examples && Object.keys(param.examples).length > 0) {
|
|
2452
|
+
if (selectedName && param.examples[selectedName]) {
|
|
2453
|
+
return param.examples[selectedName].value;
|
|
2454
|
+
}
|
|
2455
|
+
const first = Object.values(param.examples)[0];
|
|
2456
|
+
return first?.value;
|
|
2457
|
+
}
|
|
2458
|
+
return param.example;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
const TagGroup = memo(function TagGroup2({ tag, serverUrl, expandAll, expandGeneration }) {
|
|
2462
|
+
const title = /* @__PURE__ */ jsxs("span", { className: tagTitleStyle, children: [
|
|
2463
|
+
tag.displayName ?? tag.name,
|
|
2464
|
+
/* @__PURE__ */ jsx("span", { className: tagCountStyle, children: tag.operations.length })
|
|
2465
|
+
] });
|
|
2466
|
+
return /* @__PURE__ */ jsx("div", { className: `omnispec-tag-group ${tagContainerStyle}`, id: `tag-${tag.name}`, children: /* @__PURE__ */ jsxs(Collapsible, { title, defaultOpen: true, headerStyle: tagHeaderStyleObj, children: [
|
|
2467
|
+
tag.description && /* @__PURE__ */ jsx("div", { className: tagDescriptionStyle, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: tag.description }) }),
|
|
2468
|
+
tag.externalDocs && /* @__PURE__ */ jsxs(
|
|
2469
|
+
"a",
|
|
2470
|
+
{
|
|
2471
|
+
href: tag.externalDocs.url,
|
|
2472
|
+
target: "_blank",
|
|
2473
|
+
rel: "noopener noreferrer",
|
|
2474
|
+
className: externalDocsStyle,
|
|
2475
|
+
children: [
|
|
2476
|
+
tag.externalDocs.description ?? "External docs",
|
|
2477
|
+
/* @__PURE__ */ jsx("span", { className: externalDocsArrowStyle, children: "\u2197" })
|
|
2478
|
+
]
|
|
2479
|
+
}
|
|
2480
|
+
),
|
|
2481
|
+
/* @__PURE__ */ jsx("div", { className: tagOperationsStyle, children: tag.operations.map((op, idx) => /* @__PURE__ */ jsx(
|
|
2482
|
+
EndpointCard,
|
|
2483
|
+
{
|
|
2484
|
+
id: op.operationId ?? `${op.method}-${op.path}`,
|
|
2485
|
+
operation: op,
|
|
2486
|
+
serverUrl,
|
|
2487
|
+
expandAll,
|
|
2488
|
+
expandGeneration
|
|
2489
|
+
},
|
|
2490
|
+
op.operationId ?? `${op.method}-${op.path}-${idx}`
|
|
2491
|
+
)) })
|
|
2492
|
+
] }) });
|
|
2493
|
+
});
|
|
2494
|
+
const tagContainerStyle = css({
|
|
2495
|
+
marginBottom: "32px"
|
|
2496
|
+
});
|
|
2497
|
+
const tagHeaderStyleObj = {
|
|
2498
|
+
paddingBottom: "8px",
|
|
2499
|
+
borderBottom: "2px solid var(--omnispec-border-color)",
|
|
2500
|
+
marginBottom: "12px"
|
|
2501
|
+
};
|
|
2502
|
+
const tagTitleStyle = css({
|
|
2503
|
+
fontSize: "18px",
|
|
2504
|
+
fontWeight: 800,
|
|
2505
|
+
color: "var(--omnispec-fg-primary)",
|
|
2506
|
+
display: "flex",
|
|
2507
|
+
alignItems: "center",
|
|
2508
|
+
gap: "10px",
|
|
2509
|
+
letterSpacing: "-0.01em"
|
|
2510
|
+
});
|
|
2511
|
+
const tagCountStyle = css({
|
|
2512
|
+
fontSize: "11px",
|
|
2513
|
+
fontWeight: 500,
|
|
2514
|
+
color: "var(--omnispec-fg-muted)",
|
|
2515
|
+
backgroundColor: "var(--omnispec-bg-tertiary)",
|
|
2516
|
+
padding: "2px 8px",
|
|
2517
|
+
borderRadius: "10px",
|
|
2518
|
+
fontFamily: "var(--omnispec-font-mono)"
|
|
2519
|
+
});
|
|
2520
|
+
const tagDescriptionStyle = css({
|
|
2521
|
+
marginBottom: "16px",
|
|
2522
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2523
|
+
color: "var(--omnispec-fg-secondary)",
|
|
2524
|
+
lineHeight: 1.6
|
|
2525
|
+
});
|
|
2526
|
+
const externalDocsStyle = css({
|
|
2527
|
+
display: "inline-flex",
|
|
2528
|
+
alignItems: "center",
|
|
2529
|
+
gap: "0.25rem",
|
|
2530
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
2531
|
+
color: "var(--omnispec-fg-link)",
|
|
2532
|
+
textDecoration: "none",
|
|
2533
|
+
marginBottom: "1rem",
|
|
2534
|
+
"&:hover": {
|
|
2535
|
+
textDecoration: "underline"
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2538
|
+
const externalDocsArrowStyle = css({
|
|
2539
|
+
fontSize: "0.75em"
|
|
2540
|
+
});
|
|
2541
|
+
const tagOperationsStyle = css({
|
|
2542
|
+
display: "flex",
|
|
2543
|
+
flexDirection: "column"
|
|
2544
|
+
});
|
|
2545
|
+
|
|
2546
|
+
function ComponentsSection({ components, expandAll, expandGeneration }) {
|
|
2547
|
+
const schemas = Object.entries(components.schemas);
|
|
2548
|
+
if (schemas.length === 0) return null;
|
|
2549
|
+
return /* @__PURE__ */ jsxs("div", { className: `omnispec-components ${containerStyle$1}`, children: [
|
|
2550
|
+
/* @__PURE__ */ jsx(LinkableHeading, { id: "schemas", as: "h2", className: titleStyle$1, children: "Schemas" }),
|
|
2551
|
+
/* @__PURE__ */ jsx("div", { className: schemaWrapperStyle, children: schemas.map(([name, schema]) => /* @__PURE__ */ jsx("div", { className: schemaStyle, id: `schema-${name}`, children: /* @__PURE__ */ jsx(
|
|
2552
|
+
Collapsible,
|
|
2553
|
+
{
|
|
2554
|
+
title: /* @__PURE__ */ jsx("span", { className: schemaNameStyle, children: name }),
|
|
2555
|
+
defaultOpen: false,
|
|
2556
|
+
expandAll,
|
|
2557
|
+
expandGeneration,
|
|
2558
|
+
children: /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(schema) })
|
|
2559
|
+
}
|
|
2560
|
+
) }, name)) })
|
|
2561
|
+
] });
|
|
2562
|
+
}
|
|
2563
|
+
const containerStyle$1 = css({
|
|
2564
|
+
marginTop: "2rem",
|
|
2565
|
+
paddingTop: "1.5rem",
|
|
2566
|
+
borderTop: "1px solid var(--omnispec-border-color)",
|
|
2567
|
+
[mq.mobile]: {
|
|
2568
|
+
borderTop: "none",
|
|
2569
|
+
marginTop: "1.5rem",
|
|
2570
|
+
paddingTop: "1rem"
|
|
2571
|
+
}
|
|
2572
|
+
});
|
|
2573
|
+
const titleStyle$1 = css({
|
|
2574
|
+
margin: "0 0 16px",
|
|
2575
|
+
fontSize: "var(--omnispec-h2-font-size)",
|
|
2576
|
+
color: "var(--omnispec-h2-color)",
|
|
2577
|
+
fontWeight: 700
|
|
2578
|
+
});
|
|
2579
|
+
const schemaWrapperStyle = css({
|
|
2580
|
+
border: "1px solid var(--omnispec-border-color)",
|
|
2581
|
+
borderRadius: "0.5rem",
|
|
2582
|
+
padding: "1.5rem 1rem",
|
|
2583
|
+
minWidth: 0
|
|
2584
|
+
});
|
|
2585
|
+
const schemaStyle = css({
|
|
2586
|
+
marginBottom: "8px"
|
|
2587
|
+
});
|
|
2588
|
+
const schemaNameStyle = css({
|
|
2589
|
+
fontFamily: "var(--omnispec-font-mono)",
|
|
2590
|
+
fontSize: "var(--omnispec-font-size-base)",
|
|
2591
|
+
fontWeight: 600,
|
|
2592
|
+
color: "var(--omnispec-color-primary)",
|
|
2593
|
+
overflowWrap: "break-word",
|
|
2594
|
+
wordBreak: "break-all",
|
|
2595
|
+
"&:hover": {
|
|
2596
|
+
textDecoration: "none"
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
|
|
2600
|
+
function parseHash() {
|
|
2601
|
+
const hash = window.location.hash.slice(1);
|
|
2602
|
+
if (!hash || hash === "/") {
|
|
2603
|
+
return { view: "overview", operationId: null };
|
|
2604
|
+
}
|
|
2605
|
+
return { view: "operation", operationId: hash };
|
|
2606
|
+
}
|
|
2607
|
+
function useSegmentedRouter() {
|
|
2608
|
+
const [route, setRoute] = useState(parseHash);
|
|
2609
|
+
useEffect(() => {
|
|
2610
|
+
const onHashChange = () => setRoute(parseHash());
|
|
2611
|
+
window.addEventListener("hashchange", onHashChange);
|
|
2612
|
+
return () => window.removeEventListener("hashchange", onHashChange);
|
|
2613
|
+
}, []);
|
|
2614
|
+
const navigateToOperation = useCallback((operationId) => {
|
|
2615
|
+
window.location.hash = operationId;
|
|
2616
|
+
}, []);
|
|
2617
|
+
const navigateToOverview = useCallback(() => {
|
|
2618
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
2619
|
+
setRoute({ view: "overview", operationId: null });
|
|
2620
|
+
}, []);
|
|
2621
|
+
return { route, navigateToOperation, navigateToOverview };
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
function OperationView({ operation, serverUrl, onBack, tagName }) {
|
|
2625
|
+
const { allowTryIt, displayMode, tryItLayout } = useConfig();
|
|
2626
|
+
const title = operation.summary || operation.operationId || operation.path;
|
|
2627
|
+
const tryItParams = operation.parameters.map((p) => {
|
|
2628
|
+
const schema = p.schema;
|
|
2629
|
+
return {
|
|
2630
|
+
name: p.name,
|
|
2631
|
+
in: p.in,
|
|
2632
|
+
required: p.required,
|
|
2633
|
+
description: p.description,
|
|
2634
|
+
type: schema?.type,
|
|
2635
|
+
format: schema?.format,
|
|
2636
|
+
enum: schema?.enum,
|
|
2637
|
+
example: p.example !== null && p.example !== void 0 ? String(p.example) : void 0,
|
|
2638
|
+
default: schema?.default !== null && schema?.default !== void 0 ? String(schema.default) : void 0
|
|
2639
|
+
};
|
|
2640
|
+
});
|
|
2641
|
+
const requestBodyContentTypes = operation.requestBody?.content ? Object.keys(operation.requestBody.content) : void 0;
|
|
2642
|
+
const defaultContentType = requestBodyContentTypes?.[0];
|
|
2643
|
+
const defaultBodySchema = defaultContentType ? operation.requestBody?.content[defaultContentType]?.schema : void 0;
|
|
2644
|
+
const defaultBodyExample = defaultBodySchema ? JSON.stringify(generateExample(defaultBodySchema), null, 2) : void 0;
|
|
2645
|
+
const tryItPanelProps = {
|
|
2646
|
+
method: operation.method,
|
|
2647
|
+
path: operation.path,
|
|
2648
|
+
serverUrl,
|
|
2649
|
+
parameters: tryItParams,
|
|
2650
|
+
requestBodyContentTypes,
|
|
2651
|
+
defaultRequestBody: defaultBodyExample,
|
|
2652
|
+
requestBodySchema: defaultBodySchema,
|
|
2653
|
+
xCodeSamples: operation.xCodeSamples
|
|
2654
|
+
};
|
|
2655
|
+
return /* @__PURE__ */ jsxs("div", { className: containerStyle, children: [
|
|
2656
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: onBack, className: backBtnStyle, children: [
|
|
2657
|
+
"\u2190 ",
|
|
2658
|
+
tagName ?? "All Operations"
|
|
2659
|
+
] }),
|
|
2660
|
+
/* @__PURE__ */ jsx("h2", { className: titleStyle, children: title }),
|
|
2661
|
+
/* @__PURE__ */ jsx(
|
|
2662
|
+
MethodBar,
|
|
2663
|
+
{
|
|
2664
|
+
label: operation.method,
|
|
2665
|
+
path: operation.path,
|
|
2666
|
+
method: operation.method
|
|
2667
|
+
}
|
|
2668
|
+
),
|
|
2669
|
+
/* @__PURE__ */ jsx("div", { className: contentStyle, children: displayMode === "reference" ? /* @__PURE__ */ jsx(
|
|
2670
|
+
ReferenceLayout,
|
|
2671
|
+
{
|
|
2672
|
+
operationId: operation.operationId ?? `${operation.method}-${operation.path}`,
|
|
2673
|
+
schema: /* @__PURE__ */ jsx(
|
|
2674
|
+
ReferenceOperationDetail,
|
|
2675
|
+
{
|
|
2676
|
+
operationId: operation.operationId ?? `${operation.method}-${operation.path}`,
|
|
2677
|
+
description: operation.description,
|
|
2678
|
+
parameters: operation.parameters,
|
|
2679
|
+
requestBody: operation.requestBody,
|
|
2680
|
+
responses: operation.responses,
|
|
2681
|
+
security: operation.security
|
|
2682
|
+
}
|
|
2683
|
+
),
|
|
2684
|
+
samples: /* @__PURE__ */ jsx(
|
|
2685
|
+
SamplesPanel,
|
|
2686
|
+
{
|
|
2687
|
+
method: operation.method,
|
|
2688
|
+
path: operation.path,
|
|
2689
|
+
serverUrl,
|
|
2690
|
+
operationId: operation.operationId ?? `${operation.method}-${operation.path}`,
|
|
2691
|
+
requestBodySchema: defaultBodySchema,
|
|
2692
|
+
requestBodyContentType: defaultContentType,
|
|
2693
|
+
responses: operation.responses
|
|
2694
|
+
}
|
|
2695
|
+
),
|
|
2696
|
+
tryIt: allowTryIt ? /* @__PURE__ */ jsx(TryItPanel, { ...tryItPanelProps }) : /* @__PURE__ */ jsx("div", {})
|
|
2697
|
+
}
|
|
2698
|
+
) : tryItLayout === "inline" ? (
|
|
2699
|
+
// Inline (compact only): operation detail full-width, Try-It console in
|
|
2700
|
+
// a collapsed-by-default disclosure below it.
|
|
2701
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2702
|
+
/* @__PURE__ */ jsx(OperationDetail, { operation }),
|
|
2703
|
+
allowTryIt && /* @__PURE__ */ jsx(InlineTryIt, { ...tryItPanelProps })
|
|
2704
|
+
] })
|
|
2705
|
+
) : /* @__PURE__ */ jsx(
|
|
2706
|
+
ResponsiveColumns,
|
|
2707
|
+
{
|
|
2708
|
+
left: /* @__PURE__ */ jsx(OperationDetail, { operation }),
|
|
2709
|
+
right: allowTryIt ? /* @__PURE__ */ jsx(TryItPanel, { ...tryItPanelProps }) : void 0,
|
|
2710
|
+
rightLabel: "Try It"
|
|
2711
|
+
}
|
|
2712
|
+
) })
|
|
2713
|
+
] });
|
|
2714
|
+
}
|
|
2715
|
+
const containerStyle = css({
|
|
2716
|
+
padding: 0
|
|
2717
|
+
});
|
|
2718
|
+
const backBtnStyle = css({
|
|
2719
|
+
display: "inline-flex",
|
|
2720
|
+
alignItems: "center",
|
|
2721
|
+
gap: "0.25rem",
|
|
2722
|
+
background: "none",
|
|
2723
|
+
border: "none",
|
|
2724
|
+
cursor: "pointer",
|
|
2725
|
+
fontSize: "var(--omnispec-font-size-sm)",
|
|
2726
|
+
color: "var(--omnispec-fg-link)",
|
|
2727
|
+
padding: "0 0 0.75rem",
|
|
2728
|
+
fontWeight: 500,
|
|
2729
|
+
"&:hover": {
|
|
2730
|
+
textDecoration: "underline"
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
const titleStyle = css({
|
|
2734
|
+
fontSize: "var(--omnispec-h2-font-size)",
|
|
2735
|
+
fontWeight: "var(--omnispec-h2-font-weight)",
|
|
2736
|
+
color: "var(--omnispec-h2-color)",
|
|
2737
|
+
margin: "0 0 0.75rem"
|
|
2738
|
+
});
|
|
2739
|
+
const contentStyle = css({
|
|
2740
|
+
marginTop: "1rem"
|
|
2741
|
+
});
|
|
2742
|
+
|
|
2743
|
+
function SegmentedContent({
|
|
2744
|
+
route,
|
|
2745
|
+
parsedSpec,
|
|
2746
|
+
serverUrl,
|
|
2747
|
+
onBack,
|
|
2748
|
+
overviewContent
|
|
2749
|
+
}) {
|
|
2750
|
+
if (route.view === "overview" || !route.operationId) {
|
|
2751
|
+
return /* @__PURE__ */ jsx(Fragment, { children: overviewContent });
|
|
2752
|
+
}
|
|
2753
|
+
for (const tag of parsedSpec.tags) {
|
|
2754
|
+
for (const op of tag.operations) {
|
|
2755
|
+
const opId = op.operationId ?? `${op.method}-${op.path}`;
|
|
2756
|
+
if (opId === route.operationId) {
|
|
2757
|
+
return /* @__PURE__ */ jsx(
|
|
2758
|
+
OperationView,
|
|
2759
|
+
{
|
|
2760
|
+
operation: op,
|
|
2761
|
+
serverUrl,
|
|
2762
|
+
onBack,
|
|
2763
|
+
tagName: tag.displayName ?? tag.name
|
|
2764
|
+
}
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
return /* @__PURE__ */ jsx(Fragment, { children: overviewContent });
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2772
|
+
function operationMatchesSearch(op, lowercasedQuery) {
|
|
2773
|
+
return op.path.toLowerCase().includes(lowercasedQuery) || (op.summary?.toLowerCase().includes(lowercasedQuery) ?? false) || (op.description?.toLowerCase().includes(lowercasedQuery) ?? false) || (op.operationId?.toLowerCase().includes(lowercasedQuery) ?? false) || op.method.toLowerCase().includes(lowercasedQuery);
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
const OVERVIEW_NAV_ID = "__apidoc_overview__";
|
|
2777
|
+
let warnedTryItLayoutIgnored = false;
|
|
2778
|
+
function OpenApiSpec({
|
|
2779
|
+
spec,
|
|
2780
|
+
theme,
|
|
2781
|
+
proxyUrl,
|
|
2782
|
+
proxyHeaders,
|
|
2783
|
+
oauth,
|
|
2784
|
+
interactiveOAuth = true,
|
|
2785
|
+
allowTryIt = true,
|
|
2786
|
+
downloadLink,
|
|
2787
|
+
layout = "sidebar",
|
|
2788
|
+
sidebarPosition = "left",
|
|
2789
|
+
// Default `panel` (docked side column). Non-breaking: the prop was dead until
|
|
2790
|
+
// inline was implemented, so `panel` matches every consumer's current Try-It.
|
|
2791
|
+
tryItLayout = "panel",
|
|
2792
|
+
defaultExpandOperations = false,
|
|
2793
|
+
displayMode,
|
|
2794
|
+
schemaStyle,
|
|
2795
|
+
externalRefOrigins,
|
|
2796
|
+
serverUrl: serverUrlOverride,
|
|
2797
|
+
servers: serversOverride,
|
|
2798
|
+
tryItPersistTtl,
|
|
2799
|
+
navigationMode,
|
|
2800
|
+
pro,
|
|
2801
|
+
sidebarNav,
|
|
2802
|
+
slots = {},
|
|
2803
|
+
onSpecLoaded,
|
|
2804
|
+
onTryItRequest: _onTryItRequest,
|
|
2805
|
+
onTryItResponse: _onTryItResponse,
|
|
2806
|
+
className
|
|
2807
|
+
}) {
|
|
2808
|
+
const refOptions = useMemo(() => ({
|
|
2809
|
+
specUrl: typeof spec === "string" ? spec : void 0,
|
|
2810
|
+
externalRefOrigins
|
|
2811
|
+
}), [spec, externalRefOrigins]);
|
|
2812
|
+
const { data: parsedSpec, state } = useOpenApiSpec(spec, refOptions);
|
|
2813
|
+
const [selectedServer, setSelectedServer] = useState("");
|
|
2814
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
2815
|
+
const [allExpanded, setAllExpanded] = useState(defaultExpandOperations);
|
|
2816
|
+
const [expandGeneration, setExpandGeneration] = useState(0);
|
|
2817
|
+
const handleToggleExpand = useCallback(() => {
|
|
2818
|
+
setAllExpanded((prev) => !prev);
|
|
2819
|
+
setExpandGeneration((prev) => prev + 1);
|
|
2820
|
+
}, []);
|
|
2821
|
+
useMemo(() => {
|
|
2822
|
+
if (parsedSpec && onSpecLoaded) {
|
|
2823
|
+
onSpecLoaded({
|
|
2824
|
+
title: parsedSpec.title,
|
|
2825
|
+
version: parsedSpec.version,
|
|
2826
|
+
type: parsedSpec.specVersion.startsWith("2") ? SpecType.OPENAPI_2 : SpecType.OPENAPI_3
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2829
|
+
}, [parsedSpec, onSpecLoaded]);
|
|
2830
|
+
const specOrigin = useMemo(() => {
|
|
2831
|
+
if (typeof spec !== "string") return "";
|
|
2832
|
+
try {
|
|
2833
|
+
const parsed = new URL(spec, window.location.origin);
|
|
2834
|
+
return parsed.origin;
|
|
2835
|
+
} catch {
|
|
2836
|
+
return "";
|
|
2837
|
+
}
|
|
2838
|
+
}, [spec]);
|
|
2839
|
+
const resolveServerUrl = useCallback((url) => {
|
|
2840
|
+
if (url.startsWith("/") && specOrigin) {
|
|
2841
|
+
return specOrigin + url;
|
|
2842
|
+
}
|
|
2843
|
+
return url;
|
|
2844
|
+
}, [specOrigin]);
|
|
2845
|
+
const effectiveServers = useMemo(() => {
|
|
2846
|
+
if (serverUrlOverride) return [{ url: serverUrlOverride }];
|
|
2847
|
+
if (serversOverride?.length) {
|
|
2848
|
+
return serversOverride.map((s) => ({ url: s.url, description: s.description }));
|
|
2849
|
+
}
|
|
2850
|
+
return parsedSpec?.servers ?? [];
|
|
2851
|
+
}, [serverUrlOverride, serversOverride, parsedSpec]);
|
|
2852
|
+
const serverUrl = useMemo(() => {
|
|
2853
|
+
if (serverUrlOverride) return resolveServerUrl(serverUrlOverride);
|
|
2854
|
+
if (selectedServer) return resolveServerUrl(selectedServer);
|
|
2855
|
+
const first = effectiveServers[0];
|
|
2856
|
+
if (!first) return specOrigin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2857
|
+
let url = first.url;
|
|
2858
|
+
if (first.variables) {
|
|
2859
|
+
for (const [key, variable] of Object.entries(first.variables)) {
|
|
2860
|
+
if (variable.default) {
|
|
2861
|
+
url = url.replace(`{${key}}`, variable.default);
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
return resolveServerUrl(url);
|
|
2866
|
+
}, [serverUrlOverride, selectedServer, effectiveServers, specOrigin, resolveServerUrl]);
|
|
2867
|
+
const navItems = useMemo(() => {
|
|
2868
|
+
if (!parsedSpec) return [];
|
|
2869
|
+
const tagItemMap = /* @__PURE__ */ new Map();
|
|
2870
|
+
for (const tag of parsedSpec.tags) {
|
|
2871
|
+
tagItemMap.set(tag.name, {
|
|
2872
|
+
id: `tag-${tag.name}`,
|
|
2873
|
+
label: tag.displayName ?? tag.name,
|
|
2874
|
+
children: tag.operations.map((op) => ({
|
|
2875
|
+
id: op.operationId ?? `${op.method}-${op.path}`,
|
|
2876
|
+
label: op.summary ?? `${op.method.toUpperCase()} ${op.path}`,
|
|
2877
|
+
badge: op.method.toUpperCase(),
|
|
2878
|
+
badgeColor: `var(--omnispec-color-${op.method})`
|
|
2879
|
+
}))
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
let items;
|
|
2883
|
+
if (parsedSpec.tagGroups?.length) {
|
|
2884
|
+
items = parsedSpec.tagGroups.map((group) => ({
|
|
2885
|
+
id: `group-${group.name}`,
|
|
2886
|
+
label: group.name,
|
|
2887
|
+
children: group.tags.map((tagName) => tagItemMap.get(tagName)).filter(Boolean)
|
|
2888
|
+
}));
|
|
2889
|
+
} else {
|
|
2890
|
+
items = Array.from(tagItemMap.values());
|
|
2891
|
+
}
|
|
2892
|
+
if (parsedSpec.webhooks?.length) {
|
|
2893
|
+
items.push({
|
|
2894
|
+
id: "tag-Webhooks",
|
|
2895
|
+
label: "Webhooks",
|
|
2896
|
+
children: parsedSpec.webhooks.map((op) => ({
|
|
2897
|
+
id: op.operationId ?? `${op.method}-${op.path}`,
|
|
2898
|
+
label: op.summary ?? `${op.method.toUpperCase()} ${op.path}`,
|
|
2899
|
+
badge: op.method.toUpperCase(),
|
|
2900
|
+
badgeColor: `var(--omnispec-color-${op.method})`
|
|
2901
|
+
}))
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
if (parsedSpec.components && Object.keys(parsedSpec.components.schemas).length > 0) {
|
|
2905
|
+
items.push({
|
|
2906
|
+
id: "schemas",
|
|
2907
|
+
label: "Schemas",
|
|
2908
|
+
children: Object.keys(parsedSpec.components.schemas).map((name) => ({
|
|
2909
|
+
id: `schema-${name}`,
|
|
2910
|
+
label: name
|
|
2911
|
+
}))
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
return items;
|
|
2915
|
+
}, [parsedSpec]);
|
|
2916
|
+
const filteredTags = useMemo(() => {
|
|
2917
|
+
if (!parsedSpec || !searchQuery.trim()) return parsedSpec?.tags ?? [];
|
|
2918
|
+
const q = searchQuery.toLowerCase();
|
|
2919
|
+
return parsedSpec.tags.map((tag) => ({
|
|
2920
|
+
...tag,
|
|
2921
|
+
operations: tag.operations.filter((op) => operationMatchesSearch(op, q))
|
|
2922
|
+
})).filter((tag) => tag.operations.length > 0);
|
|
2923
|
+
}, [parsedSpec, searchQuery]);
|
|
2924
|
+
const webhooksTag = useMemo(() => {
|
|
2925
|
+
if (!parsedSpec?.webhooks?.length) return null;
|
|
2926
|
+
const q = searchQuery.trim().toLowerCase();
|
|
2927
|
+
const operations = q ? parsedSpec.webhooks.filter((op) => operationMatchesSearch(op, q)) : parsedSpec.webhooks;
|
|
2928
|
+
if (operations.length === 0) return null;
|
|
2929
|
+
return {
|
|
2930
|
+
name: "Webhooks",
|
|
2931
|
+
description: "Webhooks the API sends to registered subscribers.",
|
|
2932
|
+
operations
|
|
2933
|
+
};
|
|
2934
|
+
}, [parsedSpec, searchQuery]);
|
|
2935
|
+
const operationCount = useMemo(
|
|
2936
|
+
() => parsedSpec?.tags.reduce((sum, tag) => sum + tag.operations.length, 0) ?? 0,
|
|
2937
|
+
[parsedSpec]
|
|
2938
|
+
);
|
|
2939
|
+
const SEGMENTED_THRESHOLD = 50;
|
|
2940
|
+
const resolvedMode = useMemo(() => {
|
|
2941
|
+
if (navigationMode) return navigationMode;
|
|
2942
|
+
return operationCount > SEGMENTED_THRESHOLD ? "segmented" : "grouped";
|
|
2943
|
+
}, [navigationMode, operationCount]);
|
|
2944
|
+
const isSegmented = resolvedMode === "segmented";
|
|
2945
|
+
const resolvedDisplayMode = displayMode ?? "compact";
|
|
2946
|
+
const resolvedSchemaStyle = resolveSchemaStyle(schemaStyle, pro?.advancedSchemaStyles ?? false);
|
|
2947
|
+
useEffect(() => {
|
|
2948
|
+
if (process.env.NODE_ENV !== "production" && resolvedDisplayMode === "reference" && tryItLayout === "inline" && !warnedTryItLayoutIgnored) {
|
|
2949
|
+
warnedTryItLayoutIgnored = true;
|
|
2950
|
+
console.warn(
|
|
2951
|
+
"[omnispec] `tryItLayout: 'inline'` is ignored in reference display mode \u2014 reference mode renders Try-It as its own right-column tab."
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
}, [resolvedDisplayMode, tryItLayout]);
|
|
2955
|
+
const { route, navigateToOperation, navigateToOverview } = useSegmentedRouter();
|
|
2956
|
+
const { navigateTo } = useHashScroll(operationCount);
|
|
2957
|
+
const handleNavSelect = navigateTo;
|
|
2958
|
+
const handleSegmentedSelect = useCallback(
|
|
2959
|
+
(id) => {
|
|
2960
|
+
if (id === OVERVIEW_NAV_ID) {
|
|
2961
|
+
navigateToOverview();
|
|
2962
|
+
} else {
|
|
2963
|
+
navigateToOperation(id);
|
|
2964
|
+
}
|
|
2965
|
+
},
|
|
2966
|
+
[navigateToOverview, navigateToOperation]
|
|
2967
|
+
);
|
|
2968
|
+
const segmentedNavItems = useMemo(() => {
|
|
2969
|
+
if (!isSegmented) return navItems;
|
|
2970
|
+
return [
|
|
2971
|
+
{ id: OVERVIEW_NAV_ID, label: "Overview", icon: /* @__PURE__ */ jsx(Icon, { name: "home", size: "1rem" }) },
|
|
2972
|
+
...navItems
|
|
2973
|
+
];
|
|
2974
|
+
}, [isSegmented, navItems]);
|
|
2975
|
+
const navSectionIds = useMemo(() => flattenNavItemIds(navItems), [navItems]);
|
|
2976
|
+
const activeSection = useScrollSpy(navSectionIds);
|
|
2977
|
+
if (state.status === "loading") {
|
|
2978
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx("div", { className: cx("omnispec-openapi", className), children: /* @__PURE__ */ jsx(LoadingScreen, {}) }) });
|
|
2979
|
+
}
|
|
2980
|
+
if (state.status === "error") {
|
|
2981
|
+
return /* @__PURE__ */ jsx(
|
|
2982
|
+
SpecStatusScreen,
|
|
2983
|
+
{
|
|
2984
|
+
theme,
|
|
2985
|
+
layout,
|
|
2986
|
+
sidebarPosition,
|
|
2987
|
+
slots,
|
|
2988
|
+
sidebarNav,
|
|
2989
|
+
premiumThemingEnabled: pro?.premiumThemingEnabled ?? false,
|
|
2990
|
+
className: cx("omnispec-openapi", className),
|
|
2991
|
+
children: /* @__PURE__ */ jsx(ErrorMessage, { title: "Failed to load specification", message: state.error })
|
|
2992
|
+
}
|
|
2993
|
+
);
|
|
2994
|
+
}
|
|
2995
|
+
if (!parsedSpec) return null;
|
|
2996
|
+
const specNav = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2997
|
+
/* @__PURE__ */ jsx("div", { className: headingStyle, children: "Operations" }),
|
|
2998
|
+
/* @__PURE__ */ jsx(
|
|
2999
|
+
SearchBar,
|
|
3000
|
+
{
|
|
3001
|
+
placeholder: "Filter endpoints...",
|
|
3002
|
+
onSearch: setSearchQuery
|
|
3003
|
+
}
|
|
3004
|
+
),
|
|
3005
|
+
/* @__PURE__ */ jsx(
|
|
3006
|
+
NavTree,
|
|
3007
|
+
{
|
|
3008
|
+
items: segmentedNavItems,
|
|
3009
|
+
activeId: isSegmented ? route.operationId ?? OVERVIEW_NAV_ID : activeSection,
|
|
3010
|
+
onSelect: isSegmented ? handleSegmentedSelect : handleNavSelect,
|
|
3011
|
+
parentToggleOnly: isSegmented
|
|
3012
|
+
}
|
|
3013
|
+
)
|
|
3014
|
+
] });
|
|
3015
|
+
const sidebar = buildSidebar(sidebarNav, specNav);
|
|
3016
|
+
const resolvedDownloadLink = resolveDownloadLink(downloadLink, spec);
|
|
3017
|
+
return /* @__PURE__ */ jsx(ConfigProvider, { config: { proxyUrl, proxyHeaders, oauth, allowTryIt, layout, sidebarPosition, tryItLayout, defaultExpandOperations, displayMode: resolvedDisplayMode, schemaStyle: resolvedSchemaStyle, slots, proRenderers: pro?.renderers ?? /* @__PURE__ */ new Map(), premiumThemingEnabled: pro?.premiumThemingEnabled ?? false, interactiveAuth: pro?.interactiveAuth, interactiveOAuth, specKey: `${parsedSpec.title}@${parsedSpec.version}`, tryItPersistTtl }, children: /* @__PURE__ */ jsx(ExpandProvider, { expandAll: allExpanded, expandGeneration, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(AuthProvider, { schemes: parsedSpec.securitySchemes, children: /* @__PURE__ */ jsxs("div", { className: `omnispec-openapi ${className ?? ""}`, children: [
|
|
3018
|
+
/* @__PURE__ */ jsx(AuthPanelModal, { serverUrl }),
|
|
3019
|
+
/* @__PURE__ */ jsx(ErrorBoundary, { title: "Failed to render this API reference", children: /* @__PURE__ */ jsx(
|
|
3020
|
+
DocLayout,
|
|
3021
|
+
{
|
|
3022
|
+
layout,
|
|
3023
|
+
sidebarPosition,
|
|
3024
|
+
sidebar,
|
|
3025
|
+
sidebarHeader: slots.sidebarHeader ?? (parsedSpec.logo ? /* @__PURE__ */ jsx("a", { href: parsedSpec.logo.href ?? "#", className: logoLinkStyle, children: /* @__PURE__ */ jsx(
|
|
3026
|
+
"img",
|
|
3027
|
+
{
|
|
3028
|
+
src: parsedSpec.logo.url,
|
|
3029
|
+
alt: parsedSpec.logo.altText ?? "Logo",
|
|
3030
|
+
className: logoImgStyle,
|
|
3031
|
+
style: parsedSpec.logo.backgroundColor ? { backgroundColor: parsedSpec.logo.backgroundColor } : void 0
|
|
3032
|
+
}
|
|
3033
|
+
) }) : void 0),
|
|
3034
|
+
sidebarFooter: slots.sidebarFooter,
|
|
3035
|
+
header: slots.header,
|
|
3036
|
+
contentHeader: slots.contentHeader,
|
|
3037
|
+
footer: slots.footer,
|
|
3038
|
+
children: isSegmented ? /* @__PURE__ */ jsx(
|
|
3039
|
+
SegmentedContent,
|
|
3040
|
+
{
|
|
3041
|
+
route,
|
|
3042
|
+
parsedSpec,
|
|
3043
|
+
serverUrl,
|
|
3044
|
+
onBack: navigateToOverview,
|
|
3045
|
+
overviewContent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3046
|
+
/* @__PURE__ */ jsx(
|
|
3047
|
+
SpecToolbar,
|
|
3048
|
+
{
|
|
3049
|
+
overview: /* @__PURE__ */ jsx(ApiOverview, { spec: parsedSpec }),
|
|
3050
|
+
versionBadge: /* @__PURE__ */ jsx(ApiVersionBadge, { version: parsedSpec.version }),
|
|
3051
|
+
expandLabel: "schemas",
|
|
3052
|
+
allExpanded,
|
|
3053
|
+
onToggleExpand: handleToggleExpand,
|
|
3054
|
+
downloadLink: resolvedDownloadLink
|
|
3055
|
+
}
|
|
3056
|
+
),
|
|
3057
|
+
/* @__PURE__ */ jsx(
|
|
3058
|
+
ServerSelector,
|
|
3059
|
+
{
|
|
3060
|
+
servers: effectiveServers,
|
|
3061
|
+
selectedUrl: serverUrl,
|
|
3062
|
+
onSelect: setSelectedServer
|
|
3063
|
+
}
|
|
3064
|
+
),
|
|
3065
|
+
/* @__PURE__ */ jsx(
|
|
3066
|
+
ComponentsSection,
|
|
3067
|
+
{
|
|
3068
|
+
components: parsedSpec.components,
|
|
3069
|
+
expandAll: allExpanded,
|
|
3070
|
+
expandGeneration
|
|
3071
|
+
}
|
|
3072
|
+
)
|
|
3073
|
+
] })
|
|
3074
|
+
}
|
|
3075
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3076
|
+
/* @__PURE__ */ jsx(
|
|
3077
|
+
SpecToolbar,
|
|
3078
|
+
{
|
|
3079
|
+
overview: /* @__PURE__ */ jsx(ApiOverview, { spec: parsedSpec }),
|
|
3080
|
+
versionBadge: /* @__PURE__ */ jsx(ApiVersionBadge, { version: parsedSpec.version }),
|
|
3081
|
+
expandLabel: "operations",
|
|
3082
|
+
allExpanded,
|
|
3083
|
+
onToggleExpand: handleToggleExpand,
|
|
3084
|
+
downloadLink: resolvedDownloadLink
|
|
3085
|
+
}
|
|
3086
|
+
),
|
|
3087
|
+
/* @__PURE__ */ jsx(
|
|
3088
|
+
ServerSelector,
|
|
3089
|
+
{
|
|
3090
|
+
servers: effectiveServers,
|
|
3091
|
+
selectedUrl: serverUrl,
|
|
3092
|
+
onSelect: setSelectedServer
|
|
3093
|
+
}
|
|
3094
|
+
),
|
|
3095
|
+
filteredTags.map((tag) => /* @__PURE__ */ jsx(
|
|
3096
|
+
TagGroup,
|
|
3097
|
+
{
|
|
3098
|
+
tag,
|
|
3099
|
+
serverUrl,
|
|
3100
|
+
expandAll: allExpanded,
|
|
3101
|
+
expandGeneration
|
|
3102
|
+
},
|
|
3103
|
+
tag.name
|
|
3104
|
+
)),
|
|
3105
|
+
webhooksTag && /* @__PURE__ */ jsx(
|
|
3106
|
+
TagGroup,
|
|
3107
|
+
{
|
|
3108
|
+
tag: webhooksTag,
|
|
3109
|
+
serverUrl,
|
|
3110
|
+
expandAll: allExpanded,
|
|
3111
|
+
expandGeneration
|
|
3112
|
+
},
|
|
3113
|
+
"__webhooks__"
|
|
3114
|
+
),
|
|
3115
|
+
/* @__PURE__ */ jsx(
|
|
3116
|
+
ComponentsSection,
|
|
3117
|
+
{
|
|
3118
|
+
components: parsedSpec.components,
|
|
3119
|
+
expandAll: allExpanded,
|
|
3120
|
+
expandGeneration
|
|
3121
|
+
}
|
|
3122
|
+
)
|
|
3123
|
+
] })
|
|
3124
|
+
}
|
|
3125
|
+
) })
|
|
3126
|
+
] }) }) }) }) });
|
|
3127
|
+
}
|
|
3128
|
+
const headingStyle = css({
|
|
3129
|
+
fontSize: "var(--omnispec-font-size-xs)",
|
|
3130
|
+
fontWeight: 700,
|
|
3131
|
+
textTransform: "uppercase",
|
|
3132
|
+
letterSpacing: "0.08em",
|
|
3133
|
+
color: "var(--omnispec-nav-heading-color)",
|
|
3134
|
+
padding: "1rem 0.75rem 0.25rem"
|
|
3135
|
+
});
|
|
3136
|
+
const logoLinkStyle = css({
|
|
3137
|
+
display: "block",
|
|
3138
|
+
padding: "0.75rem",
|
|
3139
|
+
textDecoration: "none"
|
|
3140
|
+
});
|
|
3141
|
+
const logoImgStyle = css({
|
|
3142
|
+
maxWidth: "100%",
|
|
3143
|
+
maxHeight: "4rem",
|
|
3144
|
+
objectFit: "contain"
|
|
3145
|
+
});
|
|
3146
|
+
|
|
3147
|
+
var OpenApiSpec$1 = /*#__PURE__*/Object.freeze({
|
|
3148
|
+
__proto__: null,
|
|
3149
|
+
OpenApiSpec: OpenApiSpec
|
|
3150
|
+
});
|
|
3151
|
+
|
|
3152
|
+
export { OpenApiSpec as O, authSchemeLabel as a, OpenApiSpec$1 as b };
|
|
3153
|
+
//# sourceMappingURL=OpenApiSpec-Cy-oW6jA.js.map
|