@redocly/openapi-docs 3.10.0-next.7 → 3.10.0-next.8

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.
@@ -1,4 +1,2 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OAuthFlow=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),styled_components_1=__importDefault(require("styled-components")),Markdown_1=require("../Markdown"),SecuritySchemeItem_1=require("./SecuritySchemeItem"),styled_1=require("./styled"),hooks_1=require("../../hooks");function OAuthFlowComponent({flow:e}){const t=Object.keys((null==e?void 0:e.scopes)||{}),r=(0,hooks_1.useTranslate)();return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.authorizationUrl","Authorization URL")}:`,value:(null==e?void 0:e.authorizationUrl)&&(0,jsx_runtime_1.jsx)(styled_1.StyledLink,{target:"_blank",rel:"noopener noreferrer",href:null==e?void 0:e.authorizationUrl,children:null==e?void 0:e.authorizationUrl})}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.tokenUrl","Token URL")}:`,value:null==e?void 0:e.tokenUrl}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.refreshUrl","Refresh URL")}:`,value:null==e?void 0:e.refreshUrl}),t.length&&(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.scopes","Scopes")}:`,value:" "}),t.map((t=>(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:(0,jsx_runtime_1.jsx)(StyledTag,{className:"tag-grey",children:t}),value:(0,jsx_runtime_1.jsx)(Markdown_1.Markdown,{source:(null==e?void 0:e.scopes[t])||""})},t)))]})||null]})}const StyledTag=(0,styled_components_1.default)(styled_1.Tag)`
2
- margin-left: var(--spacing-xs);
3
- `;exports.OAuthFlow=(0,react_1.memo)(OAuthFlowComponent);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OAuthFlow=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),SecuritySchemeItem_1=require("./SecuritySchemeItem"),styled_1=require("./styled"),hooks_1=require("../../hooks");function OAuthFlowComponent({flow:e}){const r=(0,hooks_1.useTranslate)();return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.authorizationUrl","Authorization URL")}:`,value:(null==e?void 0:e.authorizationUrl)&&(0,jsx_runtime_1.jsx)(styled_1.StyledLink,{target:"_blank",rel:"noopener noreferrer",href:null==e?void 0:e.authorizationUrl,children:null==e?void 0:e.authorizationUrl})}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.tokenUrl","Token URL")}:`,value:null==e?void 0:e.tokenUrl}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${r("openapi.refreshUrl","Refresh URL")}:`,value:null==e?void 0:e.refreshUrl})]})}exports.OAuthFlow=(0,react_1.memo)(OAuthFlowComponent);
4
2
  //# sourceMappingURL=OAuthFlow.js.map
