@redocly/openapi-docs 3.12.0 → 3.12.2
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/dist/redocly-openapi-docs.min.js +753 -750
- package/lib/components/ApiInfo/ApiInfo.js +29 -1
- package/lib/components/ApiInfo/Metadata.js +29 -1
- package/lib/components/ApiInfo/index.js +2 -1
- package/lib/components/ApiInfo/styled.js +16 -8
- package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
- package/lib/components/CallbackSamples/index.js +2 -1
- package/lib/components/Callbacks/CallbackDetails.js +17 -3
- package/lib/components/Callbacks/CallbackOperation.js +24 -3
- package/lib/components/Callbacks/CallbackSummary.js +19 -3
- package/lib/components/Callbacks/CallbacksList.js +16 -1
- package/lib/components/Callbacks/index.js +4 -1
- package/lib/components/Callbacks/styled.js +6 -3
- package/lib/components/Content/Content.js +10 -1
- package/lib/components/Content/index.js +2 -1
- package/lib/components/Content/useAutoScroll.js +50 -1
- package/lib/components/ContentItem/ContentItem.js +31 -1
- package/lib/components/ContentItem/index.js +2 -1
- package/lib/components/ContentItem/useIsExpanded.js +33 -1
- package/lib/components/ContentItems/ContentItems.js +19 -1
- package/lib/components/ContentItems/Items.js +13 -1
- package/lib/components/ContentItems/VirtualList.js +35 -1
- package/lib/components/ContentItems/helpers.js +49 -1
- package/lib/components/ContentItems/index.js +2 -1
- package/lib/components/ContentItems/useScrollOnRender.js +26 -1
- package/lib/components/Discriminator/Discriminator.js +27 -2
- package/lib/components/Discriminator/index.js +2 -1
- package/lib/components/Download/DownloadSpecification.js +46 -4
- package/lib/components/Download/index.js +2 -1
- package/lib/components/Download/types.js +2 -0
- package/lib/components/Download/useDownloadInfo.js +42 -1
- package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
- package/lib/components/ErrorBoundary/index.js +2 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
- package/lib/components/ExpandAllButton/index.js +2 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
- package/lib/components/ExternalDocumentation/index.js +2 -1
- package/lib/components/Language/LanguageDropdown.js +21 -1
- package/lib/components/Language/LanguageItem.js +33 -1
- package/lib/components/Language/LanguageList.js +93 -1
- package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
- package/lib/components/Language/constants.js +3 -1
- package/lib/components/Language/index.js +4 -1
- package/lib/components/Language/styled.js +29 -15
- package/lib/components/Markdown/Markdown.js +64 -1
- package/lib/components/Markdown/index.js +3 -1
- package/lib/components/Markdown/types.js +2 -0
- package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
- package/lib/components/MediaTypeSwitch/index.js +2 -1
- package/lib/components/OperationItem/Description.js +9 -1
- package/lib/components/OperationItem/OperationItem.js +70 -5
- package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
- package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
- package/lib/components/OperationItem/index.js +2 -1
- package/lib/components/OperationItem/types.js +2 -0
- package/lib/components/Overlay.js +48 -3
- package/lib/components/Overview/Overview.js +20 -1
- package/lib/components/Overview/index.js +2 -1
- package/lib/components/PageFooter/PageFooter.js +19 -1
- package/lib/components/PageFooter/index.js +2 -1
- package/lib/components/Panel/ResponsePanel.js +12 -6
- package/lib/components/Panel/Trigger.js +4 -2
- package/lib/components/Panel/index.js +3 -1
- package/lib/components/PanelItem/PanelItem.js +6 -1
- package/lib/components/PanelItem/index.js +3 -1
- package/lib/components/PanelItem/styled.js +20 -10
- package/lib/components/PayloadSamples/Example.js +6 -1
- package/lib/components/PayloadSamples/ExampleValue.js +30 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
- package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
- package/lib/components/PayloadSamples/index.js +7 -1
- package/lib/components/PayloadSamples/styled.js +9 -4
- package/lib/components/PayloadSamples/types.js +2 -0
- package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
- package/lib/components/PropertyDetails/EnumValues.js +37 -1
- package/lib/components/PropertyDetails/Examples.js +26 -1
- package/lib/components/PropertyDetails/Extensions.js +17 -2
- package/lib/components/PropertyDetails/FieldDetail.js +15 -2
- package/lib/components/PropertyDetails/FieldDetails.js +51 -6
- package/lib/components/PropertyDetails/Pattern.js +21 -1
- package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
- package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
- package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
- package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
- package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
- package/lib/components/PropertyDetails/index.js +4 -1
- package/lib/components/PropertyDetails/styled.js +15 -7
- package/lib/components/PropertyDetails/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
- package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
- package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
- package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
- package/lib/components/RenderHook/RenderHook.js +17 -1
- package/lib/components/RenderHook/index.js +2 -1
- package/lib/components/Replay/EmbeddedReplay.js +41 -3
- package/lib/components/Replay/Replay.js +99 -1
- package/lib/components/Replay/index.js +3 -1
- package/lib/components/Replay/utils.js +208 -1
- package/lib/components/Request/RequestDetails.js +33 -2
- package/lib/components/Request/types.js +2 -0
- package/lib/components/RequestParameters/Body.js +8 -1
- package/lib/components/RequestParameters/ParametersGroup.js +19 -4
- package/lib/components/RequestParameters/RequestParameters.js +40 -1
- package/lib/components/RequestParameters/index.js +4 -1
- package/lib/components/RequestSamples/CodeSample.js +55 -2
- package/lib/components/RequestSamples/Example.js +37 -1
- package/lib/components/RequestSamples/RequestSamples.js +89 -5
- package/lib/components/RequestSamples/index.js +3 -1
- package/lib/components/RequestSamples/useCodeSamples.js +92 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
- package/lib/components/ResponseSamples/Summary.js +9 -1
- package/lib/components/ResponseSamples/index.js +2 -1
- package/lib/components/Responses/OperationResponseList.js +42 -2
- package/lib/components/Responses/ResponseDetails.js +18 -1
- package/lib/components/Responses/ResponseHeaders.js +15 -1
- package/lib/components/Responses/index.js +6 -1
- package/lib/components/Responses/styled.js +14 -6
- package/lib/components/Responses/types.js +2 -0
- package/lib/components/RightPanel/RightPanel.js +21 -1
- package/lib/components/RightPanel/index.js +2 -1
- package/lib/components/Samples/ExampleSwitch.js +33 -1
- package/lib/components/Samples/index.js +3 -1
- package/lib/components/Samples/use-example-key.js +12 -1
- package/lib/components/Schema/ArraySchema.js +45 -1
- package/lib/components/Schema/ObjectSchema.js +29 -1
- package/lib/components/Schema/OneOfSchema.js +47 -3
- package/lib/components/Schema/RecursiveSchema.js +10 -1
- package/lib/components/Schema/Schema.js +63 -2
- package/lib/components/Schema/SubSchema.js +20 -1
- package/lib/components/Schema/helpers.js +16 -1
- package/lib/components/Schema/index.js +5 -1
- package/lib/components/Schema/types.js +2 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
- package/lib/components/SchemaDefinition/index.js +2 -1
- package/lib/components/SectionContent/SectionContent.js +49 -6
- package/lib/components/SectionContent/index.js +2 -1
- package/lib/components/SectionItem/SectionItem.js +14 -1
- package/lib/components/SectionItem/index.js +2 -1
- package/lib/components/Security/Divider.js +9 -2
- package/lib/components/Security/OAuthFlow.js +11 -1
- package/lib/components/Security/OAuthScopes.js +59 -9
- package/lib/components/Security/Security.js +15 -1
- package/lib/components/Security/SecurityButton.js +31 -7
- package/lib/components/Security/SecurityFlow.js +28 -4
- package/lib/components/Security/SecurityModal.js +34 -5
- package/lib/components/Security/SecuritySchemeItem.js +15 -4
- package/lib/components/Security/helper.js +16 -1
- package/lib/components/Security/index.js +11 -1
- package/lib/components/Security/styled.js +6 -3
- package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
- package/lib/components/SelectOrLabel/index.js +2 -1
- package/lib/components/ServerList/ServerList.js +36 -10
- package/lib/components/ServerList/index.js +2 -1
- package/lib/components/ServerList/types.js +2 -0
- package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
- package/lib/components/ServerListDropdown/index.js +2 -1
- package/lib/components/ServerListDropdown/styled.js +15 -6
- package/lib/components/SideMenu/SideMenu.js +13 -2
- package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
- package/lib/components/SideMenu/index.js +2 -1
- package/lib/components/SideMenu/types.js +2 -0
- package/lib/components/StickySidebar/SidebarActions.js +14 -2
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
- package/lib/components/StickySidebar/index.js +2 -1
- package/lib/components/Tabs/Tabs.js +16 -5
- package/lib/components/Tabs/index.js +3 -1
- package/lib/components/Tabs/useTabsState.js +22 -1
- package/lib/components/TagItem/OperationNavigationItems.js +18 -4
- package/lib/components/TagItem/OperationsNavigation.js +46 -2
- package/lib/components/TagItem/TagItem.js +40 -7
- package/lib/components/TagItem/index.js +2 -1
- package/lib/components/TagItem/styled.js +5 -2
- package/lib/components/TagItem/types.js +2 -0
- package/lib/components/ViewNested/ViewNested.js +42 -9
- package/lib/components/ViewNested/index.js +2 -1
- package/lib/components/common/Badges.js +21 -5
- package/lib/components/common/BodyContent/BodyContent.js +31 -4
- package/lib/components/common/BodyContent/index.js +2 -1
- package/lib/components/common/ClearButton/ClearButton.js +5 -1
- package/lib/components/common/ClearButton/index.js +3 -1
- package/lib/components/common/ClearButton/styled.js +5 -2
- package/lib/components/common/ClearButton/types.js +2 -0
- package/lib/components/common/CodeBlockPanel.js +7 -3
- package/lib/components/common/ConstraintsView.js +14 -2
- package/lib/components/common/Dropdown/Dropdown.js +22 -4
- package/lib/components/common/Dropdown/index.js +2 -1
- package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
- package/lib/components/common/ExpandableExample/index.js +2 -1
- package/lib/components/common/Extensions.js +17 -2
- package/lib/components/common/Fields/fields-layout.js +76 -51
- package/lib/components/common/Fields/fields.js +39 -17
- package/lib/components/common/Fields/index.js +3 -1
- package/lib/components/common/LinkToField.js +33 -6
- package/lib/components/common/OperationItemTitle.js +12 -6
- package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
- package/lib/components/common/SchemaSelection/index.js +2 -1
- package/lib/components/common/Select/Select.js +21 -1
- package/lib/components/common/Select/index.js +3 -1
- package/lib/components/common/Select/styled.js +17 -9
- package/lib/components/common/Select/types.js +2 -0
- package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
- package/lib/components/common/Skeleton/Skeleton.js +15 -5
- package/lib/components/common/Skeleton/index.js +3 -1
- package/lib/components/common/headers.js +4 -2
- package/lib/components/common/index.js +14 -1
- package/lib/components/common/linkify.js +28 -4
- package/lib/components/common/mixins.js +4 -2
- package/lib/components/common/panels.js +52 -29
- package/lib/components/common/schema.js +16 -8
- package/lib/components/common/styled.js +15 -7
- package/lib/components/index.js +25 -1
- package/lib/components/pluggable/RedocExample.js +20 -1
- package/lib/components/pluggable/RedocSchema.js +22 -1
- package/lib/components/pluggable/index.js +3 -1
- package/lib/components/pluggable/styled.components.js +9 -4
- package/lib/constants.js +30 -1
- package/lib/empty.js +7 -1
- package/lib/events/codeSampleCopy.js +19 -1
- package/lib/events/creator.js +5 -1
- package/lib/events/index.js +8 -1
- package/lib/events/languageSwitch.js +18 -1
- package/lib/events/panelToggle.js +16 -1
- package/lib/events/serverSwitch.js +13 -1
- package/lib/events/tryItOpen.js +12 -1
- package/lib/events/tryItSent.js +12 -1
- package/lib/events/types.js +11 -1
- package/lib/hoc/types.js +2 -0
- package/lib/hoc/utils.js +4 -1
- package/lib/hoc/withRouter.js +17 -1
- package/lib/hoc/withStore.js +28 -1
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/useActivateExample.js +35 -1
- package/lib/hooks/useActiveWithFallback.js +12 -1
- package/lib/hooks/useContentItems.js +10 -1
- package/lib/hooks/useLicense.js +17 -1
- package/lib/hooks/usePerformanceMetrics.js +26 -1
- package/lib/hooks/useRouter.js +17 -1
- package/lib/hooks/useTelemetry.js +5 -1
- package/lib/hooks/useTranslate.js +6 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
- package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
- package/lib/icons/CSharpIcon/index.js +2 -1
- package/lib/icons/CurlIcon/CurlIcon.js +8 -2
- package/lib/icons/CurlIcon/index.js +2 -1
- package/lib/icons/GOIcon/GOIcon.js +7 -1
- package/lib/icons/GOIcon/index.js +2 -1
- package/lib/icons/JavaIcon/JavaIcon.js +7 -1
- package/lib/icons/JavaIcon/index.js +2 -1
- package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
- package/lib/icons/JavaScriptIcon/index.js +2 -1
- package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
- package/lib/icons/NodeJSIcon/index.js +2 -1
- package/lib/icons/PHPIcon/PHPIcon.js +7 -1
- package/lib/icons/PHPIcon/index.js +2 -1
- package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
- package/lib/icons/PayloadIcon/index.js +2 -1
- package/lib/icons/PythonIcon/PythonIcon.js +7 -1
- package/lib/icons/PythonIcon/index.js +2 -1
- package/lib/icons/RIcon/RIcon.js +7 -1
- package/lib/icons/RIcon/index.js +2 -1
- package/lib/icons/RubyIcon/RubyIcon.js +7 -1
- package/lib/icons/RubyIcon/index.js +2 -1
- package/lib/index.js +49 -1
- package/lib/jotai/app.js +113 -1
- package/lib/jotai/operation.js +28 -1
- package/lib/jotai/replay.js +5 -1
- package/lib/jotai/store.js +8 -1
- package/lib/jotai/use-write-atom.js +9 -1
- package/lib/models/callback.js +28 -1
- package/lib/models/code-sample-options.js +2 -0
- package/lib/models/example.js +17 -1
- package/lib/models/field.js +109 -1
- package/lib/models/group.js +38 -1
- package/lib/models/index.js +14 -1
- package/lib/models/mediaContent.js +26 -1
- package/lib/models/mediaType.js +153 -1
- package/lib/models/operation.js +166 -1
- package/lib/models/request.js +25 -1
- package/lib/models/response.js +46 -1
- package/lib/models/schema.js +474 -2
- package/lib/models/security.js +84 -1
- package/lib/models/tab.js +2 -0
- package/lib/models/types.js +2 -0
- package/lib/services/OpenAPIParser.js +321 -1
- package/lib/services/check.js +104 -1
- package/lib/services/code-samples/constants.js +16 -1
- package/lib/services/code-samples/generator.js +540 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
- package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
- package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
- package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
- package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
- package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
- package/lib/services/code-samples/httpsnippet/index.js +166 -1
- package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
- package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
- package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
- package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
- package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
- package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
- package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
- package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
- package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
- package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
- package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
- package/lib/services/code-samples/index.js +3 -1
- package/lib/services/code-samples/types.js +2 -0
- package/lib/services/config-options/helpers.js +49 -1
- package/lib/services/config-options/index.js +3 -1
- package/lib/services/config-options/normalizeOptions.js +83 -1
- package/lib/services/config-options/types.js +2 -0
- package/lib/services/history/helpers.js +63 -1
- package/lib/services/history/index.js +2 -1
- package/lib/services/index.js +9 -1
- package/lib/services/menu/builder.js +47 -1
- package/lib/services/menu/index.js +2 -1
- package/lib/services/menu/markdown.js +93 -1
- package/lib/services/menu/operation.js +50 -1
- package/lib/services/menu/tags.js +166 -1
- package/lib/services/types.js +2 -0
- package/lib/services/utils.js +83 -1
- package/lib/standalone.js +68 -1
- package/lib/styled-components.js +6 -1
- package/lib/types/app.js +2 -0
- package/lib/types/index.js +4 -1
- package/lib/types/open-api.js +2 -0
- package/lib/types/security.js +2 -0
- package/lib/utils/JsonPointer.js +84 -1
- package/lib/utils/areArraysEqual.js +4 -1
- package/lib/utils/argValuesHelpers.js +35 -1
- package/lib/utils/compose.js +2 -1
- package/lib/utils/configure-helpers.js +223 -1
- package/lib/utils/convertSwagger2OpenAPI.js +14 -1
- package/lib/utils/cookies.js +73 -1
- package/lib/utils/debounce.js +22 -1
- package/lib/utils/debug.js +11 -1
- package/lib/utils/dom.js +65 -1
- package/lib/utils/environments.js +13 -1
- package/lib/utils/helpers.js +222 -12
- package/lib/utils/index.js +25 -1
- package/lib/utils/isMobile.js +13 -1
- package/lib/utils/loadAndBundleSpec.js +32 -1
- package/lib/utils/local-storage.js +12 -1
- package/lib/utils/object.js +31 -1
- package/lib/utils/openapi.js +592 -1
- package/lib/utils/parameters.js +13 -1
- package/lib/utils/path.js +22 -1
- package/lib/utils/queryString.js +60 -1
- package/lib/utils/replaceVariables.js +14 -1
- package/lib/utils/saveTextBeforeHeading.js +35 -1
- package/lib/utils/security-details.js +49 -1
- package/lib/utils/session-storage.js +12 -1
- package/lib/utils/simplifyAstStructure.js +22 -1
- package/lib/utils/sort.js +21 -1
- package/lib/utils/string.js +65 -1
- package/lib/utils/telemetry.js +7 -1
- package/lib/utils/test-utils.js +26 -1
- package/lib/utils/theme-helpers.js +24 -3
- package/lib/utils/url.js +38 -1
- package/package.json +4 -4
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{getMediaType
|
|
1
|
+
import { getMediaType } from './mediaType.js';
|
|
2
|
+
/**
|
|
3
|
+
* MediaContent model ready to be sued by React components
|
|
4
|
+
* Contains multiple MediaTypes and keeps track of the currently active one
|
|
5
|
+
*/
|
|
6
|
+
export function getMediaContent({ parser, info, isRequestType, options, data: { operation, type, response, absolutePointer = '' }, }) {
|
|
7
|
+
const mediaTypes = Object.keys(info).map((name) => getMediaType(parser, name, isRequestType, info[name], options, {
|
|
8
|
+
operation,
|
|
9
|
+
type,
|
|
10
|
+
response,
|
|
11
|
+
absolutePointer,
|
|
12
|
+
}));
|
|
13
|
+
const hasSample = mediaTypes.filter((mime) => !!mime.examples || !!mime.formExamples).length > 0;
|
|
14
|
+
return {
|
|
15
|
+
mediaTypes,
|
|
16
|
+
isRequestType,
|
|
17
|
+
hasSample,
|
|
18
|
+
operation,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function getActiveMediaType(content, activeMimeName) {
|
|
22
|
+
const mediaType = (activeMimeName && content.mediaTypes.find((type) => type.name === activeMimeName)) ||
|
|
23
|
+
content.mediaTypes[0];
|
|
24
|
+
return mediaType || {};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=mediaContent.js.map
|
package/lib/models/mediaType.js
CHANGED
|
@@ -1 +1,153 @@
|
|
|
1
|
-
import{getSchema
|
|
1
|
+
import { getSchema } from './schema.js';
|
|
2
|
+
import { isFormUrlEncoded, isJsonLike, isXmlLike, isMultipartFormData, JsonPointer, mapValues, } from '../utils/index.js';
|
|
3
|
+
import { getExamples } from './example.js';
|
|
4
|
+
import { safeSample } from '../services/code-samples/index.js';
|
|
5
|
+
function generateExamples({ parser, info: { encoding, schema: infoSchema }, schema, mime, options: { isRequestType, onlyRequiredInSamples, generatedSamplesMaxDepth, format = 'json' }, }) {
|
|
6
|
+
// FIXME: check warning in rebilly spec
|
|
7
|
+
const samplerOptions = {
|
|
8
|
+
skipReadOnly: isRequestType,
|
|
9
|
+
skipWriteOnly: !isRequestType,
|
|
10
|
+
skipNonRequired: isRequestType && onlyRequiredInSamples,
|
|
11
|
+
maxSampleDepth: generatedSamplesMaxDepth,
|
|
12
|
+
quiet: true,
|
|
13
|
+
format,
|
|
14
|
+
};
|
|
15
|
+
let examples = {};
|
|
16
|
+
if (schema && schema.oneOf) {
|
|
17
|
+
for (const subSchema of schema.oneOf) {
|
|
18
|
+
const sample = safeSample(subSchema.rawSchema, samplerOptions, parser.definition);
|
|
19
|
+
if (sample === null) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (schema.discriminatorProp &&
|
|
23
|
+
typeof sample === 'object' &&
|
|
24
|
+
sample &&
|
|
25
|
+
sample[schema.discriminatorProp] // handle case with readOnly with discriminator
|
|
26
|
+
) {
|
|
27
|
+
sample[schema.discriminatorProp] = subSchema.title;
|
|
28
|
+
}
|
|
29
|
+
examples[subSchema.title] = getExamples({
|
|
30
|
+
parser,
|
|
31
|
+
infoOrRef: {
|
|
32
|
+
value: sample,
|
|
33
|
+
},
|
|
34
|
+
mime,
|
|
35
|
+
encoding,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (schema) {
|
|
40
|
+
const sample = safeSample(infoSchema, samplerOptions, parser.definition);
|
|
41
|
+
if (sample !== null) {
|
|
42
|
+
examples = {
|
|
43
|
+
default: getExamples({
|
|
44
|
+
parser,
|
|
45
|
+
infoOrRef: {
|
|
46
|
+
value: sample,
|
|
47
|
+
},
|
|
48
|
+
mime,
|
|
49
|
+
encoding,
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
examples = {
|
|
55
|
+
default: {
|
|
56
|
+
value: null,
|
|
57
|
+
rawValue: 'null',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// default to {} example when schema is not defined
|
|
64
|
+
examples = {
|
|
65
|
+
default: {
|
|
66
|
+
value: null,
|
|
67
|
+
rawValue: 'null',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return examples;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @param parser
|
|
75
|
+
* @param name
|
|
76
|
+
* @param isRequestType needed to know if skip RO/RW fields in objects
|
|
77
|
+
* @param info
|
|
78
|
+
* @param options
|
|
79
|
+
* @param operation
|
|
80
|
+
* @param type
|
|
81
|
+
* @param response
|
|
82
|
+
*/
|
|
83
|
+
export function getMediaType(parser, name, isRequestType, info, options, { operation, type, response, absolutePointer = '', }) {
|
|
84
|
+
let examples;
|
|
85
|
+
let formExamples;
|
|
86
|
+
const schema = info.schema &&
|
|
87
|
+
getSchema({
|
|
88
|
+
parser,
|
|
89
|
+
schemaOrRef: info.schema,
|
|
90
|
+
pointer: '',
|
|
91
|
+
absolutePointer: JsonPointer.join(absolutePointer, ['content', name, 'schema']),
|
|
92
|
+
options,
|
|
93
|
+
deps: {
|
|
94
|
+
operation,
|
|
95
|
+
type,
|
|
96
|
+
response,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const { onlyRequiredInSamples, generatedSamplesMaxDepth } = options;
|
|
100
|
+
const { encoding, examples: infoExamples, example } = info;
|
|
101
|
+
if (!options.unstable_skipSamples) {
|
|
102
|
+
if (infoExamples !== undefined) {
|
|
103
|
+
examples = mapValues(infoExamples, (example) => getExamples({ parser, infoOrRef: example, mime: name, encoding }));
|
|
104
|
+
}
|
|
105
|
+
else if (example !== undefined) {
|
|
106
|
+
examples = {
|
|
107
|
+
default: getExamples({
|
|
108
|
+
parser,
|
|
109
|
+
infoOrRef: { value: parser.deref(example).resolved },
|
|
110
|
+
mime: name,
|
|
111
|
+
encoding,
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else if (isJsonLike(name) || isXmlLike(name)) {
|
|
116
|
+
examples = generateExamples({
|
|
117
|
+
parser,
|
|
118
|
+
info,
|
|
119
|
+
schema,
|
|
120
|
+
mime: name,
|
|
121
|
+
options: {
|
|
122
|
+
isRequestType,
|
|
123
|
+
onlyRequiredInSamples,
|
|
124
|
+
generatedSamplesMaxDepth,
|
|
125
|
+
format: isXmlLike(name) ? 'xml' : 'json',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else if (isFormUrlEncoded(name) || isMultipartFormData(name)) {
|
|
130
|
+
formExamples = generateExamples({
|
|
131
|
+
parser,
|
|
132
|
+
info,
|
|
133
|
+
schema,
|
|
134
|
+
mime: name,
|
|
135
|
+
options: {
|
|
136
|
+
isRequestType,
|
|
137
|
+
onlyRequiredInSamples,
|
|
138
|
+
generatedSamplesMaxDepth,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
examples,
|
|
145
|
+
schema,
|
|
146
|
+
name,
|
|
147
|
+
isRequestType,
|
|
148
|
+
formExamples,
|
|
149
|
+
onlyRequiredInSamples,
|
|
150
|
+
operation,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=mediaType.js.map
|
package/lib/models/operation.js
CHANGED
|
@@ -1 +1,166 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC
|
|
1
|
+
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
|
+
import { removeLeadingSlash } from '@redocly/theme/core/openapi';
|
|
3
|
+
import { configure } from '@redocly/theme/ext/configure';
|
|
4
|
+
import { extractExtensions, getOperationId, getOperationName, getStatusCodeType, getValueFromMdParsedExtension, isStatusCode, JsonPointer, mergeParams, normalizeServers, sortByDeprecated, sortByRequired, updateOperationWithRequestValues, updateParametersWithUserValues, } from '../utils/index.js';
|
|
5
|
+
import { getCallback } from './callback.js';
|
|
6
|
+
import { getField } from './field.js';
|
|
7
|
+
import { getRequestBody } from './request.js';
|
|
8
|
+
import { getSecurity } from './security.js';
|
|
9
|
+
import { getResponse } from './response.js';
|
|
10
|
+
import { getHref } from '../services/menu/operation.js';
|
|
11
|
+
export function isPayloadSample(sample) {
|
|
12
|
+
return sample.lang === 'Payload' && 'requestBodyContent' in sample;
|
|
13
|
+
}
|
|
14
|
+
export function getOperation(parser, operationDefinition, parent, options, href, callback, userClaims) {
|
|
15
|
+
const isWebhook = operationDefinition.isWebhook;
|
|
16
|
+
const operation = {
|
|
17
|
+
operationDefinition,
|
|
18
|
+
parent,
|
|
19
|
+
pointer: operationDefinition.pointer,
|
|
20
|
+
description: getValueFromMdParsedExtension(operationDefinition, 'description'),
|
|
21
|
+
externalDocs: operationDefinition.externalDocs,
|
|
22
|
+
deprecated: !!operationDefinition.deprecated,
|
|
23
|
+
httpVerb: operationDefinition.httpVerb,
|
|
24
|
+
operationId: operationDefinition.operationId,
|
|
25
|
+
path: operationDefinition.pathName,
|
|
26
|
+
isWebhook,
|
|
27
|
+
isCallback: Boolean(callback?.isCallback),
|
|
28
|
+
isEvent: callback?.isCallback || isWebhook,
|
|
29
|
+
name: getOperationName(operationDefinition),
|
|
30
|
+
defaultExampleName: operationDefinition.defaultSampleName,
|
|
31
|
+
[REDOCLY_TEAMS_RBAC]: operationDefinition[REDOCLY_TEAMS_RBAC] || parent?.[REDOCLY_TEAMS_RBAC],
|
|
32
|
+
type: 'operation',
|
|
33
|
+
callbackId: callback?.id,
|
|
34
|
+
href,
|
|
35
|
+
get callbacks() {
|
|
36
|
+
return Object.keys(operationDefinition.callbacks || []).map((callbackEventName) => {
|
|
37
|
+
return getCallback(parser, callbackEventName, operationDefinition.callbacks?.[callbackEventName], operation.pointer, options, href, parent, userClaims);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
get responses() {
|
|
41
|
+
let hasSuccessResponses = false;
|
|
42
|
+
return Object.keys(operationDefinition.responses || [])
|
|
43
|
+
.filter((code) => {
|
|
44
|
+
if (code === 'default') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (getStatusCodeType(code) === 'success') {
|
|
48
|
+
hasSuccessResponses = true;
|
|
49
|
+
}
|
|
50
|
+
return isStatusCode(code);
|
|
51
|
+
}) // filter out other props (e.g. x-props)
|
|
52
|
+
.map((code) => {
|
|
53
|
+
return getResponse({
|
|
54
|
+
parser,
|
|
55
|
+
code,
|
|
56
|
+
defaultAsError: hasSuccessResponses,
|
|
57
|
+
infoOrRef: operationDefinition.responses[code],
|
|
58
|
+
options,
|
|
59
|
+
isEvent: operation.isEvent,
|
|
60
|
+
operation,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
get parameters() {
|
|
65
|
+
return processParameters(parser, operationDefinition, operation, options, userDefinedRequestValues);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
if (callback?.isCallback) {
|
|
69
|
+
// NOTE: Callbacks by default should not inherit the specification's global `security` definition.
|
|
70
|
+
// Can be defined individually per-callback in the specification. Defaults to none.
|
|
71
|
+
operation.security = getSecurity(operationDefinition.security, parser);
|
|
72
|
+
// TODO: update getting pathInfo for overriding servers on path level
|
|
73
|
+
operation.servers = normalizeServers('', operationDefinition.servers || operationDefinition.pathServers || []);
|
|
74
|
+
// TODO: remove it when all deep links are updated with one proper handler
|
|
75
|
+
operation.id = removeLeadingSlash(href); // pass operation href as id for callbacks
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
operation.id = getOperationId(operationDefinition, parent);
|
|
79
|
+
operation.href = operation.href || getHref(operation);
|
|
80
|
+
operation.security = getSecurity(operationDefinition.security || parser.definition.security, parser);
|
|
81
|
+
const servers = operationDefinition.servers ||
|
|
82
|
+
(operationDefinition.pathServers?.length ? operationDefinition.pathServers : null) ||
|
|
83
|
+
parser.definition.servers ||
|
|
84
|
+
[];
|
|
85
|
+
operation.servers = normalizeServers(parser.definitionUrl, mergeInMockServer(servers, options.mockServer));
|
|
86
|
+
}
|
|
87
|
+
if (options.showExtensions) {
|
|
88
|
+
operation.extensions = extractExtensions(operationDefinition, options.showExtensions);
|
|
89
|
+
}
|
|
90
|
+
operation.requestBody = operationDefinition.requestBody
|
|
91
|
+
? getRequestBody({
|
|
92
|
+
parser: parser,
|
|
93
|
+
infoOrRef: operationDefinition.requestBody,
|
|
94
|
+
options,
|
|
95
|
+
operation,
|
|
96
|
+
isEvent: operation.isEvent,
|
|
97
|
+
})
|
|
98
|
+
: undefined;
|
|
99
|
+
const requestBodyContent = operation.requestBody?.content;
|
|
100
|
+
operation.payload = {
|
|
101
|
+
lang: 'Payload',
|
|
102
|
+
source: '',
|
|
103
|
+
requestBodyContent: requestBodyContent?.hasSample ? requestBodyContent : undefined,
|
|
104
|
+
};
|
|
105
|
+
operation.definitionSamples = operationDefinition['x-codeSamples'] || [];
|
|
106
|
+
operation.badges =
|
|
107
|
+
operationDefinition['x-badges']?.map(({ name, color, position }) => ({
|
|
108
|
+
name,
|
|
109
|
+
color: color || 'var(--color-info-base)',
|
|
110
|
+
position: position || 'after',
|
|
111
|
+
})) || [];
|
|
112
|
+
operation.hasSamples = requestBodyContent?.hasSample || operation.definitionSamples.length > 0;
|
|
113
|
+
operation.hideReplay = operationDefinition['x-hideReplay'] === true;
|
|
114
|
+
const operationParams = {
|
|
115
|
+
userClaims,
|
|
116
|
+
operation: {
|
|
117
|
+
operationId: operation.operationId,
|
|
118
|
+
name: operation.name,
|
|
119
|
+
path: operation.path,
|
|
120
|
+
href: operation.href,
|
|
121
|
+
method: operation.httpVerb,
|
|
122
|
+
},
|
|
123
|
+
servers: operation.servers,
|
|
124
|
+
};
|
|
125
|
+
const configResult = configure(operationParams) || {};
|
|
126
|
+
const userDefinedRequestValues = configResult.requestValues || {};
|
|
127
|
+
updateOperationWithRequestValues(operation, userDefinedRequestValues);
|
|
128
|
+
return operation;
|
|
129
|
+
}
|
|
130
|
+
function processParameters(parser, operationDefinition, operation, options, userDefinedRequestValues) {
|
|
131
|
+
let parameters = mergeParams(parser, operationDefinition.pathParameters, operationDefinition.parameters, {
|
|
132
|
+
pathPointer: JsonPointer.dirName(operation.pointer),
|
|
133
|
+
operationPointer: operation.pointer,
|
|
134
|
+
}).map(({ paramOrRef, pointer }) => {
|
|
135
|
+
const param = getField(parser, paramOrRef, pointer, options, {
|
|
136
|
+
operation,
|
|
137
|
+
type: 'request',
|
|
138
|
+
});
|
|
139
|
+
updateParametersWithUserValues(param, userDefinedRequestValues);
|
|
140
|
+
return param;
|
|
141
|
+
});
|
|
142
|
+
if (options.sortRequiredPropsFirst) {
|
|
143
|
+
parameters = sortByRequired(parameters);
|
|
144
|
+
}
|
|
145
|
+
return sortByDeprecated(parameters);
|
|
146
|
+
}
|
|
147
|
+
export function mergeInMockServer(servers, mockServerOptions) {
|
|
148
|
+
if (!mockServerOptions) {
|
|
149
|
+
return servers;
|
|
150
|
+
}
|
|
151
|
+
const mockServer = {
|
|
152
|
+
url: mockServerOptions.url,
|
|
153
|
+
description: mockServerOptions.description,
|
|
154
|
+
};
|
|
155
|
+
switch (mockServerOptions.position) {
|
|
156
|
+
case 'first':
|
|
157
|
+
return [mockServer, ...servers];
|
|
158
|
+
case 'last':
|
|
159
|
+
return [...servers, mockServer];
|
|
160
|
+
case 'replace':
|
|
161
|
+
return [mockServer];
|
|
162
|
+
default:
|
|
163
|
+
return servers;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=operation.js.map
|
package/lib/models/request.js
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import{getContentWithLegacyExamples
|
|
1
|
+
import { getContentWithLegacyExamples, getValueFromMdParsedExtension, JsonPointer, } from '../utils/index.js';
|
|
2
|
+
import { getMediaContent } from './mediaContent.js';
|
|
3
|
+
export function getRequestBody({ parser, infoOrRef, options, isEvent, operation, }) {
|
|
4
|
+
const { resolved: info } = parser.deref(infoOrRef);
|
|
5
|
+
const description = getValueFromMdParsedExtension(info, 'description') || '';
|
|
6
|
+
const required = info.required;
|
|
7
|
+
let content;
|
|
8
|
+
const isRequestType = !isEvent;
|
|
9
|
+
const mediaContent = getContentWithLegacyExamples(info);
|
|
10
|
+
if (mediaContent !== undefined) {
|
|
11
|
+
content = getMediaContent({
|
|
12
|
+
parser,
|
|
13
|
+
info: mediaContent,
|
|
14
|
+
isRequestType,
|
|
15
|
+
options,
|
|
16
|
+
data: {
|
|
17
|
+
operation,
|
|
18
|
+
type: 'request',
|
|
19
|
+
absolutePointer: infoOrRef['$ref'] || JsonPointer.join(operation.pointer, ['requestBody']),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return { description, required, content };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=request.js.map
|
package/lib/models/response.js
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
import{getStatusCodeType
|
|
1
|
+
import { getStatusCodeType, getContentWithLegacyExamples, JsonPointer, getValueFromMdParsedExtension, } from '../utils/index.js';
|
|
2
|
+
import { getField } from './field.js';
|
|
3
|
+
import { getMediaContent } from './mediaContent.js';
|
|
4
|
+
export function getResponse({ parser, code, defaultAsError, infoOrRef, options, isEvent, operation, }) {
|
|
5
|
+
const isRequestType = !!isEvent;
|
|
6
|
+
const { resolved: info } = parser.deref(infoOrRef);
|
|
7
|
+
const response = { code };
|
|
8
|
+
if (info['x-summary'] !== undefined) {
|
|
9
|
+
response.summary = getValueFromMdParsedExtension(info, 'x-summary');
|
|
10
|
+
response.description = getValueFromMdParsedExtension(info, 'description') || '';
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
response.summary = getValueFromMdParsedExtension(info, 'description') || '';
|
|
14
|
+
response.description = '';
|
|
15
|
+
}
|
|
16
|
+
response.type = getStatusCodeType(code, defaultAsError);
|
|
17
|
+
const infoHeaders = info.headers;
|
|
18
|
+
const absolutePointer = infoOrRef['$ref'] || JsonPointer.join(operation?.pointer || '', ['responses', code]);
|
|
19
|
+
if (infoHeaders !== undefined) {
|
|
20
|
+
response.headers = Object.keys(infoHeaders).map((name) => {
|
|
21
|
+
const header = infoHeaders[name];
|
|
22
|
+
return getField(parser, { ...header, name }, JsonPointer.join(absolutePointer, ['headers', name]), options, {
|
|
23
|
+
operation,
|
|
24
|
+
type: 'response',
|
|
25
|
+
response,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const mediaContent = getContentWithLegacyExamples(info);
|
|
30
|
+
if (mediaContent !== undefined) {
|
|
31
|
+
response.content = getMediaContent({
|
|
32
|
+
parser,
|
|
33
|
+
info: mediaContent,
|
|
34
|
+
isRequestType,
|
|
35
|
+
options,
|
|
36
|
+
data: {
|
|
37
|
+
operation,
|
|
38
|
+
type: 'response',
|
|
39
|
+
response,
|
|
40
|
+
absolutePointer,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=response.js.map
|