@@ -0,0 +1,13 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import type { OpenAPISecurityScheme } from '../../types';
3
+ import type { SecurityRequirement } from '../../models';
4
+ export interface OAuthOptionalScopesProps {
5
+ flow: OpenAPISecurityScheme['flows'][keyof OpenAPISecurityScheme['flows']];
6
+ }
7
+ export interface OAuthRequiredScopesProps {
8
+ id: string;
9
+ securities: SecurityRequirement[];
10
+ flow: OpenAPISecurityScheme['flows'][keyof OpenAPISecurityScheme['flows']];
11
+ }
12
+ export declare const OAuthOptionalScopes: import("react").NamedExoticComponent<PropsWithChildren<OAuthOptionalScopesProps>>;
13
+ export declare const OAuthRequiredScopes: import("react").NamedExoticComponent<PropsWithChildren<OAuthRequiredScopesProps>>;
@@ -0,0 +1,34 @@
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OAuthRequiredScopes=exports.OAuthOptionalScopes=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme"),Markdown_1=require("../Markdown"),SecuritySchemeItem_1=require("./SecuritySchemeItem"),styled_1=require("./styled"),hooks_1=require("../../hooks"),helper_1=require("./helper");function OAuthOptionalScopesComponent({flow:e}){const t=Object.keys((null==e?void 0:e.scopes)||{}),r=(0,hooks_1.useTranslate)(),[s,o]=(0,react_1.useState)(!1);if(!t.length)return null;return(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:(0,jsx_runtime_1.jsxs)(ScopeHeader,{onClick:()=>{o((e=>!e))},children:[r(s?"openapi.hideOptionalScopes":"openapi.showOptionalScopes",s?"Hide optional scopes":"Show optional scopes"),(0,jsx_runtime_1.jsx)(AnimatedChevronWrapper,{isOpen:s,children:(0,jsx_runtime_1.jsx)(theme_1.ChevronRightIcon,{size:"var(--font-size-base)",color:"var(--tree-content-color-default)"})})]}),value:" "}),(0,jsx_runtime_1.jsx)(ScopesListWrapper,{isOpen:s,children:t.map((t=>(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:(0,jsx_runtime_1.jsx)(StyledTag,{className:"tag-grey",children:t}),value:(0,jsx_runtime_1.jsx)(Markdown_1.Markdown,{source:(null==e?void 0:e.scopes[t])||""})},t)))})]})}function OAuthRequiredScopesComponent({id:e,securities:t,flow:r}){const s=(0,helper_1.getRequiredScopes)(e,t),o=(0,hooks_1.useTranslate)();return s.length?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:o("openapi.requiredScopes","Required scopes"),value:" "}),(0,jsx_runtime_1.jsx)(Row,{children:s.map((e=>(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:(0,jsx_runtime_1.jsx)(StyledTag,{className:"tag-grey",children:e}),value:(0,jsx_runtime_1.jsx)(Markdown_1.Markdown,{source:(null==r?void 0:r.scopes[e])||""})},e)))})]}):null}const StyledTag=(0,styled_components_1.default)(styled_1.Tag)`
2
+ font-family: var(--font-family-base);
3
+ font-size: var(--font-size-base);
4
+ line-height: var(--line-height-base);
5
+ align-self: flex-start;
6
+ padding: 0 var(--spacing-xs);
7
+ border: var(--tag-border-width) var(--tag-border-style) var(--tag-bg-color);
8
+ border-radius: var(--tag-border-radius);
9
+ `,ScopeHeader=styled_components_1.default.div`
10
+ cursor: pointer;
11
+ display: flex;
12
+ gap: var(--spacing-xxs);
13
+ align-items: center;
14
+ user-select: none;
15
+ `,Row=styled_components_1.default.div`
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ gap: var(--spacing-xxs);
19
+ word-break: normal;
20
+ `,ScopesListWrapper=styled_components_1.default.div`
21
+ max-height: ${e=>e.isOpen?"1000px":"0"};
22
+ opacity: ${e=>e.isOpen?"1":"0"};
23
+ overflow: hidden;
24
+ transition:
25
+ max-height 0.5s ease-in-out,
26
+ opacity 0.5s ease-in-out;
27
+ `,AnimatedChevronWrapper=styled_components_1.default.span`
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ transform: ${e=>e.isOpen?"rotate(90deg)":"rotate(0deg)"};
32
+ transition: transform 0.5s ease-in-out;
33
+ `;exports.OAuthOptionalScopes=(0,react_1.memo)(OAuthOptionalScopesComponent),exports.OAuthRequiredScopes=(0,react_1.memo)(OAuthRequiredScopesComponent);
34
+ //# sourceMappingURL=OAuthScopes.js.map
@@ -1,28 +1,31 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityButton=SecurityButton;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme");function SecurityButton({securities:e,onClick:t}){return(0,jsx_runtime_1.jsxs)(StyledButton,{onClick:t,children:[(0,jsx_runtime_1.jsx)(theme_1.SecurityIcon,{}),(0,jsx_runtime_1.jsx)(Title,{children:"Security:"}),(0,jsx_runtime_1.jsx)(SecurityList,{children:e.map((t=>{const n=e.length>1&&t.schemes.length>1;return`\n ${n?"(":""}\n ${t.schemes.map((({id:e})=>e)).join(" and ")}\n ${n?")":""}\n `})).join(" or ")})]})}const StyledButton=styled_components_1.default.button`
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityButton=SecurityButton;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme"),react_1=require("react"),hooks_1=require("../../hooks");function SecurityButton({securities:e,onClick:t}){const r=(0,hooks_1.useTranslate)();return(0,jsx_runtime_1.jsx)(SecurityPanel,{header:()=>(0,jsx_runtime_1.jsxs)(SecurityHeader,{children:[(0,jsx_runtime_1.jsx)(theme_1.SecurityIcon,{}),(0,jsx_runtime_1.jsx)(Title,{children:"Security"}),(0,jsx_runtime_1.jsx)(ViewDetailsButton,{onClick:t,variant:"link",children:r("openapi.viewDetails","View details")})]}),isExpandable:!1,children:(0,jsx_runtime_1.jsx)(SecurityList,{children:e.map(((t,r)=>{const n=e.length>1&&t.schemes.length>1,i=t.schemes.map((({id:e},r)=>(0,jsx_runtime_1.jsxs)(react_1.Fragment,{children:[e,r<t.schemes.length-1&&(0,jsx_runtime_1.jsx)(Conjunction,{children:" and "})]},e)));return(0,jsx_runtime_1.jsxs)(react_1.Fragment,{children:[n?"(":"",i,n?")":"",r<e.length-1&&(0,jsx_runtime_1.jsx)(Conjunction,{children:" or "})]},r)}))})})}const SecurityPanel=(0,styled_components_1.default)(theme_1.Panel)`
2
+ margin-top: var(--spacing-base);
3
+ border: var(--panel-border);
4
+ border-radius: var(--panel-border-radius);
5
+ `,SecurityHeader=styled_components_1.default.div`
2
6
  display: flex;
3
7
  align-items: center;
4
- align-self: flex-start;
5
- gap: var(--spacing-xxs);
6
- min-height: 32px;
7
- background: var(--color-info-bg);
8
- padding: 0 var(--spacing-xs);
9
- margin-top: var(--spacing-base);
8
+ justify-content: space-between;
9
+ gap: var(--spacing-xs);
10
10
  color: var(--link-color-primary);
11
- border: none;
12
- font-size: var(--font-size-base);
13
- font-family: var(--font-family-base);
14
- line-height: var(--line-height-base);
15
- border-radius: var(--border-radius-md);
16
- max-width: 100%;
11
+ padding: var(--spacing-xs) var(--spacing-sm);
12
+ background-color: var(--layer-color);
13
+ border-bottom: var(--panel-border);
14
+ border-radius: var(--panel-border-radius) var(--panel-border-radius) 0 0;
15
+ `,ViewDetailsButton=(0,styled_components_1.default)(theme_1.Button)`
16
+ margin-left: auto;
17
+ font-size: var(--font-size-sm);
17
18
  `,Title=styled_components_1.default.span`
18
- font-family: var(--font-family-monospaced);
19
- font-weight: var(--font-weight-semibold);
20
- letter-spacing: -0.5px;
21
- `,SecurityList=styled_components_1.default.span`
19
+ font-family: var(--font-family-base);
20
+ font-weight: var(--font-weight-medium);
21
+ color: var(--text-color-primary);
22
+ `,SecurityList=styled_components_1.default.div`
22
23
  flex: 1;
23
- cursor: pointer;
24
- white-space: nowrap;
25
24
  text-overflow: ellipsis;
26
25
  overflow: hidden;
26
+ padding: var(--spacing-xs) var(--spacing-sm);
27
+ color: var(--text-color-primary);
28
+ `,Conjunction=styled_components_1.default.span`
29
+ color: var(--text-color-description);
27
30
  `;
28
31
  //# sourceMappingURL=SecurityButton.js.map
@@ -1,4 +1,4 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityFlow=SecurityFlow;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importDefault(require("styled-components")),SecuritySchemeItem_1=require("./SecuritySchemeItem"),utils_1=require("../../utils"),OAuthFlow_1=require("./OAuthFlow"),styled_1=require("./styled"),Markdown_1=require("../Markdown"),helper_1=require("./helper"),hooks_1=require("../../hooks");function SecurityFlow({type:e,bearerFormat:r,name:t,flows:i,openIdConnectUrl:s,description:n,id:a,securities:o,in:u}){const l=(0,hooks_1.useTranslate)();if(!e||!a)return null;const c=(0,helper_1.getRequiredScopes)(a,o),m={http:(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:l("openapi.httpAuthorizationScheme","HTTP Authorization Scheme"),value:e}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:l("openapi.bearerFormat","Bearer Format"),value:r})]}),apiKey:(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${(0,utils_1.titleize)(u||"")} ${l("openapi.parameterName","parameter name")}:`,value:t}),oauth2:(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:l("openapi.flowType","Flow type"),value:e}),i&&Object.keys(i).map((e=>(0,jsx_runtime_1.jsx)(OAuthFlow_1.OAuthFlow,{flow:i[e]},e)))]}),openIdConnect:(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:l("openapi.connectUrl","Connect URL"),value:s&&(0,jsx_runtime_1.jsx)(styled_1.StyledLink,{target:"_blank",rel:"noopener noreferrer",href:s,children:s})})};return(0,jsx_runtime_1.jsxs)(Wrapper,{children:[(0,jsx_runtime_1.jsx)(TitleSchema,{children:a}),(0,jsx_runtime_1.jsx)(Markdown_1.Markdown,{source:n}),(0,jsx_runtime_1.jsxs)(List,{children:[m[e]||null,(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:l("openapi.requiredScopes","Required scopes"),value:c.length&&(0,jsx_runtime_1.jsx)(Row,{children:c.map((e=>(0,jsx_runtime_1.jsx)(styled_1.Tag,{className:"tag-grey",children:e},e)))})})]})]})}const Wrapper=styled_components_1.default.div`
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityFlow=SecurityFlow;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importDefault(require("styled-components")),SecuritySchemeItem_1=require("./SecuritySchemeItem"),utils_1=require("../../utils"),OAuthFlow_1=require("./OAuthFlow"),styled_1=require("./styled"),Markdown_1=require("../Markdown"),hooks_1=require("../../hooks"),OAuthScopes_1=require("./OAuthScopes");function SecurityFlow({type:e,bearerFormat:t,name:r,flows:i,openIdConnectUrl:s,description:n,id:o,securities:u,in:a}){const c=(0,hooks_1.useTranslate)();if(!e||!o)return null;const l={http:(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:c("openapi.httpAuthorizationScheme","HTTP Authorization Scheme"),value:e}),(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:c("openapi.bearerFormat","Bearer Format"),value:t})]}),apiKey:(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:`${(0,utils_1.titleize)(a||"")} ${c("openapi.parameterName","parameter name")}:`,value:r}),oauth2:(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:c("openapi.flowType","Flow type"),value:e}),i&&Object.keys(i).map((e=>(0,jsx_runtime_1.jsx)(OAuthFlow_1.OAuthFlow,{flow:i[e]},e)))]}),openIdConnect:(0,jsx_runtime_1.jsx)(SecuritySchemeItem_1.SecuritySchemeItem,{label:c("openapi.connectUrl","Connect URL"),value:s&&(0,jsx_runtime_1.jsx)(styled_1.StyledLink,{target:"_blank",rel:"noopener noreferrer",href:s,children:s})})},m=i&&Object.keys(i).map((e=>(0,jsx_runtime_1.jsx)(OAuthScopes_1.OAuthRequiredScopes,{id:o,securities:u,flow:i[e]},e))),_=i&&Object.keys(i).map((e=>(0,jsx_runtime_1.jsx)(OAuthScopes_1.OAuthOptionalScopes,{flow:i[e]},e)));return(0,jsx_runtime_1.jsxs)(Wrapper,{children:[(0,jsx_runtime_1.jsx)(TitleSchema,{children:o}),(0,jsx_runtime_1.jsx)(Markdown_1.Markdown,{source:n}),(0,jsx_runtime_1.jsxs)(List,{children:[l[e]||null,m,_]})]})}const Wrapper=styled_components_1.default.div`
2
2
  background: var(--layer-color);
3
3
  padding: var(--spacing-base);
4
4
  border-radius: var(--border-radius);
@@ -8,11 +8,6 @@
8
8
  `,List=styled_components_1.default.div`
9
9
  width: 100%;
10
10
  margin-top: var(--spacing-md);
11
- `,Row=styled_components_1.default.div`
12
- display: flex;
13
- flex-wrap: wrap;
14
- gap: var(--spacing-xxs);
15
- word-break: normal;
16
11
  `,TitleSchema=styled_components_1.default.p`
17
12
  font-size: var(--font-size-base);
18
13
  margin: 0 0 var(--spacing-xs);
@@ -2,7 +2,7 @@
2
2
  display: flex;
3
3
  flex-wrap: wrap;
4
4
  justify-content: flex-start;
5
- margin-bottom: var(--spacing-xxs);
5
+ margin-bottom: var(--spacing-xs);
6
6
  font-size: var(--font-size-sm);
7
7
  color: var(--text-color-secondary);
8
8
  `,Label=styled_components_1.default.div`
@@ -1,4 +1,2 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import styled from"styled-components";import{Markdown}from"../Markdown";import{SecuritySchemeItem}from"./SecuritySchemeItem";import{StyledLink,Tag}from"./styled";import{useTranslate}from"../../hooks";function OAuthFlowComponent({flow:e}){const r=Object.keys((null==e?void 0:e.scopes)||{}),o=useTranslate();return _jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:`${o("openapi.authorizationUrl","Authorization URL")}:`,value:(null==e?void 0:e.authorizationUrl)&&_jsx(StyledLink,{target:"_blank",rel:"noopener noreferrer",href:null==e?void 0:e.authorizationUrl,children:null==e?void 0:e.authorizationUrl})}),_jsx(SecuritySchemeItem,{label:`${o("openapi.tokenUrl","Token URL")}:`,value:null==e?void 0:e.tokenUrl}),_jsx(SecuritySchemeItem,{label:`${o("openapi.refreshUrl","Refresh URL")}:`,value:null==e?void 0:e.refreshUrl}),r.length&&_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:`${o("openapi.scopes","Scopes")}:`,value:" "}),r.map((r=>_jsx(SecuritySchemeItem,{label:_jsx(StyledTag,{className:"tag-grey",children:r}),value:_jsx(Markdown,{source:(null==e?void 0:e.scopes[r])||""})},r)))]})||null]})}const StyledTag=styled(Tag)`
2
- margin-left: var(--spacing-xs);
3
- `;export const OAuthFlow=memo(OAuthFlowComponent);
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import{SecuritySchemeItem}from"./SecuritySchemeItem";import{StyledLink}from"./styled";import{useTranslate}from"../../hooks";function OAuthFlowComponent({flow:e}){const r=useTranslate();return _jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:`${r("openapi.authorizationUrl","Authorization URL")}:`,value:(null==e?void 0:e.authorizationUrl)&&_jsx(StyledLink,{target:"_blank",rel:"noopener noreferrer",href:null==e?void 0:e.authorizationUrl,children:null==e?void 0:e.authorizationUrl})}),_jsx(SecuritySchemeItem,{label:`${r("openapi.tokenUrl","Token URL")}:`,value:null==e?void 0:e.tokenUrl}),_jsx(SecuritySchemeItem,{label:`${r("openapi.refreshUrl","Refresh URL")}:`,value:null==e?void 0:e.refreshUrl})]})}export const OAuthFlow=memo(OAuthFlowComponent);
4
2
  //# sourceMappingURL=OAuthFlow.js.map
@@ -0,0 +1,13 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import type { OpenAPISecurityScheme } from '../../types';
3
+ import type { SecurityRequirement } from '../../models';
4
+ export interface OAuthOptionalScopesProps {
5
+ flow: OpenAPISecurityScheme['flows'][keyof OpenAPISecurityScheme['flows']];
6
+ }
7
+ export interface OAuthRequiredScopesProps {
8
+ id: string;
9
+ securities: SecurityRequirement[];
10
+ flow: OpenAPISecurityScheme['flows'][keyof OpenAPISecurityScheme['flows']];
11
+ }
12
+ export declare const OAuthOptionalScopes: import("react").NamedExoticComponent<PropsWithChildren<OAuthOptionalScopesProps>>;
13
+ export declare const OAuthRequiredScopes: import("react").NamedExoticComponent<PropsWithChildren<OAuthRequiredScopesProps>>;
@@ -0,0 +1,34 @@
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{memo,useState}from"react";import styled from"styled-components";import{ChevronRightIcon}from"@redocly/theme";import{Markdown}from"../Markdown";import{SecuritySchemeItem}from"./SecuritySchemeItem";import{Tag}from"./styled";import{useTranslate}from"../../hooks";import{getRequiredScopes}from"./helper";function OAuthOptionalScopesComponent({flow:e}){const t=Object.keys((null==e?void 0:e.scopes)||{}),o=useTranslate(),[r,s]=useState(!1);if(!t.length)return null;return _jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:_jsxs(ScopeHeader,{onClick:()=>{s((e=>!e))},children:[o(r?"openapi.hideOptionalScopes":"openapi.showOptionalScopes",r?"Hide optional scopes":"Show optional scopes"),_jsx(AnimatedChevronWrapper,{isOpen:r,children:_jsx(ChevronRightIcon,{size:"var(--font-size-base)",color:"var(--tree-content-color-default)"})})]}),value:" "}),_jsx(ScopesListWrapper,{isOpen:r,children:t.map((t=>_jsx(SecuritySchemeItem,{label:_jsx(StyledTag,{className:"tag-grey",children:t}),value:_jsx(Markdown,{source:(null==e?void 0:e.scopes[t])||""})},t)))})]})}function OAuthRequiredScopesComponent({id:e,securities:t,flow:o}){const r=getRequiredScopes(e,t),s=useTranslate();return r.length?_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:s("openapi.requiredScopes","Required scopes"),value:" "}),_jsx(Row,{children:r.map((e=>_jsx(SecuritySchemeItem,{label:_jsx(StyledTag,{className:"tag-grey",children:e}),value:_jsx(Markdown,{source:(null==o?void 0:o.scopes[e])||""})},e)))})]}):null}const StyledTag=styled(Tag)`
2
+ font-family: var(--font-family-base);
3
+ font-size: var(--font-size-base);
4
+ line-height: var(--line-height-base);
5
+ align-self: flex-start;
6
+ padding: 0 var(--spacing-xs);
7
+ border: var(--tag-border-width) var(--tag-border-style) var(--tag-bg-color);
8
+ border-radius: var(--tag-border-radius);
9
+ `,ScopeHeader=styled.div`
10
+ cursor: pointer;
11
+ display: flex;
12
+ gap: var(--spacing-xxs);
13
+ align-items: center;
14
+ user-select: none;
15
+ `,Row=styled.div`
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+ gap: var(--spacing-xxs);
19
+ word-break: normal;
20
+ `,ScopesListWrapper=styled.div`
21
+ max-height: ${e=>e.isOpen?"1000px":"0"};
22
+ opacity: ${e=>e.isOpen?"1":"0"};
23
+ overflow: hidden;
24
+ transition:
25
+ max-height 0.5s ease-in-out,
26
+ opacity 0.5s ease-in-out;
27
+ `,AnimatedChevronWrapper=styled.span`
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ transform: ${e=>e.isOpen?"rotate(90deg)":"rotate(0deg)"};
32
+ transition: transform 0.5s ease-in-out;
33
+ `;export const OAuthOptionalScopes=memo(OAuthOptionalScopesComponent);export const OAuthRequiredScopes=memo(OAuthRequiredScopesComponent);
34
+ //# sourceMappingURL=OAuthScopes.js.map
@@ -1,28 +1,31 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styled-components";import{SecurityIcon}from"@redocly/theme";export function SecurityButton({securities:e,onClick:t}){return _jsxs(StyledButton,{onClick:t,children:[_jsx(SecurityIcon,{}),_jsx(Title,{children:"Security:"}),_jsx(SecurityList,{children:e.map((t=>{const i=e.length>1&&t.schemes.length>1;return`\n ${i?"(":""}\n ${t.schemes.map((({id:e})=>e)).join(" and ")}\n ${i?")":""}\n `})).join(" or ")})]})}const StyledButton=styled.button`
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styled-components";import{SecurityIcon,Panel,Button}from"@redocly/theme";import{Fragment}from"react";import{useTranslate}from"../../hooks";export function SecurityButton({securities:e,onClick:r}){const t=useTranslate();return _jsx(SecurityPanel,{header:()=>_jsxs(SecurityHeader,{children:[_jsx(SecurityIcon,{}),_jsx(Title,{children:"Security"}),_jsx(ViewDetailsButton,{onClick:r,variant:"link",children:t("openapi.viewDetails","View details")})]}),isExpandable:!1,children:_jsx(SecurityList,{children:e.map(((r,t)=>{const i=e.length>1&&r.schemes.length>1,n=r.schemes.map((({id:e},t)=>_jsxs(Fragment,{children:[e,t<r.schemes.length-1&&_jsx(Conjunction,{children:" and "})]},e)));return _jsxs(Fragment,{children:[i?"(":"",n,i?")":"",t<e.length-1&&_jsx(Conjunction,{children:" or "})]},t)}))})})}const SecurityPanel=styled(Panel)`
2
+ margin-top: var(--spacing-base);
3
+ border: var(--panel-border);
4
+ border-radius: var(--panel-border-radius);
5
+ `,SecurityHeader=styled.div`
2
6
  display: flex;
3
7
  align-items: center;
4
- align-self: flex-start;
5
- gap: var(--spacing-xxs);
6
- min-height: 32px;
7
- background: var(--color-info-bg);
8
- padding: 0 var(--spacing-xs);
9
- margin-top: var(--spacing-base);
8
+ justify-content: space-between;
9
+ gap: var(--spacing-xs);
10
10
  color: var(--link-color-primary);
11
- border: none;
12
- font-size: var(--font-size-base);
13
- font-family: var(--font-family-base);
14
- line-height: var(--line-height-base);
15
- border-radius: var(--border-radius-md);
16
- max-width: 100%;
11
+ padding: var(--spacing-xs) var(--spacing-sm);
12
+ background-color: var(--layer-color);
13
+ border-bottom: var(--panel-border);
14
+ border-radius: var(--panel-border-radius) var(--panel-border-radius) 0 0;
15
+ `,ViewDetailsButton=styled(Button)`
16
+ margin-left: auto;
17
+ font-size: var(--font-size-sm);
17
18
  `,Title=styled.span`
18
- font-family: var(--font-family-monospaced);
19
- font-weight: var(--font-weight-semibold);
20
- letter-spacing: -0.5px;
21
- `,SecurityList=styled.span`
19
+ font-family: var(--font-family-base);
20
+ font-weight: var(--font-weight-medium);
21
+ color: var(--text-color-primary);
22
+ `,SecurityList=styled.div`
22
23
  flex: 1;
23
- cursor: pointer;
24
- white-space: nowrap;
25
24
  text-overflow: ellipsis;
26
25
  overflow: hidden;
26
+ padding: var(--spacing-xs) var(--spacing-sm);
27
+ color: var(--text-color-primary);
28
+ `,Conjunction=styled.span`
29
+ color: var(--text-color-description);
27
30
  `;
28
31
  //# sourceMappingURL=SecurityButton.js.map
@@ -1,4 +1,4 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styled-components";import{SecuritySchemeItem}from"./SecuritySchemeItem";import{titleize}from"../../utils";import{OAuthFlow}from"./OAuthFlow";import{StyledLink,Tag}from"./styled";import{Markdown}from"../Markdown";import{getRequiredScopes}from"./helper";import{useTranslate}from"../../hooks";export function SecurityFlow({type:e,bearerFormat:r,name:t,flows:a,openIdConnectUrl:o,description:i,id:s,securities:n,in:l}){const m=useTranslate();if(!e||!s)return null;const p=getRequiredScopes(s,n),c={http:_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:m("openapi.httpAuthorizationScheme","HTTP Authorization Scheme"),value:e}),_jsx(SecuritySchemeItem,{label:m("openapi.bearerFormat","Bearer Format"),value:r})]}),apiKey:_jsx(SecuritySchemeItem,{label:`${titleize(l||"")} ${m("openapi.parameterName","parameter name")}:`,value:t}),oauth2:_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:m("openapi.flowType","Flow type"),value:e}),a&&Object.keys(a).map((e=>_jsx(OAuthFlow,{flow:a[e]},e)))]}),openIdConnect:_jsx(SecuritySchemeItem,{label:m("openapi.connectUrl","Connect URL"),value:o&&_jsx(StyledLink,{target:"_blank",rel:"noopener noreferrer",href:o,children:o})})};return _jsxs(Wrapper,{children:[_jsx(TitleSchema,{children:s}),_jsx(Markdown,{source:i}),_jsxs(List,{children:[c[e]||null,_jsx(SecuritySchemeItem,{label:m("openapi.requiredScopes","Required scopes"),value:p.length&&_jsx(Row,{children:p.map((e=>_jsx(Tag,{className:"tag-grey",children:e},e)))})})]})]})}const Wrapper=styled.div`
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styled-components";import{SecuritySchemeItem}from"./SecuritySchemeItem";import{titleize}from"../../utils";import{OAuthFlow}from"./OAuthFlow";import{StyledLink}from"./styled";import{Markdown}from"../Markdown";import{useTranslate}from"../../hooks";import{OAuthRequiredScopes,OAuthOptionalScopes}from"./OAuthScopes";export function SecurityFlow({type:e,bearerFormat:r,name:t,flows:o,openIdConnectUrl:a,description:i,id:s,securities:n,in:l}){const m=useTranslate();if(!e||!s)return null;const c={http:_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:m("openapi.httpAuthorizationScheme","HTTP Authorization Scheme"),value:e}),_jsx(SecuritySchemeItem,{label:m("openapi.bearerFormat","Bearer Format"),value:r})]}),apiKey:_jsx(SecuritySchemeItem,{label:`${titleize(l||"")} ${m("openapi.parameterName","parameter name")}:`,value:t}),oauth2:_jsxs(_Fragment,{children:[_jsx(SecuritySchemeItem,{label:m("openapi.flowType","Flow type"),value:e}),o&&Object.keys(o).map((e=>_jsx(OAuthFlow,{flow:o[e]},e)))]}),openIdConnect:_jsx(SecuritySchemeItem,{label:m("openapi.connectUrl","Connect URL"),value:a&&_jsx(StyledLink,{target:"_blank",rel:"noopener noreferrer",href:a,children:a})})},p=o&&Object.keys(o).map((e=>_jsx(OAuthRequiredScopes,{id:s,securities:n,flow:o[e]},e))),d=o&&Object.keys(o).map((e=>_jsx(OAuthOptionalScopes,{flow:o[e]},e)));return _jsxs(Wrapper,{children:[_jsx(TitleSchema,{children:s}),_jsx(Markdown,{source:i}),_jsxs(List,{children:[c[e]||null,p,d]})]})}const Wrapper=styled.div`
2
2
  background: var(--layer-color);
3
3
  padding: var(--spacing-base);
4
4
  border-radius: var(--border-radius);
@@ -8,11 +8,6 @@ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";i
8
8
  `,List=styled.div`
9
9
  width: 100%;
10
10
  margin-top: var(--spacing-md);
11
- `,Row=styled.div`
12
- display: flex;
13
- flex-wrap: wrap;
14
- gap: var(--spacing-xxs);
15
- word-break: normal;
16
11
  `,TitleSchema=styled.p`
17
12
  font-size: var(--font-size-base);
18
13
  margin: 0 0 var(--spacing-xs);
@@ -2,7 +2,7 @@ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import styled from"styl
2
2
  display: flex;
3
3
  flex-wrap: wrap;
4
4
  justify-content: flex-start;
5
- margin-bottom: var(--spacing-xxs);
5
+ margin-bottom: var(--spacing-xs);
6
6
  font-size: var(--font-size-sm);
7
7
  color: var(--text-color-secondary);
8
8
  `,Label=styled.div`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.10.0-next.7",
3
+ "version": "3.10.0-next.8",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -46,7 +46,7 @@
46
46
  "util": "~0.12.5",
47
47
  "web-vitals": "3.3.1",
48
48
  "@redocly/config": "0.25.0",
49
- "@redocly/replay": "0.13.0-next.6"
49
+ "@redocly/replay": "0.13.0-next.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@shikijs/transformers": "1.24.0",
@@ -92,7 +92,7 @@
92
92
  "webpack": "5.94.0",
93
93
  "webpack-cli": "5.1.4",
94
94
  "webpack-dev-server": "5.1.0",
95
- "@redocly/theme": "0.54.0-next.6"
95
+ "@redocly/theme": "0.54.0-next.7"
96
96
  },
97
97
  "scripts": {
98
98
  "start": "npm run copy-highlight-hook && webpack serve --mode=development --hot",